trivial diff: fix mdb retry bugs

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 12 11:16:06 AEDT 1999


Estimated hours taken: 0.5

trace/mercury_trace.h:
trace/mercury_trace.c:
trace/mercury_trace_internal.c:
	Add a missing const on the return type of MR_trace_retry().

trace/mercury_trace.c:
	Delete an old `#include <unistd.h>', since it is no longer needed.

trace/mercury_trace_internal.c:
	Fix two bug: check whether the return value from
	MR_trace_retry() is null; if it is null, don't try to print it
	out (this fixes a bug Erwan introduced), and if it is not null,
	then after printing out the message, keep interacting with the
	user rather than doing a step (this fixes a bug in Zoltan's
	original code).

Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.4
diff -u -r1.4 mercury_trace.c
--- mercury_trace.c	1999/02/10 22:31:18	1.4
+++ mercury_trace.c	1999/02/12 00:11:35
@@ -46,7 +46,6 @@
 #include "mercury_misc.h"
 #include "mercury_array_macros.h"
 #include <stdio.h>
-#include <unistd.h>		/* for the write system call */
 
 static	MR_Trace_Cmd_Info	MR_trace_ctrl = { MR_CMD_GOTO, 0, 0,
 					MR_PRINT_LEVEL_SOME, FALSE };
@@ -281,7 +280,7 @@
 	return jumpaddr;
 }
 
-char *
+const char *
 MR_trace_retry(const MR_Stack_Layout_Label *this_label, Word *saved_regs,
 	MR_Event_Details *event_details, int seqno, int depth,
 	int *max_mr_num, Code **jumpaddr)
@@ -295,7 +294,7 @@
 	Word				arg_value;
 	int				i;
 	bool				succeeded;
-	char			        *message;
+	const char			*message;
 
 	entry = this_label->MR_sll_entry;
 	call_label = entry->MR_sle_call_label;
Index: trace/mercury_trace.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.h,v
retrieving revision 1.4
diff -u -r1.4 mercury_trace.h
--- mercury_trace.h	1999/02/10 22:31:19	1.4
+++ mercury_trace.h	1999/02/12 00:05:42
@@ -30,11 +30,11 @@
 /* The initial size of arrays of argument values. */
 #define	MR_INIT_ARG_COUNT	20
 
-char *	MR_trace_retry(const MR_Stack_Layout_Label *layout,
+const char *	MR_trace_retry(const MR_Stack_Layout_Label *layout,
 			Word *saved_regs, MR_Event_Details *event_details,
 			int seqno, int depth, int *max_mr_num,
 			Code **jumpaddr);
-Word	MR_trace_find_input_arg(const MR_Stack_Layout_Label *label, 
+Word		MR_trace_find_input_arg(const MR_Stack_Layout_Label *label, 
 			Word *saved_regs, const char *name, bool *succeeded);
 
 /*
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.24
diff -u -r1.24 mercury_trace_internal.c
--- mercury_trace_internal.c	1999/02/10 22:31:20	1.24
+++ mercury_trace_internal.c	1999/02/12 00:13:26
@@ -660,8 +660,8 @@
 			MR_trace_usage("forward", "continue");
 		}
 	} else if (streq(words[0], "retry")) {
-		int	stop_depth;
-		char   *message;
+		int		stop_depth;
+		const char   	*message;
 
 		if (word_count == 2 && MR_trace_is_number(words[1], &n)) {
 			stop_depth = depth - n;
@@ -673,11 +673,14 @@
 		}
 
 		if (stop_depth == depth && MR_port_is_final(port)) {
-			message = MR_trace_retry(layout, saved_regs, event_details,
-				seqno, depth, max_mr_num, jumpaddr);
-			fflush(MR_mdb_out);
-			fprintf(MR_mdb_err, "%s\n", message);
-
+			message = MR_trace_retry(layout, saved_regs,
+				event_details, seqno, depth, max_mr_num,
+				jumpaddr);
+			if (message != NULL) {
+				fflush(MR_mdb_out);
+				fprintf(MR_mdb_err, "%s\n", message);
+				goto return_keep_interacting;
+			}
 			cmd->MR_trace_cmd = MR_CMD_GOTO;
 			cmd->MR_trace_stop_event = MR_trace_event_number + 1;
 			cmd->MR_trace_strict = FALSE;

-- 
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