Check-in [335466fed4]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Base for new way to do call traces via the system call interface.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 335466fed43d6f76c4c3af886ea65dddb4831291
User & Date: stephanie.gawroriski 2019-06-16 23:01:45
Context
2019-06-16
23:05
Implement CallTraceElement.traceRaw(). check-in: 21f1d5cbaa user: stephanie.gawroriski tags: trunk
23:01
Base for new way to do call traces via the system call interface. check-in: 335466fed4 user: stephanie.gawroriski tags: trunk
22:40
Define API for obtaining the call stack. check-in: 3dea657674 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bldt/javase/libs/javase-runtime/cc/squirreljme/runtime/cldc/asm/DebugAccess.java.

19
20
21
22
23
24
25

26
27
28
29
30
31
32
..
59
60
61
62
63
64
65

66
67
68
69
70
71
72
..
82
83
84
85
86
87
88

89
90
91
92
93
94
95
...
144
145
146
147
148
149
150

151
152
153
154
155
156
157
...
176
177
178
179
180
181
182

183
184
185
186
187
188
189
...
194
195
196
197
198
199
200

201
202
203
204
205
206
207
208
209
210
211
212
213

214
215
216
217
218
219
220
...
225
226
227
228
229
230
231

232
233
234
235
236
237
238
239
240
241
242
243
244

245
246
247
248
249
250
251
...
254
255
256
257
258
259
260

261
262
263
264
265
266
267
...
276
277
278
279
280
281
282

283
284
285
286
287
288
289
...
297
298
299
300
301
302
303

304
305
306
307
308
309
310
/**
 * This is used to provide debug access to the virtual machine and to do
 * some unsafe things. This file is for the Java SE bootstrap since it does not
 * know what SquirrelJME does in its library.
 *
 * @since 2018/09/29
 */

public final class DebugAccess
{
	/** The elements per trace. */
	public static final int TRACE_COUNT =
		11;
	
	/** Lock. */
................................................................................
	 * Since the code might end up infinite looping while constantly hitting
	 * TODOs, this is a means it might not be reported properly. This call
	 * should be fatal and terminate the machine.
	 *
	 * @param __rct The raw trace code.
	 * @since 2018/09/19
	 */

	public static final void fatalTodoReport(int[] __rct)
	{
		new Error(Arrays.toString(__rct)).printStackTrace(System.err);
		System.exit(-1);
	}
	
	/**
................................................................................
	 *  10 . The line of code in the file this is in, if it is possible to get.
	 *
	 * If any value is unknown then {@code -1} will be used as the value.
	 *
	 * @return The raw call trace in pointer and value format.
	 * @since 2018/09/16
	 */

	public static final int[] rawCallTrace()
	{
		// Get origin trace
		StackTraceElement[] from = new Throwable().getStackTrace();
		int n = from.length;
		
		// Convert to call trace elements
................................................................................
	 * simpler to easier to parse.
	 *
	 * @param __v The input raw call trace.
	 * @return The translated call trace.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */

	public static final CallTraceElement[] resolveRawCallTrace(int[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		int rawlen = __v.length,
................................................................................
	 * Resolves the given string pointer.
	 *
	 * @param __p The pointer.
	 * @return The string at the given pointer or {@code null} if it has no
	 * resolution.
	 * @since 2018/09/29
	 */

	public static final String resolveString(long __p)
	{
		if (__p == -1L)
			return null;
		
		synchronized (DebugAccess._LOCK)
		{
................................................................................
	/**
	 * Unresolves the string to the given pointer.
	 *
	 * @param __s The string to resolve.
	 * @return The pointer to the string, or {@code -1} if it is not valid.
	 * @since 2018/09/29
	 */

	public static final long unresolveString(String __s)
	{
		return DebugAccess.__unresolveString(__s);
	}
	
	/**
	 * Combines an integer to long.
	 *
	 * @param __dx The index.
	 * @param __v The input integers.
	 * @return The resulting long.
	 * @since 2018/09/29
	 */

	static final long __intToLong(int __dx, int[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return (((long)__v[__dx]) << 32L) |
................................................................................
	 * Splits long to integers.
	 *
	 * @param __dx The index.
	 * @param __v The output integers.
	 * @param __l The input long.
	 * @since 2018/09/29
	 */

	static final void __longToInt(int __dx, int[] __v, long __l)
	{
		__v[__dx] = (int)(__l >>> 32);
		__v[__dx + 1] = (int)__l;
	}
	
	/**
	 * Normalize class name string.
	 *
	 * @param __s The input string.
	 * @return The normalized string.
	 * @since 2018/09/29
	 */

	static final String __normalize(String __s)
	{
		if (__s == null)
			return null;
		
		return __s.replace('.', '/');
	}
................................................................................
	 * Converts a debug call trace element to a stack trace element.
	 *
	 * @param __e The input element.
	 * @return The converted element.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/15
	 */

	static StackTraceElement __stackDebugToJava(CallTraceElement __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		String clname = __e.className();
................................................................................
	 * Converts a stack trace element to a debug call trace element.
	 *
	 * @param __e The input element.
	 * @return The converted element.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/15
	 */

	static CallTraceElement __stackJavaToDebug(StackTraceElement __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		String clname = __e.getClassName();
................................................................................
	/**
	 * Unresolves the given string.
	 *
	 * @param __s The string to unresolve.
	 * @return The pointer to the string.
	 * @since 2018/09/29
	 */

	static long __unresolveString(String __s)
	{
		if (__s == null)
			return -1L;
		
		synchronized (DebugAccess._LOCK)
		{







>







 







>







 







>







 







>







 







>







 







>













>







 







>













>







 







>







 







>







 







>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
...
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
...
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
...
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/**
 * This is used to provide debug access to the virtual machine and to do
 * some unsafe things. This file is for the Java SE bootstrap since it does not
 * know what SquirrelJME does in its library.
 *
 * @since 2018/09/29
 */
@Deprecated
public final class DebugAccess
{
	/** The elements per trace. */
	public static final int TRACE_COUNT =
		11;
	
	/** Lock. */
................................................................................
	 * Since the code might end up infinite looping while constantly hitting
	 * TODOs, this is a means it might not be reported properly. This call
	 * should be fatal and terminate the machine.
	 *
	 * @param __rct The raw trace code.
	 * @since 2018/09/19
	 */
	@Deprecated
	public static final void fatalTodoReport(int[] __rct)
	{
		new Error(Arrays.toString(__rct)).printStackTrace(System.err);
		System.exit(-1);
	}
	
	/**
................................................................................
	 *  10 . The line of code in the file this is in, if it is possible to get.
	 *
	 * If any value is unknown then {@code -1} will be used as the value.
	 *
	 * @return The raw call trace in pointer and value format.
	 * @since 2018/09/16
	 */
	@Deprecated
	public static final int[] rawCallTrace()
	{
		// Get origin trace
		StackTraceElement[] from = new Throwable().getStackTrace();
		int n = from.length;
		
		// Convert to call trace elements
................................................................................
	 * simpler to easier to parse.
	 *
	 * @param __v The input raw call trace.
	 * @return The translated call trace.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	@Deprecated
	public static final CallTraceElement[] resolveRawCallTrace(int[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		int rawlen = __v.length,
................................................................................
	 * Resolves the given string pointer.
	 *
	 * @param __p The pointer.
	 * @return The string at the given pointer or {@code null} if it has no
	 * resolution.
	 * @since 2018/09/29
	 */
	@Deprecated
	public static final String resolveString(long __p)
	{
		if (__p == -1L)
			return null;
		
		synchronized (DebugAccess._LOCK)
		{
................................................................................
	/**
	 * Unresolves the string to the given pointer.
	 *
	 * @param __s The string to resolve.
	 * @return The pointer to the string, or {@code -1} if it is not valid.
	 * @since 2018/09/29
	 */
	@Deprecated
	public static final long unresolveString(String __s)
	{
		return DebugAccess.__unresolveString(__s);
	}
	
	/**
	 * Combines an integer to long.
	 *
	 * @param __dx The index.
	 * @param __v The input integers.
	 * @return The resulting long.
	 * @since 2018/09/29
	 */
	@Deprecated
	static final long __intToLong(int __dx, int[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return (((long)__v[__dx]) << 32L) |
................................................................................
	 * Splits long to integers.
	 *
	 * @param __dx The index.
	 * @param __v The output integers.
	 * @param __l The input long.
	 * @since 2018/09/29
	 */
	@Deprecated
	static final void __longToInt(int __dx, int[] __v, long __l)
	{
		__v[__dx] = (int)(__l >>> 32);
		__v[__dx + 1] = (int)__l;
	}
	
	/**
	 * Normalize class name string.
	 *
	 * @param __s The input string.
	 * @return The normalized string.
	 * @since 2018/09/29
	 */
	@Deprecated
	static final String __normalize(String __s)
	{
		if (__s == null)
			return null;
		
		return __s.replace('.', '/');
	}
................................................................................
	 * Converts a debug call trace element to a stack trace element.
	 *
	 * @param __e The input element.
	 * @return The converted element.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/15
	 */
	@Deprecated
	static StackTraceElement __stackDebugToJava(CallTraceElement __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		String clname = __e.className();
................................................................................
	 * Converts a stack trace element to a debug call trace element.
	 *
	 * @param __e The input element.
	 * @return The converted element.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/15
	 */
	@Deprecated
	static CallTraceElement __stackJavaToDebug(StackTraceElement __e)
		throws NullPointerException
	{
		if (__e == null)
			throw new NullPointerException("NARG");
		
		String clname = __e.getClassName();
................................................................................
	/**
	 * Unresolves the given string.
	 *
	 * @param __s The string to unresolve.
	 * @return The pointer to the string.
	 * @since 2018/09/29
	 */
	@Deprecated
	static long __unresolveString(String __s)
	{
		if (__s == null)
			return -1L;
		
		synchronized (DebugAccess._LOCK)
		{

Changes to runt/apis/cldc-compact/cc/squirreljme/jvm/CallStackItem.java.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public interface CallStackItem
{
	/** The class name. */
	public static final short CLASS_NAME =
		0;
	
	/** The method name. */
	public static final short METHOD_NAME
		1;
	
	/** The method type. */
	public static final short METHOD_TYPE =
		2;
	
	/** Source line. */







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public interface CallStackItem
{
	/** The class name. */
	public static final short CLASS_NAME =
		0;
	
	/** The method name. */
	public static final short METHOD_NAME =
		1;
	
	/** The method type. */
	public static final short METHOD_TYPE =
		2;
	
	/** Source line. */

Changes to runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/asm/DebugAccess.java.

16
17
18
19
20
21
22

23
24
25
26
27
28
29
..
42
43
44
45
46
47
48

49
50
51
52
53
54
55
..
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88
89

90
91
92
93
94
95
96
97
98
99

100
101
102
103
104
105
106
...
112
113
114
115
116
117
118

119
120
121
122
123
124
125

/**
 * This is used to provide debug access to the virtual machine and to do
 * some unsafe things.
 *
 * @since 2018/09/16
 */

public final class DebugAccess
{
	/** The elements per trace. */
	public static final int TRACE_COUNT =
		11;
	
	/**
................................................................................
	 * TODOs, this is a means it might not be reported properly. This call
	 * should be fatal and terminate the machine.
	 *
	 * @param __rct The raw trace code.
	 * @since 2018/09/19
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)

	public static final native void fatalTodoReport(int[] __rct);
	
	/**
	 * Returns the raw call trace without any objects.
	 *
	 * The values are in groups of longs for each individual element, dual
	 * elements are in {@code [high, low]} order:
................................................................................
	 *
	 * If any value is unknown then {@code -1} will be used as the value.
	 *
	 * @return The raw call trace in pointer and value format.
	 * @since 2018/09/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)

	public static final native int[] rawCallTrace();
	
	/**
	 * Resolves the given string pointer.
	 *
	 * @param __p The pointer.
	 * @return The string at the given pointer or {@code null} if it has no
	 * resolution.
	 * @since 2018/09/29
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)

	public static final native String resolveString(long __p);
	
	/**
	 * Unresolves the string to the given pointer.
	 *
	 * @param __s The string to resolve.
	 * @return The pointer to the string, or {@code -1} if it is not valid.
	 * @since 2018/09/29
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)

	public static final native long unresolveString(String __s);
	
	/**
	 * Combines an integer to long.
	 *
	 * @param __dx The index.
	 * @param __v The input integers.
	 * @return The resulting long.
	 * @since 2018/09/29
	 */

	public static final long intToLong(int __dx, int[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return (((long)__v[__dx]) << 32L) |
................................................................................
	 * simpler to easier to parse.
	 *
	 * @param __v The input raw call trace.
	 * @return The translated call trace.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */

	public static final CallTraceElement[] resolveRawCallTrace(int[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		int rawlen = __v.length,







>







 







>







 







>











>










>










>







 







>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
..
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

/**
 * This is used to provide debug access to the virtual machine and to do
 * some unsafe things.
 *
 * @since 2018/09/16
 */
@Deprecated
public final class DebugAccess
{
	/** The elements per trace. */
	public static final int TRACE_COUNT =
		11;
	
	/**
................................................................................
	 * TODOs, this is a means it might not be reported properly. This call
	 * should be fatal and terminate the machine.
	 *
	 * @param __rct The raw trace code.
	 * @since 2018/09/19
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native void fatalTodoReport(int[] __rct);
	
	/**
	 * Returns the raw call trace without any objects.
	 *
	 * The values are in groups of longs for each individual element, dual
	 * elements are in {@code [high, low]} order:
................................................................................
	 *
	 * If any value is unknown then {@code -1} will be used as the value.
	 *
	 * @return The raw call trace in pointer and value format.
	 * @since 2018/09/16
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native int[] rawCallTrace();
	
	/**
	 * Resolves the given string pointer.
	 *
	 * @param __p The pointer.
	 * @return The string at the given pointer or {@code null} if it has no
	 * resolution.
	 * @since 2018/09/29
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native String resolveString(long __p);
	
	/**
	 * Unresolves the string to the given pointer.
	 *
	 * @param __s The string to resolve.
	 * @return The pointer to the string, or {@code -1} if it is not valid.
	 * @since 2018/09/29
	 */
	@Api(ApiLevel.LEVEL_SQUIRRELJME_0_2_0_20181225)
	@Deprecated
	public static final native long unresolveString(String __s);
	
	/**
	 * Combines an integer to long.
	 *
	 * @param __dx The index.
	 * @param __v The input integers.
	 * @return The resulting long.
	 * @since 2018/09/29
	 */
	@Deprecated
	public static final long intToLong(int __dx, int[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		return (((long)__v[__dx]) << 32L) |
................................................................................
	 * simpler to easier to parse.
	 *
	 * @param __v The input raw call trace.
	 * @return The translated call trace.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/09/16
	 */
	@Deprecated
	public static final CallTraceElement[] resolveRawCallTrace(int[] __v)
		throws NullPointerException
	{
		if (__v == null)
			throw new NullPointerException("NARG");
		
		int rawlen = __v.length,

Changes to runt/apis/cldc-compact/cc/squirreljme/runtime/cldc/debug/CallTraceElement.java.

6
7
8
9
10
11
12




13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
547
548
549
550
551
552
553

554
555
556
557
558
559
560
...
566
567
568
569
570
571
572

573
574
575
576
577
578
579
580
581
582
583
584
585
586


587











































// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.cldc.debug;





import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a single entry within the call stack. This is used for
 * debugging purporses to determine where code has thrown an exception.
 *
 * @since 2018/02/21
 */
public final class CallTraceElement
{
	/** The class name. */
	protected final String classname;
................................................................................
	 * @param __l The length of the input data.
	 * @return The resulting call trace element.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/14
	 */

	public static final CallTraceElement[] decode(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
................................................................................
	 * Encodes all of the specified call trace elements to a byte array and
	 * returns it.
	 *
	 * @param __e The elements to encode
	 * @return The byte array containing encoded call trace information.
	 * @since 2018/03/14
	 */

	public static final byte[] encode(CallTraceElement... __el)
	{
		// Decode each sequence.
		__el = (__el == null ? new CallTraceElement[0] : __el.clone());
		for (int i = 0, n = __el.length; i < n; i++)
		{
			CallTraceElement e = __el[i];
			
			throw new todo.TODO();
		}
		
		throw new todo.TODO();
	}
}





















































>
>
>
>






|







 







>







 







>













|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
...
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
...
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

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 java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Objects;

/**
 * This represents a single entry within the call stack. This is used for
 * debugging purposes to determine where code has thrown an exception.
 *
 * @since 2018/02/21
 */
public final class CallTraceElement
{
	/** The class name. */
	protected final String classname;
................................................................................
	 * @param __l The length of the input data.
	 * @return The resulting call trace element.
	 * @throws ArrayIndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2018/03/14
	 */
	@Deprecated
	public static final CallTraceElement[] decode(byte[] __b, int __o, int __l)
		throws ArrayIndexOutOfBoundsException, NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new ArrayIndexOutOfBoundsException("IOOB");
................................................................................
	 * Encodes all of the specified call trace elements to a byte array and
	 * returns it.
	 *
	 * @param __e The elements to encode
	 * @return The byte array containing encoded call trace information.
	 * @since 2018/03/14
	 */
	@Deprecated
	public static final byte[] encode(CallTraceElement... __el)
	{
		// Decode each sequence.
		__el = (__el == null ? new CallTraceElement[0] : __el.clone());
		for (int i = 0, n = __el.length; i < n; i++)
		{
			CallTraceElement e = __el[i];
			
			throw new todo.TODO();
		}
		
		throw new todo.TODO();
	}
	
	/**
	 * Obtains the current call trace.
	 *
	 * @return The current call trace.
	 * @since 2019/06/16
	 */
	public static final CallTraceElement[] trace()
	{
		return CallTraceElement.traceResolve(CallTraceElement.traceRaw());
	}
	
	/**
	 * Obtains the current raw call trace which has not been resolved.
	 *
	 * @return The raw call trace.
	 * @since 2019/06/16
	 */
	public static final int[] traceRaw()
	{
		// Get the call height, ignore if not supported!
		int callheight = Assembly.sysCallPV(SystemCallIndex.CALL_STACK_HEIGHT);
		if (callheight <= 0 || Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.CALL_STACK_HEIGHT) != SystemCallError.NO_ERROR)
			return new int[0];
		
		throw new todo.TODO();
	}
	
	/**
	 * Resolves the specified call trace into call trace elements.
	 *
	 * @param __trace The trace to resolve.
	 * @return The resolved trace.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/06/16
	 */
	public static final CallTraceElement[] traceResolve(int[] __trace)
		throws NullPointerException
	{
		if (__trace == null)
			throw new NullPointerException("NARG");
		
		throw new todo.TODO();
	}
}

Changes to runt/apis/cldc-compact/java/lang/Throwable.java.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;

import cc.squirreljme.runtime.cldc.asm.DebugAccess;
import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * This class is the base class for all types which are thrown, itself being a
................................................................................
 * exception that was caused in a try-with-resources when the resource was
 * attempted to be closed.
 *
 * @since 2018/09/15
 */
public class Throwable
{
	/** String ID for the throwable. */
	private static final int _THROWABLE_ID_HI,
		_THROWABLE_ID_LO;
	
	/** Exception message. */
	private static final int _TYPE_EXCEPTION =
		0;
	
	/** Caused by message. */
	private static final int _TYPE_CAUSED_BY =
		1;
................................................................................
	 * constructor.
	 */
	private volatile Throwable _cause;
	
	/** The stack trace for this throwable (in raw form). */
	private volatile int[] _stack;
	
	/**
	 * Initializes the throwable ID.
	 *
	 * @since 2018/09/29
	 */
	static
	{
		long id = DebugAccess.unresolveString("java/lang/Throwable");
		_THROWABLE_ID_HI = (int)(id >>> 32);
		_THROWABLE_ID_LO = (int)id;
	}
	
	/**
	 * Initializes a throwable with no cause or message.
	 *
	 * @since 2018/09/15
	 */
	public Throwable()
	{
................................................................................
	{
		// {@squirreljme.error ZZ1h Cannot specify a negative clip for a
		// stack trace.}
		if (__clip < 0)
			throw new IllegalArgumentException("ZZ1h");
		
		// Get the raw trace here
		int[] rawstack = DebugAccess.rawCallTrace();
		
		// Determine the new length of the raw data
		int len = rawstack.length,
			skippy = DebugAccess.TRACE_COUNT * (__clip + 1),
			newlen = len - skippy;
		if (newlen < 0)
			newlen = 0;
		
		// If this is initializer clipping, clip out any references that lead
		// up to this Throwable class so that they do not appear on the stack
		// at all
		int thi = Throwable._THROWABLE_ID_HI,
			tlo = Throwable._THROWABLE_ID_LO;
		if (__initclip && __this != null && thi != -1 && tlo != -1)
		{
			// Resolve the name for this class, because it will be at the
			// bottom of the constructor stack
			long lid = DebugAccess.unresolveString(
				__this.getClass()._data.binaryName());
			
			// Split off IDs
			int lhi = (int)(lid >>> 32),
				llo = (int)lid;
			
			// Go down the trace and find the first instance
			int scan = 0;
			boolean seek = true,
				hit = false;
			for (; scan < len; scan += DebugAccess.TRACE_COUNT)
			{
				// Read scan here
				int xhi = rawstack[scan],
					xlo = rawstack[scan + 1];
				
				// Missing trace information, we do not want to lose this
				// information at all so just ignore!
				if (xhi == -1 && xlo == -1)
					break;
				
				// Seek to the current class for this current object
				if (seek)
				{
					// We found our class, switch out of seek mode
					if (lhi == xhi && llo == xlo)
					{
						seek = false;
						break;
					}
				}
				else
				{
					// Stop on the first entry which is not in this class
					if (lhi != xhi || llo != xlo)
					{
						hit = true;
						break;
					}
				}
			}
			
			// Use the new scan instead, only if it was found
			if (hit)
			{
				skippy = scan;
				newlen = len - skippy;
				
				if (newlen < 0)
					newlen = 0;
			}
		}
		
		// Copy the trace data into this one
		int[] rv = new int[newlen];
		for (int i = skippy, o = 0; o < newlen; i++, o++)
			rv[o] = rawstack[i];
		
		return rv;
	}
	
	/**
	 * Prints the indentation of the stack trace.
	 *
	 * @param __ps The stream to print to.
	 * @param __indent The current indentation.
................................................................................
		if (rawstack == null)
		{
			__ps.println("<No stack trace>");
			return;
		}
		
		// Resolve the stack trace so it is easier to work with
		CallTraceElement[] stack = DebugAccess.resolveRawCallTrace(rawstack);
		
		// Indent and print exception type
		Throwable.__printStackIndent(__ps, __indent);
		switch (__type)
		{
			case _TYPE_CAUSED_BY:
				__ps.print("> CAUSED BY ");







<







 







<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<







 







|

|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|







 







|







6
7
8
9
10
11
12

13
14
15
16
17
18
19
..
27
28
29
30
31
32
33




34
35
36
37
38
39
40
..
59
60
61
62
63
64
65












66
67
68
69
70
71
72
...
341
342
343
344
345
346
347
348
349
350










































































351
352
353
354
355
356
357
358
...
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package java.lang;


import cc.squirreljme.runtime.cldc.debug.CallTraceElement;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * This class is the base class for all types which are thrown, itself being a
................................................................................
 * exception that was caused in a try-with-resources when the resource was
 * attempted to be closed.
 *
 * @since 2018/09/15
 */
public class Throwable
{




	/** Exception message. */
	private static final int _TYPE_EXCEPTION =
		0;
	
	/** Caused by message. */
	private static final int _TYPE_CAUSED_BY =
		1;
................................................................................
	 * constructor.
	 */
	private volatile Throwable _cause;
	
	/** The stack trace for this throwable (in raw form). */
	private volatile int[] _stack;
	












	/**
	 * Initializes a throwable with no cause or message.
	 *
	 * @since 2018/09/15
	 */
	public Throwable()
	{
................................................................................
	{
		// {@squirreljme.error ZZ1h Cannot specify a negative clip for a
		// stack trace.}
		if (__clip < 0)
			throw new IllegalArgumentException("ZZ1h");
		
		// Get the raw trace here
		int[] rawstack = CallTraceElement.traceRaw();
		
		// Just use the raw stack










































































		return rawstack;
	}
	
	/**
	 * Prints the indentation of the stack trace.
	 *
	 * @param __ps The stream to print to.
	 * @param __indent The current indentation.
................................................................................
		if (rawstack == null)
		{
			__ps.println("<No stack trace>");
			return;
		}
		
		// Resolve the stack trace so it is easier to work with
		CallTraceElement[] stack = CallTraceElement.traceResolve(rawstack);
		
		// Indent and print exception type
		Throwable.__printStackIndent(__ps, __indent);
		switch (__type)
		{
			case _TYPE_CAUSED_BY:
				__ps.print("> CAUSED BY ");

Changes to runt/apis/cldc-compact/todo/TODO.java.

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
	public TODO(String __s)
	{
		super(__s);
		
		// Detect TODOs tripping multiple times and fail
		boolean doubletripped = TODO._DOUBLE_TRIP;
		if (doubletripped)
			DebugAccess.fatalTodoReport(DebugAccess.rawCallTrace());
		TODO._DOUBLE_TRIP = true;
		
		// Print a starting banner, but only if the error stream exists
		PrintStream ps = System.err;
		if (ps != null)
		{
			ps.println("****************************************************");
................................................................................
		}
		
		// No streams are currently available, but we would still like to
		// report the trace information to the debugger, we might not be in any
		// condition to actually do printing to the console so this will end
		// here
		else
			DebugAccess.fatalTodoReport(DebugAccess.rawCallTrace());
		
		// {@squirreljme.property
		// cc.squirreljme.notodoexit=(boolean)
		// If this is {@code true} then the ToDo exception will not tell the
		// virtual machine to exit.}
		if (!Boolean.valueOf(
			System.getProperty("cc.squirreljme.notodoexit")))
................................................................................
	 * @return The call trace element for the current location.
	 * @since 2018/04/02
	 */
	static final CallTraceElement __where()
	{
		// For the SquirrelJME runtime, use the debug stuff to get the
		// current call trace
		CallTraceElement[] stack = DebugAccess.resolveRawCallTrace(
			DebugAccess.rawCallTrace());
		
		// Get the first one which is not in this class
		for (CallTraceElement e : stack)
		{
			String cn = e.className();
			if (cn == null)
				cn = "<unknown>";







|







 







|







 







|
<







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
...
433
434
435
436
437
438
439
440

441
442
443
444
445
446
447
	public TODO(String __s)
	{
		super(__s);
		
		// Detect TODOs tripping multiple times and fail
		boolean doubletripped = TODO._DOUBLE_TRIP;
		if (doubletripped)
			DebugAccess.fatalTodoReport(CallTraceElement.traceRaw());
		TODO._DOUBLE_TRIP = true;
		
		// Print a starting banner, but only if the error stream exists
		PrintStream ps = System.err;
		if (ps != null)
		{
			ps.println("****************************************************");
................................................................................
		}
		
		// No streams are currently available, but we would still like to
		// report the trace information to the debugger, we might not be in any
		// condition to actually do printing to the console so this will end
		// here
		else
			DebugAccess.fatalTodoReport(CallTraceElement.traceRaw());
		
		// {@squirreljme.property
		// cc.squirreljme.notodoexit=(boolean)
		// If this is {@code true} then the ToDo exception will not tell the
		// virtual machine to exit.}
		if (!Boolean.valueOf(
			System.getProperty("cc.squirreljme.notodoexit")))
................................................................................
	 * @return The call trace element for the current location.
	 * @since 2018/04/02
	 */
	static final CallTraceElement __where()
	{
		// For the SquirrelJME runtime, use the debug stuff to get the
		// current call trace
		CallTraceElement[] stack = CallTraceElement.trace();

		
		// Get the first one which is not in this class
		for (CallTraceElement e : stack)
		{
			String cn = e.className();
			if (cn == null)
				cn = "<unknown>";

Changes to runt/klib/supervisor/cc/squirreljme/jvm/CallStackItem.java.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public interface CallStackItem
{
	/** The class name. */
	public static final short CLASS_NAME =
		0;
	
	/** The method name. */
	public static final short METHOD_NAME
		1;
	
	/** The method type. */
	public static final short METHOD_TYPE =
		2;
	
	/** Source line. */







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public interface CallStackItem
{
	/** The class name. */
	public static final short CLASS_NAME =
		0;
	
	/** The method name. */
	public static final short METHOD_NAME =
		1;
	
	/** The method type. */
	public static final short METHOD_TYPE =
		2;
	
	/** Source line. */