for review: an even bigger step towards the debugger (part 4 of 4)

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Apr 1 17:14:40 AEST 1998


Index: runtime/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace.c,v
retrieving revision 1.8
diff -u -u -r1.8 mercury_trace.c
--- mercury_trace.c	1998/03/11 22:07:31	1.8
+++ mercury_trace.c	1998/04/01 04:29:00
@@ -18,7 +18,29 @@
 #include "mercury_trace.h"
 #include "mercury_engine.h"
 #include "mercury_wrapper.h"
+#include "mercury_misc.h"
 #include <stdio.h>
+#include <ctype.h>
+
+/*
+** Do we want to use the debugger within this process, or do want to use
+** the Opium-style trace analyzer debugger implemented by an external process.
+** This variable is set in mercury_wrapper.c and never modified afterwards.
+*/
+
+MR_trace_type	MR_trace_handler = MR_TRACE_INTERNAL;
+
+/*
+** Compiler generated tracing code will check whether MR_trace_enabled is true,
+** before calling MR_trace. For now, and until we implement interface tracing,
+** MR_trace_enabled should keep the same value throughout the execution of
+** the entire program after being set in mercury_wrapper.c. There is one
+** exception to this: the Mercury routines called as part of the functionality
+** of the tracer itself (e.g. the term browser) should always be executed
+** with MR_trace_enabled set to FALSE.
+*/
+
+bool	MR_trace_enabled = FALSE;
 
 /*
 ** MR_trace_call_seqno counts distinct calls. The prologue of every
@@ -42,18 +64,21 @@
 int	MR_trace_call_depth = 0;
 
 /*
-** MR_trace_event_number is a simple counter of events; currently we only
-** use it for display.
+** MR_trace_event_number is a simple counter of events. This is used in
+** two places: here, for display to the user and for skipping a given number
+** of events, and when printing an abort message, so that the programmer
+** can zero in on the source of the problem more quickly.
 */
 
-static	int	MR_trace_event_number = 0;
+int	MR_trace_event_number = 0;
 
 /*
 ** MR_trace_cmd and MR_trace_seqno are globals variables that we use
 ** to manage an interface between the tracer and the user.
 **
 ** MR_trace_cmd says what mode the tracer is in, i.e. what the last
-** trace command was.
+** trace command was. The details of the semantics are given by the
+** code of MR_trace().
 **
 ** MR_trace_seqno is meaningful only when MR_trace_cmd is MR_SKIP or MR_JUMP.
 ** In those cases, it holds the sequence number of the call at whose exit
@@ -61,17 +86,30 @@
 */
 
 typedef enum {
-	MR_CMD_CONT,	/* c: continue to end, not printing the trace	  */
-	MR_CMD_DUMP,	/* d: continue to end, printing the trace	  */
-	MR_CMD_NEXT,	/* n: go to the next trace event		  */
-	MR_CMD_SKIP,	/* s: skip the current call, not printing trace	  */
-	MR_CMD_JUMP	/* j: jump to end of current call, printing trace */
+	MR_CMD_GOTO,		/* stop at an event with a given number    */
+	MR_CMD_FINISH,		/* stop when exiting/failing out of a proc */
+	MR_CMD_RESUME_FORWARD,	/* stop at the next non-final port         */
+	MR_CMD_TO_END		/* do not stop until the end of execution  */
 } MR_trace_cmd_type;
 
+#define	MR_NAME_LEN		80
+#define	MR_MAX_SPY_POINTS	20
+#define	MR_LOG10_MAX_SPY_POINTS	20
+
+typedef struct {
+	bool	enabled;
+	char	module_name[MR_NAME_LEN];
+	char	pred_name[MR_NAME_LEN];
+} MR_spy_point;
+
+MR_spy_point	MR_spy_points[MR_MAX_SPY_POINTS];
+int		MR_next_spy_point = 0;
+
 /*
 ** This type must match the definition of classify_request in
 ** library/debugger_interface.m.
 */
+
 typedef enum {
 	MR_REQUEST_HELLO_REPLY = 0,  /* initiate debugging session	    */
 	MR_REQUEST_FORWARD_MOVE = 1, /* go to the next matching trace event */
@@ -81,8 +119,10 @@
 	MR_REQUEST_ERROR = 5         /* something went wrong                */
 } MR_debugger_request_type;
 
-static	MR_trace_cmd_type	MR_trace_cmd = MR_CMD_NEXT;
-static	int			MR_trace_seqno = 0;
+static	MR_trace_cmd_type	MR_trace_cmd = MR_CMD_GOTO;
+static	int			MR_trace_stop_seqno = 0;
+static	int			MR_trace_stop_event = 0;
+static	bool			MR_trace_print_intermediate = FALSE;
 
 typedef	enum {
 	MR_INTERACT,
@@ -90,25 +130,34 @@
 } MR_trace_interact;
 
 static void	MR_trace_event(MR_trace_interact interact,
-			const MR_stack_layout_entry *layout,
+			const MR_Stack_Layout_Label *layout,
 			MR_trace_port port, int seqno, int depth,
-			const char *path);
+			const char *path, int max_r_num);
+static void	MR_copy_saved_regs_to_regs(int max_mr_num);
+static void	MR_copy_regs_to_saved_regs(int max_mr_num);
 static void	MR_trace_display_user(MR_trace_interact interact,
-			const MR_stack_layout_entry *layout,
+			const MR_Stack_Layout_Label *layout,
 			MR_trace_port port, int seqno, int depth,
 			const char *path);
 static void	MR_trace_browse(int var_count,
-			const MR_stack_layout_vars *var_info);
-static void	MR_trace_browse_var(char *name,
-			const MR_stack_layout_var *var);
-static int	MR_trace_get_cmd(void);
+			const MR_Stack_Layout_Vars *var_info);
+static void	MR_trace_browse_var(const char *name,
+			const MR_Stack_Layout_Var *var, Word *type_params);
+static int	MR_trace_skip_spaces(int c);
+static void	MR_trace_discard_to_eol(int c);
+static int	MR_trace_get_word(int *c, char word[], int len);
 static void	MR_trace_help(void);
 
+static void	MR_add_spy_point(void);
+static void	MR_list_spy_points(void);
+static void	MR_change_spy_point_status(bool status);
+static bool	MR_event_matches_spy_point(const MR_Stack_Layout_Label *layout);
+
 static Word	MR_trace_make_var_list(MR_trace_port port,
-			const MR_stack_layout_entry *layout);
+			const MR_Stack_Layout_Label *layout);
 static Word	MR_trace_lookup_live_lval(MR_Live_Lval locn, bool *succeeded);
-static bool	MR_trace_get_type_and_value(const MR_stack_layout_var *var,
-			Word *type_info, Word *value);
+static bool	MR_trace_get_type_and_value(const MR_Stack_Layout_Var *var,
+			Word *type_params, Word *type_info, Word *value);
 
 /*
 We could use
@@ -118,7 +167,7 @@
 check for an additional flag in the MERCURY_OPTIONS
 environment variable and set MR_use_debugger accordingly.
 */
-#ifdef MR_USE_DEBUGGER
+#ifdef MR_USE_EXTERNAL_DEBUGGER
 
 static MercuryFile MR_debugger_socket_in;
 static MercuryFile MR_debugger_socket_out;
@@ -129,21 +178,18 @@
 			Integer *debugger_request_type_ptr);
 	
 static void	MR_debugger_step(MR_trace_interact interact,
-			const MR_stack_layout_entry *layout,
+			const MR_Stack_Layout_Label *layout,
 			MR_trace_port port, int seqno, int depth,
 			const char *path);
-static bool	MR_found_match(const MR_stack_layout_entry *layout,
+static bool	MR_found_match(const MR_Stack_Layout_Label *layout,
 			MR_trace_port port, int seqno, int depth,
 			/* XXX registers */
 			const char *path, Word search_data);
-static void	MR_output_current(const MR_stack_layout_entry *layout,
+static void	MR_output_current(const MR_Stack_Layout_Label *layout,
 			MR_trace_port port, int seqno, int depth,
 			Word var_list,
 			const char *path, Word current_request);
 
-static void	MR_copy_saved_regs_to_regs(void);
-static void	MR_copy_regs_to_saved_regs(void);
-
 #endif
 
 #define	MR_port_is_final(port)	(port == MR_PORT_EXIT || port == MR_PORT_FAIL)
@@ -154,72 +200,220 @@
 */
 
 void
-MR_trace(const Word *layout_word, MR_trace_port port,
-	int seqno, int depth, const char *path)
+MR_trace(const MR_Stack_Layout_Label *layout, MR_trace_port port,
+	int seqno, int depth, const char *path, int max_r_num)
 {
-	const MR_stack_layout_entry	*layout;
-	MR_trace_interact		interact;
-
-	layout = (const MR_stack_layout_entry *) layout_word;
-
 	MR_trace_event_number++;
 	switch (MR_trace_cmd) {
-		case MR_CMD_NEXT:
-			MR_trace_event(MR_INTERACT, layout,
-				port, seqno, depth, path);
-			break;
+		case MR_CMD_FINISH:
+			if (MR_trace_stop_seqno == seqno
+			&& MR_port_is_final(port)) {
+				MR_trace_event(MR_INTERACT, layout,
+					port, seqno, depth, path, max_r_num);
 
-		case MR_CMD_JUMP:
-			if (MR_trace_seqno == seqno && MR_port_is_final(port))
-			{
-				interact = MR_INTERACT;
-			} else {
-				interact = MR_NO_INTERACT;
+			} else if (MR_trace_print_intermediate) {
+				MR_trace_event(MR_NO_INTERACT, layout,
+					port, seqno, depth, path, max_r_num);
 			}
 
-			MR_trace_event(interact, layout,
-				port, seqno, depth, path);
-
 			break;
 
-		case MR_CMD_SKIP:
-			if (MR_trace_seqno == seqno && MR_port_is_final(port))
-			{
+		case MR_CMD_GOTO:
+			if (MR_trace_event_number >= MR_trace_stop_event
+			|| MR_event_matches_spy_point(layout)) {
 				MR_trace_event(MR_INTERACT, layout,
-					port, seqno, depth, path);
+					port, seqno, depth, path, max_r_num);
+			} else if (MR_trace_print_intermediate) {
+				MR_trace_event(MR_NO_INTERACT, layout,
+					port, seqno, depth, path, max_r_num);
 			}
 
 			break;
 
-		case MR_CMD_CONT:
+		case MR_CMD_RESUME_FORWARD:
+			if (MR_port_is_final(port)) {
+				MR_trace_event(MR_INTERACT, layout,
+					port, seqno, depth, path, max_r_num);
+			} else if (MR_trace_print_intermediate) {
+				MR_trace_event(MR_NO_INTERACT, layout,
+					port, seqno, depth, path, max_r_num);
+			}
+
 			break;
 
-		case MR_CMD_DUMP:
-			MR_trace_event(MR_NO_INTERACT, layout,
-				port, seqno, depth, path);
+		case MR_CMD_TO_END:
+			if (MR_event_matches_spy_point(layout)) {
+				MR_trace_event(MR_INTERACT, layout,
+					port, seqno, depth, path, max_r_num);
+			} else if (MR_trace_print_intermediate) {
+				MR_trace_event(MR_NO_INTERACT, layout,
+					port, seqno, depth, path, max_r_num);
+			}
+
 			break;
 
 		default:
-			fatal_error("MR_trace called with inappropriate port");
+			fatal_error("invalid cmd in MR_trace");
 			break;
 	}
 }
 
+static bool
+MR_event_matches_spy_point(const MR_Stack_Layout_Label *layout)
+{
+	const	MR_Stack_Layout_Entry	*entry;
+	int				i;
+
+	entry = layout->MR_sll_entry;
+
+	for (i = 0; i < MR_next_spy_point; i++) {
+		if (streq(MR_spy_points[i].pred_name, entry->MR_sle_name)
+		&& streq(MR_spy_points[i].module_name, entry->MR_sle_def_module)
+		&& MR_spy_points[i].enabled) {
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
 static void
 MR_trace_event(MR_trace_interact interact,
-	const MR_stack_layout_entry *layout,
-	MR_trace_port port, int seqno, int depth, const char *path)
+	const MR_Stack_Layout_Label *layout, MR_trace_port port,
+	int seqno, int depth, const char *path, int max_r_num)
 {
-#ifdef MR_USE_DEBUGGER
-	MR_copy_regs_to_saved_regs();
-	MR_debugger_step(interact, layout, port, seqno, depth, path);
-	MR_copy_saved_regs_to_regs();
+	int	max_mr_num;
+
+	if (max_r_num + MR_NUM_SPECIAL_REG > MR_MAX_SPECIAL_REG_MR) {
+		max_mr_num = max_r_num + MR_NUM_SPECIAL_REG;
+	} else {
+		max_mr_num = MR_MAX_SPECIAL_REG_MR;
+	}
+
+	MR_copy_regs_to_saved_regs(max_mr_num);
+#ifdef MR_USE_EXTERNAL_DEBUGGER
+	if (MR_trace_debugger == MR_TRACE_EXTERNAL) {
+		MR_debugger_step(interact, layout, port, seqno, depth, path);
+	} else {
+		MR_trace_display_user(interact, layout, port, seqno, depth,
+			path);
+	}
 #else
+	/*
+	** We should get here only if MR_trace_debugger == MR_TRACE_INTERNAL.
+	** This is enforced by mercury_wrapper.c.
+	*/
+
 	MR_trace_display_user(interact, layout, port, seqno, depth, path);
 #endif
+	MR_copy_saved_regs_to_regs(max_mr_num);
+}
+
+static Word	MR_saved_regs[MAX_FAKE_REG];
+
+static void
+MR_copy_regs_to_saved_regs(int max_mr_num)
+{
+	/*
+	** In the process of browsing, we call Mercury code,
+	** which may clobber the contents of the virtual machine registers,
+	** both control and general purpose, and both real and virtual
+	** registers. We must therefore save and restore these.
+	** We store them in the MR_saved_regs array.
+	**
+	** The call to MR_trace will clobber the transient registers
+	** on architectures that have them. The compiler generated code
+	** will therefore call save_transient_registers to save the transient
+	** registers in the fake_reg array. We here restore them to the
+	** real registers, save them with the other registers back in
+	** fake_reg, and then copy all fake_reg entries to MR_saved_regs.
+	**
+	** If any code invoked by MR_trace is itself traced,
+	** MR_saved_regs will be overwritten, leading to a crash later on.
+	** This is one reason (but not the only one) why we turn off
+	** tracing when we call back Mercury code from this file.
+	*/
+
+	int i;
+
+	restore_transient_registers();
+	save_registers();
+
+	for (i = 0; i <= max_mr_num; i++) {
+		MR_saved_regs[i] = fake_reg[i];
+	}
+}
+
+static void
+MR_copy_saved_regs_to_regs(int max_mr_num)
+{
+	/*
+	** We execute the converse procedure to MR_copy_regs_to_saved_regs.
+	** The save_transient_registers is there so that a call to the
+	** restore_transient_registers macro after MR_trace will do the
+	** right thing.
+	*/
+
+	int i;
+
+	for (i = 0; i <= max_mr_num; i++) {
+		fake_reg[i] = MR_saved_regs[i];
+	}
+
+	restore_registers();
+	save_transient_registers();
+}
+
+void
+MR_trace_report(FILE *fp)
+{
+	if (MR_trace_event_number > 0) {
+		/*
+		** This means that the executable was compiled with tracing,
+		** which implies that the user wants trace info on abort.
+		*/
+
+		fprintf(fp, "Last trace event was event #%d.\n",
+			MR_trace_event_number);
+	}
+}
+
+void
+MR_trace_report_raw(int fd)
+{
+	char	buf[80];	/* that ought to be more than long enough */
+
+	if (MR_trace_event_number > 0) {
+		/*
+		** This means that the executable was compiled with tracing,
+		** which implies that the user wants trace info on abort.
+		*/
+
+		sprintf(buf, "Last trace event was event #%d.\n",
+			MR_trace_event_number);
+		write(fd, buf, strlen(buf));
+	}
+}
+
+void
+MR_trace_init(void)
+{
+#ifdef MR_USE_EXTERNAL_DEBUGGER
+	if (MR_trace_handler == MR_TRACE_EXTERNAL)
+		MR_trace_init_external();
+#endif
+}
+
+void
+MR_trace_end(void)
+{
+#ifdef MR_USE_EXTERNAL_DEBUGGER
+	if (MR_trace_handler == MR_TRACE_EXTERNAL)
+		MR_trace_end_external();
+#endif
 }
 
-#ifdef MR_USE_DEBUGGER
+#ifdef MR_USE_EXTERNAL_DEBUGGER
 
 #include <errno.h>
 #include <sys/types.h>
@@ -289,7 +483,7 @@
 static bool MR_debug_socket = FALSE;
 
 void
-MR_trace_init(void)
+MR_trace_init_external(void)
 {
 	int fd;
 	int len;
@@ -446,7 +640,7 @@
 }
 
 void
-MR_trace_end(void)
+MR_trace_end_external(void)
 {
 	/*
 	** This can only happen during a forward_move(),
@@ -466,7 +660,7 @@
 
 static void
 MR_debugger_step(MR_trace_interact interact,
-	const MR_stack_layout_entry *layout,
+	const MR_Stack_Layout_Label *layout,
 	MR_trace_port port, int seqno, int depth, const char *path)
 {
 	static bool searching = FALSE;
@@ -519,7 +713,7 @@
 				break;
 				
 			case MR_REQUEST_NO_TRACE:
-				MR_trace_cmd = MR_CMD_CONT;
+				MR_trace_cmd = MR_CMD_TO_END;
 				return;
 
 			default:
@@ -530,7 +724,7 @@
 }
 
 static void
-MR_output_current(const MR_stack_layout_entry *layout,
+MR_output_current(const MR_Stack_Layout_Label *layout,
 	MR_trace_port port, int seqno, int depth,
 	Word var_list,
 	const char *path, Word current_request)
@@ -540,11 +734,11 @@
 		seqno,
 		depth,
 		port,
-		layout->MR_sle_def_module,
-		layout->MR_sle_name,
-		layout->MR_sle_arity,
-		layout->MR_sle_mode,
-		layout->MR_sle_detism,
+		layout->MR_sll_entry->MR_sle_def_module,
+		layout->MR_sll_entry->MR_sle_name,
+		layout->MR_sll_entry->MR_sle_arity,
+		layout->MR_sll_entry->MR_sle_mode,
+		layout->MR_sll_entry->MR_sle_detism,
 		var_list,
 		(String) (Word) path,
 		current_request,
@@ -565,7 +759,7 @@
  
 
 static bool
-MR_found_match(const MR_stack_layout_entry *layout,
+MR_found_match(const MR_Stack_Layout_Label *layout,
 	MR_trace_port port, int seqno, int depth,
 	/* XXX live vars */
 	const char *path, Word search_data)
@@ -579,11 +773,11 @@
 		seqno,
 		depth,
 		port,
-		layout->MR_sle_def_module,
-		layout->MR_sle_name,
-		layout->MR_sle_arity,
-		layout->MR_sle_mode,
-		layout->MR_sle_detism,
+		layout->MR_sll_entry->MR_sle_def_module,
+		layout->MR_sll_entry->MR_sle_name,
+		layout->MR_sll_entry->MR_sle_arity,
+		layout->MR_sll_entry->MR_sle_mode,
+		layout->MR_sll_entry->MR_sle_detism,
 		arguments,
 		(String) (Word) path,
 		search_data);
@@ -598,54 +792,55 @@
 	MR_debugger_socket_out.line_number++;
 }
 
-#else /* !MR_USE_DEBUGGER */
-
-void MR_trace_init(void) {}
-void MR_trace_end(void) {}
-
-#endif /* MR_USE_DEBUGGER */
+#endif /* MR_USE_EXTERNAL_DEBUGGER */
 
 static void
 MR_trace_display_user(MR_trace_interact interact,
-	const MR_stack_layout_entry *layout,
+	const MR_Stack_Layout_Label *layout,
 	MR_trace_port port, int seqno, int depth, const char *path)
 {
 	int	i;
+	int	c;
+	int	count;
+	bool	count_given;
 
-	fflush(stdout);
-	fprintf(stderr, "%8d: %6d %2d ", MR_trace_event_number, seqno, depth);
-
-	for (i = 0; i < depth; i++) {
-		putc(' ', stderr);
-	}
+	printf("%8d: %6d %2d ", MR_trace_event_number, seqno, depth);
 
 	switch (port) {
 		case MR_PORT_CALL:
-			fprintf(stderr, "CALL ");
+			printf("CALL ");
 			break;
 
 		case MR_PORT_EXIT:
-			fprintf(stderr, "EXIT ");
+			printf("EXIT ");
 			break;
 
 		case MR_PORT_FAIL:
-			fprintf(stderr, "FAIL ");
+			printf("FAIL ");
 			break;
 
 		case MR_PORT_THEN:
-			fprintf(stderr, "THEN ");
+			printf("THEN ");
 			break;
 
 		case MR_PORT_ELSE:
-			fprintf(stderr, "ELSE ");
+			printf("ELSE ");
 			break;
 
 		case MR_PORT_DISJ:
-			fprintf(stderr, "DISJ ");
+			printf("DISJ ");
 			break;
 
 		case MR_PORT_SWITCH:
-			fprintf(stderr, "SWTC ");
+			printf("SWTC ");
+			break;
+
+		case MR_PORT_PRAGMA_FIRST:
+			printf("FRST ");
+			break;
+
+		case MR_PORT_PRAGMA_LATER:
+			printf("LATR ");
 			break;
 
 		default:
@@ -653,41 +848,41 @@
 					"with bad port");
 	}
 
-	switch ((int) layout->MR_sle_detism) {
+	switch ((int) layout->MR_sll_entry->MR_sle_detism) {
 		case MR_DETISM_DET:
-			fprintf(stderr, "DET   ");
+			printf("DET   ");
 			break;
 
 		case MR_DETISM_SEMI:
-			fprintf(stderr, "SEMI  ");
+			printf("SEMI  ");
 			break;
 
 		case MR_DETISM_NON:
-			fprintf(stderr, "NON   ");
+			printf("NON   ");
 			break;
 
 		case MR_DETISM_MULTI:
-			fprintf(stderr, "MUL   ");
+			printf("MUL   ");
 			break;
 
 		case MR_DETISM_ERRONEOUS:
-			fprintf(stderr, "ERR   ");
+			printf("ERR   ");
 			break;
 
 		case MR_DETISM_FAILURE:
-			fprintf(stderr, "FAIL  ");
+			printf("FAIL  ");
 			break;
 
 		case MR_DETISM_CCNON:
-			fprintf(stderr, "CCNON ");
+			printf("CCNON ");
 			break;
 
 		case MR_DETISM_CCMULTI:
-			fprintf(stderr, "CCMUL ");
+			printf("CCMUL ");
 			break;
 		
 		default:
-			fprintf(stderr, "mercury_trace.c: ???  ");
+			printf("BAD DETERMINISM\n");
 			break;
 	}
 
@@ -697,82 +892,165 @@
 	** not interested in tracing compiler-generated procedures.
 	*/
 
-	fprintf(stderr, "%s:%s/%ld-%ld %s\n",
-		layout->MR_sle_def_module,
-		layout->MR_sle_name,
-		(long) layout->MR_sle_arity,
-		(long) layout->MR_sle_mode,
+	printf("%s:%s/%ld-%ld %s\n",
+		layout->MR_sll_entry->MR_sle_def_module,
+		layout->MR_sll_entry->MR_sle_name,
+		(long) layout->MR_sll_entry->MR_sle_arity,
+		(long) layout->MR_sll_entry->MR_sle_mode,
 		path);
 
 	while (interact == MR_INTERACT) {
-		fprintf(stderr, "mtrace> ");
+		printf("mtrace> ");
+
+		count = 1;
+		count_given = FALSE;
+		MR_trace_print_intermediate = FALSE;
+
+		c = MR_trace_skip_spaces(' ');
+		if (isdigit(c)) {
+			count_given = TRUE;
+			count = c - '0';
+			c = getchar();
+			while (c != EOF && isdigit(c)) {
+				count = (count * 10) + c - '0';
+				c = getchar();
+			}
 
-		switch (MR_trace_get_cmd()) {
-			case 'n':
+			c = MR_trace_skip_spaces(c);
+		}
+
+		switch (c) {
+			case 'S':
+				MR_trace_print_intermediate = TRUE;
+				/* fall through */
+
+			case 's':
 			case '\n':
-				MR_trace_cmd = MR_CMD_NEXT;
+				MR_trace_cmd = MR_CMD_GOTO;
+				MR_trace_stop_event =
+					MR_trace_event_number + count;
+				MR_trace_discard_to_eol(c);
 				break;
 
-			case 'c':
-				MR_trace_cmd = MR_CMD_CONT;
-				break;
+			case 'G':
+				MR_trace_print_intermediate = TRUE;
+				/* fall through */
+
+			case 'g':
+				if (! count_given) {
+					MR_trace_discard_to_eol(c);
+					printf("mtrace: no count given\n");
+					continue;
+				}
 
-			case 'd':
-				MR_trace_cmd = MR_CMD_DUMP;
+				MR_trace_cmd = MR_CMD_GOTO;
+				MR_trace_stop_event = count;
+				MR_trace_discard_to_eol(c);
 				break;
 
-			case 'j':
+			case 'F':
+				MR_trace_print_intermediate = TRUE;
+				/* fall through */
+
+			case 'f':
 				if (MR_port_is_final(port)) {
-					fprintf(stderr, "mtrace: cannot jump"
-							" from this port\n");
+					MR_trace_discard_to_eol(c);
+					printf("mtrace: this port is "
+						"already final\n");
 					continue;
 				} else {
-					MR_trace_cmd = MR_CMD_JUMP;
-					MR_trace_seqno = seqno;
+					MR_trace_cmd = MR_CMD_FINISH;
+					MR_trace_stop_seqno = seqno;
 				}
 
+				MR_trace_discard_to_eol(c);
+				break;
+
+			case 'C':
+				MR_trace_print_intermediate = TRUE;
+				/* fall through */
+
+			case 'c':
+				if (count_given)
+					printf("mtrace: count ignored\n");
+
+				MR_trace_cmd = MR_CMD_TO_END;
+				MR_trace_discard_to_eol(c);
 				break;
 
 			case 'p':
-				if (port == MR_PORT_CALL) {
-					MR_trace_browse((int)
-						layout->MR_sle_in_arg_count,
-						&layout->MR_sle_in_arg_info);
-				} else if (port == MR_PORT_EXIT) {
-					MR_trace_browse((int)
-						layout->MR_sle_out_arg_count,
-						&layout->MR_sle_out_arg_info);
-				} else {
-					fprintf(stderr, "mtrace: cannot print"
-							" from this port\n");
-				}
+				if (count_given)
+					printf("mtrace: count ignored\n");
+
+				MR_trace_discard_to_eol(c);
+				MR_trace_browse((int)
+					layout->MR_sll_var_count,
+					&layout->MR_sll_var_info);
 
 				continue;
 
-			case 's':
-				if (MR_port_is_final(port)) {
-					fprintf(stderr, "mtrace: cannot skip"
-							" from this port\n");
-					continue;
-				} else {
-					MR_trace_cmd = MR_CMD_SKIP;
-					MR_trace_seqno = seqno;
-				}
+			case 'r':
+				if (count_given)
+					printf("mtrace: count ignored\n");
 
+				MR_trace_cmd = MR_CMD_RESUME_FORWARD;
+				MR_trace_discard_to_eol(c);
 				break;
 
-			case EOF:
+			case 'b':
+				if (count_given)
+					printf("mtrace: count ignored\n");
+
+				MR_add_spy_point();
+				continue;
+
+			case '?':
+				if (count_given)
+					printf("mtrace: count ignored\n");
+
+				MR_list_spy_points();
+				continue;
+
+			case '+':
+				if (count_given)
+					printf("mtrace: count ignored\n");
+
+				MR_change_spy_point_status(TRUE);
+				continue;
+
+			case '-':
+				if (count_given)
+					printf("mtrace: count ignored\n");
+
+				MR_change_spy_point_status(FALSE);
+				continue;
+
 			case 'a':
-				fprintf(stderr, "mtrace: are you sure"
+			case EOF:
+				MR_trace_discard_to_eol(c);
+				printf("mtrace: are you sure"
 						" you want to abort? ");
 
-				if (MR_trace_get_cmd() == 'y') {
+				c = MR_trace_skip_spaces(' ');
+				if (c == 'y' || c == EOF) {
+					/*
+					** We reset MR_trace_event_number
+					** that fatal_error will not
+					** print the last trace event number
+					** (since in this case it is not
+					** meaningful).
+					*/
+
+					MR_trace_event_number = 0;
 					fatal_error("aborting the execution "
 						"on user request");
 				}
+
+				MR_trace_discard_to_eol(c);
 				continue;
 
 			default:
+				MR_trace_discard_to_eol(c);
 				MR_trace_help();
 				continue;
 		}
@@ -781,71 +1059,95 @@
 	}
 }
 
-static Word	MR_saved_regs[MAX_FAKE_REG];
-
 static void
-MR_copy_regs_to_saved_regs(void)
+MR_add_spy_point(void)
 {
-	/*
-	** In the process of browsing, we call Mercury code,
-	** which may clobber the contents of the registers,
-	** both the control registers and the general purpose registers.
-	** We must therefore save and restore these.
-	**
-	** XXX This is very inefficient!
-	**
-	** Some are in real machine registers; others in the fake_reg array.
-	** We need to copy them all to the fake_reg array, because the
-	** calling convention for calling Mercury functions exported to C
-	** assumes that they will be in the fake_reg array.
-	*/
+	int	c;
 
-	int i;
+	c = getchar();
 
-	restore_transient_registers();
-	save_registers();
-	for (i = 0; i < MAX_FAKE_REG; i++) {
-		MR_saved_regs[i] = fake_reg[i];
+	if (MR_next_spy_point >= MR_MAX_SPY_POINTS) {
+		MR_trace_discard_to_eol(c);
+		printf("mtrace: no room for more spy points\n");
+		return;
+	}
+
+	if (MR_trace_get_word(&c, MR_spy_points[MR_next_spy_point].module_name,
+			MR_NAME_LEN)
+	&& MR_trace_get_word(&c, MR_spy_points[MR_next_spy_point].pred_name,
+			MR_NAME_LEN)) {
+		MR_trace_discard_to_eol(c);
+		MR_spy_points[MR_next_spy_point].enabled = TRUE;
+		MR_next_spy_point++;
+	}
+	else {
+		printf("usage: \"b module_name pred_name\"\n");
 	}
 }
 
 static void
-MR_copy_saved_regs_to_regs(void)
+MR_list_spy_points(void)
 {
-	int i;
+	int	i;
 
-	for (i = 0; i < MAX_FAKE_REG; i++) {
-		fake_reg[i] = MR_saved_regs[i];
+	for (i = 0; i < MR_next_spy_point; i++) {
+		printf("%2d: %s %s:%s\n", i,
+			MR_spy_points[i].enabled? "+": "-",
+			MR_spy_points[i].module_name,
+			MR_spy_points[i].pred_name);
 	}
-	restore_registers();
-	save_transient_registers();
+
+	MR_trace_discard_to_eol(getchar());
+}
+
+static void
+MR_change_spy_point_status(bool status)
+{
+	char	buf[MR_LOG10_MAX_SPY_POINTS];
+	int	c;
+	int	i;
+
+	c = getchar();
+
+	if (MR_trace_get_word(&c, buf, MR_LOG10_MAX_SPY_POINTS)) {
+		if (sscanf(buf, "%d", &i) == 1) {
+			if (0 <= i && i < MR_next_spy_point) {
+				MR_spy_points[i].enabled = status;
+			} else {
+				printf("spy point #%d does not exist\n", i);
+			}
+		} else if (strcmp(buf, "*") == 0) {
+			for (i = 0; i < MR_next_spy_point; i++) {
+				MR_spy_points[i].enabled = status;
+			}
+		} else {
+			printf("garbled spy point number\n");
+		}
+	} else {
+		printf("missing spy point number\n");
+	}
+
+	MR_trace_discard_to_eol(c);
 }
 
 static Word
-MR_trace_make_var_list(MR_trace_port port, const MR_stack_layout_entry *layout)
+MR_trace_make_var_list(MR_trace_port port, const MR_Stack_Layout_Label *layout)
 {
 	int 				var_count;
-	const MR_stack_layout_vars 	*vars;
+	const MR_Stack_Layout_Vars 	*vars;
 	int				i;
 	const char			*name;
 
 	Word				univ_list;
-	MR_stack_layout_var*		var;
+	MR_Stack_Layout_Var*		var;
 	Word				univ, value;
 	MR_Live_Type			live_type;
 	Word				type_info;
 
 	restore_transient_registers();
 
-	if (port == MR_PORT_CALL) {
-		var_count = layout->MR_sle_in_arg_count;
-		vars = &layout->MR_sle_in_arg_info;
-	} else if (port == MR_PORT_EXIT) {
-		var_count = layout->MR_sle_out_arg_count;
-		vars = &layout->MR_sle_out_arg_info;
-	} else {
-		return list_empty();
-	}
+	var_count = layout->MR_sll_var_count;
+	vars = &layout->MR_sll_var_info;
 
 	/* build up the live variable list, starting from the end */
 	univ_list = list_empty();
@@ -855,15 +1157,24 @@
 		** (XXX we don't include the name or the inst
 		** in the list that we return)
 		*/
-		if (vars->MR_slvs_names != NULL &&
-				vars->MR_slvs_names[i] != NULL)
-		{
-			name = vars->MR_slvs_names[i];
-		} else {
-			name = "";
-		}
+
+		name = MR_name_if_present(vars, i);
 		var = &vars->MR_slvs_pairs[i];
-		if (!MR_trace_get_type_and_value(var, &type_info, &value)) {
+
+		/*
+		** XXX The printing of type_infos is buggy at the moment
+		** due to the fake arity of mercury_builtin:typeinfo/1.
+		**
+		** "variables" representing the saved values of succip, hp etc,
+		** which are the "variables" for which get_type_and_value
+		** fails, are not of interest to the trace analyzer.
+		*/
+
+		if ((strncmp(name, "TypeInfo", 8) == 0)
+		|| (strncmp(name, "ModuleInfo", 10) == 0)
+		|| (strncmp(name, "HLDS", 4) == 0)
+		|| !MR_trace_get_type_and_value(var, NULL, &type_info, &value))
+		{
 			continue;
 		}
 
@@ -881,31 +1192,34 @@
 }
 
 static void
-MR_trace_browse(int var_count, const MR_stack_layout_vars *vars)
+MR_trace_browse(int var_count, const MR_Stack_Layout_Vars *vars)
 {
+	Word	*type_params;
+	bool	succeeded;
 	int	i;
-	char	*name;
 
 	if (var_count == 0) {
 		printf("mtrace: no live variables\n");
 		return;
 	}
 
-	MR_copy_regs_to_saved_regs();
-
-	for (i = 0; i < var_count; i++) {
-		if (vars->MR_slvs_names != NULL &&
-				vars->MR_slvs_names[i] != NULL)
-		{
-			name = vars->MR_slvs_names[i];
-		} else {
-			name = NULL;
+	type_params = checked_malloc((vars->MR_slvs_tvar_count + 1)
+		* sizeof(Word));
+	/* type_params should look like a typeinfo; type_params[0] is empty */
+	for (i = 0; i < vars->MR_slvs_tvar_count; i++) {
+		type_params[i+1] = MR_trace_lookup_live_lval(
+			vars->MR_slvs_tvars[i], &succeeded);
+		if (!succeeded) {
+			fatal_error("missing type param in MR_trace_browse");
 		}
+	}
 
-		MR_trace_browse_var(name, &vars->MR_slvs_pairs[i]);
+	for (i = 0; i < var_count; i++) {
+		MR_trace_browse_var(MR_name_if_present(vars, i),
+			&vars->MR_slvs_pairs[i], type_params);
 	}
 
-	MR_copy_saved_regs_to_regs();
+	free(type_params);
 }
 
 /* if you want to debug this code, you may want to set this var to TRUE */
@@ -991,26 +1305,45 @@
 	return value;
 }
 
+/* XXX fix this ref to the library */
+extern	Word	*ML_create_type_info(Word *term_type_info,
+			Word *arg_pseudo_type_info);
+
 static bool
-MR_trace_get_type_and_value(const MR_stack_layout_var *var,
-	Word *type_info, Word *value)
+MR_trace_get_type_and_value(const MR_Stack_Layout_Var *var,
+	Word *type_params, Word *type_info, Word *value)
 {
-	bool succeeded;
+	bool	succeeded;
+	Word	*pseudo_type_info;
+	int	i;
 
-	if (MR_LIVE_TYPE_IS_VAR(var->MR_slv_live_type)) {
-		*type_info = MR_LIVE_TYPE_GET_VAR_TYPE(var->MR_slv_live_type);
-	} else {
+	if (!MR_LIVE_TYPE_IS_VAR(var->MR_slv_live_type)) {
 		return FALSE;
 	}
+
+	pseudo_type_info = MR_LIVE_TYPE_GET_VAR_TYPE(var->MR_slv_live_type);
+	*type_info = (Word) ML_create_type_info(type_params, pseudo_type_info);
 	*value = MR_trace_lookup_live_lval(var->MR_slv_locn, &succeeded);
 	return succeeded;
 }
 
 static void
-MR_trace_browse_var(char *name, const MR_stack_layout_var *var)
+MR_trace_browse_var(const char *name, const MR_Stack_Layout_Var *var,
+	Word *type_params)
 {
-	Word			value, type_info;
-	bool			print_value;
+	Word	value, type_info;
+	bool	print_value;
+	int	i;
+
+	/*
+	** XXX The printing of type_infos is buggy at the moment
+	** due to the fake arity of the type mercury_builtin:typeinfo/1.
+	*/
+
+	if ((strncmp(name, "TypeInfo", 8) == 0)
+	|| (strncmp(name, "ModuleInfo", 10) == 0)
+	|| (strncmp(name, "HLDS", 4) == 0))
+		return;
 
 	/* The initial blanks are to visually separate */
 	/* the variable names from the prompt. */
@@ -1021,7 +1354,16 @@
 		printf("%10s%-21s\t", "", "anonymous variable");
 	}
 
-	if (MR_trace_get_type_and_value(var, &type_info, &value)) {
+	fflush(stdout);
+
+	/*
+	** "variables" representing the saved values of succip, hp etc,
+	** which are the "variables" for which get_type_and_value fails,
+	** are not of interest to the user.
+	*/
+
+	if (MR_trace_get_type_and_value(var, type_params, &type_info, &value))
+	{
 		printf("\t");
 
 		/*
@@ -1030,42 +1372,108 @@
 		** avoid going through call_engine, but for some unknown
 		** reason, that seemed to cause the Mercury code in the
 		** browser to clobber part of the C stack.
+		**
 		** Probably that was due to a bug which has since been
 		** fixed, so we should change the code below back again...
+		**
+		** call_engine expects the transient registers to be
+		** in fake_reg, others in their normal homes.
+		** The code below works by placing r1, r2 and all other
+		** transient registers both in their normal homes and
+		** and in fake_reg as well.
 		*/
+
+		MR_trace_enabled = FALSE;
+		for (i = 0; i < MR_MAX_SPECIAL_REG_MR; i++) {
+			fake_reg[i] = MR_saved_regs[i];
+		}
+		restore_registers();
 		r1 = type_info;
 		r2 = value;
+		save_transient_registers(); /* r1 or r2 may be transient */
 		call_engine(MR_library_trace_browser);
+		MR_trace_enabled = TRUE;
 	}
 
 	printf("\n");
 }
 
 static int
-MR_trace_get_cmd(void)
+MR_trace_skip_spaces(int c)
 {
-	int	cmd;
-	int	c;
+	while (c != EOF && c != '\n' && isspace(c))
+		c = getchar();
 
-	cmd = getchar();	/* read the trace command */
+	return c;
+}
 
-	/* skip the rest of the line */
-	c = cmd;
+static void
+MR_trace_discard_to_eol(int c)
+{
 	while (c != EOF && c != '\n')
 		c = getchar();
+}
+
+static int
+MR_trace_get_word(int *cptr, char word[], int len)
+{
+	int	c;
+	int	i;
+
+	c = MR_trace_skip_spaces(*cptr);
+
+	i = 0;
+	while (c != EOF && (isalnum(c) || c == '_')) {
+		if (i < len) {
+			word[i++] = c;
+		}
+
+		c = getchar();
+	}
+
+	*cptr = c;
+
+	if (i > 0) {
+		word[i] = '\0';
+		return TRUE;
+	}
 
-	return cmd;
+	return FALSE;
 }
 
 static void
 MR_trace_help(void)
 {
-	fprintf(stderr, "valid commands are:\n"
-			" a: abort the current execution.\n"
-			" c: continue to end, not printing the trace.\n"
-			" d: continue to end, printing the trace.\n"
-			" n: go to the next trace event.\n"
-			" s: skip the current call, not printing trace.\n"
-			" j: jump to end of current call, printing trace.\n"
-			" p: print the variables live at this point.\n");
+	printf("valid commands are:\n"
+		"a, EOF:\t\t"
+		"\tabort the current execution.\n"
+		"b module pred:\t"
+		"\tset breakpoint in module:pred.\n"
+		"c:\t\t"
+		"\tcontinue to end of program, not printing the trace.\n"
+		"C:\t\t"
+		"\tcontinue to end of program, printing the trace.\n"
+		"f:\t\t"
+		"\tfinish this call, not printing the trace.\n"
+		"F:\t\t"
+		"\tfinish this call, printing the trace.\n"
+		"<N> g:\t\t"
+		"\tgo to event #N, not printing the trace.\n"
+		"<N> G:\t\t"
+		"\tgo to event #N, printing the trace.\n"
+		"p:\t\t"
+		"\tprint the variables live at this point.\n"
+		"r:\t\t"
+		"\tcontinue until forward execution is resumed.\n"
+		"[<N>] s, [N] CR:"
+		"\tskip N events, not printing the trace.\n"
+		"[<N>] S:\t"
+		"\tskip N events, printing the trace.\n"
+		"?:\t\t"
+		"\tlist all the breakpoints.\n"
+		"+ N:\t\t"
+		"\tenable breakpoint #N.\n"
+		"- N:\t\t"
+		"\tdisable breakpoint #N.\n"
+	);
 }
Index: runtime/mercury_trace.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace.h,v
retrieving revision 1.6
diff -u -u -r1.6 mercury_trace.h
--- mercury_trace.h	1998/03/11 22:07:32	1.6
+++ mercury_trace.h	1998/03/31 10:12:47
@@ -8,9 +8,9 @@
 ** mercury_trace.h - defines the interface between
 ** the tracing subsystem and compiled code.
 **
-** The macros and the function defined in this module are intended to be
-** called only from code generated by the Mercury compiler, and from
-** hand-compiled code in the Mercury runtime or the Mercury standard library.
+** The macros and functions defined in this module are intended to be called
+** only from code generated by the Mercury compiler, and from hand-written
+** code in the Mercury runtime or the Mercury standard library.
 */
 
 #ifndef MERCURY_TRACE_H
@@ -27,6 +27,7 @@
 ** This enum should exactly match the definition of the `trace_port' type in
 ** library/debugger_interface.
 */
+
 typedef	enum {
 	MR_PORT_CALL,
 	MR_PORT_EXIT,
@@ -34,15 +35,26 @@
 	MR_PORT_THEN,
 	MR_PORT_ELSE,
 	MR_PORT_DISJ,
-	MR_PORT_SWITCH
+	MR_PORT_SWITCH,
+	MR_PORT_PRAGMA_FIRST,
+	MR_PORT_PRAGMA_LATER
 } MR_trace_port;
 
 extern	void	MR_trace(
-	const Word *,		/* pointer to stack layout info */
+	const MR_Stack_Layout_Label *,	/* layout info for the event */
 	MR_trace_port,
 	int,			/* call sequence number */
 	int,			/* call depth */
-	const char *);		/* path to event goal within procedure */
+	const char *,		/* path to event goal within procedure */
+	int);			/* highest numbered rN register in use */
+
+/*
+** These functions will report the number of the last event,
+** if there have been some events, and will do nothing otherwise.
+*/
+
+extern	void	MR_trace_report(FILE *fp);
+extern	void	MR_trace_report_raw(int fd);
 
 /*
 ** MR_trace_init() is called from mercury_runtime_init()
@@ -50,7 +62,18 @@
 ** MR_trace_end() is called from mercury_runtime_terminate()
 ** when the debuggee programs is exiting.
 */
+
 extern	void	MR_trace_init(void);
 extern	void	MR_trace_end(void);
+
+typedef	enum {
+	MR_TRACE_INTERNAL,
+	MR_TRACE_EXTERNAL
+} MR_trace_type;
+
+extern	MR_trace_type	MR_trace_handler;
+extern	bool		MR_trace_enabled;
+
+extern	int		MR_trace_event_number;
 
 #endif /* MERCURY_TRACE_H */
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.8
diff -u -u -r1.8 mercury_wrapper.c
--- mercury_wrapper.c	1998/03/16 12:23:40	1.8
+++ mercury_wrapper.c	1998/03/31 10:25:21
@@ -65,10 +65,6 @@
 
 /* other options */
 
-int		r1val = -1;
-int		r2val = -1;
-int		r3val = -1;
-
 bool		check_space = FALSE;
 
 static	bool	benchmark_all_solns = FALSE;
@@ -443,7 +439,7 @@
 	unsigned long size;
 	int c;
 
-	while ((c = getopt(argc, argv, "acC:d:hLlP:pr:s:tT:w:xz:1:2:3:")) != EOF)
+	while ((c = getopt(argc, argv, "acC:d:D:hLlP:pr:s:tT:w:xz:")) != EOF)
 	{
 		switch (c)
 		{
@@ -512,6 +508,21 @@
 			use_own_timer = FALSE;
 			break;
 
+		case 'D':
+			MR_trace_enabled = TRUE;
+
+			if (streq(optarg, "i"))
+				MR_trace_handler = MR_TRACE_INTERNAL;
+#ifdef	MR_USE_EXTERNAL_DEBUGGER
+			else if (streq(optarg, "e"))
+				MR_trace_handler = MR_TRACE_EXTERNAL;
+#endif
+
+			else
+				usage();
+
+			break;
+
 		case 'h':
 			usage();
 			break;
@@ -647,24 +658,6 @@
 
 			break;
 
-		case '1':	
-			if (sscanf(optarg, "%d", &r1val) != 1)
-				usage();
-
-			break;
-
-		case '2':	
-			if (sscanf(optarg, "%d", &r2val) != 1)
-				usage();
-
-			break;
-
-		case '3':	
-			if (sscanf(optarg, "%d", &r3val) != 1)
-				usage();
-
-			break;
-
 		default:	
 			usage();
 
@@ -698,6 +691,10 @@
 		"-dm \t\tdebug memory allocation\n"
 		"-dG \t\tdebug garbage collection\n"
 		"-dd \t\tdetailed debug\n"
+		"-Di \t\tdebug the program using the internal debugger\n"
+#ifdef MR_USE_EXTERNAL_DEBUGGER
+		"-De \t\tdebug the program using the external debugger\n"
+#endif
 		"-sh<n> \t\tallocate n kb for the heap\n"
 		"-sd<n> \t\tallocate n kb for the det stack\n"
 		"-sn<n> \t\tallocate n kb for the nondet stack\n"
@@ -718,9 +715,7 @@
 #endif
 		"-r<n> \t\trepeat n times\n"
 		"-w<name> \tcall predicate with given name (default: main/2)\n"
-		"-1<x> \t\tinitialize register r1 with value x\n"
-		"-2<x> \t\tinitialize register r2 with value x\n"
-		"-3<x> \t\tinitialize register r3 with value x\n");
+		);
 	fflush(stdout);
 	exit(1);
 } /* end usage() */
Index: runtime/mercury_wrapper.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.h,v
retrieving revision 1.6
diff -u -u -r1.6 mercury_wrapper.h
--- mercury_wrapper.h	1998/03/11 22:07:35	1.6
+++ mercury_wrapper.h	1998/03/31 10:25:27
@@ -91,10 +91,6 @@
 /* size of the primary cache */
 extern	size_t		pcache_size;
 
-extern	int		r1val;
-extern	int		r2val;
-extern	int		r3val;
-
 extern	bool		check_space;
 
 /* timing */
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
Index: samples/diff/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/samples/diff/Mmakefile,v
retrieving revision 1.4
diff -u -u -r1.4 Mmakefile
--- Mmakefile	1998/01/13 00:51:48	1.4
+++ Mmakefile	1998/03/25 05:59:12
@@ -19,4 +19,5 @@
 # BTW, the predicate which isn't compiled correctly is diff_out__show_file
 # in diff_out.m.
 MGNUCFLAGS=-O0
-
+MCFLAGS = --generate-trace
+MC = lmc2
cvs diff: Diffing scripts
Index: scripts/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmakefile,v
retrieving revision 1.6
diff -u -u -r1.6 Mmakefile
--- Mmakefile	1997/11/21 07:11:00	1.6
+++ Mmakefile	1998/03/14 06:07:48
@@ -14,7 +14,7 @@
 
 #-----------------------------------------------------------------------------#
 
-SCRIPTS = mmake mmc c2init mgnuc ml mprof mprof_merge_runs mint \
+SCRIPTS = mmake mmc mmd c2init mgnuc ml mprof mprof_merge_runs mint \
 	  sicstus_conv mtags vpath_find mercury_update_interface \
 	  mkfifo_using_mknod
 NUPROLOG_SCRIPTS = mnc mnl mnp
cvs diff: scripts/mmd is a new entry, no comparison available
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: tests/debugger/Mmakefile is a new entry, no comparison available
cvs diff: tests/debugger/debugger_regs.exp is a new entry, no comparison available
cvs diff: tests/debugger/debugger_regs.inp is a new entry, no comparison available
cvs diff: tests/debugger/debugger_regs.m is a new entry, no comparison available
cvs diff: tests/debugger/interpreter.exp is a new entry, no comparison available
cvs diff: tests/debugger/interpreter.inp is a new entry, no comparison available
cvs diff: tests/debugger/interpreter.m is a new entry, no comparison available
cvs diff: tests/debugger/queens.exp is a new entry, no comparison available
cvs diff: tests/debugger/queens.inp is a new entry, no comparison available
cvs diff: tests/debugger/queens.m is a new entry, no comparison available
cvs diff: tests/debugger/runtests is a new entry, no comparison available
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
Index: tests/misc_tests/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/misc_tests/Mmakefile,v
retrieving revision 1.6
diff -u -u -r1.6 Mmakefile
--- Mmakefile	1998/02/16 17:23:15	1.6
+++ Mmakefile	1998/03/18 00:57:55
@@ -9,41 +9,14 @@
 mdemangle_test.out: mdemangle_test.inp
 	mdemangle < mdemangle_test.inp > mdemangle_test.out 2>&1
 
-debugger_regs.out: debugger_regs debugger_regs.inp
-	./debugger_regs debugger_regs.m < debugger_regs.inp \
-		> debugger_regs.out 2>&1
-
-debugger_test.out: debugger_test debugger_test.inp
-	./debugger_test debugger_test.m < debugger_test.inp \
-		> debugger_test.out 2>&1
-
 pretty_print_test.out: pretty_print_test.ugly
 	cp pretty_print_test.ugly pretty_print_test.out
 
 #-----------------------------------------------------------------------------#
 
-STACK_LAYOUT_PROGS=	\
-	debugger_regs	\
-	debugger_test
-
-OTHER_PROGS =
+PROGS =
 
 OTHER_TESTS = mdemangle_test pretty_print_test
-
-MCFLAGS-debugger_regs = --generate-trace
-MCFLAGS-debugger_test = --generate-trace
-
-# Not all grades can be used with stack layouts
-#
-ifeq ($(GRADE),jump) 
-	PROGS=$(OTHER_PROGS)
-else
-	ifeq ($(GRADE),fast)
-		PROGS=$(OTHER_PROGS)
-	else
-		PROGS=$(STACK_LAYOUT_PROGS) $(OTHER_PROGS)
-	endif
-endif
 
 #-----------------------------------------------------------------------------#
 
cvs diff: tests/misc_tests/debugger_regs.exp was removed, no comparison available
cvs diff: tests/misc_tests/debugger_regs.inp was removed, no comparison available
cvs diff: tests/misc_tests/debugger_regs.m was removed, no comparison available
cvs diff: tests/misc_tests/debugger_test.exp was removed, no comparison available
cvs diff: tests/misc_tests/debugger_test.inp was removed, no comparison available
cvs diff: tests/misc_tests/debugger_test.m was removed, no comparison available
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trial
cvs diff: Diffing util
Index: util/mkinit.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mkinit.c,v
retrieving revision 1.29
diff -u -u -r1.29 mkinit.c
--- mkinit.c	1998/03/11 22:07:38	1.29
+++ mkinit.c	1998/03/31 10:18:18
@@ -133,7 +133,7 @@
 	"	MR_library_initializer = ML_io_init_state;\n"
 	"	MR_library_finalizer = ML_io_finalize_state;\n"
 	"	MR_library_trace_browser = ENTRY(mercury__io__print_3_0);\n"
-	"#ifdef MR_USE_DEBUGGER\n"
+	"#ifdef MR_USE_EXTERNAL_DEBUGGER\n"
 	"	MR_DI_output_current = ML_DI_output_current;\n"
 	"	MR_DI_found_match = ML_DI_found_match;\n"
 	"	MR_DI_read_request_from_socket = ML_DI_read_request_from_socket;\n"



More information about the developers mailing list