for review: nondet stack dumps.
Tyson Dowd
trd at cs.mu.OZ.AU
Fri Apr 3 16:12:01 AEST 1998
Hi,
This was easier than I thought it would be.
Anyone not writing a paper today can review this.
===================================================================
Estimated hours taken: 1
Implement nondet stack dumps.
library/require.m:
Call MR_dump_stack with MR_curfr.
runtime/mercury_stack_trace.c:
runtime/mercury_stack_trace.h:
Get MR_curfr as input.
If we hit a nondet stack frame, handle moving down a frame a
little differently.
Index: library/require.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/require.m,v
retrieving revision 1.18
diff -u -r1.18 require.m
--- require.m 1998/03/11 05:57:41 1.18
+++ require.m 1998/04/03 05:37:43
@@ -58,7 +58,7 @@
:- pragma c_code(error(Message::in), "
fflush(stdout);
fprintf(stderr, ""Software error: %s\\n"", Message);
- MR_dump_stack(MR_succip, MR_sp);
+ MR_dump_stack(MR_succip, MR_sp, MR_curfr);
exit(1);
#ifndef USE_GCC_NONLOCAL_GOTOS
return 0; /* suppress some dumb warnings */
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.2
diff -u -r1.2 mercury_stack_trace.c
--- mercury_stack_trace.c 1998/03/16 12:23:37 1.2
+++ mercury_stack_trace.c 1998/04/03 05:42:17
@@ -15,7 +15,8 @@
#include <stdio.h>
void
-MR_dump_stack(Code *success_pointer, Word *det_stack_pointer)
+MR_dump_stack(Code *success_pointer, Word *det_stack_pointer,
+ Word *current_frame)
{
Label *label;
MR_Live_Lval location;
@@ -28,7 +29,7 @@
#ifndef MR_STACK_TRACE
fprintf(stderr, "Stack dump not available in this grade.\n");
#else
- fprintf(stderr, "Stack dump follows (deterministic stack only):\n");
+ fprintf(stderr, "Stack dump follows:\n");
do {
label = lookup_label_addr(success_pointer);
@@ -52,7 +53,7 @@
determinism = entry_layout->MR_sle_detism;
if (MR_DETISM_DET_CODE_MODEL(determinism)) {
- fprintf(stderr, "\t%s\n", label->e_name);
+ fprintf(stderr, "\t%s (det stack)\n", label->e_name);
if (type == MR_LVAL_TYPE_STACKVAR) {
success_pointer = (Code *) field(0,
det_stack_pointer, -number);
@@ -61,8 +62,12 @@
}
det_stack_pointer = det_stack_pointer -
entry_layout->MR_sle_stack_slots;
+ } else if (determinism != -1) {
+ fprintf(stderr, "\t%s (nondet stack)\n", label->e_name);
+ success_pointer = bt_succip(current_frame);
+ current_frame = bt_succfr(current_frame);
}
- } while (MR_DETISM_DET_CODE_MODEL(determinism));
+ } while (determinism != -1);
#endif /* MR_STACK_TRACE */
}
Index: runtime/mercury_stack_trace.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_stack_trace.h,v
retrieving revision 1.1
diff -u -r1.1 mercury_stack_trace.h
--- mercury_stack_trace.h 1998/03/11 05:58:42 1.1
+++ mercury_stack_trace.h 1998/04/03 05:37:13
@@ -17,13 +17,10 @@
/*
** MR_dump_stack:
** Given the succip and det stack pointer, generate a stack dump
-** showing then name of each procedure on the stack.
-** XXX
-** Currently only deterministic stack frames are handled, if a
-** nondeterministic stack frame is found while tracing down the
-** stack, the stack dump ends.
+** showing then name of each active procedure on the stack.
*/
-extern void MR_dump_stack(Code *success_pointer, Word *det_stack_pointer);
+extern void MR_dump_stack(Code *success_pointer, Word *det_stack_pointer,
+ Word *current_frame);
#endif /* MERCURY_STACK_TRACE_H */
--
Tyson Dowd # There isn't any reason why Linux can't be
# implemented as an enterprise computing solution.
trd at cs.mu.oz.au # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.
More information about the developers
mailing list