For review: Stacks dump in the external debugger

Erwan Jahier Erwan.Jahier at irisa.fr
Fri Feb 12 02:56:52 AEDT 1999


Estimated hours taken: 1

This change implement stack dump commands for the external debugger.

browser/debugger_interface.m:
	Add three new kinds of requests: stack, nondet_stack and stack_regs.

trace/mercury_trace_external.c:
	Implement the ancestors, non det and registers stack dump.

__________________________________________________________________________
RCS file: /home/mercury1/repository/mercury/browser/debugger_interface.m,v
retrieving revision 1.5
diff -u -r1.5 debugger_interface.m
--- debugger_interface.m	1999/02/10 22:31:27	1.5
+++ debugger_interface.m	1999/02/11 15:51:36
@@ -118,6 +118,14 @@
 			% restarts execution at the call port of the call 
 			% corresponding to the current event
 	;	retry
+			% print the ancestors stack
+	;	stack
+			% prints the contents of the fixed slots of the 
+			% frames on the nondet stack
+	;	nondet_stack
+			% print the contents of the virtual machine registers 
+			% that point to the det and nondet stacks
+	;	stack_regs
 			% something went wrong when trying to get the
 			% next request
 	;	error(string)
@@ -383,6 +391,9 @@
 classify_request(current_live_var_names, 7).
 classify_request(current_nth_var(_), 8).
 classify_request(retry, 9).
+classify_request(stack, 10).
+classify_request(nondet_stack, 11).
+classify_request(stack_regs, 12).
 
 
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.6
diff -u -r1.6 mercury_trace_external.c
--- mercury_trace_external.c	1999/02/10 22:31:23	1.6
+++ mercury_trace_external.c	1999/02/11 15:51:37
@@ -53,12 +53,16 @@
 	MR_REQUEST_ERROR         = 6, /* something went wrong                 */
 	MR_REQUEST_CURRENT_LIVE_VAR_NAMES  
 				 = 7, /* report data for 
-					 current_live_var_names query */
+					 current_live_var_names query	      */
 	MR_REQUEST_CURRENT_NTH_VAR 
 				 = 8, /* report data for 
-					 current_nth_var query */
-	MR_REQUEST_RETRY	 = 9  /* restart the execution to the call 
+					 current_nth_var query		      */
+	MR_REQUEST_RETRY	 = 9, /* restart the execution to the call 
 					 port of the current event	      */
+	MR_REQUEST_STACK         = 10,/* print the ancestors list             */
+	MR_REQUEST_NONDET_STACK  = 11,/* print the non det stack	      */
+	MR_REQUEST_STACK_REGS    = 12 /* prints the contents of the virtual
+							   machine registers. */
 
 } MR_debugger_request_type;
@@ -343,6 +347,7 @@
 	Word		var;
 	Code		*jumpaddr = NULL;
 	MR_Event_Details	event_details;
+      	bool		include_trace_data;
 	char		*message;
 
 	event_details.MR_call_seqno = MR_trace_call_seqno;
@@ -443,6 +448,53 @@
 					MR_send_message_to_socket_format(
 						"error(\"%s\").\n", message);
 				}
+				break;
+
+			case MR_REQUEST_STACK:
+				if (MR_debug_socket) {
+					fprintf(stderr, "\nMercury runtime: "
+						"REQUEST_STACK\n");
+				}
+				include_trace_data = TRUE;
+				do_init_modules();
+				message = MR_dump_stack_from_layout(stdout,
+					layout->MR_sll_entry,
+					MR_saved_sp(saved_regs),
+					MR_saved_curfr(saved_regs),
+					include_trace_data);
+				if (message != NULL) {
+					MR_send_message_to_socket_format(
+						"error(\"%s\").\n", message);
+				} else {
+					MR_send_message_to_socket("ok");
+				}
+				break;
+
+			case MR_REQUEST_NONDET_STACK:
+				if (MR_debug_socket) {
+					fprintf(stderr, "\nMercury runtime: "
+						"REQUEST_NONDET_STACK\n");
+				}
+				do_init_modules();
+				MR_dump_nondet_stack_from_layout(stdout,
+					MR_saved_maxfr(saved_regs));
+				MR_send_message_to_socket("ok");
+				break;
+
+			case MR_REQUEST_STACK_REGS:
+				if (MR_debug_socket) {
+					fprintf(stderr, "\nMercury runtime: "
+						"REQUEST_STACK_REGS\n");
+				}
+				MR_send_message_to_socket_format(
+					"sp(\"%p\").\n",
+					(char *) MR_saved_sp(saved_regs));
+				MR_send_message_to_socket_format(
+					"curfr(\"%p\").\n",
+					(char *) MR_saved_curfr(saved_regs));
+				MR_send_message_to_socket_format(
+					"maxfr(\"%p\").\n",
+					(char *) MR_saved_maxfr(saved_regs));
 				break;
 
 			case MR_REQUEST_NO_TRACE:

-- 
R1.





More information about the developers mailing list