[Commit] nickle nickle.h,1.102,1.103 sched.c,1.50,1.51
Keith Packard
commit at keithp.com
Wed Jun 25 13:49:17 PDT 2003
Committed by: keithp
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv22923
Modified Files:
nickle.h sched.c
Log Message:
Add stack trace to unhandled exception message, reformat message to reduce wasted space
Index: nickle.h
===================================================================
RCS file: /local/src/CVS/nickle/nickle.h,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- nickle.h 10 Jun 2003 00:42:46 -0000 1.102
+++ nickle.h 25 Jun 2003 19:49:14 -0000 1.103
@@ -579,8 +579,8 @@
void ThreadSetState (Value thread, ThreadState state);
void ThreadClearState (Value thread, ThreadState state);
void ThreadInit (void);
-void TraceFunction (FramePtr frame, CodePtr code, ExprPtr name);
-void TraceFrame (FramePtr frame, ObjPtr obj, InstPtr pc);
+void TraceFunction (Value file, FramePtr frame, CodePtr code, ExprPtr name);
+void TraceFrame (Value file, FramePtr frame, ObjPtr obj, InstPtr pc, int depth);
void ThreadStackDump (Value thread);
typedef struct _jump {
Index: sched.c
===================================================================
RCS file: /local/src/CVS/nickle/sched.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- sched.c 10 Jun 2003 00:42:46 -0000 1.50
+++ sched.c 25 Jun 2003 19:49:14 -0000 1.51
@@ -348,38 +348,45 @@
}
void
-TraceFunction (FramePtr frame, CodePtr code, ExprPtr name)
+TraceFunction (Value file, FramePtr frame, CodePtr code, ExprPtr name)
{
int fe;
+ FilePuts (file, " ");
if (name)
- PrettyExpr (FileStdout, name, -1, 0, False, 0);
+ PrettyExpr (file, name, -1, 0, False, 0);
else
- FilePuts (FileStdout, "<anonymous>");
- FilePuts (FileStdout, " (");
+ FilePuts (file, "<anonymous>");
+ FilePuts (file, " (");
for (fe = 0; fe < code->base.argc; fe++)
{
if (fe)
- FilePuts (FileStdout, ", ");
- FilePrintf (FileStdout, "%v", BoxValue (frame->frame, fe));
+ FilePuts (file, ", ");
+ FilePrintf (file, "%v", BoxValue (frame->frame, fe));
}
- FilePuts (FileStdout, ")\n");
+ FilePuts (file, ")\n");
+}
+
+static void
+TraceStatement (Value file, ExprPtr stat)
+{
+ FilePrintf (file, "%A:%d: ", stat->base.file, stat->base.line);
+ PrettyStat (file, stat, False);
}
void
-TraceFrame (FramePtr frame, ObjPtr obj, InstPtr pc)
+TraceFrame (Value file, FramePtr frame, ObjPtr obj, InstPtr pc, int depth)
{
ENTER ();
int max;
CodePtr code;
- PrettyStat (FileStdout, ObjStatement (obj, pc), False);
- for (max = 20; frame && max--; frame = frame->previous)
+ TraceStatement (file, ObjStatement (obj, pc));
+ for (max = depth; frame && max--; frame = frame->previous)
{
code = frame->function->func.code;
- TraceFunction (frame, code, code->base.name);
- PrettyStat (FileStdout, ObjStatement (frame->saveObj,
- frame->savePc), False);
+ TraceFunction (file, frame, code, code->base.name);
+ TraceStatement (file, ObjStatement (frame->saveObj, frame->savePc));
}
EXIT ();
}
@@ -389,7 +396,7 @@
TraceIndent (int indent)
{
while (indent--)
- FilePuts (FileStdout, " ");
+ FilePuts (file, " ");
}
#endif
@@ -401,11 +408,18 @@
FramePtr frame;
InstPtr pc;
ObjPtr obj;
+ int depth = 20;
if (n == 0)
v = lookupVar (0, "cont");
else
- v = *p;
+ v = p[0];
+ if (n > 1)
+ {
+ depth = IntPart (p[1], "Invalid trace depth");
+ if (aborting)
+ RETURN (Void);
+ }
switch (ValueTag(v)) {
case rep_thread:
case rep_continuation:
@@ -424,7 +438,7 @@
1, v);
RETURN (Void);
}
- TraceFrame (frame, obj, pc);
+ TraceFrame (FileStdout, frame, obj, pc, depth);
RETURN(Void);
}
@@ -1049,21 +1063,23 @@
if (!continuation)
{
int i;
- ObjPtr obj = thread->thread.continuation.obj;
InstPtr pc = thread->thread.continuation.pc;
- ExprPtr stat = ObjStatement (obj, pc);
- if (stat->base.file)
- PrintError ("Unhandled exception \"%A\" at %A:%d\n",
- except->symbol.name, stat->base.file, stat->base.line);
- else
- PrintError ("Unhandled exception \"%A\"\n",
- except->symbol.name);
+ PrintError ("Unhandled exception %A (", except->symbol.name);
if (args)
{
for (i = 0; i < args->array.ents; i++)
- PrintError ("\t%v\n", BoxValueGet (args->array.values, i));
+ {
+ PrintError ("%v", BoxValueGet (args->array.values, i));
+ if (i < args->array.ents - 1)
+ PrintError (", ");
+ }
}
+ PrintError (")\n");
+ TraceFrame (FileStderr, thread->thread.continuation.frame,
+ thread->thread.continuation.obj,
+ pc,
+ 20);
continuation = EmptyContinuation();
STACK_PUSH (continuation->stack,
NewContinuation (&thread->thread.continuation, pc));
More information about the Commit
mailing list