For review: Add a pred_or_func attribute to the external debugger

Erwan Jahier Erwan.Jahier at irisa.fr
Sat Feb 20 00:26:56 AEDT 1999


Estimated hours taken: 1

Add a pred_or_func attribute to the Mercury event for the external debugger
that indicates if the current procedure is a function or a predicate.


browser/debugger_interface.m:
trace/mercury_trace_external.c:
	Add a slot in MR_found_match() and MR_output_current_slots() for the
	pred_or_func attribute.



------------------------------------------------------------------------------
Index: trace/mercury_trace_external.c
--- fixbug1.4/trace/mercury_trace_external.c Fri, 19 Feb 1999 11:06:08 +0100 jahier (submitdiff/5_mercury_tr 1.14 640)
+++ fixbug1.4(w)/trace/mercury_trace_external.c Fri, 19 Feb 1999 12:58:59 +0100 jahier (submitdiff/5_mercury_tr 1.14 640)
@@ -553,6 +553,8 @@
 MR_output_current_slots(const MR_Stack_Layout_Label *layout,
 	MR_Trace_Port port, Unsigned seqno, Unsigned depth, const char *path)
 {
+	char	*pred_or_func;
+
 	/*
 	** XXX This function and the Mercury predicates it calls
 	** ought to be generalized to handle inter-module inlining,
@@ -561,12 +563,20 @@
 	** compiler-generated procedures.
 	*/
 
+	if (layout->MR_sll_entry->MR_sle_user.MR_user_pred_or_func 
+	    == MR_PREDICATE) {
+		pred_or_func = "pred";
+	} else {
+		pred_or_func = "func";
+	}
+
     MR_TRACE_CALL_MERCURY(
 	ML_DI_output_current_slots(
 		MR_trace_event_number,
 		seqno,
 		depth,
 		port,
+		(String) (Word) pred_or_func,
 		layout->MR_sll_entry->MR_sle_user.MR_user_def_module,
 		layout->MR_sll_entry->MR_sle_user.MR_user_name,
 		layout->MR_sll_entry->MR_sle_user.MR_user_arity,
@@ -632,6 +642,7 @@
 	const char *path, Word search_data)
 {
 	bool result;
+	char	*pred_or_func;
 
 	/*
 	** XXX This function and the Mercury predicates it calls
@@ -644,12 +655,20 @@
 	/* XXX get live vars from registers */
 	Word arguments = /* XXX FIXME!!! */ 0;
 
+	if (layout->MR_sll_entry->MR_sle_user.MR_user_pred_or_func 
+	    == MR_PREDICATE) {
+		pred_or_func = "pred";
+	} else {
+		pred_or_func = "func";
+	}
+
     MR_TRACE_CALL_MERCURY(
 	result = ML_DI_found_match(
 		MR_trace_event_number,
 		seqno,
 		depth,
 		port,
+		pred_or_func,
 		layout->MR_sll_entry->MR_sle_user.MR_user_def_module,
 		layout->MR_sll_entry->MR_sle_user.MR_user_name,
 		layout->MR_sll_entry->MR_sle_user.MR_user_arity,
Index: browser/debugger_interface.m
--- fixbug1.4/browser/debugger_interface.m Thu, 18 Feb 1999 22:16:50 +0100 jahier (submitdiff/6_debugger_i 1.6 640)
+++ fixbug1.4(w)/browser/debugger_interface.m Fri, 19 Feb 1999 13:04:00 +0100 jahier (submitdiff/6_debugger_i 1.6 640)
@@ -80,6 +80,7 @@
 			match(call_number),
 			match(depth_number),
 			match(trace_port_type),
+			match(string),		% "pred" or "func"
 			match(string),		% module name
 			match(string),		% pred name
 			match(arity),
@@ -166,6 +167,7 @@
 			call_number,
 			depth_number,
 			trace_port_type,
+			string,		% "pred" or "func"
 			string,		% module name
 			string,		% pred name
 			arity,
@@ -194,23 +196,23 @@
 %	send to the debugger (e.g. Opium) the attributes of the current event
 %	except the list of arguments.
 
-:- pragma export(output_current_slots(in, in, in, in, in, in, in, in, in,
+:- pragma export(output_current_slots(in, in, in, in, in, in, in, in, in, in,
 		in, in, di, uo), "ML_DI_output_current_slots").
 			
 :- pred output_current_slots(event_number, call_number, depth_number, 
-	trace_port_type, /* module name */ string, /* pred name */ string, 
-	arity, /* mode num */ int, determinism, goal_path_string, 
-	io__output_stream, io__state, io__state).
-:- mode output_current_slots(in, in, in, in, in, in, in, in, in, in, in,
+	trace_port_type, /* pred or func */ string, /* module name */ string,
+	/* pred name */ string, arity, /* mode num */ int, determinism, 
+	goal_path_string, io__output_stream, io__state, io__state).
+:- mode output_current_slots(in, in, in, in, in, in, in, in, in, in, in, in,
  	di, uo) is det.
 
 
-output_current_slots(EventNumber, CallNumber, DepthNumber, Port,
+output_current_slots(EventNumber, CallNumber, DepthNumber, Port, PredOrFunc,
 	ModuleName, PredName, Arity, ModeNum, Determinism,
 	Path, OutputStream) -->
 	
 	{ CurrentTraceInfo = current_slots(EventNumber, CallNumber, 
-		DepthNumber, Port, ModuleName, PredName, Arity,
+		DepthNumber, Port, PredOrFunc, ModuleName, PredName, Arity,
 		ModeNum, Determinism, Path) },
 	io__write(OutputStream, CurrentTraceInfo),
 	io__print(OutputStream, ".\n"),
@@ -289,31 +291,34 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pragma export(found_match(in, in, in, in, in, in, in, in, in, in,
+:- pragma export(found_match(in, in, in, in, in, in, in, in, in, in, in,
 			in, in), "ML_DI_found_match").
 			
 :- pred found_match(event_number, call_number, depth_number, trace_port_type,
-	/* module name */ string, /* pred name */ string, arity,
-	/* mode num */ int, determinism, /* the arguments */ list(univ),
+	/* "pred" or "func" */ string, /* module name */ string, 
+	/* pred name */ string, arity, /* mode num */ int, determinism, 
+	/* the arguments */ list(univ),
 				% XXX we could provide better ways of
 				% matching on arguments
 	goal_path_string, debugger_request).
-:- mode found_match(in, in, in, in, in, in, in, in, in, in, in, in)
+:- mode found_match(in, in, in, in, in, in, in, in, in, in, in, in, in)
 	is semidet.
 
-found_match(EventNumber, CallNumber, DepthNumber, Port, ModuleName, 
+found_match(EventNumber, CallNumber, DepthNumber, Port, PredOrFunc, ModuleName, 
 		PredName, Arity, ModeNum, Determinism, Args, Path, 
 		DebuggerRequest) :-
 	(
 		DebuggerRequest = forward_move(MatchEventNumber,
 			MatchCallNumber, MatchDepthNumber, MatchPort,
-			MatchModuleName, MatchPredName, MatchArity,
-			MatchModeNum, MatchDeterminism, MatchArgs, MatchPath)
+			MatchPredOrFunc, MatchModuleName, MatchPredName, 
+			MatchArity, MatchModeNum, MatchDeterminism, 
+			MatchArgs, MatchPath)
 	->
 		match(MatchEventNumber, EventNumber),
 		match(MatchCallNumber, CallNumber),
 		match(MatchDepthNumber, DepthNumber),
 		match(MatchPort, Port),
+		match(MatchPredOrFunc, PredOrFunc),
 		match(MatchModuleName, ModuleName),
 		match(MatchPredName, PredName),
 		match(MatchArity, Arity),
@@ -382,7 +387,7 @@
 % MR_debugger_request_type in runtime/mercury_trace_external.c.
 
 classify_request(hello_reply, 0).
-classify_request(forward_move(_, _, _, _, _, _, _, _, _, _, _), 1).
+classify_request(forward_move(_, _, _, _, _, _, _, _, _, _, _, _), 1).
 classify_request(current_vars, 2).
 classify_request(current_slots, 3).
 classify_request(no_trace, 4).

-- 
R1.





More information about the developers mailing list