Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
SquirrelJME
Commits
795433b4
Commit
795433b4
authored
Jul 18, 2021
by
Stephanie Gawroriski
Browse files
More pickings of the call traces.
parent
9d51007d
Changes
5
Hide whitespace changes
Inline
Side-by-side
modules/cldc-compact/src/main/java/cc/squirreljme/jvm/JVMFunction.java
View file @
795433b4
...
...
@@ -345,9 +345,8 @@ public final class JVMFunction
public
static
final
long
jvmSystemCall
(
short
__si
,
int
__a
,
int
__b
,
int
__c
,
int
__d
,
int
__e
,
int
__f
,
int
__g
,
int
__h
)
{
// Call pure form
return
Assembly
.
sysCallPVL
(
__si
,
__a
,
__b
,
__c
,
__d
,
__e
,
__f
,
__g
,
__h
);
Assembly
.
breakpoint
();
throw
Debugging
.
todo
();
}
}
modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SystemCallError.java
View file @
795433b4
...
...
@@ -76,40 +76,21 @@ public final class SystemCallError
public
static
final
byte
NO_SUCH_CONFIG_KEY
=
-
14
;
/**
* Not used.
*
* @since 2019/05/23
*/
private
SystemCallError
()
{
}
/** Invalid memory handle kind. */
public
static
final
byte
INVALID_MEMHANDLE_KIND
=
-
15
;
/**
* Checks if an error was set, if it was an exception is thrown.
*
* @param __si The system call to check.
* @throws SystemCallException If there was an error.
* @since 2020/01/12
*/
public
static
void
checkError
(
short
__si
)
throws
SystemCallException
{
int
code
=
SystemCallError
.
getError
(
__si
);
if
(
code
!=
SystemCallError
.
NO_ERROR
)
throw
new
SystemCallException
(
__si
,
code
);
}
/** Could not flush the pipe. */
public
static
final
byte
PIPE_DESCRIPTOR_BAD_FLUSH
=
-
16
;
/**
*
Returns the error state
.
*
Not used
.
*
* @param __si The system call index.
* @return The error, 0 will be on success.
* @since 2019/05/23
*/
p
ublic
static
int
getError
(
short
__si
)
p
rivate
SystemCallError
(
)
{
return
Assembly
.
sysCallV
(
SystemCallIndex
.
ERROR_GET
,
__si
);
}
/**
...
...
modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/debug/CallTraceElement.java
View file @
795433b4
...
...
@@ -10,13 +10,6 @@
package
cc.squirreljme.runtime.cldc.debug
;
import
cc.squirreljme.jvm.Assembly
;
import
cc.squirreljme.jvm.CallStackItem
;
import
cc.squirreljme.jvm.SystemCallError
;
import
cc.squirreljme.jvm.SystemCallIndex
;
import
cc.squirreljme.jvm.mle.brackets.TracePointBracket
;
import
java.lang.ref.Reference
;
import
java.lang.ref.WeakReference
;
import
java.util.Objects
;
/**
...
...
@@ -54,14 +47,8 @@ public final class CallTraceElement
/** The task ID. */
protected
final
int
taskId
;
/** String representation. */
private
Reference
<
String
>
_string
;
/** At line form. */
private
Reference
<
String
>
_stringatl
;
/** Class header form. */
private
Reference
<
String
>
_stringclh
;
/** The native instruction type. */
protected
final
int
nativeOp
;
/** Hash code. */
private
int
_hash
;
...
...
@@ -142,6 +129,28 @@ public final class CallTraceElement
*/
public
CallTraceElement
(
String
__cl
,
String
__mn
,
String
__md
,
long
__addr
,
String
__file
,
int
__line
,
int
__jbc
,
int
__jpc
,
int
__tid
)
{
this
(
__cl
,
__mn
,
__md
,
__addr
,
__file
,
__line
,
__jbc
,
__jpc
,
__tid
,
-
1
);
}
/**
* Initializes a call trace element.
*
* @param __cl The class name.
* @param __mn The method name.
* @param __md The method descriptor.
* @param __addr The address the method executes at.
* @param __file The file.
* @param __line The line in the file.
* @param __jbc The Java byte code instruction used.
* @param __jpc The Java PC address.
* @param __tid The task ID.
* @param __nOp The native operation.
* @since 2021/01/24
*/
public
CallTraceElement
(
String
__cl
,
String
__mn
,
String
__md
,
long
__addr
,
String
__file
,
int
__line
,
int
__jbc
,
int
__jpc
,
int
__tid
,
int
__nOp
)
{
this
.
className
=
__cl
;
this
.
methodName
=
__mn
;
...
...
@@ -152,6 +161,7 @@ public final class CallTraceElement
this
.
byteCodeOp
=
__jbc
;
this
.
byteCodeAddr
=
__jpc
;
this
.
taskId
=
__tid
;
this
.
nativeOp
=
__nOp
;
}
/**
...
...
@@ -224,7 +234,8 @@ public final class CallTraceElement
this
.
line
==
o
.
line
&&
this
.
byteCodeOp
==
o
.
byteCodeOp
&&
this
.
byteCodeAddr
==
o
.
byteCodeAddr
&&
this
.
taskId
==
o
.
taskId
;
this
.
taskId
==
o
.
taskId
&&
this
.
nativeOp
==
o
.
nativeOp
;
}
/**
...
...
@@ -257,7 +268,8 @@ public final class CallTraceElement
~
this
.
line
+
~
this
.
byteCodeOp
+
~
this
.
byteCodeAddr
+
~
this
.
taskId
);
~
this
.
taskId
+
~
this
.
nativeOp
);
}
return
rv
;
}
...
...
@@ -295,6 +307,17 @@ public final class CallTraceElement
return
this
.
methodName
;
}
/**
* Returns the native operation.
*
* @return The native operation.
* @since 2021/01/24
*/
public
final
int
nativeOp
()
{
return
this
.
nativeOp
;
}
/**
* Formats the call trace element but having it only represent the method
* point without the class information.
...
...
@@ -304,102 +327,95 @@ public final class CallTraceElement
*/
public
final
String
toAtLineString
()
{
Reference
<
String
>
ref
=
this
.
_stringatl
;
String
rv
;
// Get all fields to determine how to print it pretty
String
methodname
=
this
.
methodName
,
methoddescriptor
=
this
.
methodType
;
long
address
=
this
.
address
;
int
line
=
this
.
line
;
int
jInst
=
this
.
byteCodeOp
&
0xFF
;
int
jAddr
=
this
.
byteCodeAddr
;
int
taskId
=
this
.
taskId
;
int
nativeOp
=
this
.
nativeOp
;
if
(
ref
==
null
||
null
==
(
rv
=
ref
.
get
()))
// Format it nicely
StringBuilder
sb
=
new
StringBuilder
();
// Method name
sb
.
append
(
'.'
);
sb
.
append
((
methodname
==
null
?
"<unknown>"
:
methodname
));
// Method type
if
(
methoddescriptor
!=
null
)
{
// Get all fields to determine how to print it pretty
String
methodname
=
this
.
methodName
,
methoddescriptor
=
this
.
methodType
;
long
address
=
this
.
address
;
int
line
=
this
.
line
;
int
jInst
=
this
.
byteCodeOp
&
0xFF
;
int
jAddr
=
this
.
byteCodeAddr
;
int
taskid
=
this
.
taskId
;
// Format it nicely
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
':'
);
sb
.
append
(
methoddescriptor
);
}
// Task ID?
if
(
taskId
!=
0
)
{
sb
.
append
(
" T"
);
sb
.
append
(
taskId
);
}
// Execution address
if
(
address
!=
Long
.
MIN_VALUE
)
{
sb
.
append
(
" @"
);
// Method name
sb
.
append
(
'.'
);
sb
.
append
((
methodname
==
null
?
"<unknown>"
:
methodname
));
sb
.
append
(
Long
.
toString
(
address
,
16
).
toUpperCase
());
sb
.
append
(
'h'
);
}
// Is there a native operation?
if
(
nativeOp
>=
0
)
{
sb
.
append
(
" ^"
);
sb
.
append
(
Integer
.
toString
(
nativeOp
,
16
).
toUpperCase
());
sb
.
append
(
"h/"
);
sb
.
append
(
Integer
.
toString
(
nativeOp
,
2
).
toUpperCase
());
sb
.
append
(
'b'
);
}
// File, Line, and/or Java instruction/address
boolean
hasLine
=
(
line
>=
0
),
hasJInst
=
(
jInst
>=
0
&&
jInst
<
0xFF
),
hasJAddr
=
(
jAddr
>=
0
);
if
(
hasLine
||
hasJInst
||
hasJAddr
)
{
sb
.
append
(
" ("
);
// Method type
if
(
methoddescriptor
!=
null
)
// Line
boolean
sp
=
false
;
if
((
sp
|=
hasLine
))
{
sb
.
append
(
':'
);
sb
.
append
(
methoddescriptor
);
sb
.
append
(
line
);
}
//
Task ID?
if
(
taskid
!=
0
)
//
Java instruction info
if
(
hasJInst
||
hasJAddr
)
{
sb
.
append
(
" T"
);
sb
.
append
(
taskid
);
}
// Execution address
if
(
address
!=
Long
.
MIN_VALUE
)
{
sb
.
append
(
" @"
);
// If the address is really high then it is very likely that
// this is some RAM/ROM address rather than some easily read
// index. This makes them more readable and understandable
if
(
address
>
4096
)
{
sb
.
append
(
Long
.
toString
(
address
,
16
).
toUpperCase
());
sb
.
append
(
'h'
);
}
// Otherwise use an index
else
sb
.
append
(
address
);
}
// Using space?
if
(
sp
)
sb
.
append
(
' '
);
// File, Line, and/or Java instruction/address
boolean
hasLine
=
(
line
>=
0
),
hasJInst
=
(
jInst
>=
0
&&
jInst
<
0xFF
),
hasJAddr
=
(
jAddr
>=
0
);
if
(
hasLine
||
hasJInst
||
hasJAddr
)
{
sb
.
append
(
" ("
);
// Line
boolean
sp
=
false
;
if
((
sp
|=
hasLine
))
{
sb
.
append
(
':'
);
sb
.
append
(
line
);
}
// Write instruction
if
(
hasJInst
)
sb
.
append
(
JavaOpCodeUtils
.
toString
(
jInst
));
//
Java instruction info
if
(
hasJInst
||
hasJAddr
)
//
Write address of Java operation
if
(
hasJAddr
)
{
// Using space?
if
(
sp
)
sb
.
append
(
' '
);
// Write instruction
if
(
hasJInst
)
sb
.
append
(
JavaOpCodeUtils
.
toString
(
jInst
));
// Write address of Java operation
if
(
hasJAddr
)
{
sb
.
append
(
'@'
);
sb
.
append
(
jAddr
);
}
sb
.
append
(
'@'
);
sb
.
append
(
jAddr
);
}
sb
.
append
(
')'
);
}
this
.
_stringatl
=
new
WeakReference
<>((
rv
=
sb
.
toString
())
);
sb
.
append
(
')'
);
}
return
rv
;
return
sb
.
toString
()
;
}
/**
...
...
@@ -410,34 +426,26 @@ public final class CallTraceElement
*/
public
final
String
toClassHeaderString
()
{
Reference
<
String
>
ref
=
this
.
_stringclh
;
String
rv
;
// Get all fields to determine how to print it pretty
String
classname
=
this
.
className
,
file
=
this
.
file
;
// Format it nicely
StringBuilder
sb
=
new
StringBuilder
();
// Class name
sb
.
append
((
classname
==
null
?
"<unknown>"
:
classname
.
replace
(
'/'
,
'.'
)));
if
(
ref
==
null
||
null
==
(
rv
=
ref
.
get
()))
// Is this in a file?
if
(
file
!=
null
)
{
// Get all fields to determine how to print it pretty
String
classname
=
this
.
className
,
file
=
this
.
file
;
// Format it nicely
StringBuilder
sb
=
new
StringBuilder
();
// Class name
sb
.
append
((
classname
==
null
?
"<unknown>"
:
classname
.
replace
(
'/'
,
'.'
)));
// Is this in a file?
if
(
file
!=
null
)
{
sb
.
append
(
" ("
);
sb
.
append
(
file
);
sb
.
append
(
')'
);
}
this
.
_stringclh
=
new
WeakReference
<>((
rv
=
sb
.
toString
()));
sb
.
append
(
" ("
);
sb
.
append
(
file
);
sb
.
append
(
')'
);
}
return
rv
;
return
sb
.
toString
()
;
}
/**
...
...
@@ -447,227 +455,100 @@ public final class CallTraceElement
@Override
public
final
String
toString
()
{
Reference
<
String
>
ref
=
this
.
_string
;
String
rv
;
// Get all fields to determine how to print it pretty
String
classname
=
this
.
className
,
methodname
=
this
.
methodName
,
methoddescriptor
=
this
.
methodType
,
file
=
this
.
file
;
long
address
=
this
.
address
;
int
line
=
this
.
line
;
int
jbcinst
=
this
.
byteCodeOp
&
0xFF
;
int
jbcaddr
=
this
.
byteCodeAddr
;
int
taskid
=
this
.
taskId
;
int
nativeOp
=
this
.
nativeOp
;
if
(
ref
==
null
||
null
==
(
rv
=
ref
.
get
()))
// Format it nicely
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
((
classname
==
null
?
"<unknown>"
:
classname
));
sb
.
append
(
'.'
);
sb
.
append
((
methodname
==
null
?
"<unknown>"
:
methodname
));
if
(
methoddescriptor
!=
null
)
{
// Get all fields to determine how to print it pretty
String
classname
=
this
.
className
,
methodname
=
this
.
methodName
,
methoddescriptor
=
this
.
methodType
,
file
=
this
.
file
;
long
address
=
this
.
address
;
int
line
=
this
.
line
;
int
jbcinst
=
this
.
byteCodeOp
&
0xFF
;
int
jbcaddr
=
this
.
byteCodeAddr
;
int
taskid
=
this
.
taskId
;
sb
.
append
(
':'
);
sb
.
append
(
methoddescriptor
);
}
// Task ID?
if
(
taskid
!=
0
)
{
sb
.
append
(
" T"
);
sb
.
append
(
taskid
);
}
if
(
address
!=
Long
.
MIN_VALUE
)
{
sb
.
append
(
" @"
);
// Format it nicely
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
Long
.
toString
(
address
,
16
).
toUpperCase
());
sb
.
append
(
'h'
);
}
// Is there a native operation?
if
(
nativeOp
>=
0
)
{
sb
.
append
(
" ^"
);
sb
.
append
(
Integer
.
toString
(
nativeOp
,
16
).
toUpperCase
());
sb
.
append
(
"h/"
);
sb
.
append
(
Integer
.
toString
(
nativeOp
,
2
).
toUpperCase
());
sb
.
append
(
'b'
);
}
// File, Line, and/or Java instruction/address
boolean
hasfile
=
(
file
!=
null
),
hasline
=
(
line
>=
0
),
hasjbcinst
=
(
jbcinst
>
0x00
&&
jbcinst
<
0xFF
),
hasjbcaddr
=
(
jbcaddr
>=
0
);
if
(
hasfile
||
hasline
||
hasjbcinst
||
hasjbcaddr
)
{
sb
.
append
(
" ("
);
sb
.
append
((
classname
==
null
?
"<unknown>"
:
classname
));
sb
.
append
(
'.'
);
sb
.
append
((
methodname
==
null
?
"<unknown>"
:
methodname
));
// File
boolean
sp
=
false
;
if
((
sp
|=
hasfile
))
sb
.
append
(
file
);
if
(
methoddescriptor
!=
null
)
// Line
if
((
sp
|=
hasline
))
{
sb
.
append
(
':'
);
sb
.
append
(
methoddescriptor
);
sb
.
append
(
line
);
}
//
Task ID?
if
(
t
as
kid
!=
0
)
//
Java instruction info
if
(
h
as
jbcinst
||
hasjbcaddr
)
{
sb
.
append
(
" T"
);
sb
.
append
(
taskid
);
}
if
(
address
!=
Long
.
MIN_VALUE
)
{
sb
.
append
(
" @"
);
// If the address is really high then it is very likely that
// this is some RAM/ROM address rather than some easily read
// index. This makes them more readable and understandable
if
(
address
>
4096
)
{
sb
.
append
(
Long
.
toString
(
address
,
16
).
toUpperCase
());
sb
.
append
(
'h'
);
}
// Otherwise use an index
else
sb
.
append
(
address
);
}
// Using space?
if
(
sp
)
sb
.
append
(
' '
);
// File, Line, and/or Java instruction/address
boolean
hasfile
=
(
file
!=
null
),
hasline
=
(
line
>=
0
),
hasjbcinst
=
(
jbcinst
>
0x00
&&
jbcinst
<
0xFF
),
hasjbcaddr
=
(
jbcaddr
>=
0
);
if
(
hasfile
||
hasline
||
hasjbcinst
||
hasjbcaddr
)
{
sb
.
append
(
" ("
);
// File
boolean
sp
=
false
;
if
((
sp
|=
hasfile
))
sb
.
append
(
file
);
// Line
if
((
sp
|=
hasline
))
{
sb
.
append
(
':'
);
sb
.
append
(
line
);
}
// Write instruction
if
(
hasjbcinst
)
sb
.
append
(
JavaOpCodeUtils
.
toString
(
jbcinst
));
//
Java instruction info
if
(
hasjbcinst
||
hasjbcaddr
)
//
Write address of Java operation
if
(
hasjbcaddr
)
{
// Using space?
if
(
sp
)
sb
.
append
(
' '
);
// Write instruction
if
(
hasjbcinst
)
sb
.
append
(
JavaOpCodeUtils
.
toString
(
jbcinst
));
// Write address of Java operation
if
(
hasjbcaddr
)
{
sb
.
append
(
'@'
);
sb
.
append
(
jbcaddr
);
}
sb
.
append
(
'@'
);
sb
.
append
(
jbcaddr
);
}
sb
.
append
(
')'
);
}
this
.
_string
=
new
WeakReference
<>((
rv
=
sb
.
toString
())
);
sb
.
append
(
')'
);
}
return
rv
;
}
/**
* Obtains the current raw call trace which has not been resolved.
*
* @return The raw call trace.
* @since 2019/06/16
<