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

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Aug 7 16:13:03 AEST 2000


For review by anyone. My main motivation is mainly that this new command
will make it easier to provide imputs to the debugger test cases, but the
command seems useful independently of that.

Add a new debugger command, next, which steps to the next event from the
current call or its selected ancestor, thus stepping over events in called
procedures. In concept it is therefore like gdb's next command. The
implementation is very similar to the implementation of mdb's finish command,
without the latter's requirement for the stopping event being a final event.

trace/mercury_trace.[ch]:
	Add the MR_CMD_NEXT movement command.

trace/mercury_trace_internal.c:
	Check for the "next" command, and implement it.

doc/user_guide.texi:
	Document the next command.

doc/mdb_categories.texi:
	Update the list of forward movement commands to include "next"
	and (a little late) "exception".

Zoltan.

cvs diff: Diffing .
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/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
Index: doc/mdb_categories
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/mdb_categories,v
retrieving revision 1.6
diff -u -b -r1.6 mdb_categories
--- doc/mdb_categories	1999/12/09 15:40:15	1.6
+++ doc/mdb_categories	2000/08/07 03:46:45
@@ -14,8 +14,8 @@
 end
 document_category 200 forward
 forward    - Commands that move execution forward.
-             The forward commands are `step', `goto', `finish', `forward',
-             `mindepth', `maxdepth' and `continue'.
+             The forward commands are `step', `goto', `next', `finish',
+	      `exception', `forward', `mindepth', `maxdepth' and `continue'.
 
 end
 document_category 300 backward
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.213
diff -u -b -r1.213 user_guide.texi
--- doc/user_guide.texi	2000/07/25 09:27:38	1.213
+++ doc/user_guide.texi	2000/08/07 04:10:01
@@ -1818,6 +1818,22 @@
 @sp 1
 By default, this command is strict, and it uses the default print level.
 @sp 1
+ at item next [-NSans] [@var{num}]
+Continues execution until it reaches the next event of
+the @var{num}'th ancestor of the call to which the current event refers,
+The default value of @var{num} is zero,
+which means skipping to the next event of the current call.
+Reports an error if execution is already at the end of the specified call.
+ at sp 1
+The options @samp{-n} or @samp{--none}, @samp{-s} or @samp{--some},
+ at samp{-a} or @samp{--all} specify the print level to use
+for the duration of the command,
+while the options @samp{-S} or @samp{--strict}
+and @samp{-N} or @samp{--nostrict} specify
+the strictness of the command.
+ at sp 1
+By default, this command is strict, and it uses the default print level.
+ at sp 1
 @item finish [-NSans] [@var{num}]
 Continues execution until it reaches a final (EXIT or FAIL) port of
 the @var{num}'th ancestor of the call to which the current event refers.
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/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
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/moose
cvs diff: Diffing extras/moose/samples
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/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 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
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/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/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.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.24
diff -u -b -r1.24 mercury_trace.c
--- trace/mercury_trace.c	2000/08/03 06:19:23	1.24
+++ trace/mercury_trace.c	2000/08/07 03:44:25
@@ -132,6 +132,26 @@
 #endif	/* MR_TRACE_HISTOGRAM */
 
 	switch (MR_trace_ctrl.MR_trace_cmd) {
+		case MR_CMD_GOTO:
+			if (MR_trace_event_number >=
+					MR_trace_ctrl.MR_trace_stop_event)
+			{
+				port = (MR_Trace_Port) layout->MR_sll_port;
+				return MR_trace_event(&MR_trace_ctrl, TRUE,
+						layout, port, seqno, depth);
+			} else {
+				goto check_stop_print;
+			}
+
+		case MR_CMD_NEXT:
+			if (MR_trace_ctrl.MR_trace_stop_depth != depth) {
+				goto check_stop_print;
+			} else {
+				return MR_trace_event(&MR_trace_ctrl,
+					TRUE, layout, port,
+					seqno, depth);
+			}
+
 		case MR_CMD_FINISH:
 			if (MR_trace_ctrl.MR_trace_stop_depth != depth) {
 				goto check_stop_print;
@@ -145,17 +165,6 @@
 						TRUE, layout, port,
 						seqno, depth);
 				}
-			}
-
-		case MR_CMD_GOTO:
-			if (MR_trace_event_number >=
-					MR_trace_ctrl.MR_trace_stop_event)
-			{
-				port = (MR_Trace_Port) layout->MR_sll_port;
-				return MR_trace_event(&MR_trace_ctrl, TRUE,
-						layout, port, seqno, depth);
-			} else {
-				goto check_stop_print;
 			}
 
 		case MR_CMD_RESUME_FORWARD:
Index: trace/mercury_trace.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.h,v
retrieving revision 1.14
diff -u -b -r1.14 mercury_trace.h
--- trace/mercury_trace.h	2000/08/03 06:19:24	1.14
+++ trace/mercury_trace.h	2000/08/07 03:43:09
@@ -63,9 +63,12 @@
 ** If MR_trace_cmd == MR_CMD_GOTO, the event handler will stop at the next
 ** event whose event number is equal to or greater than MR_trace_stop_event.
 **
+** If MR_trace_cmd == MR_CMD_NEXT, the event handler will stop at the next
+** event at depth MR_trace_stop_depth.
+**
 ** If MR_trace_cmd == MR_CMD_FINISH, the event handler will stop at the next
-** event that specifies the procedure invocation whose call number is in
-** MR_trace_stop_seqno and whose port is EXIT or FAIL or EXCEPTION.
+** event at depth MR_trace_stop_depth and whose port is EXIT or FAIL or
+** EXCEPTION.
 **
 ** If MR_trace_cmd == MR_CMD_RESUME_FORWARD, the event handler will stop at
 ** the next event of any call whose port is *not* REDO or FAIL or EXCEPTION.
@@ -88,6 +91,7 @@
 
 typedef enum {
 	MR_CMD_GOTO,
+	MR_CMD_NEXT,
 	MR_CMD_FINISH,
 	MR_CMD_RESUME_FORWARD,
 	MR_CMD_EXCP,
@@ -105,8 +109,17 @@
 
 typedef struct {
 	MR_Trace_Cmd_Type	MR_trace_cmd;	
-	Unsigned		MR_trace_stop_depth;	/* if MR_CMD_FINISH */
-	Unsigned		MR_trace_stop_event;	/* if MR_CMD_GOTO   */
+				/*
+				** The MR_trace_stop_depth field is meaningful
+				** if MR_trace_cmd is MR_CMD_NEXT or
+				** MR_CMD_FINISH.
+				*/
+	Unsigned		MR_trace_stop_depth;
+				/*
+				** The MR_trace_stop_event field is meaningful
+				** if MR_trace_cmd is MR_CMD_GOTO  
+				*/
+	Unsigned		MR_trace_stop_event;
 	MR_Trace_Print_Level	MR_trace_print_level;
 	bool			MR_trace_strict;
 
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.72
diff -u -b -r1.72 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	2000/08/03 06:19:28	1.72
+++ trace/mercury_trace_internal.c	2000/08/07 04:07:34
@@ -610,6 +610,37 @@
 		} else {
 			MR_trace_usage("forward", "goto");
 		}
+	} else if (streq(words[0], "next")) {
+		Unsigned	depth = event_info->MR_call_depth;
+		int		stop_depth;
+		int		n;
+
+		cmd->MR_trace_strict = TRUE;
+		cmd->MR_trace_print_level = MR_default_print_level;
+		if (! MR_trace_options_strict_print(cmd, &words, &word_count,
+				"forward", "next"))
+		{
+			; /* the usage message has already been printed */
+			return KEEP_INTERACTING;
+		} else if (word_count == 2 && MR_trace_is_number(words[1], &n))
+		{
+			stop_depth = depth - n;
+		} else if (word_count == 1) {
+			stop_depth = depth;
+		} else {
+			MR_trace_usage("forward", "next");
+			return KEEP_INTERACTING;
+		}
+
+		if (depth == stop_depth &&
+			MR_port_is_final(event_info->MR_trace_port))
+		{
+			MR_trace_do_noop();
+		} else {
+			cmd->MR_trace_cmd = MR_CMD_NEXT;
+			cmd->MR_trace_stop_depth = stop_depth;
+			return STOP_INTERACTING;
+		}
 	} else if (streq(words[0], "finish")) {
 		Unsigned	depth = event_info->MR_call_depth;
 		int		stop_depth;
@@ -2449,6 +2480,7 @@
 	{ "queries", "io_query" },
 	{ "forward", "step" },
 	{ "forward", "goto" },
+	{ "forward", "next" },
 	{ "forward", "finish" },
 	{ "forward", "exception" },
 	{ "forward", "return" },
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