[m-rev.] for review: stack -lN and nondet_stack -lN

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Apr 14 19:49:52 AEST 2003


Add a mechanism to limit the output from the "stack" and "nondet_stack"
mdb commands to a given number of stack frames. (We may later add a
mechanism to limit the output to a given number of lines, but that
is significantly harder, since it requires knowing how wide the
terminal is and which lines exceed that width.)

doc/user_guide.texi:
	Document the new -lN options of the two commands.

trace/mercury_trace_internal.c:
	Implement the new options.

runtime/mercury_stack_trace.[ch]:
	Add limit parameters to the stack trace functions, and obey them.

trace/mercury_trace_external.c:
	Pass the new parameters.

tests/debugger/queens.{inp,exp*}:
	Add tests of stack -lN to the supplied input, and update the expected
	outputs accordingly. Remove the .exp3 file, which cannot have been
	used recently (it still has raw event numbers, not the standardized
	ones the Mmakefile now calls for).

tests/debugger/nondet_stack.{inp,exp*}:
	Add tests of nondet_stack -lN to the supplied input, and update
	the expected outputs accordingly.

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
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.363
diff -u -b -r1.363 user_guide.texi
--- doc/user_guide.texi	13 Apr 2003 05:48:33 -0000	1.363
+++ doc/user_guide.texi	14 Apr 2003 07:35:56 -0000
@@ -2520,7 +2520,7 @@
 The options @samp{-f} or @samp{--flat}, @samp{-p} or @samp{--pretty},
 and @samp{-v} or @samp{--verbose} specify the format to use for browsing.
 @sp 1
- at item stack [-d]
+ at item stack [-d] [-l at var{num}]
 @kindex stack (mdb command)
 Prints the names of the ancestors of the call
 specified by the current event.
@@ -2533,6 +2533,9 @@
 the call's event number, sequence number and depth should also be printed
 if the call is to a procedure that is being execution traced.
 @sp 1
+The option @samp{-l at var{num}}
+specifies that only the topmost @var{num} stack frames should be printed.
+ at sp 1
 This command will report an error if there is no stack trace
 information available about any ancestor.
 @sp 1
@@ -3223,12 +3226,15 @@
 prints the contents of the frames on the possible negated context stack.
 In other grades, it reports an error.
 @sp 1
- at item nondet_stack [-d]
+ at item nondet_stack [-d] [-l at var{num}]
 @kindex nondet_stack (mdb command)
 Prints the contents of the frames on the nondet stack.
 By default, it prints only of the fixed slots in each nondet stack frame,
 but if the option @samp{-d} or @samp{--detailed} option is given,
 it will also print the names and values of the live variables in them.
+ at sp 1
+The option @samp{-l at var{num}}
+specifies that only the topmost @var{num} stack frames should be printed.
 @sp 1
 @item stack_regs
 @kindex stack_regs (mdb command)
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_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/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/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/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.54
diff -u -b -r1.54 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c	2 Apr 2003 23:01:40 -0000	1.54
+++ runtime/mercury_stack_trace.c	14 Apr 2003 07:40:41 -0000
@@ -87,7 +87,7 @@
         layout = label->i_layout;
         result = MR_dump_stack_from_layout(stderr, layout,
             det_stack_pointer, current_frame, include_trace_data,
-            MR_TRUE, &MR_dump_stack_record_print);
+            MR_TRUE, 0, &MR_dump_stack_record_print);
 
         if (result != NULL) {
             fprintf(stderr, "%s\n", result);
@@ -99,7 +99,7 @@
 const char *
 MR_dump_stack_from_layout(FILE *fp, const MR_Label_Layout *label_layout,
     MR_Word *det_stack_pointer, MR_Word *current_frame,
-    MR_bool include_trace_data, MR_bool include_contexts,
+    MR_bool include_trace_data, MR_bool include_contexts, int limit,
     MR_Print_Stack_Record print_stack_record)
 {
     MR_Stack_Walk_Step_Result       result;
@@ -111,6 +111,7 @@
     MR_Word                         *stack_trace_curfr;
     MR_Word                         *old_trace_sp;
     MR_Word                         *old_trace_curfr;
+    int                             frames_dumped_so_far;
 
     MR_do_init_modules();
     MR_dump_stack_record_init(include_trace_data, include_contexts);
@@ -120,7 +121,14 @@
 
     cur_label_layout = label_layout;
 
+    frames_dumped_so_far = 0;
     do {
+        if (limit > 0 && frames_dumped_so_far >= limit) {
+            MR_dump_stack_record_flush(fp, print_stack_record);
+            fprintf(fp, "<more stack frames snipped>\n");
+            return NULL;
+        }
+
         entry_layout = cur_label_layout->MR_sll_entry;
         prev_label_layout = cur_label_layout;
 
@@ -142,6 +150,8 @@
                 MR_dump_stack_record_frame(fp, prev_label_layout,
                     old_trace_sp, old_trace_curfr, print_stack_record);
         }
+
+        frames_dumped_so_far++;
     } while (cur_label_layout != NULL);
 
     MR_dump_stack_record_flush(fp, print_stack_record);
@@ -259,11 +269,11 @@
 /**************************************************************************/
 
 void
-MR_dump_nondet_stack(FILE *fp, MR_Word *base_maxfr)
+MR_dump_nondet_stack(FILE *fp, int limit, MR_Word *base_maxfr)
 {
 #ifndef MR_HIGHLEVEL_CODE
 
-    MR_dump_nondet_stack_from_layout(fp, base_maxfr, NULL, NULL, NULL);
+    MR_dump_nondet_stack_from_layout(fp, limit, base_maxfr, NULL, NULL, NULL);
 
 #else   /* !MR_HIGHLEVEL_CODE */
 
@@ -275,7 +285,7 @@
 #ifdef MR_HIGHLEVEL_CODE
 
 void
-MR_dump_nondet_stack_from_layout(FILE *fp, MR_Word *base_maxfr,
+MR_dump_nondet_stack_from_layout(FILE *fp, int limit, MR_Word *base_maxfr,
     const MR_Label_Layout *top_layout, MR_Word *base_sp, MR_Word *base_curfr)
 {
     MR_fatal_error("MR_dump_nondet_stack_from_layout in high level grade");
@@ -348,13 +358,14 @@
 #define MR_INIT_NONDET_BRANCH_ARRAY_SIZE        10
 
 void
-MR_dump_nondet_stack_from_layout(FILE *fp, MR_Word *base_maxfr,
+MR_dump_nondet_stack_from_layout(FILE *fp, int limit, MR_Word *base_maxfr,
     const MR_Label_Layout *top_layout, MR_Word *base_sp, MR_Word *base_curfr)
 {
     int             frame_size;
     int             level_number;
     MR_bool         print_vars;
     const char      *problem;
+    int             frames_dumped_so_far;
 
     MR_do_init_modules();
 
@@ -382,8 +393,14 @@
     ** frame to be included.
     */
 
+    frames_dumped_so_far = 0;
     level_number = 0;
     while (base_maxfr >= MR_nondet_stack_trace_bottom) {
+        if (limit > 0 && frames_dumped_so_far >= limit) {
+            fprintf(fp, "<more stack frames snipped>\n");
+            return;
+        }
+
         frame_size = base_maxfr - MR_prevfr_slot(base_maxfr);
         if (frame_size == MR_NONDET_TEMP_SIZE) {
             MR_print_nondstackptr(fp, base_maxfr);
@@ -439,6 +456,7 @@
         }
 
         base_maxfr = MR_prevfr_slot(base_maxfr);
+        frames_dumped_so_far++;
     }
 }
 
Index: runtime/mercury_stack_trace.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_stack_trace.h,v
retrieving revision 1.27
diff -u -b -r1.27 mercury_stack_trace.h
--- runtime/mercury_stack_trace.h	18 Feb 2002 07:01:19 -0000	1.27
+++ runtime/mercury_stack_trace.h	1 Apr 2003 08:51:52 -0000
@@ -51,10 +51,11 @@
 **	layout of the current point in the current procedure as input.
 **	It also takes a parameter that tells it where to put the stack dump
 **	and flags that say whether to include execution trace data and/or
-**	line numbers.
+**	line numbers. If limit is nonzero, dumps at most limit frames.
 **
-**	If the entire stack was printed successfully, the return value is NULL;
-**	otherwise, it is a string indicating why the dump was cut short.
+**	If the entire wanted part of the stack was printed successfully,
+**	the return value is NULL; otherwise, it is a string indicating
+**	why the dump was cut short.
 */
 
 typedef	void		(*MR_Print_Stack_Record)(FILE *fp,
@@ -70,25 +71,27 @@
 				MR_Word *det_stack_pointer,
 				MR_Word *current_frame,
 				MR_bool include_trace_data,
-				MR_bool include_contexts,
+				MR_bool include_contexts, int limit,
 				MR_Print_Stack_Record print_stack_record);
 
 /*
 ** MR_dump_nondet_stack:
 **	This function dumps the control slots of the nondet stack.
+**	If limit is nonzero, dumps at most limit frames.
 **	The output format is not meant to be intelligible to non-implementors.
 */
 
-extern	void	MR_dump_nondet_stack(FILE *fp, MR_Word *maxfr);
+extern	void	MR_dump_nondet_stack(FILE *fp, int limit, MR_Word *maxfr);
 
 /*
 ** MR_dump_nondet_stack_from_layout:
 **	This function dumps the nondet stack.
+**	If limit is nonzero, dumps at most limit frames.
 **	The output format is not meant to be intelligible to non-implementors.
 */
 
-extern	void	MR_dump_nondet_stack_from_layout(FILE *fp, MR_Word *maxfr,
-			const MR_Label_Layout *label_layout,
+extern	void	MR_dump_nondet_stack_from_layout(FILE *fp, int limit,
+			MR_Word *maxfr, const MR_Label_Layout *label_layout,
 			MR_Word *base_sp, MR_Word *base_curfr);
 
 /*
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/nondet_stack.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/nondet_stack.exp,v
retrieving revision 1.7
diff -u -b -r1.7 nondet_stack.exp
--- tests/debugger/nondet_stack.exp	18 Mar 2003 16:38:32 -0000	1.7
+++ tests/debugger/nondet_stack.exp	2 Apr 2003 23:16:08 -0000
@@ -6,6 +6,19 @@
 mdb> register --quiet
 mdb> goto 22
       E2:     C2  6 SWTC pred nondet_stack.qperm/2-0 (nondet) s2;
+mdb> nondet_stack -l3
+non 135: ordinary, 13 words
+ redoip: unnamed label
+ redofr: non 135
+ succip: unnamed label
+ succfr: non 103
+non 122: temp
+ redoip: label UNKNOWN
+ redofr: non 116
+non 119: temp
+ redoip: unnamed label
+ redofr: non 116
+<more stack frames snipped>
 mdb> nondet_stack
 non 135: ordinary, 13 words
  redoip: unnamed label
Index: tests/debugger/nondet_stack.exp2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/nondet_stack.exp2,v
retrieving revision 1.8
diff -u -b -r1.8 nondet_stack.exp2
--- tests/debugger/nondet_stack.exp2	18 Mar 2003 16:38:32 -0000	1.8
+++ tests/debugger/nondet_stack.exp2	2 Apr 2003 23:16:38 -0000
@@ -6,6 +6,19 @@
 mdb> register --quiet
 mdb> goto 22
       E2:     C2  6 SWTC pred nondet_stack.qperm/2-0 (nondet) s2;
+mdb> nondet_stack -l3
+non 162: ordinary, 16 words
+ redoip: unnamed label
+ redofr: non 162
+ succip: unnamed label
+ succfr: non 123
+non 146: temp
+ redoip: label UNKNOWN
+ redofr: non 140
+non 143: temp
+ redoip: unnamed label
+ redofr: non 140
+<more stack frames snipped>
 mdb> nondet_stack
 non 162: ordinary, 16 words
  redoip: unnamed label
Index: tests/debugger/nondet_stack.exp3
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/nondet_stack.exp3,v
retrieving revision 1.6
diff -u -b -r1.6 nondet_stack.exp3
--- tests/debugger/nondet_stack.exp3	18 Mar 2003 16:38:32 -0000	1.6
+++ tests/debugger/nondet_stack.exp3	2 Apr 2003 23:17:06 -0000
@@ -6,6 +6,19 @@
 mdb> register --quiet
 mdb> goto 21
       21:     10  6 SWTC pred nondet_stack.qperm/2-0 (nondet) s2;
+mdb> nondet_stack -l3
+non 154: ordinary, 15 words
+ redoip: unnamed label
+ redofr: non 154
+ succip: unnamed label
+ succfr: non 117
+non 139: temp
+ redoip: label UNKNOWN
+ redofr: non 133
+non 136: temp
+ redoip: unnamed label
+ redofr: non 133
+<more stack frames snipped>
 mdb> nondet_stack
 non 154: ordinary, 15 words
  redoip: unnamed label
Index: tests/debugger/nondet_stack.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/nondet_stack.inp,v
retrieving revision 1.2
diff -u -b -r1.2 nondet_stack.inp
--- tests/debugger/nondet_stack.inp	13 Sep 2002 03:37:41 -0000	1.2
+++ tests/debugger/nondet_stack.inp	2 Apr 2003 23:09:13 -0000
@@ -2,6 +2,7 @@
 context none
 register --quiet
 goto 22
+nondet_stack -l3
 nondet_stack
 stack_regs
 nondet_stack -d
Index: tests/debugger/queens.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/queens.exp,v
retrieving revision 1.25
diff -u -b -r1.25 queens.exp
--- tests/debugger/queens.exp	17 Jan 2003 05:56:55 -0000	1.25
+++ tests/debugger/queens.exp	1 Apr 2003 09:08:52 -0000
@@ -143,6 +143,14 @@
    3      E5      C4    3 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
    4      E4      C3    2 pred queens.queen/2-0 (nondet) (queens.m:42) c2;
    5      E1      C1    1 pred queens.main/2-0 (cc_multi) (queens.m:15) ?;c2;q!;
+mdb> stack -l3
+   0    3* pred queens.qperm/2-0 (nondet) (queens.m:45 and others)
+<more stack frames snipped>
+mdb> stack -d -l3
+   0     E20     C10    6 pred queens.qperm/2-0 (nondet) (queens.m:45) (empty)
+   1     E15      C8    5 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
+   2     E10      C6    4 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
+<more stack frames snipped>
 mdb> print *
        HeadVar__1             	[4, 5]
 mdb> 
Index: tests/debugger/queens.exp2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/queens.exp2,v
retrieving revision 1.6
diff -u -b -r1.6 queens.exp2
--- tests/debugger/queens.exp2	30 Jan 2003 05:59:26 -0000	1.6
+++ tests/debugger/queens.exp2	2 Apr 2003 23:18:50 -0000
@@ -143,6 +143,14 @@
    3      E5      C4    3 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
    4      E4      C3    2 pred queens.queen/2-0 (nondet) (queens.m:42) c2;
    5      E1      C1    1 pred queens.main/2-0 (cc_multi) (queens.m:15) ?;c2;q!;
+mdb> stack -l3
+   0    3* pred queens.qperm/2-0 (nondet) (queens.m:45 and others)
+<more stack frames snipped>
+mdb> stack -d -l3
+   0     E20     C10    6 pred queens.qperm/2-0 (nondet) (queens.m:45) (empty)
+   1     E15      C8    5 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
+   2     E10      C6    4 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
+<more stack frames snipped>
 mdb> print *
        HeadVar__1             	[4, 5]
 mdb> 
Index: tests/debugger/queens.exp3
===================================================================
RCS file: tests/debugger/queens.exp3
diff -N tests/debugger/queens.exp3
--- tests/debugger/queens.exp3	17 Jan 2003 05:56:56 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,316 +0,0 @@
-       1:      1  1 CALL pred queens.main/2-0 (cc_multi) queens.m:17
-mdb> echo on
-Command echo enabled.
-mdb> retry 1
-not that many ancestors
-mdb> print *
-       DCG_0 (arg 1)          	state('<<c_pointer>>')
-mdb> 
-       2:      2  2 CALL pred queens.data/1-0 (det) queens.m:39 (queens.m:15)
-mdb> print *
-mdb: there are no live variables.
-mdb> 
-       3:      2  2 EXIT pred queens.data/1-0 (det) queens.m:39 (queens.m:15)
-mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
-mdb> 
-       4:      3  2 CALL pred queens.queen/2-0 (nondet) queens.m:41 (queens.m:15)
-mdb> print *
-       Data (arg 1)           	[1, 2, 3, 4, 5]
-mdb> 
-       5:      4  3 CALL pred queens.qperm/2-0 (nondet) queens.m:45 (queens.m:42)
-mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
-mdb> print_optionals on
-optional values are  being printed
-mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
-       TypeInfo_for_T         	int
-mdb> print_optionals off
-optional values are not being printed
-mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
-mdb> 
-       6:      4  3 SWTC pred queens.qperm/2-0 (nondet) s2; queens.m:46
-mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
-mdb> 
-       7:      5  4 CALL pred queens.qdelete/3-0 (nondet) queens.m:51 (queens.m:47)
-mdb> print *
-       HeadVar__2             	[1, 2, 3, 4, 5]
-mdb> 
-       8:      5  4 DISJ pred queens.qdelete/3-0 (nondet) c2;d1; queens.m:51
-mdb> print *
-       HeadVar__2             	[1, 2, 3, 4, 5]
-mdb> level 1
-Ancestor level set to 1:
-   1  pred queens.qperm/2-0 (nondet) queens.m:47
-mdb> level -d 1
-Ancestor level set to 1:
-   1       5       4    3  pred queens.qperm/2-0 (nondet) queens.m:47
-mdb> context nextline
-Contexts will be printed on the next line.
-mdb> level 1
-Ancestor level set to 1:
-   1  pred queens.qperm/2-0 (nondet)
-      queens.m:47
-mdb> level -d 1
-Ancestor level set to 1:
-   1       5       4    3  pred queens.qperm/2-0 (nondet)
-                           queens.m:47
-mdb> context prevline
-Contexts will be printed on the previous line.
-mdb> level 1
-Ancestor level set to 1:
-   1  queens.m:47
-      pred queens.qperm/2-0 (nondet)
-mdb> level -d 1
-Ancestor level set to 1:
-   1       5       4    3  queens.m:47
-                           pred queens.qperm/2-0 (nondet)
-mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
-       L                      	[1, 2, 3, 4, 5]
-mdb> up 1
-Ancestor level set to 2:
-   2  queens.m:42
-      pred queens.queen/2-0 (nondet)
-mdb> vars
-        1 Data (arg 1)
-mdb> print *
-       Data (arg 1)           	[1, 2, 3, 4, 5]
-mdb> 
-       9:      5  4 EXIT queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-mdb> print HeadVar__1
-       HeadVar__1             	1
-mdb> print HeadVar__2
-       HeadVar__2             	[1, 2, 3, 4, 5]
-mdb> print HeadVar__3
-       HeadVar__3             	[2, 3, 4, 5]
-mdb> 
-      10:      6  4 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> print *
-       HeadVar__1             	[2, 3, 4, 5]
-mdb> 
-      11:      6  4 SWTC queens.m:46
-                         pred queens.qperm/2-0 (nondet) s2;
-mdb> print *
-       HeadVar__1             	[2, 3, 4, 5]
-mdb> 
-      12:      7  5 CALL queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-mdb> print *
-       HeadVar__2             	[2, 3, 4, 5]
-mdb> 
-      13:      7  5 DISJ queens.m:51
-                         pred queens.qdelete/3-0 (nondet) c2;d1;
-mdb> print *
-       HeadVar__2             	[2, 3, 4, 5]
-mdb> 
-      14:      7  5 EXIT queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-mdb> print *
-       HeadVar__1             	2
-       HeadVar__2             	[2, 3, 4, 5]
-       HeadVar__3             	[3, 4, 5]
-mdb> 
-      15:      8  5 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> goto -a 20
-      16:      8  5 SWTC queens.m:46
-                         pred queens.qperm/2-0 (nondet) s2;
-      17:      9  6 CALL queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-      18:      9  6 DISJ queens.m:51
-                         pred queens.qdelete/3-0 (nondet) c2;d1;
-      19:      9  6 EXIT queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-      20:     10  6 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> stack
-   0    4* pred queens.qperm/2-0 (nondet) (queens.m:45 and others)
-   4       pred queens.queen/2-0 (nondet) (queens.m:42)
-   5       pred queens.main/2-0 (cc_multi) (queens.m:15)
-mdb> stack -d
-   0      20      10    6 pred queens.qperm/2-0 (nondet) (queens.m:45) (empty)
-   1      15       8    5 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
-   2      10       6    4 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
-   3       5       4    3 pred queens.qperm/2-0 (nondet) (queens.m:49) s2;c3;
-   4       4       3    2 pred queens.queen/2-0 (nondet) (queens.m:42) c2;
-   5       1       1    1 pred queens.main/2-0 (cc_multi) (queens.m:15) ?;c2;q!;
-mdb> print *
-       HeadVar__1             	[4, 5]
-mdb> 
-      21:     10  6 SWTC queens.m:46
-                         pred queens.qperm/2-0 (nondet) s2;
-mdb> retry
-      20:     10  6 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> print *
-       HeadVar__1             	[4, 5]
-mdb> finish -a
-      21:     10  6 SWTC queens.m:46
-                         pred queens.qperm/2-0 (nondet) s2;
-      22:     11  7 CALL queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-      23:     11  7 DISJ queens.m:51
-                         pred queens.qdelete/3-0 (nondet) c2;d1;
-      24:     11  7 EXIT queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-      25:     12  7 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      26:     12  7 SWTC queens.m:46
-                         pred queens.qperm/2-0 (nondet) s2;
-      27:     13  8 CALL queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-      28:     13  8 DISJ queens.m:51
-                         pred queens.qdelete/3-0 (nondet) c2;d1;
-      29:     13  8 EXIT queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-      30:     14  8 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      31:     14  8 SWTC queens.m:45
-                         pred queens.qperm/2-0 (nondet) s1;
-      32:     14  8 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      33:     12  7 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      34:     10  6 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> register --quiet
-mdb> break print_list
- 0: + stop  interface pred queens.print_list/3-0 (det)
-mdb> break qdelete
- 1: + stop  interface pred queens.qdelete/3-0 (nondet)
-mdb> continue -a
-      35:      8  5 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      36:      6  4 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      37:      4  3 EXIT queens.m:45 (from queens.m:42)
-                         pred queens.qperm/2-0 (nondet)
-      38:     15  3 CALL queens.m:55 (from queens.m:43)
-                         pred queens.safe/1-0 (semidet)
-      39:     15  3 SWTC queens.m:56
-                         pred queens.safe/1-0 (semidet) s2;
-      40:     16  4 CALL queens.m:60 (from queens.m:57)
-                         pred queens.nodiag/3-0 (semidet)
-      41:     16  4 SWTC queens.m:61
-                         pred queens.nodiag/3-0 (semidet) s2;
-      42:     16  4 THEN queens.m:65
-                         pred queens.nodiag/3-0 (semidet) s2;c6;t;
-      43:     16  4 FAIL queens.m:60 (from queens.m:57)
-                         pred queens.nodiag/3-0 (semidet)
-      44:     15  3 FAIL queens.m:55 (from queens.m:43)
-                         pred queens.safe/1-0 (semidet)
-      45:      4  3 REDO queens.m:45 (from queens.m:42)
-                         pred queens.qperm/2-0 (nondet)
-      46:      6  4 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      47:      8  5 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      48:     10  6 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      49:     12  7 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      50:     14  8 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      51:     14  8 FAIL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      52:     13  8 REDO queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-mdb> break info
- 0: + stop  interface pred queens.print_list/3-0 (det)
- 1: + stop  interface pred queens.qdelete/3-0 (nondet)
-mdb> enable *
- 0: + stop  interface pred queens.print_list/3-0 (det)
- 1: + stop  interface pred queens.qdelete/3-0 (nondet)
-mdb> step -aS 5
-      53:     13  8 DISJ queens.m:52
-                         pred queens.qdelete/3-0 (nondet) c2;d2;
-      54:     17  9 CALL queens.m:51 (from queens.m:53)
-                         pred queens.qdelete/3-0 (nondet)
-      55:     17  9 FAIL queens.m:51 (from queens.m:53)
-                         pred queens.qdelete/3-0 (nondet)
-      56:     13  8 FAIL queens.m:51 (from queens.m:47)
-                         pred queens.qdelete/3-0 (nondet)
-      57:     12  7 FAIL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> disable 1
- 1: - stop  interface pred queens.qdelete/3-0 (nondet)
-mdb> retry 4
-       5:      4  3 CALL queens.m:45 (from queens.m:42)
-                         pred queens.qperm/2-0 (nondet)
-mdb> break 49
- 2: + stop  linenumber queens.m:49
-mdb> continue -n
-      10:      6  4 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> continue -n
-      15:      8  5 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> continue -n
-      20:     10  6 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> continue -n
-      25:     12  7 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> continue -n
-      30:     14  8 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> continue -n
-      32:     14  8 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> return
-      33:     12  7 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      34:     10  6 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      35:      8  5 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      36:      6  4 EXIT queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      38:     15  3 CALL queens.m:55 (from queens.m:43)
-                         pred queens.safe/1-0 (semidet)
-mdb> continue -n
-      46:      6  4 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> continue -n
-      47:      8  5 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> forward
-      48:     10  6 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      49:     12  7 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      50:     14  8 REDO queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      51:     14  8 FAIL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-      53:     13  8 DISJ queens.m:52
-                         pred queens.qdelete/3-0 (nondet) c2;d2;
-mdb> continue -n
-      57:     12  7 FAIL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> continue -n
-      64:     19  7 CALL queens.m:45 (from queens.m:49)
-                         pred queens.qperm/2-0 (nondet)
-mdb> delete *
- 0: E stop  interface pred queens.print_list/3-0 (det)
- 1: D stop  interface pred queens.qdelete/3-0 (nondet)
- 2: E stop  linenumber queens.m:49
-mdb> break main
- 0: + stop  interface pred queens.main/2-0 (cc_multi)
-mdb> continue -n
-[1, 3, 5, 2, 4]
-     698:      1  1 EXIT queens.m:17
-                         pred queens.main/2-0 (cc_multi)
-mdb> retry
-Retry across I/O operations without saved I/O action numbers is not safe.
-Are you sure you want to do it? yes
-       1:      1  1 CALL queens.m:17
-                         pred queens.main/2-0 (cc_multi)
-mdb> continue -n -S
-[1, 3, 5, 2, 4]
Index: tests/debugger/queens.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/queens.inp,v
retrieving revision 1.12
diff -u -b -r1.12 queens.inp
--- tests/debugger/queens.inp	13 Sep 2002 03:37:41 -0000	1.12
+++ tests/debugger/queens.inp	1 Apr 2003 08:57:33 -0000
@@ -52,6 +52,8 @@
 goto -a 21
 stack
 stack -d
+stack -l3
+stack -d -l3
 print *
 
 retry
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_external.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.68
diff -u -b -r1.68 mercury_trace_external.c
--- trace/mercury_trace_external.c	2 Apr 2003 23:01:45 -0000	1.68
+++ trace/mercury_trace_external.c	3 Apr 2003 01:34:20 -0000
@@ -644,7 +644,7 @@
 					stdout, layout,
 					MR_saved_sp(saved_regs),
 					MR_saved_curfr(saved_regs),
-					include_trace_data, MR_FALSE,
+					include_trace_data, MR_FALSE, 0,
 					&MR_dump_stack_record_print_to_socket);
 				MR_send_message_to_socket("end_stack");
 				if (message != NULL) {
@@ -671,7 +671,7 @@
 				** MR_dump_nondet_stack() (as we do
 				** with MR_dump_stack_record_print()).
 				*/						
-				MR_dump_nondet_stack(stdout,
+				MR_dump_nondet_stack(stdout, 0,
 					MR_saved_maxfr(saved_regs));
 				MR_send_message_to_socket("ok");
 				break;
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.155
diff -u -b -r1.155 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	2 Apr 2003 10:18:50 -0000	1.155
+++ trace/mercury_trace_internal.c	2 Apr 2003 23:04:35 -0000
@@ -493,6 +493,9 @@
 			int *word_count, const char *cat, const char *item);
 static	MR_bool	MR_trace_options_detailed(MR_bool *detailed, char ***words,
 			int *word_count, const char *cat, const char *item);
+static	MR_bool	MR_trace_options_stack_trace(MR_bool *detailed, int *limit,
+			char ***words, int *word_count,
+			const char *cat, const char *item);
 static	MR_bool	MR_trace_options_confirmed(MR_bool *confirmed, char ***words,
 			int *word_count, const char *cat, const char *item);
 static	MR_bool	MR_trace_options_format(MR_Browse_Format *format,
@@ -1994,12 +1997,14 @@
 	const MR_Label_Layout	*layout;
 	MR_Word 		*saved_regs;
 	MR_bool			detailed;
+	int			limit;
 
 	layout = event_info->MR_event_sll;
 	saved_regs = event_info->MR_saved_regs;
 
 	detailed = MR_FALSE;
-	if (! MR_trace_options_detailed(&detailed,
+	limit = 0;
+	if (! MR_trace_options_stack_trace(&detailed, &limit,
 			&words, &word_count, "browsing", "stack"))
 	{
 		; /* the usage message has already been printed */
@@ -2010,8 +2015,8 @@
 				MR_saved_sp(saved_regs),
 				MR_saved_curfr(saved_regs),
 				detailed,
-				MR_context_position !=
-					MR_CONTEXT_NOWHERE,
+				MR_context_position != MR_CONTEXT_NOWHERE,
+				limit,
 				&MR_dump_stack_record_print);
 		if (msg != NULL) {
 			fflush(MR_mdb_out);
@@ -3379,12 +3384,14 @@
 	const MR_Label_Layout	*layout;
 	MR_Word 		*saved_regs;
 	MR_bool			detailed;
+	int			limit;
 
 	layout = event_info->MR_event_sll;
 	saved_regs = event_info->MR_saved_regs;
-	detailed = MR_FALSE;
 
-	if (! MR_trace_options_detailed(&detailed,
+	detailed = MR_FALSE;
+	limit = 0;
+	if (! MR_trace_options_stack_trace(&detailed, &limit,
 		&words, &word_count, "browsing", "nondet_stack"))
 	{
 		; /* the usage message has already been printed */
@@ -3394,7 +3401,7 @@
 			int	saved_level;
 
 			saved_level = MR_trace_current_level();
-			MR_dump_nondet_stack_from_layout(MR_mdb_out,
+			MR_dump_nondet_stack_from_layout(MR_mdb_out, limit,
 				MR_saved_maxfr(saved_regs),
 				layout,
 				MR_saved_sp(saved_regs),
@@ -3402,7 +3409,7 @@
 			MR_trace_set_level(saved_level,
 				MR_print_optionals);
 		} else {
-			MR_dump_nondet_stack(MR_mdb_out,
+			MR_dump_nondet_stack(MR_mdb_out, limit,
 				MR_saved_maxfr(saved_regs));
 		}
 	} else {
@@ -5007,7 +5014,7 @@
 };
 
 static MR_bool
-MR_trace_options_ignore_count(MR_Spy_Ignore_When*ignore_when,
+MR_trace_options_ignore_count(MR_Spy_Ignore_When *ignore_when,
 	int *ignore_count, char ***words, int *word_count,
 	const char *cat, const char *item)
 {
@@ -5068,6 +5075,41 @@
 
 			case 'd':
 				*detailed = MR_TRUE;
+				break;
+
+			default:
+				MR_trace_usage(cat, item);
+				return MR_FALSE;
+		}
+	}
+
+	*words = *words + MR_optind - 1;
+	*word_count = *word_count - MR_optind + 1;
+	return MR_TRUE;
+}
+
+static MR_bool
+MR_trace_options_stack_trace(MR_bool *detailed, int *limit,
+	char ***words, int *word_count, const char *cat, const char *item)
+{
+	int	c;
+
+	MR_optind = 0;
+	while ((c = MR_getopt_long(*word_count, *words, "dl:",
+			MR_trace_detailed_opts, NULL)) != EOF)
+	{
+		switch (c) {
+
+			case 'd':
+				*detailed = MR_TRUE;
+				break;
+
+			case 'l':
+				if (sscanf(MR_optarg, "%d", limit) != 1)
+				{
+					MR_trace_usage(cat, item);
+					return MR_FALSE;
+				}
 				break;
 
 			default:
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