Oberon || Library || Module Index || Search Engine || Definition || Module
PROCEDURE PrintBackTrace(s: Streams.Stream; cr: Coroutines.Coroutine); PROCEDURE PrintAllBackTraces(s: Streams.Stream);
Each line in a backtrace specifies the contents of two major registers (frame pointer and program counter) in hex and the qualified name of the procedure.
PrintBackTrace prints the backtrace for cr onto s. The results are undefined if cr is the current coroutine.
PrintAllBackTraces prints the backtraces of all coroutines onto s. Multiple back traces are separated by empty lines.
MODULE CrashHandler; IMPORT Coroutines, Errors, Events, Process, Streams, SysStackTraces, SYSTEM, Write; PROCEDURE PrintBackTrace(VAR cr: Coroutines.Coroutine); BEGIN SYSTEM.CRSPAWN(cr); SysStackTraces.PrintBackTrace(Streams.stderr, Coroutines.source); SYSTEM.CRSWITCH(Coroutines.source); END PrintBackTrace; PROCEDURE AbortHandler(event: Events.Event); VAR cr: Coroutines.Coroutine; BEGIN Write.StringS(Streams.stderr, Process.name); Write.StringS(Streams.stderr, ": "); Errors.Write(Streams.stderr, event); Write.LnS(Streams.stderr); Write.LineS(Streams.stderr, "backtrace of current coroutine:"); PrintBackTrace(cr); SYSTEM.CRSWITCH(cr); END AbortHandler; BEGIN Events.Handler(Process.abort, AbortHandler); END CrashHandler.Please note that SysStackTraces.PrintBackTrace creates a new coroutine for printing the backtrace as a coroutine shall not print its own backtrace.
Oberon || Library || Module Index || Search Engine || Definition || Module