[m-rev.] for review: dd and global counters

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Apr 29 16:06:34 AEST 2002


For review by Mark.

trace/mercury_trace_declarative.c:
	Save the values of the three global counters used by execution tracing
	when initiating declarative debugging, and restore their values
	at its conclusion. This is needed to avoid changes in these counters
	as unwanted side-effects of declarative debugging when the browser
	directory is compiled with debugging and/or the user uses the "dd_dd"
	command instead of "dd".

Zoltan.

cvs diff: Diffing trace
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.48
diff -u -b -r1.48 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c	23 Apr 2002 08:52:42 -0000	1.48
+++ trace/mercury_trace_declarative.c	23 Apr 2002 11:07:08 -0000
@@ -163,6 +163,26 @@
 
 static	FILE		*MR_trace_store_file;
 
+/*
+** At each dd command, we save the three global counters that indicate the
+** progress of the program, to enable us to restore their values when the
+** dd command has finished. (The Mercury code we call to allocate the nodes of
+** the annotated trace and to perform diagnosis may alter their values if
+** the browser directory is compiled in a debugging grade.)
+*/
+
+typedef	struct
+{
+	MR_Unsigned	MR_dd_event_number;
+	MR_Unsigned	MR_dd_call_seqno;
+	MR_Unsigned	MR_dd_call_depth;
+} MR_decl_debug_dd_point;
+
+static MR_decl_debug_dd_point	MR_dd_point;
+
+static void		MR_trace_dd_save_point(MR_Event_Info *event_info);
+static void		MR_trace_dd_restore_point(void);
+
 static	MR_Trace_Node
 MR_trace_decl_call(MR_Event_Info *event_info, MR_Trace_Node prev);
 
@@ -1211,6 +1231,22 @@
 	}
 }
 
+static void
+MR_trace_dd_save_point(MR_Event_Info *event_info)
+{
+	MR_dd_point.MR_dd_event_number = event_info->MR_event_number;
+	MR_dd_point.MR_dd_call_seqno   = event_info->MR_call_seqno;
+	MR_dd_point.MR_dd_call_depth   = event_info->MR_call_depth;
+}
+
+static void
+MR_trace_dd_restore_point(void)
+{
+	MR_trace_event_number = MR_dd_point.MR_dd_event_number;
+	MR_trace_call_seqno = MR_dd_point.MR_dd_call_seqno;
+	MR_trace_call_depth = MR_dd_point.MR_dd_call_depth - 1;
+}
+
 MR_bool
 MR_trace_start_decl_debug(MR_Trace_Mode trace_mode, const char *outfile,
 		MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
@@ -1269,6 +1305,8 @@
 	}
 #endif /* MR_USE_DECL_STACK_SLOT */
 
+	MR_trace_dd_save_point(event_info);
+
 	if (trace_mode == MR_TRACE_DECL_DEBUG_DUMP) {
 		out = fopen(outfile, "w");
 		if (out == NULL) {
@@ -1437,6 +1475,11 @@
 	);
 
 	if (bug_found) {
+		/*
+		** The retry performed by MR_decl_handle_bug_found and the
+		** subsequent forward execution will restore to the global
+		** counters the same values as MR_trace_dd_restore_point would.
+		*/
 		return MR_decl_handle_bug_found(bug_event, cmd,
 				event_info, event_details);
 	}
@@ -1457,6 +1500,7 @@
 	*/
 	MR_trace_decl_mode = MR_TRACE_INTERACTIVE;
 	MR_trace_enabled = MR_TRUE;
+	MR_trace_dd_restore_point();
 	return MR_trace_event_internal(cmd, MR_TRUE, event_info);
 }
 
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list