[m-dev.] spypoints in external debugger

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Sep 16 03:53:13 AEST 1999


On 15-Sep-1999, Gregory Daniel Denehy <gdenehy at cs.monash.edu.au> wrote:
> 
> 
> My second question is concerned with how the spypoints themselves are to
> implemented.  I'm able to add spypoints to the spypoint table, however,
> I'm unable to get the execution to stop when it reaches a spypoint.  What
> needs to be done here?

Basically you need to set the `must_check' flag properly.
Currently there were two bugs where we were failing to
set that properly: it was not being initialized properly,
and the code in MR_trace_external_event() was not setting
it properly either.

The following changes should fix it, I think.
I will commit this.  I haven't tested them, though,
so it would be great if you could let me know if they work.

----------

Estimated hours taken: 2

Fix a couple of bugs that affected the external debugger.

trace/mercury_trace.c:
	Ensure that the `MR_trace_must_check' field of the MR_Trace_Cmd_Info
	struct is initialized correctly.
	Also add some comments.

trace/mercury_trace_external.c:
	Ensure that _all_ exits from the MR_trace_event_external() function
	perform all the necessary actions before returning from the
	function.  In particular, these actions are setting the 
	`MR_trace_must_check' field of the MR_Trace_Cmd_Info,
	in case we changed anything that might affect its value,
	and restoring the event numbers, in case we called Mercury code
	that was compiled with debugging from inside the trace system.
	Also make sure that the code to save the event numbers occurs
	before any code that might clobber them.
	Also add some comments.

Workspace: /home/mercury0/fjh/mercury
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.11
diff -u -r1.11 mercury_trace.c
--- mercury_trace.c	1999/08/24 01:40:57	1.11
+++ mercury_trace.c	1999/09/15 17:04:32
@@ -47,8 +47,14 @@
 #include "mercury_array_macros.h"
 #include <stdio.h>
 
-static	MR_Trace_Cmd_Info	MR_trace_ctrl = { MR_CMD_GOTO, 0, 0,
-					MR_PRINT_LEVEL_SOME, FALSE };
+static	MR_Trace_Cmd_Info	MR_trace_ctrl = {
+	MR_CMD_GOTO,
+	0,	/* stop depth */
+	0,	/* stop event */
+	MR_PRINT_LEVEL_SOME,
+	FALSE,	/* not strict */
+	TRUE	/* must check */
+};
 
 Code 		*MR_trace_real(const MR_Stack_Layout_Label *layout,
 			MR_Trace_Port port, Unsigned seqno, Unsigned depth,
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.19
diff -u -r1.19 mercury_trace_external.c
--- mercury_trace_external.c	1999/06/24 18:10:40	1.19
+++ mercury_trace_external.c	1999/09/15 17:41:26
@@ -391,21 +391,29 @@
 	Word		*saved_regs = event_info->MR_saved_regs;
 	Integer		modules_list_length;
 	Word		modules_list;
+	static String	MR_mmc_options;
+
+	/*
+	** These globals can be overwritten when we call Mercury code,
+	** such as the code in browser/debugger_interface.m.
+	** We therefore save them here and restore them before
+	** exiting from this function.  However, we store the
+	** saved values in a structure that we pass to MR_trace_debug_cmd,
+	** to allow them to be modified by MR_trace_retry().
+	*/
+	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;
 
 	/* 
 	** MR_mmc_options contains the options to pass to mmc when compiling 
 	** queries. We initialise it to the String "".
 	*/
-	static String	MR_mmc_options;
 	MR_TRACE_CALL_MERCURY(ML_DI_init_mercury_string(&MR_mmc_options));
 
 	MR_trace_init_point_vars(event_info->MR_event_sll,
 		event_info->MR_saved_regs);
 
-	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 (searching) {
 		/* XXX should also pass registers here,
 		   since they're needed for checking for matches with the
@@ -416,7 +424,7 @@
 			MR_send_message_to_socket("forward_move_match_found");
 			searching = FALSE;
 		} else {
-			return jumpaddr;
+			goto done;
 		}
 	}
 
@@ -436,7 +444,7 @@
 				}
 				search_data = debugger_request;
 			        searching = TRUE;
-				return jumpaddr;
+				goto done;
 
 			case MR_REQUEST_CURRENT_LIVE_VAR_NAMES:
 				if (MR_debug_socket) {
@@ -492,7 +500,7 @@
 					cmd->MR_trace_cmd = MR_CMD_GOTO;
 					cmd->MR_trace_stop_event = 
 						MR_trace_event_number + 1;
-					return jumpaddr;
+					goto done;
 				} else {
 					MR_send_message_to_socket_format(
 						"error(\"%s\").\n", message);
@@ -626,7 +634,7 @@
 			  }
 			case MR_REQUEST_NO_TRACE:
 				cmd->MR_trace_cmd = MR_CMD_TO_END;
-				return jumpaddr;
+				goto done;
 
 			default:
 				fatal_error("unexpected request read from "
@@ -634,9 +642,21 @@
 		}
 	}
 
+done:
+	/*
+	** Recalculate the `must_check' flag, in case we
+	** changed the command strictness or print-level
+	*/
 	cmd->MR_trace_must_check = (! cmd->MR_trace_strict) ||
 			(cmd->MR_trace_print_level != MR_PRINT_LEVEL_NONE);
 
+	/*
+	** Restore the event numbers, in case the Mercury
+	** code that we call from the trace system
+	** (e.g. browser/debugger_interface.m)
+	** clobbered them.  That could happen if that code
+	** had been compiled with debugging enabled.
+	*/
 	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;
@@ -1008,6 +1028,7 @@
 **	- the atom 'pred' or 'func' depending if the procedure is a function 
 **	  or not
 **	- proc('string:string'/long-long) (the name of the procedure)
+**		XXX this is not valid format for a Mercury term
 **	- det(string) (the determinism of the procedure)
 **	- def_module(string) (the name of the defining module if different from
 **	  the current one)
@@ -1017,6 +1038,8 @@
 **	- detail(unsigned long, unsigned long, unsigned long) (as above)
 **	- proc('string for string:string'/long-long) (the name of the 
 **	  compiler-generated procedure)
+**		XXX this is not valid format for a Mercury term
+**	- det(string) (as above)
 **	- def_module(string) (as above)
 ** 3) The debuggee sends "end_stack"
 */

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list