[m-dev.] for review: new debugger command "all_regs"

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Aug 9 15:17:15 AEST 1999


trace/mercury_trace_internal.c:
	Add a command, "all_regs", that prints the contents of all the Mercury
	abstract machine registers.

doc/user_guide.texi:
tests/debugger/mdb_command_test.inp:
	Document and test the new command.

runtime/mercury_regorder.h:
	Fix an old bug: the macros that define which mrN registers hold
	the pointers to and indexes into the cut and gen stacks disagreed
	with the macros that related the pointers and indexes to slots in
	the array holding saved mrNs. Until I added all_regs, the latter
	macros were not used; if they were, the code would have gotten
	a type error from the C compiler.

Zoltan.

Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.182
diff -u -b -r1.182 user_guide.texi
--- user_guide.texi	1999/08/04 06:19:46	1.182
+++ user_guide.texi	1999/08/06 08:43:16
@@ -1928,6 +1928,9 @@
 @item stack_regs
 Prints the contents of the virtual machine registers
 that point to the det and nondet stacks.
+ at sp 1
+ at item all_regs
+Prints the contents of all the virtual machine registers.
 @end table
 @node Miscellaneous commands
 @subsection Miscellaneous commands
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/dynamic_linking
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/graphics
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/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/mercury_regorder.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_regorder.h,v
retrieving revision 1.11
diff -u -b -r1.11 mercury_regorder.h
--- mercury_regorder.h	1999/04/20 11:48:15	1.11
+++ mercury_regorder.h	1999/08/04 02:39:02
@@ -142,12 +142,12 @@
 #define MR_saved_min_hp_rec(save_area)	LVALUE_CAST(Word *, save_area[39])
 #define MR_saved_min_sol_hp_rec(save_area) LVALUE_CAST(Word *, save_area[40])
 #define MR_saved_global_hp(save_area)	LVALUE_CAST(Word *, save_area[41])
-#define MR_saved_gen_stack(save_area)	LVALUE_CAST(Integer, save_area[42])
-#define MR_saved_gen_next(save_area)	LVALUE_CAST(			      \
+#define MR_saved_gen_next(save_area)	LVALUE_CAST(Integer, save_area[42])
+#define MR_saved_gen_stack(save_area)	LVALUE_CAST(			      \
 					struct MR_GeneratorStackFrameStruct *,\
 					save_area[43])
-#define MR_saved_cut_stack(save_area)	LVALUE_CAST(Integer, save_area[44])
-#define MR_saved_cut_next(save_area)	LVALUE_CAST(			      \
+#define MR_saved_cut_next(save_area)	LVALUE_CAST(Integer, save_area[44])
+#define MR_saved_cut_stack(save_area)	LVALUE_CAST(			      \
 					struct MR_CutStackFrameStruct *,      \
 					save_area[45])
 
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 scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/mdb_command_test.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/mdb_command_test.inp,v
retrieving revision 1.4
diff -u -b -r1.4 mdb_command_test.inp
--- mdb_command_test.inp	1999/03/25 19:08:29	1.4
+++ mdb_command_test.inp	1999/08/07 15:07:50
@@ -34,5 +34,6 @@
 clear_histogram      xyzzy xyzzy xyzzy xyzzy xyzzy
 nondet_stack         xyzzy xyzzy xyzzy xyzzy xyzzy
 stack_regs           xyzzy xyzzy xyzzy xyzzy xyzzy
+all_regs             xyzzy xyzzy xyzzy xyzzy xyzzy
 source               xyzzy xyzzy xyzzy xyzzy xyzzy
 quit                 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/hard_coded
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
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/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.47
diff -u -b -r1.47 mercury_trace_internal.c
--- mercury_trace_internal.c	1999/08/04 02:05:34	1.47
+++ mercury_trace_internal.c	1999/08/04 02:42:25
@@ -141,6 +141,10 @@
 static	MR_Next	MR_trace_handle_cmd(char **words, int word_count,
 			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
 			MR_Event_Details *event_details, Code **jumpaddr);
+static	void	MR_print_stack_regs(Word *saved_regs);
+static	void	MR_print_heap_regs(Word *saved_regs);
+static	void	MR_print_tabling_regs(Word *saved_regs);
+static	void	MR_print_succip_reg(Word *saved_regs);
 static	bool	MR_trace_options_strict_print(MR_Trace_Cmd_Info *cmd,
 			char ***words, int *word_count,
 			const char *cat, const char *item);
@@ -1324,19 +1328,19 @@
 #endif
 	} else if (streq(words[0], "stack_regs")) {
 		if (word_count == 1) {
-			fprintf(MR_mdb_out, "sp = ");
-			MR_print_detstackptr(MR_mdb_out,
-				MR_saved_sp(saved_regs));
-			fprintf(MR_mdb_out, ", curfr = ");
-			MR_print_nondstackptr(MR_mdb_out,
-				MR_saved_curfr(saved_regs));
-			fprintf(MR_mdb_out, ", maxfr = ");
-			MR_print_nondstackptr(MR_mdb_out,
-				MR_saved_maxfr(saved_regs));
-			fprintf(MR_mdb_out, "\n");
+			MR_print_stack_regs(saved_regs);
 		} else {
 			MR_trace_usage("developer", "stack_regs");
 		}
+	} else if (streq(words[0], "all_regs")) {
+		if (word_count == 1) {
+			MR_print_stack_regs(saved_regs);
+			MR_print_heap_regs(saved_regs);
+			MR_print_tabling_regs(saved_regs);
+			MR_print_succip_reg(saved_regs);
+		} else {
+			MR_trace_usage("developer", "all_regs");
+		}
 	} else if (streq(words[0], "source")) {
 		if (word_count == 2) {
 			/*
@@ -1416,6 +1420,57 @@
 	return KEEP_INTERACTING;
 }
 
+static void
+MR_print_stack_regs(Word *saved_regs)
+{
+	fprintf(MR_mdb_out, "sp = ");
+	MR_print_detstackptr(MR_mdb_out,
+		MR_saved_sp(saved_regs));
+	fprintf(MR_mdb_out, "\ncurfr = ");
+	MR_print_nondstackptr(MR_mdb_out,
+		MR_saved_curfr(saved_regs));
+	fprintf(MR_mdb_out, "\nmaxfr = ");
+	MR_print_nondstackptr(MR_mdb_out,
+		MR_saved_maxfr(saved_regs));
+	fprintf(MR_mdb_out, "\n");
+}
+
+static void
+MR_print_heap_regs(Word *saved_regs)
+{
+	fprintf(MR_mdb_out, "hp = ");
+	MR_print_heapptr(MR_mdb_out,
+		MR_saved_hp(saved_regs));
+	fprintf(MR_mdb_out, "\nsol_hp = ");
+	MR_print_heapptr(MR_mdb_out,
+		MR_saved_sol_hp(saved_regs));
+	fprintf(MR_mdb_out, "\nmin_hp_rec = ");
+	MR_print_heapptr(MR_mdb_out,
+		MR_saved_min_hp_rec(saved_regs));
+	fprintf(MR_mdb_out, "\nglobal_hp = ");
+	MR_print_heapptr(MR_mdb_out,
+		MR_saved_global_hp(saved_regs));
+	fprintf(MR_mdb_out, "\n");
+}
+
+static void
+MR_print_tabling_regs(Word *saved_regs)
+{
+	fprintf(MR_mdb_out, "gen_next = %ld\n",
+		(long) MR_saved_gen_next(saved_regs));
+	fprintf(MR_mdb_out, "cut_next = %ld\n",
+		(long) MR_saved_cut_next(saved_regs));
+}
+
+static void
+MR_print_succip_reg(Word *saved_regs)
+{
+	fprintf(MR_mdb_out, "succip = ");
+	MR_print_label(MR_mdb_out,
+		MR_saved_gen_next(saved_regs));
+	fprintf(MR_mdb_out, "\n");
+}
+
 static struct MR_option MR_trace_strict_print_opts[] =
 {
 	{ "all",	FALSE,	NULL,	'a' },
@@ -2224,6 +2279,7 @@
 	{ "developer", "gen_stack" },
 #endif
 	{ "developer", "stack_regs" },
+	{ "developer", "all_regs" },
 	{ "misc", "source" },
 	{ "misc", "quit" },
 	/* End of doc/mdb_command_list. */
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list