diff: fix some mdb bugs
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Dec 9 22:42:04 AEDT 1998
Estimated hours taken: 8
Fix a few bugs in the debugger.
compiler/trace.m:
Fix a bug for procedures compiled with shallow tracing:
if from_full is false, it still needs to save the call depth,
since calls in the body of the procedure will reset the
call depth to the saved value.
Also fix some comment rot.
trace/mercury_trace_internal.c:
Fix a couple of problems with the retry command:
- if we're already at a call port, then just print a
warning rather than finishing the call and then
retrying it;
- restore MR_trace_from_full to TRUE before jumping
to the procedure.
runtime/mercury_stack_trace.c:
Fix some problems with the printing of detailed stack traces:
- for procedures whose stack layouts didn't include execution
tracing information, the columns didn't match up;
- for procedures with shallow (interface) tracing only,
it was sometimes printing out bogus details.
runtime/mercury_trace_base.c:
Fix some formatting problems in the error message output by
MR_trace_fake().
--- ../mercury-compiler-0.8/compiler/trace.m Mon Nov 16 00:34:12 1998
+++ compiler/trace.m Wed Dec 9 15:54:03 1998
@@ -12,12 +12,13 @@
% "Opium: An extendable trace analyser for Prolog" by Mireille Ducasse,
% available from http://www.irisa.fr/lande/ducasse.
%
-% We reserve two slots in the stack frame of the traced procedure.
+% We reserve some slots in the stack frame of the traced procedure.
% One contains the call sequence number, which is set in the procedure prologue
-% by incrementing a global counter. The other contains the call depth, which
+% by incrementing a global counter. An other contains the call depth, which
% is also set by incrementing a global variable containing the depth of the
% caller. The caller sets this global variable from its own saved depth
-% just before the call.
+% just before the call. We also save the event number, and sometimes also
+% the redo layout and the from_full flag.
%
% Each event has a label associated with it. The stack layout for that label
% records what variables are live and where they are at the time of the event.
@@ -308,6 +309,8 @@
"\t\t", CallFromFullSlotStr, " = MR_trace_from_full;\n",
"\t\tif (MR_trace_from_full) {\n",
FillFourSlots, "\n",
+ "\t\t} else {\n",
+ "\t\t\t", CallDepthStr, " = MR_trace_call_depth;\n",
"\t\t}"
], TraceStmt)
;
--- ../mercury-compiler-0.8/runtime/mercury_stack_trace.c Sat Nov 14 00:30:40 1998
+++ runtime/mercury_stack_trace.c Wed Dec 9 14:19:54 1998
@@ -378,9 +378,34 @@
fatal_error("cannot print procedure id without layout");
}
- if (MR_ENTRY_LAYOUT_HAS_EXEC_TRACE(entry)) {
- if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
- if (base_sp != NULL) {
+ if (base_sp != NULL && base_curfr != NULL) {
+ bool print_details = FALSE;
+ if (MR_ENTRY_LAYOUT_HAS_EXEC_TRACE(entry)) {
+ Word maybe_from_full = entry->MR_sle_maybe_from_full;
+ if (maybe_from_full > 0) {
+ /*
+ ** for procedures compiled with shallow
+ ** tracing, the details will be valid only
+ ** if the value of MR_from_full saved in
+ ** the appropriate stack slot was TRUE.
+ */
+ if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
+ print_details = MR_based_stackvar(
+ base_sp, maybe_from_full);
+ } else {
+ print_details = MR_based_framevar(
+ base_curfr, maybe_from_full);
+ }
+ } else {
+ /*
+ ** for procedures compiled with full tracing,
+ ** always print out the details
+ */
+ print_details = TRUE;
+ }
+ }
+ if (print_details) {
+ if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
fprintf(fp, "%7lu %7lu %4lu ",
(unsigned long)
MR_event_num_stackvar(base_sp) + 1,
@@ -388,9 +413,7 @@
MR_call_num_stackvar(base_sp),
(unsigned long)
MR_call_depth_stackvar(base_sp));
- }
- } else {
- if (base_curfr != NULL) {
+ } else {
fprintf(fp, "%7lu %7lu %4lu ",
(unsigned long)
MR_event_num_framevar(base_curfr) + 1,
@@ -399,6 +422,9 @@
(unsigned long)
MR_call_depth_framevar(base_curfr));
}
+ } else {
+ /* ensure that the remaining columns line up */
+ fprintf(fp, "%21s", "");
}
}
--- ../mercury-compiler-0.8/runtime/mercury_trace_base.c Thu Nov 12 00:30:48 1998
+++ runtime/mercury_trace_base.c Wed Dec 9 12:46:56 1998
@@ -143,11 +143,12 @@
{
fatal_error("This executable is not set up for debugging.\n"
"Rebuild the <main>_init.c file, "
- "and give the -t flag to c2init when you do so.\n"
+ "and give the `-t' flag to c2init when you do so.\n"
"If you are using mmake, you can do this by including "
- "-t in C2INIT_FLAGS.\n"
- "For further details, please see the Debugging chapter"
- "of the Mercury User's Guide.\n");
+ "`-t' in C2INIT_FLAGS.\n"
+ "For further details, please see the \"Debugging\" chapter "
+ "of the\n"
+ "Mercury User's Guide.\n");
/*NOTREACHED*/
return NULL;
}
@@ -281,6 +282,10 @@
printf("MR_redo_layout_framevar(MR_redofr_slot(MR_curfr) = %p\n",
MR_redo_layout_framevar(MR_redofr_slot(MR_curfr)));
#endif
+ /*
+ ** If this code ever needs changing, you may also need to change
+ ** the code in extras/exceptions/exception.m similarly.
+ */
{
Code *MR_jumpaddr;
save_transient_registers();
--- ../mercury-compiler-0.8/trace/mercury_trace_internal.c Mon Nov 16 04:58:48 1998
+++ trace/mercury_trace_internal.c Wed Dec 9 15:47:02 1998
@@ -607,6 +610,8 @@
cmd->MR_trace_strict = FALSE;
cmd->MR_trace_print_level = MR_default_print_level;
goto return_stop_interacting;
+ } else if (stop_depth == depth && MR_port_is_entry(port)) {
+ printf("This command is a no-op from this port.\n");
} else {
char *retry_cmd;
@@ -1472,6 +1477,8 @@
MR_trace_call_seqno = seqno - 1;
MR_trace_call_depth = depth - 1;
+ MR_trace_from_full = TRUE;
+
if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
MR_Live_Lval location;
Word *this_frame;
--
Fergus Henderson <fjh at cs.mu.oz.au> | "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh> | but source code lives forever"
PGP: finger fjh at 128.250.37.3 | -- leaked Microsoft memo.
More information about the developers
mailing list