added System>>backtrace

This commit is contained in:
hyunghwan.chung
2019-07-12 07:24:37 +00:00
parent 18e186677e
commit 3e506cbcfb
8 changed files with 47 additions and 45 deletions

View File

@ -313,8 +313,6 @@ class UndefinedObject(Apex)
}
}
extend Error
{
/* ----------------------------
@ -343,6 +341,7 @@ extend Error
method(#primitive) asString.
/* -----------------------
method signal
{
| exctx exblk retval actpos ctx |
@ -367,17 +366,8 @@ extend Error
// -----------------------------------------------------------------
//thisContext unwindTo: nil return: nil.
//thisContext unwindTo: (Processor activeProcess initialContext) return: nil.
// TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE...
System logNl: "== BACKTRACE ==".
ctx := thisContext.
while (ctx notNil)
{
if (ctx class == MethodContext) { System logNl: (" " & ctx method owner name & ">>" & ctx method name) }.
// TODO: include blockcontext???
ctx := ctx sender.
}.
System logNl: "== END OF BACKTRACE ==".
System backtrace.
thisContext unwindTo: (thisProcess initialContext) return: nil.
("### ERROR NOT HANDLED #### " & self class name & " - " & self asString) dump.
@ -386,4 +376,5 @@ System logNl: "== END OF BACKTRACE ==".
//Processor activeProcess terminate.
thisProcess terminate.
}
---------------------- */
}

View File

@ -69,21 +69,7 @@ TODO: can i convert 'thisProcess primError' to a relevant exception?
//thisContext unwindTo: nil return: nil.
//thisContext unwindTo: (Processor activeProcess initialContext) return: nil.
// TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... MOVE THIS TO System>>backtrace and skip the first method context for backtrace itself.
System logNl: "== BACKTRACE ==".
ctx := thisContext.
while (ctx notNil)
{
if (ctx class == MethodContext)
{
System logNl: (" " & ctx method owner name & ">>" & ctx method name &
" (" & ctx method sourceFile & " " & (ctx method ipSourceLine: (ctx pc)) asString & ")").
// TODO: get location of the current pc and include it... (ctx method sourceLine: ctx pc) asString dump.
}.
// TODO: include blockcontext???
ctx := ctx sender.
}.
System logNl: "== END OF BACKTRACE ==".
System backtrace.
thisContext unwindTo: (thisProcess initialContext) return: nil.
("### EXCEPTION NOT HANDLED(Exception) #### " & self class name & " - " & self messageText) dump.
@ -540,17 +526,7 @@ extend Apex
| class_name ctx |
class_name := if (self class == Class) { self name } else { self class name }.
// TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE...
System logNl: "== BACKTRACE ==".
ctx := thisContext.
while (ctx notNil)
{
if (ctx class == MethodContext) { System logNl: (" " & ctx method owner name & ">>" & ctx method name) }.
// TODO: include blockcontext???
ctx := ctx sender.
}.
System logNl: "== END OF BACKTRACE ==".
System backtrace.
NoSuchMessageException signal: (message_name & " not understood by " & class_name).
}

View File

@ -214,6 +214,28 @@ TODO: how to pass all variadic arguments to another variadic methods???
^self atLevel: System.Log.INFO logNl: message and: message2.
}
method(#class) backtrace
{
| ctx |
// TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... MOVE THIS TO System>>backtrace and skip the first method context for backtrace itself.
System logNl: "== BACKTRACE ==".
//ctx := thisContext.
ctx := thisContext sender. // skip the current context. skip to the caller context.
while (ctx notNil)
{
if (ctx class == MethodContext)
{
System logNl: (" " & ctx method owner name & ">>" & ctx method name &
" (" & ctx method sourceFile & " " & (ctx method ipSourceLine: (ctx pc)) asString & ")").
// TODO: get location of the current pc and include it... (ctx method sourceLine: ctx pc) asString dump.
}.
// TODO: include blockcontext???
ctx := ctx sender.
}.
System logNl: "== END OF BACKTRACE ==".
}
/* nsdic access */
method(#class) at: key
{

View File

@ -92,7 +92,8 @@ class MyObject(Object)
tb := tc at: idx.
System log(System.Log.INFO, idx asString, (if (tb value) { " PASS" } else { " FAIL" }), "\n").
].
Exception signal: 'xxx'.
Exception signal: 'experiment with exception signalling'.
// TODO:
String format("%s", " 나 는\\\"") dump.