Fix a bug caused by one of my recent changes

Erwan Jahier Erwan.Jahier at irisa.fr
Tue Feb 23 01:31:01 AEDT 1999


One of my recent change broke the compiler in asm_fast.gc.tr.debug grade. It
was due to the fact that I have forgotten to add print_stack_trace() as an
argument of the occurence of MR_dump_stack_from_layout() that was inside the
body of MR_dump_stack(); which means that I need to pass the address of
MR_dump_print_stack_trace() down to MR_dump_stack(). But MR_dump_stack() is
also called in the library, and in order to respect the invariant "trace ->
library -> runtime" we can't call MR_dump_print_stack_trace() from there. So I
move the definition of the functions the performs stack print in
runtime/mercury_stack_trace.c.


Estimated hours taken: 2

Moves the definition of MR_dump_stack_record_print() and
MR_dump_stack_record_print_to_socket() from trace/ to runtime/ to be able to
call MR_dump_stack() from the library. Pass down a flag (of type
MR_stack_print_target) that tells which stack printing function to use.


runtime/mercury_stack_trace.[ch]:
	Pass a parameter of type MR_stack_print_target down
	functions that perform stack printing instead of passing the address of
	MR_dump_stack_record_print*().
	
	Define a new type MR_stack_print_target that is a flag that tells which 
	stack printing function to use.

runtime/mercury_stack_trace.c:
trace/mercury_trace_external.c:
	Move the definition of MR_dump_stack_record_print_to_socket() and
	MR_print_proc_id() from mercury_trace_external.c to mercury_stack_trace.c

runtime/mercury_stack_trace.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_tables.[ch]:
	Move the definition of MR_dump_stack_record_print() from
	mercury_trace_internal.c to mercury_stack_trace.c and
	MR_print_proc_id() from mercury_trace_tables.c to mercury_stack_trace.c

runtime/mercury_stack_trace.c:
trace/mercury_trace.[ch]:
	Move the definition of MR_detism_names[] from mercury_trace.c to
	mercury_stack_trace.c.



Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.27
diff -u -r1.27 mercury_stack_trace.c
--- mercury_stack_trace.c	1999/02/20 06:58:06	1.27
+++ mercury_stack_trace.c	1999/02/22 14:24:56
@@ -16,17 +16,23 @@
 
 
 static	void	MR_dump_stack_record_init(void);
-static	void	MR_dump_stack_record_frame(FILE *fp,
-			const MR_Stack_Layout_Entry *,
-			Word *base_sp, Word *base_curfr, 
-			void (*print_stack_record)(
-				FILE *, const MR_Stack_Layout_Entry *, 
-				int, int, Word *, Word *));
-static	void	MR_dump_stack_record_flush(FILE *fp, 
-			void (*print_stack_record)(
-				FILE *, const MR_Stack_Layout_Entry *, 
-				int, int, Word *, Word *));
+static	void	MR_dump_stack_record_frame(FILE *fp, 
+			const MR_Stack_Layout_Entry *entry_layout,
+			Word *base_sp, Word *base_curfr, MR_stack_print_target target);
+static	void	MR_dump_stack_record_flush(FILE *fp, MR_stack_print_target target);
 
+
+static	void	MR_dump_stack_record_print(FILE *fp,
+			const MR_Stack_Layout_Entry *, int, int,
+			Word *base_sp, Word *base_curfr);
+
+static	void	MR_dump_stack_record_print_to_socket(FILE *fp, 
+			const MR_Stack_Layout_Entry *entry_layout, int count, 
+			int start_level, Word *base_sp, Word *base_curfr);
+static	void	MR_print_proc_id_to_socket(const MR_Stack_Layout_Entry *entry,
+			const char *extra, Word *base_sp, Word *base_curfr);
+
+
 void
 MR_dump_stack(Code *success_pointer, Word *det_stack_pointer,
 	Word *current_frame, bool include_trace_data)
@@ -49,7 +55,8 @@
 		layout = label->i_layout;
 		entry_layout = layout->MR_sll_entry;
 		result = MR_dump_stack_from_layout(stderr, entry_layout,
-			det_stack_pointer, current_frame, include_trace_data);
+			det_stack_pointer, current_frame, include_trace_data,
+			FILE_POINTEUR);
 
 		if (result != NULL) {
 			fprintf(stderr, "%s\n", result);
@@ -61,8 +68,7 @@
 const char *
 MR_dump_stack_from_layout(FILE *fp, const MR_Stack_Layout_Entry *entry_layout,
 	Word *det_stack_pointer, Word *current_frame, bool include_trace_data,
-	void (*print_stack_record)(FILE *, const MR_Stack_Layout_Entry *, 
-	int, int, Word *, Word *))
+	MR_stack_print_target target)
 {
 	MR_Stack_Walk_Step_Result	result;
 	const MR_Stack_Layout_Label	*return_label_layout;
@@ -85,30 +91,26 @@
 		result = MR_stack_walk_step(entry_layout, &return_label_layout,
 				&stack_trace_sp, &stack_trace_curfr, &problem);
 		if (result == STEP_ERROR_BEFORE) {
-			MR_dump_stack_record_flush(fp, 
-				print_stack_record);
+			MR_dump_stack_record_flush(fp, target);
 			return problem;
 		} else if (result == STEP_ERROR_AFTER) {
 			if (include_trace_data) {
 				MR_dump_stack_record_frame(fp, entry_layout,
-					old_trace_sp, old_trace_curfr, 
-					print_stack_record);
+					old_trace_sp, old_trace_curfr, target);
 			} else {
 				MR_dump_stack_record_frame(fp, entry_layout,
-					NULL, NULL, print_stack_record);
+					NULL, NULL, target);
 			}
 
-			MR_dump_stack_record_flush(fp, 
-				print_stack_record);
+			MR_dump_stack_record_flush(fp, target);
 			return problem;
 		} else {
 			if (include_trace_data) {
 				MR_dump_stack_record_frame(fp, entry_layout,
-					old_trace_sp, old_trace_curfr, 
-					print_stack_record);
+					old_trace_sp, old_trace_curfr, target);
 			} else {
 				MR_dump_stack_record_frame(fp, entry_layout,
-					NULL, NULL, print_stack_record);
+					NULL, NULL, target);
 			}
 		}
 
@@ -119,7 +121,7 @@
 		entry_layout = return_label_layout->MR_sll_entry;
 	} while (TRUE); 
 
-	MR_dump_stack_record_flush(fp, print_stack_record);
+	MR_dump_stack_record_flush(fp, target);
 	return NULL;
 }
 
@@ -284,8 +286,7 @@
 
 static void
 MR_dump_stack_record_frame(FILE *fp, const MR_Stack_Layout_Entry *entry_layout,
-	Word *base_sp, Word *base_curfr, void (*print_stack_record)(
-		FILE *, const MR_Stack_Layout_Entry *, int, int, Word *, Word *))
+	Word *base_sp, Word *base_curfr, MR_stack_print_target target)
 {
 	bool	must_flush;
 
@@ -311,7 +312,7 @@
 		((base_sp != NULL) || (base_curfr != NULL));
 
 	if (must_flush) {
-		MR_dump_stack_record_flush(fp, print_stack_record);
+		MR_dump_stack_record_flush(fp, target);
 
 		prev_entry_layout = entry_layout;
 		prev_entry_layout_count = 1;
@@ -326,13 +327,332 @@
 }
 
 static void
-MR_dump_stack_record_flush(FILE *fp, void (*print_stack_record)(
-	FILE *, const MR_Stack_Layout_Entry *, int, int, Word *, Word *))
+MR_dump_stack_record_flush(FILE *fp, MR_stack_print_target target)
 {
+#ifdef MR_USE_EXTERNAL_DEBUGGER
 	if (prev_entry_layout != NULL) {
-		print_stack_record(fp, prev_entry_layout,
-			prev_entry_layout_count, prev_entry_start_level,
-			prev_entry_base_sp, prev_entry_base_curfr);
+		if (target == DEBUGGER_SOCKET) {
+			MR_dump_stack_record_print_to_socket(
+				prev_entry_layout, prev_entry_layout_count, 
+				prev_entry_start_level, prev_entry_base_sp, 
+				prev_entry_base_curfr);
+		} else {
+		  /* target == FILE_POINTEUR */
+			MR_dump_stack_record_print(fp, prev_entry_layout,
+				prev_entry_layout_count, prev_entry_start_level,
+				prev_entry_base_sp, prev_entry_base_curfr);
+		}
+	}
+#elseif
+	if (prev_entry_layout != NULL) {
+		MR_dump_stack_record_print(fp, prev_entry_layout,
+				prev_entry_layout_count, prev_entry_start_level,
+				prev_entry_base_sp, prev_entry_base_curfr);
+	}
+
+#endif
+}
+
+/*
+** MR_dump_stack_record_print() and 
+*/
+
+void
+MR_dump_stack_record_print(FILE *fp, const MR_Stack_Layout_Entry *entry_layout,
+	int count, int start_level, Word *base_sp, Word *base_curfr)
+{
+	fprintf(fp, "%4d ", start_level);
+
+	if (count > 1) {
+		fprintf(fp, " %3d* ", count);
+	} else if ((base_sp == NULL) && (base_curfr == NULL)) {
+		fprintf(fp, "%5s ", "");
+	} else {
+		/*
+		** If we are printing trace data, we need all the horizonal
+		** room we can get, and there will not be any repeated lines,
+		** so we don't reserve space for the repeat counts.
+		*/
+	}
+
+	MR_print_proc_id(fp, entry_layout, NULL, base_sp, base_curfr);
+}
+
+void
+MR_print_proc_id(FILE *fp, const MR_Stack_Layout_Entry *entry,
+	const char *extra, Word *base_sp, Word *base_curfr)
+{
+	if (! MR_ENTRY_LAYOUT_HAS_PROC_ID(entry)) {
+		fatal_error("cannot print procedure id without layout");
+	}
+
+	if (base_sp != NULL && base_curfr != NULL) {
+		bool print_details = FALSE;
+		if (MR_ENTRY_LAYOUT_HAS_EXEC_TRACE(entry)) {
+			Word maybe_from_full = entry->MR_sle_maybe_from_full;
+			if (maybe_from_full > 0) {
+				/*
+				** for procedures compiled with shallow
+				** tracing, the details will be valid only
+				** if the value of MR_from_full saved in
+				** the appropriate stack slot was TRUE.
+			    	*/
+				if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
+					print_details = MR_based_stackvar(
+						base_sp, maybe_from_full);
+				} else {
+					print_details = MR_based_framevar(
+						base_curfr, maybe_from_full);
+				}
+			} else {
+				/*
+				** for procedures compiled with full tracing,
+				** always print out the details
+				*/
+				print_details = TRUE;
+			}
+		}
+		if (print_details) {
+			if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
+				fprintf(fp, "%7lu %7lu %4lu ",
+					(unsigned long)
+					MR_event_num_stackvar(base_sp) + 1,
+					(unsigned long)
+					MR_call_num_stackvar(base_sp),
+					(unsigned long)
+					MR_call_depth_stackvar(base_sp));
+			} else {
+				fprintf(fp, "%7lu %7lu %4lu ",
+					(unsigned long)
+					MR_event_num_framevar(base_curfr) + 1,
+					(unsigned long)
+					MR_call_num_framevar(base_curfr),
+					(unsigned long)
+					MR_call_depth_framevar(base_curfr));
+			}
+		} else {
+			/* ensure that the remaining columns line up */
+			fprintf(fp, "%21s", "");
+		}
+	}
+
+	if (MR_ENTRY_LAYOUT_COMPILER_GENERATED(entry)) {
+		fprintf(fp, "%s for %s:%s/%ld-%ld",
+			entry->MR_sle_comp.MR_comp_pred_name,
+			entry->MR_sle_comp.MR_comp_type_module,
+			entry->MR_sle_comp.MR_comp_type_name,
+			(long) entry->MR_sle_comp.MR_comp_arity,
+			(long) entry->MR_sle_comp.MR_comp_mode);
+
+		if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
+				entry->MR_sle_comp.MR_comp_def_module) != 0)
+		{
+			fprintf(fp, " {%s}",
+				entry->MR_sle_comp.MR_comp_def_module);
+		}
+	} else {
+		if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
+			fprintf(fp, "pred");
+		} else if (entry->MR_sle_user.MR_user_pred_or_func ==
+				MR_FUNCTION)
+		{
+			fprintf(fp, "func");
+		} else {
+			fatal_error("procedure is not pred or func");
+		}
+
+		fprintf(fp, " %s:%s/%ld-%ld",
+			entry->MR_sle_user.MR_user_decl_module,
+			entry->MR_sle_user.MR_user_name,
+			(long) entry->MR_sle_user.MR_user_arity,
+			(long) entry->MR_sle_user.MR_user_mode);
+
+		if (strcmp(entry->MR_sle_user.MR_user_decl_module,
+				entry->MR_sle_user.MR_user_def_module) != 0)
+		{
+			fprintf(fp, " {%s}",
+				entry->MR_sle_user.MR_user_def_module);
+		}
+	}
+
+	fprintf(fp, " (%s)", MR_detism_names[entry->MR_sle_detism]);
+
+	if (extra != NULL) {
+		fprintf(fp, " %s\n", extra);
+	} else {
+		fprintf(fp, "\n");
 	}
 }
+
+/*
+** The different Mercury determinisms are internally represented by integers. 
+** This array gives the correspondance with the internal representation and 
+** the names that are usually used to denote determinisms.
+*/
+
+extern const char * MR_detism_names[] = {
+	"failure",	/* 0 */
+	"",		/* 1 */
+	"semidet",	/* 2 */
+	"nondet",	/* 3 */
+	"erroneous",	/* 4 */
+	"",		/* 5 */
+	"det",		/* 6 */
+	"multi",	/* 7 */
+	"",		/* 8 */
+	"",		/* 9 */
+	"cc_nondet",	/* 10 */
+	"",		/* 11 */
+	"",		/* 12 */
+	"",		/* 13 */
+	"cc_multi"	/* 14 */
+};
+
+#ifdef MR_USE_EXTERNAL_DEBUGGER
+
+void    
+MR_send_message_to_socket_format(const char *format, ...)
+{
+	va_list args;
+
+       	va_start(args, format);
+       	vfprintf(MR_debugger_socket_out.file, format, args);
+       	va_end(args);
+       	fflush(MR_debugger_socket_out.file);
+       	MR_debugger_socket_out.line_number++;
+}
+
+
+
+void
+MR_send_message_to_socket(const char *message)
+{
+	fprintf(MR_debugger_socket_out.file, "%s.\n", message);
+	fflush(MR_debugger_socket_out.file);
+	MR_debugger_socket_out.line_number++;
+}
+
+/*
+** These two functions are the same as the two previous ones except they send
+** messages to the socket. They are intented to be used by the external debugger.
+*/
+
+static void
+MR_dump_stack_record_print_to_socket(
+	const MR_Stack_Layout_Entry *entry_layout, int count, int start_level, 
+	Word *base_sp, Word *base_curfr)
+{
+	MR_send_message_to_socket_format("level(%d).\n", start_level);
+	MR_print_proc_id_to_socket(entry_layout, NULL, base_sp, base_curfr);
+}
+
+
+static void
+MR_print_proc_id_to_socket(const MR_Stack_Layout_Entry *entry,
+	const char *extra, Word *base_sp, Word *base_curfr)
+{
+	if (! MR_ENTRY_LAYOUT_HAS_PROC_ID(entry)) {
+		fatal_error("cannot retrieve procedure id without layout");
+	}
+
+	if (base_sp != NULL && base_curfr != NULL) {
+		bool print_details = FALSE;
+		if (MR_ENTRY_LAYOUT_HAS_EXEC_TRACE(entry)) {
+			Word maybe_from_full = entry->MR_sle_maybe_from_full;
+			if (maybe_from_full > 0) {
+				/*
+				** for procedures compiled with shallow
+				** tracing, the details will be valid only
+				** if the value of MR_from_full saved in
+				** the appropriate stack slot was TRUE.
+			    	*/
+				if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
+					print_details = MR_based_stackvar(
+						base_sp, maybe_from_full);
+				} else {
+					print_details = MR_based_framevar(
+						base_curfr, maybe_from_full);
+				}
+			} else {
+				/*
+				** for procedures compiled with full tracing,
+				** always print out the details
+				*/
+				print_details = TRUE;
+			}
+		}
+		if (print_details) {
+			if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
+				MR_send_message_to_socket_format( 
+					"detail(%lu, %lu, %lu).\n",
+					(unsigned long)
+					MR_event_num_stackvar(base_sp) + 1,
+					(unsigned long)
+					MR_call_num_stackvar(base_sp),
+					(unsigned long)
+					MR_call_depth_stackvar(base_sp));
+			} else {
+				MR_send_message_to_socket_format( 
+					"detail(%lu, %lu, %lu).\n",
+					(unsigned long)
+					MR_event_num_framevar(base_curfr) + 1,
+					(unsigned long)
+					MR_call_num_framevar(base_curfr),
+					(unsigned long)
+					MR_call_depth_framevar(base_curfr));
+			}
+		} 
+	}
+
+	if (MR_ENTRY_LAYOUT_COMPILER_GENERATED(entry)) {
+		MR_send_message_to_socket_format(
+			/* XXX Names with ' may cause some problems here */
+			"proc('%s for %s:%s'/%ld-%ld).\n",
+			entry->MR_sle_comp.MR_comp_pred_name,
+			entry->MR_sle_comp.MR_comp_type_module,
+			entry->MR_sle_comp.MR_comp_type_name,
+			(long) entry->MR_sle_comp.MR_comp_arity,
+			(long) entry->MR_sle_comp.MR_comp_mode);
+
+		if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
+				entry->MR_sle_comp.MR_comp_def_module) != 0)
+		{
+			MR_send_message_to_socket_format(
+				"def_module(\"%s\").\n",
+				entry->MR_sle_comp.MR_comp_def_module);
+		}
+	} else {
+		if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
+			MR_send_message_to_socket("pred");
+		} else if (entry->MR_sle_user.MR_user_pred_or_func ==
+				MR_FUNCTION)
+		{
+			MR_send_message_to_socket("func");
+		} else {
+			fatal_error("procedure is not pred or func");
+		}
+		
+		MR_send_message_to_socket_format(
+			/* XXX Names with ' may cause some problems here */
+			"proc('%s:%s'/%ld-%ld).\n",
+			entry->MR_sle_user.MR_user_decl_module,
+			entry->MR_sle_user.MR_user_name,
+			(long) entry->MR_sle_user.MR_user_arity,
+			(long) entry->MR_sle_user.MR_user_mode);
+
+		if (strcmp(entry->MR_sle_user.MR_user_decl_module,
+				entry->MR_sle_user.MR_user_def_module) != 0)
+		{
+			MR_send_message_to_socket_format(
+				"def_module(\"%s\").\n",
+				entry->MR_sle_user.MR_user_def_module);
+		}
+	}
+
+	MR_send_message_to_socket_format("det(\"%s\").\n", 
+		MR_detism_names[entry->MR_sle_detism]);
+
+}
+
+#endif /* MR_USE_EXTERNAL_DEBUGGER */
 
Index: runtime/mercury_stack_trace.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.h,v
retrieving revision 1.16
diff -u -r1.16 mercury_stack_trace.h
--- mercury_stack_trace.h	1999/02/20 06:58:07	1.16
+++ mercury_stack_trace.h	1999/02/22 14:24:57
@@ -43,6 +43,19 @@
 extern	void	MR_dump_stack(Code *success_pointer, Word *det_stack_pointer,
 			Word *current_frame, bool include_trace_data);
 
+
+/*
+** A parameter of this type in pass down through all functions that performs stack
+** printing. It tells whether to use MR_dump_stack_record_print() or
+** MR_dump_stack_record_print_to_socket() to perform the stack printing.  
+*/
+
+typedef enum {
+	DEBUGGER_SOCKET, /* to print the stack on the external debugger socket */
+	FILE_POINTEUR,   /* to print the stack on the file pointer passed down  
+			    functions thats perform stack printing */
+} MR_stack_print_target;
+
 /*
 ** MR_dump_stack_from_layout:
 **	This function does the same job and makes the same assumptions
@@ -51,15 +64,16 @@
 **	that tells it where to put the stack dump. If the entire stack
 **	was printed successfully, the return value is NULL; otherwise,
 **	it is a string indicating why the dump was cut short.
+**	if (target == DEBUGGER_SOCKET) the stack will be printed on the external
+**	debugger socket; otherwise (target == FILE_POINTEUR), it will be printed 
+**	on the file descriptor pointer fp.
 */
 
 extern	const char	*MR_dump_stack_from_layout(FILE *fp,
 				const MR_Stack_Layout_Entry *entry_layout,
 				Word *det_stack_pointer, Word *current_frame,
 				bool include_trace_data,
-				void (*print_stack_record)(FILE *, 
-					const MR_Stack_Layout_Entry *, 
-					int, int, Word *, Word *));
+				MR_stack_print_target target);
 
 /*
 ** MR_dump_nondet_stack_from_layout:
@@ -137,5 +151,48 @@
 
 Word	*MR_nondet_stack_trace_bottom;
 
+/*
+** The different Mercury determinisms are internally represented by integers. 
+** This array gives the correspondance with the internal representation and 
+** the names that are usually used to denote determinisms.
+*/
+
+extern const char * MR_detism_names[];
+
+/*
+** MR_print_proc_id prints an identification of the given procedure,
+** consisting of "pred" or "func", module name, pred or func name, arity,
+** mode number and determinism, followed by an optional extra string,
+** and a newline.
+**
+** If the procedure has trace layout information and the relevant one of
+** base_sp and base_curfr is not NULL, it also prints the call event number,
+** call sequence number and call depth of the call.
+*/
+
+void	MR_print_proc_id(FILE *fp, const MR_Stack_Layout_Entry *entry,
+			const char *extra, Word *base_sp, Word *base_curfr);
+
+#ifdef MR_USE_EXTERNAL_DEBUGGER
+
+/*
+** Use a GNU C extension to enforce static type checking
+** for printf-style functions. 
+** (See the "Function attributes" section of "C extensions"
+** chapter of the GNU C manual for detailed documentation.)
+*/
+#ifdef __GNUC__
+  #define MR_LIKE_PRINTF(format_argnum, vars_argnum) \
+    __attribute__ ((format (printf, (format_argnum), (vars_argnum))))
+#else
+  #define MR_LIKE_PRINTF(n, m) /* nothing */
+#endif
+
+void	MR_send_message_to_socket_format(const char *format, ...)
+		MR_LIKE_PRINTF(1, 2);
+
+void	MR_send_message_to_socket(const char *message);
+
+#endif /* MR_USE_EXTERNAL_DEBUGGER */
 
 #endif /* MERCURY_STACK_TRACE_H */
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.7
diff -u -r1.7 mercury_trace.c
--- mercury_trace.c	1999/02/20 06:08:10	1.7
+++ mercury_trace.c	1999/02/22 14:24:59
@@ -438,27 +438,3 @@
 	return 0;
 }
 
-
-/*
-** The different Mercury determinisms are internally represented by integers. 
-** This array gives the correspondance with the internal representation and 
-** the names that are usually used to denote determinisms.
-*/
-
-extern const char * MR_detism_names[] = {
-	"failure",	/* 0 */
-	"",		/* 1 */
-	"semidet",	/* 2 */
-	"nondet",	/* 3 */
-	"erroneous",	/* 4 */
-	"",		/* 5 */
-	"det",		/* 6 */
-	"multi",	/* 7 */
-	"",		/* 8 */
-	"",		/* 9 */
-	"cc_nondet",	/* 10 */
-	"",		/* 11 */
-	"",		/* 12 */
-	"",		/* 13 */
-	"cc_multi"	/* 14 */
-};
Index: trace/mercury_trace.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.h,v
retrieving revision 1.7
diff -u -r1.7 mercury_trace.h
--- mercury_trace.h	1999/02/20 06:08:11	1.7
+++ mercury_trace.h	1999/02/22 14:24:59
@@ -125,7 +125,6 @@
 ** the names that are usually used to denote determinisms.
 */
 
-extern const char * MR_detism_names[];
 
 #define	MR_port_is_final(port)		((port) == MR_PORT_EXIT || \
 					 (port) == MR_PORT_FAIL || \
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.11
diff -u -r1.11 mercury_trace_external.c
--- mercury_trace_external.c	1999/02/22 08:28:32	1.11
+++ mercury_trace_external.c	1999/02/22 14:24:59
@@ -108,11 +108,6 @@
 static Word	MR_trace_make_nth_var(const MR_Stack_Layout_Label *layout, 
 			Word *saved_regs, Word debugger_request);
 static int	MR_get_var_number(Word debugger_request);
-static void	MR_print_proc_id_to_socket(const MR_Stack_Layout_Entry *entry,
-			const char *extra, Word *base_sp, Word *base_curfr);
-static void	MR_dump_stack_record_print_to_socket(FILE *fp, 
-			const MR_Stack_Layout_Entry *entry_layout, int count, 
-			int start_level, Word *base_sp, Word *base_curfr);
 
 #if 0
 This pseudocode should go in the debugger process:
@@ -484,7 +479,7 @@
 					MR_saved_sp(saved_regs),
 					MR_saved_curfr(saved_regs),
 					include_trace_data,
-					&MR_dump_stack_record_print_to_socket);
+					DEBUGGER_SOCKET);
 				MR_send_message_to_socket("end_stack");
 				if (message != NULL) {
 					MR_send_message_to_socket_format(
@@ -505,9 +500,7 @@
 				** output of this function on the socket. But
 				** the outputs are done via fprintf() and
 				** printlabel(), so we would need to define new
-				** fprintf() and printlabel() and pass them
-				** down as parameters of
-				** MR_dump_nondet_stack_from_layout() (as we do
+				** fprintf() and printlabel() (as we do
 				** with MR_dump_stack_record_print()).
 				*/						
 				MR_dump_nondet_stack_from_layout(stdout,
@@ -924,121 +917,5 @@
 ** 3) The debuggee sends "end_stack"
 */
 
-static void
-MR_dump_stack_record_print_to_socket(FILE *fp, 
-	const MR_Stack_Layout_Entry *entry_layout, int count, int start_level, 
-	Word *base_sp, Word *base_curfr)
-{
-	MR_send_message_to_socket_format("level(%d).\n", start_level);
-	MR_print_proc_id_to_socket(entry_layout, NULL, base_sp, base_curfr);
-}
-
-
-static void
-MR_print_proc_id_to_socket(const MR_Stack_Layout_Entry *entry,
-	const char *extra, Word *base_sp, Word *base_curfr)
-{
-	if (! MR_ENTRY_LAYOUT_HAS_PROC_ID(entry)) {
-		fatal_error("cannot retrieve procedure id without layout");
-	}
-
-	if (base_sp != NULL && base_curfr != NULL) {
-		bool print_details = FALSE;
-		if (MR_ENTRY_LAYOUT_HAS_EXEC_TRACE(entry)) {
-			Word maybe_from_full = entry->MR_sle_maybe_from_full;
-			if (maybe_from_full > 0) {
-				/*
-				** for procedures compiled with shallow
-				** tracing, the details will be valid only
-				** if the value of MR_from_full saved in
-				** the appropriate stack slot was TRUE.
-			    	*/
-				if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
-					print_details = MR_based_stackvar(
-						base_sp, maybe_from_full);
-				} else {
-					print_details = MR_based_framevar(
-						base_curfr, maybe_from_full);
-				}
-			} else {
-				/*
-				** for procedures compiled with full tracing,
-				** always print out the details
-				*/
-				print_details = TRUE;
-			}
-		}
-		if (print_details) {
-			if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
-				MR_send_message_to_socket_format( 
-					"detail(%lu, %lu, %lu).\n",
-					(unsigned long)
-					MR_event_num_stackvar(base_sp) + 1,
-					(unsigned long)
-					MR_call_num_stackvar(base_sp),
-					(unsigned long)
-					MR_call_depth_stackvar(base_sp));
-			} else {
-				MR_send_message_to_socket_format( 
-					"detail(%lu, %lu, %lu).\n",
-					(unsigned long)
-					MR_event_num_framevar(base_curfr) + 1,
-					(unsigned long)
-					MR_call_num_framevar(base_curfr),
-					(unsigned long)
-					MR_call_depth_framevar(base_curfr));
-			}
-		} 
-	}
-
-	if (MR_ENTRY_LAYOUT_COMPILER_GENERATED(entry)) {
-		MR_send_message_to_socket_format(
-			/* XXX Names with ' may cause some problems here */
-			"proc('%s for %s:%s'/%ld-%ld).\n",
-			entry->MR_sle_comp.MR_comp_pred_name,
-			entry->MR_sle_comp.MR_comp_type_module,
-			entry->MR_sle_comp.MR_comp_type_name,
-			(long) entry->MR_sle_comp.MR_comp_arity,
-			(long) entry->MR_sle_comp.MR_comp_mode);
-
-		if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
-				entry->MR_sle_comp.MR_comp_def_module) != 0)
-		{
-			MR_send_message_to_socket_format(
-				"def_module(\"%s\").\n",
-				entry->MR_sle_comp.MR_comp_def_module);
-		}
-	} else {
-		if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
-			MR_send_message_to_socket("pred");
-		} else if (entry->MR_sle_user.MR_user_pred_or_func ==
-				MR_FUNCTION)
-		{
-			MR_send_message_to_socket("func");
-		} else {
-			fatal_error("procedure is not pred or func");
-		}
-		
-		MR_send_message_to_socket_format(
-			/* XXX Names with ' may cause some problems here */
-			"proc('%s:%s'/%ld-%ld).\n",
-			entry->MR_sle_user.MR_user_decl_module,
-			entry->MR_sle_user.MR_user_name,
-			(long) entry->MR_sle_user.MR_user_arity,
-			(long) entry->MR_sle_user.MR_user_mode);
-
-		if (strcmp(entry->MR_sle_user.MR_user_decl_module,
-				entry->MR_sle_user.MR_user_def_module) != 0)
-		{
-			MR_send_message_to_socket_format(
-				"def_module(\"%s\").\n",
-				entry->MR_sle_user.MR_user_def_module);
-		}
-	}
-
-	MR_send_message_to_socket_format("det(\"%s\").\n", 
-		MR_detism_names[entry->MR_sle_detism]);
-
-}
 
 #endif /* MR_USE_EXTERNAL_DEBUGGER */
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.28
diff -u -r1.28 mercury_trace_internal.c
--- mercury_trace_internal.c	1999/02/20 06:08:15	1.28
+++ mercury_trace_internal.c	1999/02/22 14:25:02
@@ -210,10 +210,6 @@
 
 static	bool	MR_trace_valid_command(const char *word);
 
-static	void	MR_dump_stack_record_print(FILE *fp,
-			const MR_Stack_Layout_Entry *, int, int,
-			Word *base_sp, Word *base_curfr);
-
 Code *
 MR_trace_event_internal(MR_Trace_Cmd_Info *cmd, bool interactive,
 		MR_Event_Info *event_info)
@@ -788,7 +784,7 @@
 					MR_saved_sp(saved_regs),
 					MR_saved_curfr(saved_regs),
 					include_trace_data,
-					&MR_dump_stack_record_print);
+					FILE_POINTEUR);
 			if (msg != NULL) {
 				fflush(MR_mdb_out);
 				fprintf(MR_mdb_err, "%s.\n", msg);
@@ -2453,24 +2449,4 @@
 	return FALSE;
 }
 
-static void
-MR_dump_stack_record_print(FILE *fp, const MR_Stack_Layout_Entry *entry_layout,
-	int count, int start_level, Word *base_sp, Word *base_curfr)
-{
-	fprintf(fp, "%4d ", start_level);
-
-	if (count > 1) {
-		fprintf(fp, " %3d* ", count);
-	} else if ((base_sp == NULL) && (base_curfr == NULL)) {
-		fprintf(fp, "%5s ", "");
-	} else {
-		/*
-		** If we are printing trace data, we need all the horizonal
-		** room we can get, and there will not be any repeated lines,
-		** so we don't reserve space for the repeat counts.
-		*/
-	}
-
-	MR_print_proc_id(fp, entry_layout, NULL, base_sp, base_curfr);
-}
 
Index: trace/mercury_trace_tables.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_tables.c,v
retrieving revision 1.5
diff -u -r1.5 mercury_trace_tables.c
--- mercury_trace_tables.c	1999/02/18 23:33:01	1.5
+++ mercury_trace_tables.c	1999/02/22 14:25:02
@@ -397,108 +397,3 @@
 	MR_print_proc_id(fp, entry_layout, NULL, NULL, NULL);
 }
 
-void
-MR_print_proc_id(FILE *fp, const MR_Stack_Layout_Entry *entry,
-	const char *extra, Word *base_sp, Word *base_curfr)
-{
-	if (! MR_ENTRY_LAYOUT_HAS_PROC_ID(entry)) {
-		fatal_error("cannot print procedure id without layout");
-	}
-
-	if (base_sp != NULL && base_curfr != NULL) {
-		bool print_details = FALSE;
-		if (MR_ENTRY_LAYOUT_HAS_EXEC_TRACE(entry)) {
-			Word maybe_from_full = entry->MR_sle_maybe_from_full;
-			if (maybe_from_full > 0) {
-				/*
-				** for procedures compiled with shallow
-				** tracing, the details will be valid only
-				** if the value of MR_from_full saved in
-				** the appropriate stack slot was TRUE.
-			    	*/
-				if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
-					print_details = MR_based_stackvar(
-						base_sp, maybe_from_full);
-				} else {
-					print_details = MR_based_framevar(
-						base_curfr, maybe_from_full);
-				}
-			} else {
-				/*
-				** for procedures compiled with full tracing,
-				** always print out the details
-				*/
-				print_details = TRUE;
-			}
-		}
-		if (print_details) {
-			if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
-				fprintf(fp, "%7lu %7lu %4lu ",
-					(unsigned long)
-					MR_event_num_stackvar(base_sp) + 1,
-					(unsigned long)
-					MR_call_num_stackvar(base_sp),
-					(unsigned long)
-					MR_call_depth_stackvar(base_sp));
-			} else {
-				fprintf(fp, "%7lu %7lu %4lu ",
-					(unsigned long)
-					MR_event_num_framevar(base_curfr) + 1,
-					(unsigned long)
-					MR_call_num_framevar(base_curfr),
-					(unsigned long)
-					MR_call_depth_framevar(base_curfr));
-			}
-		} else {
-			/* ensure that the remaining columns line up */
-			fprintf(fp, "%21s", "");
-		}
-	}
-
-	if (MR_ENTRY_LAYOUT_COMPILER_GENERATED(entry)) {
-		fprintf(fp, "%s for %s:%s/%ld-%ld",
-			entry->MR_sle_comp.MR_comp_pred_name,
-			entry->MR_sle_comp.MR_comp_type_module,
-			entry->MR_sle_comp.MR_comp_type_name,
-			(long) entry->MR_sle_comp.MR_comp_arity,
-			(long) entry->MR_sle_comp.MR_comp_mode);
-
-		if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
-				entry->MR_sle_comp.MR_comp_def_module) != 0)
-		{
-			fprintf(fp, " {%s}",
-				entry->MR_sle_comp.MR_comp_def_module);
-		}
-	} else {
-		if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
-			fprintf(fp, "pred");
-		} else if (entry->MR_sle_user.MR_user_pred_or_func ==
-				MR_FUNCTION)
-		{
-			fprintf(fp, "func");
-		} else {
-			fatal_error("procedure is not pred or func");
-		}
-
-		fprintf(fp, " %s:%s/%ld-%ld",
-			entry->MR_sle_user.MR_user_decl_module,
-			entry->MR_sle_user.MR_user_name,
-			(long) entry->MR_sle_user.MR_user_arity,
-			(long) entry->MR_sle_user.MR_user_mode);
-
-		if (strcmp(entry->MR_sle_user.MR_user_decl_module,
-				entry->MR_sle_user.MR_user_def_module) != 0)
-		{
-			fprintf(fp, " {%s}",
-				entry->MR_sle_user.MR_user_def_module);
-		}
-	}
-
-	fprintf(fp, " (%s)", MR_detism_names[entry->MR_sle_detism]);
-
-	if (extra != NULL) {
-		fprintf(fp, " %s\n", extra);
-	} else {
-		fprintf(fp, "\n");
-	}
-}
Index: trace/mercury_trace_tables.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_tables.h,v
retrieving revision 1.3
diff -u -r1.3 mercury_trace_tables.h
--- mercury_trace_tables.h	1999/02/18 23:33:02	1.3
+++ mercury_trace_tables.h	1999/02/22 14:25:02
@@ -121,20 +121,8 @@
 			void f(void *, const MR_Stack_Layout_Entry *), 
 			void *data);
 
-/*
-** MR_print_proc_id prints an identification of the given procedure,
-** consisting of "pred" or "func", module name, pred or func name, arity,
-** mode number and determinism, followed by an optional extra string,
-** and a newline.
-**
-** If the procedure has trace layout information and the relevant one of
-** base_sp and base_curfr is not NULL, it also prints the call event number,
-** call sequence number and call depth of the call.
-*/
 
 extern	void	MR_print_proc_id_for_debugger(FILE *fp,
 			const MR_Stack_Layout_Entry *entry);
-extern	void	MR_print_proc_id(FILE *fp, const MR_Stack_Layout_Entry *entry,
-			const char *extra, Word *base_sp, Word *base_curfr);
 
 #endif	/* not MERCURY_TRACE_TABLES_H */


-- 
R1.





More information about the developers mailing list