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
...
@@ -345,9 +345,8 @@ public final class JVMFunction
public
static
final
long
jvmSystemCall
(
short
__si
,
int
__a
,
int
__b
,
public
static
final
long
jvmSystemCall
(
short
__si
,
int
__a
,
int
__b
,
int
__c
,
int
__d
,
int
__e
,
int
__f
,
int
__g
,
int
__h
)
int
__c
,
int
__d
,
int
__e
,
int
__f
,
int
__g
,
int
__h
)
{
{
// Call pure form
Assembly
.
breakpoint
();
return
Assembly
.
sysCallPVL
(
__si
,
__a
,
__b
,
__c
,
__d
,
__e
,
__f
,
__g
,
throw
Debugging
.
todo
();
__h
);
}
}
}
}
modules/cldc-compact/src/main/java/cc/squirreljme/jvm/SystemCallError.java
View file @
795433b4
...
@@ -76,40 +76,21 @@ public final class SystemCallError
...
@@ -76,40 +76,21 @@ public final class SystemCallError
public
static
final
byte
NO_SUCH_CONFIG_KEY
=
public
static
final
byte
NO_SUCH_CONFIG_KEY
=
-
14
;
-
14
;
/**
/** Invalid memory handle kind. */
* Not used.
public
static
final
byte
INVALID_MEMHANDLE_KIND
=
*
-
15
;
* @since 2019/05/23
*/
private
SystemCallError
()
{
}
/**
/** Could not flush the pipe. */
* Checks if an error was set, if it was an exception is thrown.
public
static
final
byte
PIPE_DESCRIPTOR_BAD_FLUSH
=
*
-
16
;
* @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
);
}
/**
/**
*
Returns the error state
.
*
Not used
.
*
*
* @param __si The system call index.
* @return The error, 0 will be on success.
* @since 2019/05/23
* @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 @@
...
@@ -10,13 +10,6 @@
package
cc.squirreljme.runtime.cldc.debug
;
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
;
import
java.util.Objects
;
/**
/**
...
@@ -54,14 +47,8 @@ public final class CallTraceElement
...
@@ -54,14 +47,8 @@ public final class CallTraceElement
/** The task ID. */
/** The task ID. */
protected
final
int
taskId
;
protected
final
int
taskId
;
/** String representation. */
/** The native instruction type. */
private
Reference
<
String
>
_string
;
protected
final
int
nativeOp
;
/** At line form. */
private
Reference
<
String
>
_stringatl
;
/** Class header form. */
private
Reference
<
String
>
_stringclh
;
/** Hash code. */
/** Hash code. */
private
int
_hash
;
private
int
_hash
;
...
@@ -142,6 +129,28 @@ public final class CallTraceElement
...
@@ -142,6 +129,28 @@ public final class CallTraceElement
*/
*/
public
CallTraceElement
(
String
__cl
,
String
__mn
,
String
__md
,
long
__addr
,
public
CallTraceElement
(
String
__cl
,
String
__mn
,
String
__md
,
long
__addr
,
String
__file
,
int
__line
,
int
__jbc
,
int
__jpc
,
int
__tid
)
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
.
className
=
__cl
;
this
.
methodName
=
__mn
;
this
.
methodName
=
__mn
;
...
@@ -152,6 +161,7 @@ public final class CallTraceElement
...
@@ -152,6 +161,7 @@ public final class CallTraceElement
this
.
byteCodeOp
=
__jbc
;
this
.
byteCodeOp
=
__jbc
;
this
.
byteCodeAddr
=
__jpc
;
this
.
byteCodeAddr
=
__jpc
;
this
.
taskId
=
__tid
;
this
.
taskId
=
__tid
;
this
.
nativeOp
=
__nOp
;
}
}
/**
/**
...
@@ -224,7 +234,8 @@ public final class CallTraceElement
...
@@ -224,7 +234,8 @@ public final class CallTraceElement
this
.
line
==
o
.
line
&&
this
.
line
==
o
.
line
&&
this
.
byteCodeOp
==
o
.
byteCodeOp
&&
this
.
byteCodeOp
==
o
.
byteCodeOp
&&
this
.
byteCodeAddr
==
o
.
byteCodeAddr
&&
this
.
byteCodeAddr
==
o
.
byteCodeAddr
&&
this
.
taskId
==
o
.
taskId
;
this
.
taskId
==
o
.
taskId
&&
this
.
nativeOp
==
o
.
nativeOp
;
}
}
/**
/**
...
@@ -257,7 +268,8 @@ public final class CallTraceElement
...
@@ -257,7 +268,8 @@ public final class CallTraceElement
~
this
.
line
+
~
this
.
line
+
~
this
.
byteCodeOp
+
~
this
.
byteCodeOp
+
~
this
.
byteCodeAddr
+
~
this
.
byteCodeAddr
+
~
this
.
taskId
);
~
this
.
taskId
+
~
this
.
nativeOp
);
}
}
return
rv
;
return
rv
;
}
}
...
@@ -295,6 +307,17 @@ public final class CallTraceElement
...
@@ -295,6 +307,17 @@ public final class CallTraceElement
return
this
.
methodName
;
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
* Formats the call trace element but having it only represent the method
* point without the class information.
* point without the class information.
...
@@ -304,102 +327,95 @@ public final class CallTraceElement
...
@@ -304,102 +327,95 @@ public final class CallTraceElement
*/
*/
public
final
String
toAtLineString
()
public
final
String
toAtLineString
()
{
{
Reference
<
String
>
ref
=
this
.
_stringatl
;
// Get all fields to determine how to print it pretty
String
rv
;
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
sb
.
append
(
':'
);
String
methodname
=
this
.
methodName
,
sb
.
append
(
methoddescriptor
);
methoddescriptor
=
this
.
methodType
;
}
long
address
=
this
.
address
;
int
line
=
this
.
line
;
// Task ID?
int
jInst
=
this
.
byteCodeOp
&
0xFF
;
if
(
taskId
!=
0
)
int
jAddr
=
this
.
byteCodeAddr
;
{
int
taskid
=
this
.
taskId
;
sb
.
append
(
" T"
);
sb
.
append
(
taskId
);
// Format it nicely
}
StringBuilder
sb
=
new
StringBuilder
();
// Execution address
if
(
address
!=
Long
.
MIN_VALUE
)
{
sb
.
append
(
" @"
);
// Method name
sb
.
append
(
Long
.
toString
(
address
,
16
).
toUpperCase
());
sb
.
append
(
'.'
);
sb
.
append
(
'h'
);
sb
.
append
((
methodname
==
null
?
"<unknown>"
:
methodname
));
}
// 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
// Line
if
(
methoddescriptor
!=
null
)
boolean
sp
=
false
;
if
((
sp
|=
hasLine
))
{
{
sb
.
append
(
':'
);
sb
.
append
(
':'
);
sb
.
append
(
methoddescriptor
);
sb
.
append
(
line
);
}
}
//
Task ID?
//
Java instruction info
if
(
taskid
!=
0
)
if
(
hasJInst
||
hasJAddr
)
{
{
sb
.
append
(
" T"
);
// Using space?
sb
.
append
(
taskid
);
if
(
sp
)
}
sb
.
append
(
' '
);
// 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
);
}
// File, Line, and/or Java instruction/address
// Write instruction
boolean
hasLine
=
(
line
>=
0
),
if
(
hasJInst
)
hasJInst
=
(
jInst
>=
0
&&
jInst
<
0xFF
),
sb
.
append
(
JavaOpCodeUtils
.
toString
(
jInst
));
hasJAddr
=
(
jAddr
>=
0
);
if
(
hasLine
||
hasJInst
||
hasJAddr
)
{
sb
.
append
(
" ("
);
// Line
boolean
sp
=
false
;
if
((
sp
|=
hasLine
))
{
sb
.
append
(
':'
);
sb
.
append
(
line
);
}
//
Java instruction info
//
Write address of Java operation
if
(
hasJInst
||
hasJAddr
)
if
(
hasJAddr
)
{
{
// Using space?
sb
.
append
(
'@'
);
if
(
sp
)
sb
.
append
(
jAddr
);
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
(
')'
);
}
}
this
.
_stringatl
=
new
WeakReference
<>((
rv
=
sb
.
toString
())
);
sb
.
append
(
')'
);
}
}
return
rv
;
return
sb
.
toString
()
;
}
}
/**
/**
...
@@ -410,34 +426,26 @@ public final class CallTraceElement
...
@@ -410,34 +426,26 @@ public final class CallTraceElement
*/
*/
public
final
String
toClassHeaderString
()
public
final
String
toClassHeaderString
()
{
{
Reference
<
String
>
ref
=
this
.
_stringclh
;
// Get all fields to determine how to print it pretty
String
rv
;
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
sb
.
append
(
" ("
);
String
classname
=
this
.
className
,
sb
.
append
(
file
);
file
=
this
.
file
;
sb
.
append
(
')'
);
// 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
()));
}
}
return
rv
;
return
sb
.
toString
()
;
}
}
/**
/**
...
@@ -447,227 +455,100 @@ public final class CallTraceElement
...
@@ -447,227 +455,100 @@ public final class CallTraceElement
@Override
@Override
public
final
String
toString
()
public
final
String
toString
()
{
{
Reference
<
String
>
ref
=
this
.
_string
;
// Get all fields to determine how to print it pretty
String
rv
;
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
sb
.
append
(
':'
);
String
classname
=
this
.
className
,
sb
.
append
(
methoddescriptor
);
methodname
=
this
.
methodName
,
}
methoddescriptor
=
this
.
methodType
,
file
=
this
.
file
;
// Task ID?
long
address
=
this
.
address
;
if
(
taskid
!=
0
)
int
line
=
this
.
line
;
{
int
jbcinst
=
this
.
byteCodeOp
&
0xFF
;
sb
.
append
(
" T"
);
int
jbcaddr
=
this
.
byteCodeAddr
;
sb
.
append
(
taskid
);
int
taskid
=
this
.
taskId
;
}
if
(
address
!=
Long
.
MIN_VALUE
)
{
sb
.
append
(
" @"
);
// Format it nicely
sb
.
append
(
Long
.
toString
(
address
,
16
).
toUpperCase
());
StringBuilder
sb
=
new
StringBuilder
();
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
));
// File
sb
.
append
(
'.'
);
boolean
sp
=
false
;
sb
.
append
((
methodname
==
null
?
"<unknown>"
:
methodname
));
if
((
sp
|=
hasfile
))
sb
.
append
(
file
);
if
(
methoddescriptor
!=
null
)
// Line
if
((
sp
|=
hasline
))
{
{
sb
.
append
(
':'
);
sb
.
append
(
':'
);
sb
.
append
(
methoddescriptor
);
sb
.
append
(
line
);
}
}
//
Task ID?
//
Java instruction info
if
(
t
as
kid
!=
0
)
if
(
h
as
jbcinst
||
hasjbcaddr
)
{
{
sb
.
append
(
" T"
);
// Using space?
sb
.
append
(
taskid
);
if
(
sp
)
}
sb
.
append
(
' '
);
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'
);