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
d652db7c
Commit
d652db7c
authored
Jul 18, 2021
by
Stephanie Gawroriski
Browse files
Bring in new CallTrace and Debugging.
parent
38941ae0
Pipeline
#39178
passed with stages
in 1 minute and 32 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
modules/cldc-compact/src/main/java/cc/squirreljme/runtime/cldc/debug/Debugging.java
View file @
d652db7c
...
@@ -76,6 +76,18 @@ public final class Debugging
...
@@ -76,6 +76,18 @@ public final class Debugging
Debugging
.
__format
(
'D'
,
'B'
,
__fmt
,
__args
);
Debugging
.
__format
(
'D'
,
'B'
,
__fmt
,
__args
);
}
}
/**
* Emits a notice
*
* @param __fmt The format.
* @param __args The arguments to the string.
* @since 2021/01/18
*/
public
static
void
notice
(
String
__fmt
,
Object
...
__args
)
{
Debugging
.
__format
(
'\0'
,
'\0'
,
__fmt
,
__args
);
}
/**
/**
* Emits an oops error.
* Emits an oops error.
*
*
...
@@ -99,6 +111,47 @@ public final class Debugging
...
@@ -99,6 +111,47 @@ public final class Debugging
return
Debugging
.
todo
(
__args
);
return
Debugging
.
todo
(
__args
);
}
}
/**
* Prints the given character.
*
* @param __c The character to print.
* @since 2020/05/07
*/
@SuppressWarnings
({
"SameParameterValue"
})
public
static
void
print
(
char
__c
)
{
Debugging
.
print
(
__c
,
'\0'
);
}
/**
* Prints the given characters.
*
* @param __c The character to print.
* @param __d Second character to print.
* @since 2020/05/07
*/
@SuppressWarnings
(
"FeatureEnvy"
)
public
static
void
print
(
char
__c
,
char
__d
)
{
// If we are on standard Java SE, use the System.err for output
if
(
RuntimeShelf
.
vmType
()
==
VMType
.
JAVA_SE
)
{
System
.
err
.
print
(
__c
);
if
(
__d
>
0
)
System
.
err
.
print
(
__d
);
return
;
}
// Use standard SquirrelJME output
TerminalShelf
.
write
(
StandardPipeType
.
STDERR
,
(
__c
>
Debugging
.
_BYTE_LIMIT
?
'?'
:
__c
));
if
(
__d
>
0
)
TerminalShelf
.
write
(
StandardPipeType
.
STDERR
,
(
__d
>
Debugging
.
_BYTE_LIMIT
?
'?'
:
__d
));
}
/**
/**
* Emits a To-Do error.
* Emits a To-Do error.
*
*
...
@@ -312,14 +365,19 @@ public final class Debugging
...
@@ -312,14 +365,19 @@ public final class Debugging
// Print otherwise
// Print otherwise
try
try
{
{
// Print header marker
// Print header marker, but only if it is used
Debugging
.
__print
(
__cha
,
__chb
);
if
(
__cha
!=
'\0'
&&
__chb
!=
'\0'
)
Debugging
.
__print
(
':'
,
' '
);
{
Debugging
.
print
(
__cha
,
__chb
);
Debugging
.
print
(
':'
,
' '
);
}
// The specifier to print along with the field index
// The specifier to print along with the field index
boolean
specifier
=
false
,
boolean
specifier
=
false
,
hasArgIndex
=
false
,
hasArgIndex
=
false
,
firstChar
=
false
;
firstChar
=
false
,
usePrefix
=
false
,
zeroPadding
=
false
;
int
argIndex
=
0
,
int
argIndex
=
0
,
baseArg
=
0
,
baseArg
=
0
,
width
=
-
1
,
width
=
-
1
,
...
@@ -334,15 +392,22 @@ public final class Debugging
...
@@ -334,15 +392,22 @@ public final class Debugging
if
(
specifier
)
if
(
specifier
)
{
{
// Ignore flags
// Ignore flags
if
(
c
==
'-'
||
c
==
'#'
||
c
==
'+'
||
if
(
c
==
'-'
||
c
==
'+'
||
c
==
' '
||
c
==
','
||
c
==
'('
||
c
==
' '
||
c
==
','
||
c
==
'('
)
(
firstChar
&&
c
==
'0'
))
continue
;
continue
;
// Ignore precision
// Ignore precision
else
if
(
c
==
'.'
)
else
if
(
c
==
'.'
)
continue
;
continue
;
// Zero padded?
else
if
(
firstChar
&&
c
==
'0'
)
zeroPadding
=
true
;
// Prefix flag?
else
if
(
c
==
'#'
)
usePrefix
=
true
;
// Could be width or argument index position
// Could be width or argument index position
else
if
((
c
>=
'1'
&&
c
<=
'9'
)
||
else
if
((
c
>=
'1'
&&
c
<=
'9'
)
||
(!
firstChar
&&
c
==
'0'
))
(!
firstChar
&&
c
==
'0'
))
...
@@ -352,6 +417,14 @@ public final class Debugging
...
@@ -352,6 +417,14 @@ public final class Debugging
if
(
width
<
0
)
if
(
width
<
0
)
width
=
0
;
width
=
0
;
width
=
(
width
*
10
)
+
(
c
-
'0'
);
width
=
(
width
*
10
)
+
(
c
-
'0'
);
// If the width is still zero, then this is the
// zero padding flag
if
(
width
==
0
)
{
zeroPadding
=
true
;
width
=
-
1
;
}
}
}
else
else
argIndex
=
(
argIndex
*
10
)
+
(
c
-
'0'
);
argIndex
=
(
argIndex
*
10
)
+
(
c
-
'0'
);
...
@@ -365,7 +438,7 @@ public final class Debugging
...
@@ -365,7 +438,7 @@ public final class Debugging
else
if
(
c
==
'%'
||
c
==
'n'
)
else
if
(
c
==
'%'
||
c
==
'n'
)
{
{
if
(
c
==
'%'
)
if
(
c
==
'%'
)
Debugging
.
__
print
(
'%'
);
Debugging
.
print
(
'%'
);
else
else
Debugging
.
__printLine
();
Debugging
.
__printLine
();
...
@@ -389,28 +462,56 @@ public final class Debugging
...
@@ -389,28 +462,56 @@ public final class Debugging
// Print its value
// Print its value
if
(
value
==
null
)
if
(
value
==
null
)
{
{
Debugging
.
__
print
(
'n'
,
'u'
);
Debugging
.
print
(
'n'
,
'u'
);
Debugging
.
__
print
(
'l'
,
'l'
);
Debugging
.
print
(
'l'
,
'l'
);
}
}
// A
ssume a
string
// A string
printed value
else
else
{
{
String
string
=
value
.
toString
();
String
string
;
// Hex sequence
if
(
c
==
'x'
||
c
==
'X'
)
{
string
=
(
usePrefix
?
"0x"
:
""
)
+
Long
.
toString
(((
Number
)
value
).
longValue
(),
16
);
if
(
c
==
'X'
)
string
=
string
.
toUpperCase
();
}
// Octal
else
if
(
c
==
'o'
)
string
=
Long
.
toString
(
((
Number
)
value
).
longValue
(),
8
);
// Assume string
else
string
=
value
.
toString
();
// Print left padding?
// Print left padding?
int
strLen
=
string
.
length
(),
int
strLen
=
string
.
length
(),
pad
=
width
-
strLen
;
pad
=
width
-
strLen
;
while
((
pad
--)
>
0
)
while
((
pad
--)
>
0
)
Debugging
.
__print
(
' '
);
if
(
zeroPadding
)
Debugging
.
print
(
'0'
);
else
Debugging
.
print
(
' '
);
// Print actual string
// Print actual string
for
(
int
j
=
0
;
j
<
strLen
;
j
++)
for
(
int
j
=
0
;
j
<
strLen
;
j
++)
Debugging
.
__
print
(
string
.
charAt
(
j
));
Debugging
.
print
(
string
.
charAt
(
j
));
}
}
// Stop
// Stop
and reset
specifier
=
false
;
specifier
=
false
;
hasArgIndex
=
false
;
usePrefix
=
false
;
zeroPadding
=
false
;
width
=
-
1
;
argIndex
=
-
1
;
}
}
// No longer will be the first character
// No longer will be the first character
...
@@ -428,7 +529,7 @@ public final class Debugging
...
@@ -428,7 +529,7 @@ public final class Debugging
// Plain character?
// Plain character?
else
else
Debugging
.
__
print
(
c
);
Debugging
.
print
(
c
);
}
}
// End of line
// End of line
...
@@ -440,8 +541,8 @@ public final class Debugging
...
@@ -440,8 +541,8 @@ public final class Debugging
catch
(
Throwable
t
)
catch
(
Throwable
t
)
{
{
// Indicate this has occurred
// Indicate this has occurred
Debugging
.
__
print
(
'X'
);
Debugging
.
print
(
'X'
);
Debugging
.
__
print
(
'X'
);
Debugging
.
print
(
'X'
);
// End of line
// End of line
Debugging
.
__printLine
();
Debugging
.
__printLine
();
...
@@ -505,7 +606,7 @@ public final class Debugging
...
@@ -505,7 +606,7 @@ public final class Debugging
if
(
c
==
0
)
if
(
c
==
0
)
break
;
break
;
Debugging
.
__
print
(
c
,
'\0'
);
Debugging
.
print
(
c
,
'\0'
);
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment