diff options
author | Araq <rumpf_a@web.de> | 2012-05-20 18:42:50 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-05-20 18:42:50 +0200 |
commit | 29b63be9808e9b38a95864e41d0e048fcd94174c (patch) | |
tree | 25f6ea872f200c00430b82c1ea19721c11b1ed01 /lib | |
parent | e2221ab3105852b53aa9c1090a4cc9be462f9a06 (diff) | |
download | Nim-29b63be9808e9b38a95864e41d0e048fcd94174c.tar.gz |
added another system.getStackTrace
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/system.nim | 5 | ||||
-rwxr-xr-x | lib/system/excpt.nim | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index 5e575c814..642ee957f 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -190,6 +190,7 @@ type msg* {.exportc: "message".}: string ## the exception's message. Not ## providing an exception message ## is bad style. + trace: string EAsynch* = object of E_Base ## Abstract exception class for ## *asynchronous exceptions* (interrupts). @@ -1900,6 +1901,10 @@ when not defined(EcmaScript) and not defined(NimrodVM): when hostOS != "standalone": proc getStackTrace*(): string ## gets the current stack trace. This is only works for debug builds. + + proc getStackTrace*(e: ref E_Base): string + ## gets the stack trace associated with `e`, which is the stack that + ## lead to the ``raise`` statement. This is only works for debug builds. {.push stack_trace: off.} when hostOS == "standalone": diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index a523e4e04..204fba376 100755 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -194,6 +194,9 @@ proc quitOrDebug() {.inline.} = proc raiseException(e: ref E_Base, ename: CString) {.compilerRtl.} = e.name = ename + when hasSomeStackTrace: + e.trace = "" + rawWriteStackTrace(e.trace) if localRaiseHook != nil: if not localRaiseHook(e): return if globalRaiseHook != nil: @@ -253,6 +256,12 @@ proc getStackTrace(): string = else: result = "No stack traceback available\n" +proc getStackTrace(e: ref E_Base): string = + if not isNil(e) and not isNil(e.trace): + result = e.trace + else: + result = "" + when defined(endb): var dbgAborting: bool # whether the debugger wants to abort |