[m-rev.] diff: fix a problem for Ian

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Jul 19 13:45:04 AEST 2004


Fix a problem reported by Ian: the debugger ignored information about the head
variables of the predicates generated by the compiler from lambda expressions
because they didn't have names.

compiler/hlds_pred.m:
	Add a predicate to ensure that all headvars have names.

compiler/lambda.m:
	Call that predicate to give names to the predicates created from lambda
	expressions.

compiler/code_gen.m:
	Call that predicate to give names to the predicates created from lambda
	expressions, in case other transformations also create predicates
	with unnamed head variables.

doc/user_guide.texi:
	Add a new mdb command, var_details, and a new method of invocation of
	an existing mdb command, flag. I used them to track down this bug.

trace/mercury_trace_internal.c:
	Implement the var_details mdb command, and the new method of invocation
	of the flag command.

trace/mercury_trace_vars.[ch]:
	Add a function to print variable details.

tests/debugger/mdb_command_test.inp:
	Test the documentation of the new command.

tests/debugger/completion.exp:
	Expect the new command.

tests/debugger/lambda_expr.{m,inp,exp}:
	Add the new test case to test for the bug.

tests/debugger/Mmakefile:
	Enable the new test case.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.129
diff -u -b -r1.129 code_gen.m
--- compiler/code_gen.m	30 Jun 2004 02:47:57 -0000	1.129
+++ compiler/code_gen.m	16 Jul 2004 08:48:25 -0000
@@ -224,12 +224,13 @@
 
 %---------------------------------------------------------------------------%
 
-generate_proc_code(PredInfo, ProcInfo, ProcId, PredId, ModuleInfo0,
+generate_proc_code(PredInfo, ProcInfo0, ProcId, PredId, ModuleInfo0,
 		!GlobalData, Proc) :-
 
-		% The module_info with a modified trace level is discarded
+		% The modified module_info and proc_info are both discarded
 		% on return from generate_proc_code.
 	maybe_set_trace_level(PredInfo, ModuleInfo0, ModuleInfo),
+	ensure_all_headvars_are_named(ProcInfo0, ProcInfo),
 
 	proc_info_interface_determinism(ProcInfo, Detism),
 	proc_info_interface_code_model(ProcInfo, CodeModel),
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.148
diff -u -b -r1.148 hlds_pred.m
--- compiler/hlds_pred.m	16 Jun 2004 03:44:43 -0000	1.148
+++ compiler/hlds_pred.m	16 Jul 2004 08:51:10 -0000
@@ -1988,6 +1988,10 @@
 :- func 'mode_errors :='(proc_info, list(mode_error_info)) = proc_info.
 :- pred proc_info_is_valid_mode(proc_info::in) is semidet.
 
+	% Make sure that all headvars are named. This can be useful e.g.
+	% becasue the debugger ignores unnamed variables.
+:- pred ensure_all_headvars_are_named(proc_info::in, proc_info::out) is det.
+
 :- implementation.
 :- import_module check_hlds__mode_errors.
 
@@ -2616,6 +2620,25 @@
 	;
 		CloneProcId = TrialProcId
 	).
+
+ensure_all_headvars_are_named(!ProcInfo) :-
+	proc_info_headvars(!.ProcInfo, HeadVars),
+	proc_info_varset(!.ProcInfo, VarSet0),
+	ensure_all_headvars_are_named_2(HeadVars, 1, VarSet0, VarSet),
+	proc_info_set_varset(VarSet, !ProcInfo).
+
+:- pred ensure_all_headvars_are_named_2(list(prog_var)::in, int::in,
+	prog_varset::in, prog_varset::out) is det.
+
+ensure_all_headvars_are_named_2([], _, !VarSet).
+ensure_all_headvars_are_named_2([Var | Vars], SeqNum, !VarSet) :-
+	( varset__search_name(!.VarSet, Var, _Name) ->
+		true
+	;
+		Name = "HeadVar__" ++ int_to_string(SeqNum),
+		varset__name_var(!.VarSet, Var, Name, !:VarSet)
+	),
+	ensure_all_headvars_are_named_2(Vars, SeqNum + 1, !VarSet).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/lambda.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.91
diff -u -b -r1.91 lambda.m
--- compiler/lambda.m	16 Jun 2004 03:44:45 -0000	1.91
+++ compiler/lambda.m	16 Jul 2004 09:09:27 -0000
@@ -546,13 +546,19 @@
 			AllArgVars, InstVarSet, AllArgModes, Detism,
 			LambdaGoal, TVarMap, TCVarMap, address_is_taken,
 			ProcInfo0),
+
+		% The debugger ignores unnamed variables.
+		ensure_all_headvars_are_named(ProcInfo0, ProcInfo1),
+
 		% If we previously already needed to recompute the nonlocals,
 		% then we'd better to that recomputation for the procedure
 		% that we just created.
-		( MustRecomputeNonLocals0 = yes ->
-			requantify_proc(ProcInfo0, ProcInfo)
+		(
+			MustRecomputeNonLocals0 = yes,
+			requantify_proc(ProcInfo1, ProcInfo)
 		;
-			ProcInfo = ProcInfo0
+			MustRecomputeNonLocals0 = no,
+			ProcInfo = ProcInfo1
 		),
 
 		set__init(Assertions),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.389
diff -u -b -r1.389 user_guide.texi
--- doc/user_guide.texi	15 Jun 2004 05:35:10 -0000	1.389
+++ doc/user_guide.texi	16 Jul 2004 09:21:35 -0000
@@ -3281,6 +3281,10 @@
 of the Mercury implementation.
 @sp 1
 @table @code
+ at item var_details
+ at kindex var_details (mdb command)
+Prints all the information the debugger has
+about all the variables at the current program point.
 @c @item term_size @var{name}
 @c @itemx term_size @var{num}
 @c @itemx term_size *
@@ -3289,8 +3293,11 @@
 @c bound to the specified variable(s).
 @c In other grades, reports an error.
 @c @sp 1
- at item flag @var{flagname}
+ at item flag
 @kindex flag (mdb command)
+Prints the values of all the runtime lowlevel debugging flags.
+ at sp 1
+ at item flag @var{flagname}
 Prints the value of the specified runtime lowlevel debugging flag.
 @sp 1
 @item flag @var{flagname} on
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
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/mercury_calls_fortran
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
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.104
diff -u -b -r1.104 Mmakefile
--- tests/debugger/Mmakefile	5 Apr 2004 05:11:34 -0000	1.104
+++ tests/debugger/Mmakefile	17 Jul 2004 03:46:29 -0000
@@ -8,6 +8,7 @@
 	all_solutions			\
 	browser_test			\
 	mdb_command_test		\
+	lambda_expr			\
 	queens				\
 	retry				\
 	tabled_read			\
@@ -308,6 +309,9 @@
 implied_instance.out: implied_instance implied_instance.inp
 	$(MDB) ./implied_instance < implied_instance.inp \
 		> implied_instance.out 2>&1
+
+lambda_expr.out: lambda_expr lambda_expr.inp
+	$(MDB_STD) ./lambda_expr < lambda_expr.inp > lambda_expr.out 2>&1
 
 label_layout.out: label_layout label_layout.inp
 	$(MDB) ./label_layout < label_layout.inp > label_layout.out 2>&1
Index: tests/debugger/completion.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/completion.exp,v
retrieving revision 1.18
diff -u -b -r1.18 completion.exp
--- tests/debugger/completion.exp	16 Jun 2004 07:55:41 -0000	1.18
+++ tests/debugger/completion.exp	17 Jul 2004 05:49:32 -0000
@@ -22,13 +22,13 @@
 current            goto               query              unhide_events
 cut_stack          h                  quit               up
 d                  help               r                  v
-dd                 histogram_all      register           var_name_stats
-dd_dd              histogram_exp      retry              vars
-debug_vars         ignore             return             view
-delete             io_query           s                  
+dd                 histogram_all      register           var_details
+dd_dd              histogram_exp      retry              var_name_stats
+debug_vars         ignore             return             vars
+delete             io_query           s                  view
 h              help           histogram_all  histogram_exp  
-var_name_stats  vars            view            
-var_name_stats  vars            
+var_details     var_name_stats  vars            view
+var_details     var_name_stats  vars            
 help vars 
 vars
      Prints the names of all the known variables in the current
Index: tests/debugger/lambda_expr.exp
===================================================================
RCS file: tests/debugger/lambda_expr.exp
diff -N tests/debugger/lambda_expr.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/lambda_expr.exp	17 Jul 2004 03:49:38 -0000
@@ -0,0 +1,28 @@
+      E1:     C1  1 CALL pred lambda_expr.main/2-0 (det) lambda_expr.m:17
+mdb> echo on
+Command echo enabled.
+mdb> context none
+Contexts will not be printed.
+mdb> register --quiet
+mdb> step
+      E2:     C2  2 CALL pred lambda_expr.IntroducedFrom__pred__main__18__1/2-0 (det)
+mdb> print
+IntroducedFrom__pred__main__18__1(1, _)
+mdb> up
+Ancestor level set to 1:
+   1  pred lambda_expr.main/2-0 (det)
+mdb> print P
+       P                      	'IntroducedFrom__pred__main__18__1'
+mdb> finish ; print
+      E3:     C2  2 EXIT pred lambda_expr.IntroducedFrom__pred__main__18__1/2-0 (det)
+IntroducedFrom__pred__main__18__1(1, 2)
+mdb> retry
+      E2:     C2  2 CALL pred lambda_expr.IntroducedFrom__pred__main__18__1/2-0 (det)
+mdb> print
+IntroducedFrom__pred__main__18__1(1, _)
+mdb> finish
+      E3:     C2  2 EXIT pred lambda_expr.IntroducedFrom__pred__main__18__1/2-0 (det)
+mdb> print
+IntroducedFrom__pred__main__18__1(1, 2)
+mdb> continue
+2
Index: tests/debugger/lambda_expr.inp
===================================================================
RCS file: tests/debugger/lambda_expr.inp
diff -N tests/debugger/lambda_expr.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/lambda_expr.inp	16 Jul 2004 04:19:47 -0000
@@ -0,0 +1,13 @@
+echo on
+context none
+register --quiet
+step
+print
+up
+print P
+finish ; print
+retry
+print
+finish
+print
+continue
Index: tests/debugger/lambda_expr.m
===================================================================
RCS file: tests/debugger/lambda_expr.m
diff -N tests/debugger/lambda_expr.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/lambda_expr.m	16 Jul 2004 04:19:53 -0000
@@ -0,0 +1,21 @@
+% This is a regression test. The version of the system on 16 July 2004
+% generated bad RTTI for the lambda expression, which caused the debugger
+% to believe that neither argument of the lambda predicate was instantiated.
+
+:- module lambda_expr.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io :: di, io :: uo) is det.
+
+:- implementation.
+
+:- import_module int.
+
+main(!IO) :-
+         P = (pred(X::in, Y::out) is det :- Y = X + 1),
+         P(1, Z),
+         io__write_int(Z, !IO),
+         io__nl(!IO).
Index: tests/debugger/mdb_command_test.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/mdb_command_test.inp,v
retrieving revision 1.30
diff -u -b -r1.30 mdb_command_test.inp
--- tests/debugger/mdb_command_test.inp	15 Jun 2004 05:35:12 -0000	1.30
+++ tests/debugger/mdb_command_test.inp	17 Jul 2004 06:58:40 -0000
@@ -48,6 +48,7 @@
 histogram_all        xyzzy xyzzy xyzzy xyzzy xyzzy
 histogram_exp        xyzzy xyzzy xyzzy xyzzy xyzzy
 clear_histogram      xyzzy xyzzy xyzzy xyzzy xyzzy
+var_details          xyzzy xyzzy xyzzy xyzzy xyzzy
 flag                 xyzzy xyzzy xyzzy xyzzy xyzzy
 subgoal              xyzzy xyzzy xyzzy xyzzy xyzzy
 consumer             xyzzy xyzzy xyzzy xyzzy xyzzy
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.175
diff -u -b -r1.175 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	15 Jun 2004 05:35:13 -0000	1.175
+++ trace/mercury_trace_internal.c	16 Jul 2004 08:29:26 -0000
@@ -441,6 +441,7 @@
 static	MR_TraceCmdFunc	MR_trace_cmd_histogram_all;
 static	MR_TraceCmdFunc	MR_trace_cmd_histogram_exp;
 static	MR_TraceCmdFunc	MR_trace_cmd_clear_histogram;
+static	MR_TraceCmdFunc	MR_trace_cmd_var_details;
 static	MR_TraceCmdFunc	MR_trace_cmd_term_size;
 static	MR_TraceCmdFunc	MR_trace_cmd_flag;
 static	MR_TraceCmdFunc	MR_trace_cmd_subgoal;
@@ -3338,6 +3339,28 @@
 }
 
 static MR_Next
+MR_trace_cmd_var_details(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	int	n;
+
+	if (word_count == 1) {
+		const char	*problem;
+
+		problem = MR_trace_list_var_details(MR_mdb_out);
+		if (problem != NULL) {
+			fflush(MR_mdb_out);
+			fprintf(MR_mdb_err, "mdb: %s.\n", problem);
+		}
+	} else {
+		MR_trace_usage("developer", "var_details");
+	}
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
 MR_trace_cmd_term_size(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
 	MR_Event_Info *event_info, MR_Event_Details *event_details,
 	MR_Code **jumpaddr)
@@ -3374,9 +3397,33 @@
 	MR_bool		*flagptr;
 	int		i;
 	MR_bool		found;
+	const char	*set_word;
 
-	if (word_count >= 2) {
+	if (word_count == 1) {
+		for (i = 0; i < MR_MAXFLAG; i++) {
+			/*
+			** The true values of the debugging flags are stored
+			** in MR_saved_debug_state inside the call tree
+			** of MR_trace_event.
+			*/
+			flagptr = &MR_saved_debug_state.MR_sds_debugflags[
+				MR_debug_flag_info[i].MR_debug_flag_index];
+			name = MR_debug_flag_info[i].MR_debug_flag_name;
+			if (*flagptr) {
+				fprintf(MR_mdb_out,
+					"Flag %s is set.\n", name);
+			} else {
+				fprintf(MR_mdb_out,
+					"Flag %s is clear.\n", name);
+			}
+		}
+		return KEEP_INTERACTING;
+	} else if (word_count == 2) {
 		name = words[1];
+		set_word = NULL;
+	} else if (word_count == 3) {
+		name = words[1];
+		set_word = words[2];
 	} else {
 		MR_trace_usage("developer", "flag");
 		return KEEP_INTERACTING;
@@ -3402,24 +3449,22 @@
 		return KEEP_INTERACTING;
 	}
 
-	if (word_count == 2) {
-		if (*flagptr) {
-			fprintf(MR_mdb_out, "Flag %s is set.\n", name);
-		} else {
-			fprintf(MR_mdb_out, "Flag %s is clear.\n", name);
-		}
-	} else if (word_count == 3) {
-		if (MR_streq(words[2], "on")) {
+	if (set_word != NULL) {
+		if (MR_streq(set_word, "on")) {
 			*flagptr = MR_TRUE;
 			fprintf(MR_mdb_out, "Flag %s is now set.\n", name);
-		} else if (MR_streq(words[2], "off")) {
+		} else if (MR_streq(set_word, "off")) {
 			*flagptr = MR_FALSE;
 			fprintf(MR_mdb_out, "Flag %s is now clear.\n", name);
 		} else {
 			MR_trace_usage("developer", "flag");
 		}
 	} else {
-		MR_trace_usage("developer", "flag");
+		if (*flagptr) {
+			fprintf(MR_mdb_out, "Flag %s is set.\n", name);
+		} else {
+			fprintf(MR_mdb_out, "Flag %s is clear.\n", name);
+		}
 	}
 
 	return KEEP_INTERACTING;
@@ -7128,6 +7173,8 @@
 	{ "exp", "clear_histogram", MR_trace_cmd_clear_histogram,
 		NULL, MR_trace_null_completer },
 
+	{ "developer", "var_details", MR_trace_cmd_var_details,
+		NULL, MR_trace_null_completer },
 	{ "developer", "term_size", MR_trace_cmd_term_size,
 		NULL, MR_trace_null_completer },
 	{ "developer", "flag", MR_trace_cmd_flag,
Index: trace/mercury_trace_vars.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_vars.c,v
retrieving revision 1.57
diff -u -b -r1.57 mercury_trace_vars.c
--- trace/mercury_trace_vars.c	13 May 2004 08:50:33 -0000	1.57
+++ trace/mercury_trace_vars.c	16 Jul 2004 08:31:12 -0000
@@ -67,6 +67,7 @@
     int             MR_var_is_headvar;
     MR_bool         MR_var_is_ambiguous;
     int             MR_var_hlds_number;
+    int             MR_var_seq_num_in_label;
     MR_TypeInfo     MR_var_type;
     MR_Word         MR_var_value;
 } MR_Var_Details;
@@ -455,6 +456,7 @@
         }
 
         MR_point.MR_point_vars[slot].MR_var_hlds_number = var_num;
+        MR_point.MR_point_vars[slot].MR_var_seq_num_in_label = i;
 
         copy = MR_copy_string(name);
         MR_point.MR_point_vars[slot].MR_var_fullname = copy;
@@ -654,6 +656,34 @@
         fprintf(out, "%9d ", i + 1);
         MR_trace_print_var_name(out, &MR_point.MR_point_vars[i]);
         fprintf(out, "\n");
+    }
+
+    return NULL;
+}
+
+const char *
+MR_trace_list_var_details(FILE *out)
+{
+    MR_Var_Details  *details;
+    int             i;
+
+    if (MR_point.MR_point_problem != NULL) {
+        return MR_point.MR_point_problem;
+    }
+
+    for (i = 0; i < MR_point.MR_point_var_count; i++) {
+        details = &MR_point.MR_point_vars[i];
+        fprintf(out, "\n");
+        fprintf(out, "slot %d, seq %d, hlds %d: headvar: %d, ambiguous: %s\n",
+            i, details->MR_var_seq_num_in_label,
+            details->MR_var_hlds_number, details->MR_var_is_headvar,
+            details->MR_var_is_ambiguous ? "yes" : "no");
+        fprintf(out, "full <%s>, base <%s>, num_suffix %d, has_suffix %s\n",
+            details->MR_var_fullname, details->MR_var_basename,
+            details->MR_var_num_suffix,
+            details->MR_var_has_suffix ? "yes" : "no");
+        fprintf(out, "typeinfo %p, value %x\n",
+            details->MR_var_type, details->MR_var_value);
     }
 
     return NULL;
Index: trace/mercury_trace_vars.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_vars.h,v
retrieving revision 1.25
diff -u -b -r1.25 mercury_trace_vars.h
--- trace/mercury_trace_vars.h	24 May 2004 04:32:53 -0000	1.25
+++ trace/mercury_trace_vars.h	16 Jul 2004 08:30:30 -0000
@@ -117,6 +117,14 @@
 extern	const char	*MR_trace_list_vars(FILE *out);
 
 /*
+** Print all the information this module has on the variables live
+** at the current point on the given file. Intended only for debugging
+** the debugger itself.
+*/
+
+extern	const char 	*MR_trace_list_var_details(FILE *out);
+
+/*
 ** Return as a side effect the type and value of the variable with the
 ** specified HLDS number, in the specified locations, all of which must be
 ** non-NULL. If the variable isn't live or isn't known, return a non-null
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list