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

Mark Brown dougl at cs.mu.OZ.AU
Mon Apr 29 23:40:03 AEST 2002


On 29-Apr-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 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".
> 
The diff fixes the bug, but there is actually already code there to deal
with this issue.  The problem is that the existing code misses a spot -- the
globals are restored for the last time just _before_ the call to the front
end.  This wouldn't have caused a problem initially, because a retry was
always done just afterwards which covered up the problem.  However, a while
ago I added some alternative ways for the front end to finish, and this
would have exposed the bug.

The diff below should also fix the problem.  It is much simpler, and takes
the approach that was originally intended, so I'll commit this after the
bootchecks finish.

Cheers,
Mark.

Estimated hours taken: 0.25
Branches: main

trace/mercury_trace_declarative.c:
	Ensure mdb's globals are saved across calls to the front end.
	This is needed to avoid a large jump in the call sequence number
	after aborting the front end, when some front end modules are
	compiled with tracing enabled.

Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.48
diff -u -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	29 Apr 2002 12:59:28 -0000
@@ -1395,6 +1395,10 @@
 	MR_Unsigned		topmost_seqno;
 	MercuryFile		stream;
 
+	event_details->MR_call_seqno = MR_trace_call_seqno;
+	event_details->MR_call_depth = MR_trace_call_depth;
+	event_details->MR_event_number = MR_trace_event_number;
+
 	if (MR_edt_compiler_flag_warning) {
 		fflush(MR_mdb_out);
 		fprintf(MR_mdb_err, "Warning: some modules were compiled with"
@@ -1414,6 +1418,10 @@
 		fclose(MR_trace_store_file);
 		MR_trace_decl_mode = MR_TRACE_INTERACTIVE;
 		MR_trace_enabled = MR_TRUE;
+		MR_trace_call_seqno = event_details->MR_call_seqno;
+		MR_trace_call_depth = event_details->MR_call_depth;
+		MR_trace_event_number = event_details->MR_event_number;
+
 		return MR_trace_event_internal(cmd, MR_TRUE, event_info);
 	}
 
@@ -1435,6 +1443,10 @@
 				(MR_Word *) &final_event,
 				(MR_Word *) &topmost_seqno);
 	);
+
+	MR_trace_call_seqno = event_details->MR_call_seqno;
+	MR_trace_call_depth = event_details->MR_call_depth;
+	MR_trace_event_number = event_details->MR_event_number;
 
 	if (bug_found) {
 		return MR_decl_handle_bug_found(bug_event, cmd,
--------------------------------------------------------------------------
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