StackSummaryNoViewers.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Linda Howe, February 9, 1990 4:53:41 pm PST
DIRECTORY
BasicTime,
Commander,
IO,
Rope,
StackSummary,
RuntimeError,
UXStrings
;
StackSummaryNoViewers: CEDAR PROGRAM IMPORTS Commander, IO, StackSummary, Rope, RuntimeError, UXStrings =
BEGIN
originalUCS: RuntimeError.UCSProc ¬ NIL;
RegisterQuickStack: Commander.CommandProc =
BEGIN
Inner: PROC[] =
BEGIN
IF originalUCS = NIL THEN
originalUCS ¬ RuntimeError.RegisterUncaughtSignalHandler[UncaughtSignalPopUp];
END;
Inner[];
END;
DeRegisterQuickStack: Commander.CommandProc =
BEGIN
Inner: PROC[] =
BEGIN
IF originalUCS # NIL THEN
BEGIN
[] ¬ RuntimeError.RegisterUncaughtSignalHandler[originalUCS];
originalUCS ¬ NIL;
END;
END;
Inner[];
END;
PopUp will be called by Carl (and friends) when the debuggee wants to contact the debugger, i.e. when a breakpoint is reached.
UncaughtSignalPopUp: RuntimeError.UCSProc =
[msg: WORD, signal: SIGNAL ANY RETURNS ANY, frame: POINTER]
(except that at January 9, 1990 11:19:53 am PST the implementation calls with frame = NIL)
BEGIN
errorMessage: Rope.ROPE ¬ NIL;
self: CARD32 ~ 0;
printProc: StackSummary.PrintSummary ~ {
rope: Rope.ROPE ¬ StackSummary.GetRopeForBasicPCInfo[basicPCInfo, frame.absPC];
PutMsg[IO.PutFR["%g: %g\N", IO.card[frame.frameIndex], IO.rope[rope]]];
};
I belive the following test will eventually go away, when Carl arranges to turn ABORTED into a proper UNWIND. But for the moment, we have to blow the thread away when we are called for ABORTED. This logic is adapted from /pcedar2.0/Debugger/Debugger.mesa.
{ -- extra scope for EXITS
IF signal = LOOPHOLE[RuntimeError.Aborted] THEN BlowAwayThread[] ELSE
BEGIN
open a block to so that unwind catches can close the connection
BEGIN
ENABLE {
StackSummary.NoStack => {
errorMessage ¬ message;
GOTO fatal};
UNWIND => {NULL}};
StackSummary.Summary[self, printProc];
END;
PutMsg[IO.PutFR["This is the end of the stack\N"]];
ERROR ABORTED;
END;
EXITS
fatal => {
IF Rope.Length[errorMessage] # 0 THEN originalUCS[0, NIL, NIL];
};
};
END;
BlowAwayThread: PROC ~ TRUSTED MACHINE CODE {
"XR𡤎xit"
};
PutMsg: PROCEDURE [msg: Rope.ROPE] = {
MsgInner: PROC [buf: UXStrings.UnixString] = TRUSTED MACHINE CODE {
"<xr/ThreadsMsgPrivate.h>.XR𡤌onsoleMsg"
"""ThreadsMsgPrivate.h"".XR𡤌onsoleMsg"
};
buf: UXStrings.UnixString ¬ UXStrings.Create[msg];
MsgInner[buf: buf];
};
Main code
Commander.Register["RegisterQuickStack", RegisterQuickStack];
Commander.Register["DeRegisterQuickStack", DeRegisterQuickStack];
END..