[m-rev.] diff: break up the big function in mercury_trace_internals.c

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Apr 5 22:06:16 AEST 2002


trace/mercury_trace_internal.c:
	Break up the big function into 60 smaller functions, one for each
	debugger command.

	Make sure that all the commands are in the command table, since
	after this change they cannot be invoked if they are not.

doc/mdb_categories:
	Add some missing commands to the category lists.

tests/debugger/completion.exp:
	Update the expected outcome to reflect the presence of more debugger
	commands in the command table.

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/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/mdb_categories
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/mdb_categories,v
retrieving revision 1.11
diff -u -b -r1.11 mdb_categories
--- doc/mdb_categories	31 Oct 2001 17:53:26 -0000	1.11
+++ doc/mdb_categories	5 Apr 2002 10:09:49 -0000
@@ -38,7 +38,7 @@
 document_category 600 parameter
 parameter  - Commands that let users access debugger parameters.
              The parameter commands are `printlevel', `echo', `context',
-             `scroll', `mmc_options', `alias' and `unalias'.
+             `scroll', `mmc_options', `scope', `alias' and `unalias'.
 
 end
 document_category 700 help
@@ -57,7 +57,7 @@
 developer  - Commands that are intended to be of use only to developers
              of the Mercury implementation. The developer commands are
              `nondet_stack', `stack_regs', `all_regs', `table_io',
-	     `proc_stats' and `label_stats'.
+	     `proc_stats', `label_stats' and `print_optionals'.
 
 end
 document_category 1000 misc
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/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/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
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/completion.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/completion.exp,v
retrieving revision 1.5
diff -u -b -r1.5 completion.exp
--- tests/debugger/completion.exp	26 Mar 2002 09:45:54 -0000	1.5
+++ tests/debugger/completion.exp	5 Apr 2002 10:58:39 -0000
@@ -3,23 +3,24 @@
 Command echo enabled.
 mdb> register --quiet
 mdb> 
-?                  down               maxdepth           return
-P                  e                  mindepth           s
-alias              echo               mmc_options        save
-all_regs           enable             modules            scope
-b                  exception          next               scroll
-break              excp               nondet_stack       set
-browse             f                  p                  source
-c                  finish             print              stack
-cc_query           forward            print_optionals    stack_regs
-context            g                  printlevel         step
-continue           goto               proc_stats         table_io
-current            h                  procedures         unalias
-d                  help               query              up
-delete             ignore             quit               v
-disable            io_query           r                  vars
-document           label_stats        register           view
-document_category  level              retry              
+?                  document_category  maxdepth           return
+P                  down               mindepth           s
+alias              e                  mmc_options        save
+all_regs           echo               modules            scope
+b                  enable             next               scroll
+break              exception          nondet_stack       set
+browse             excp               p                  source
+c                  f                  print              stack
+cc_query           finish             print_optionals    stack_regs
+context            forward            printlevel         step
+continue           g                  proc_body          table_io
+current            goto               proc_stats         unalias
+d                  h                  procedures         up
+dd                 help               query              v
+dd_dd              ignore             quit               vars
+delete             io_query           r                  view
+disable            label_stats        register           
+document           level              retry              
 h     help  
 vars  view  
 help vars 
@@ -36,7 +37,7 @@
 stack --detailed 
    0       1       1    1 pred completion:main/2-0 (det) (completion.m:13) (empty)
 mdb> 
-proc_stats  procedures  
+proc_body   proc_stats  procedures  
 completion            completion:sub2       
 completion:sub1       completion:sub2:sub3  
 completion:sub1       completion:sub2       completion:sub2:sub3
@@ -70,8 +71,9 @@
 b completion:sub2:sub3:zabc3 
  3: + stop  interface func completion:sub2:sub3:zabc3/0-0 (det)
 mdb> 
-2d                  2disable            2document_category
-2delete             2document           2down
+2d                  2delete             2document_category
+2dd                 2disable            2down
+2dd_dd              2document           
 2delete 
  2: E stop  interface func completion:sub1:z1/0-0 (det)
 mdb> c
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/structure_reuse
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/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/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.124
diff -u -b -r1.124 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	3 Apr 2002 07:02:33 -0000	1.124
+++ trace/mercury_trace_internal.c	5 Apr 2002 10:18:37 -0000
@@ -216,28 +216,37 @@
 } MR_MultiMatch;
 
 /*
-** A list of the available commands.
+** We keep a table of the available commands. The information we have about
+** each command is stored in a value of type MR_Trace_Command_Info.
+**
+** The name of the command itself is stored in the name field; the category
+** field contains name of the category to which the command belongs,
+** e.g. "browsing".
+**
+** The code that the command loop should execute to handle a command of a given
+** type is the function pointed to by the function field.
+**
+** Some commands take fixed strings as arguments. The arg_strings field
+** is a NULL terminated array of those strings, or NULL if there are
+** no fixed strings.
+**
+** The arg_completer field contains the address of a function for more
+** arbitrary completion, e.g. on predicate names. This field should not be
+** null; if the command cannot use a completion function, the field should
+** contain MR_trace_null_completer.
 */
-typedef struct
-{
-		/* The category of command, e.g. "browsing". */
-	const char		*MR_trace_command_category;
 
-		/* The command name. */
-	const char		*MR_trace_command_name;
-
-		/*
-		** Some commands take fixed strings as arguments.
-		** This field is a NULL terminated array of those strings,
-		** or NULL if there are no fixed strings.
-		*/
-	const char *const	*MR_trace_command_arg_strings;
+typedef MR_Next MR_Trace_Command_Function(char **words, int word_count,
+	MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+	MR_Event_Details *event_details, MR_Code **jumpaddr);
 
-		/*
-		** A function for more arbitrary completion,
-		** e.g. on predicate names.
-		*/
-	const MR_Make_Completer	MR_trace_command_arg_completer;
+typedef struct
+{
+	const char			*MR_cmd_category;
+	const char			*MR_cmd_name;
+	MR_Trace_Command_Function 	*MR_cmd_function;
+	const char *const		*MR_cmd_arg_strings;
+	const MR_Make_Completer		MR_cmd_arg_completer;
 } MR_Trace_Command_Info;
 
 static	void	MR_trace_internal_ensure_init(void);
@@ -251,6 +260,198 @@
 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, MR_Code **jumpaddr);
+
+static MR_Next	MR_trace_cmd_step(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_goto(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_next(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_finish(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_fail(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_exception(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_return(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_forward(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_mindepth(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_maxdepth(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_continue(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_retry(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_level(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_up(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_down(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_vars(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_print(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_browse(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_stack(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_current(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_set(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_view(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_break(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_ignore(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_enable(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_disable(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_delete(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_register(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_modules(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_procedures(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_query(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_cc_query(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_io_query(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_printlevel(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_mmc_options(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_scroll(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_context(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_scope(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_echo(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_alias(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_unalias(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_document_category(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_document(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_help(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+
+#ifdef MR_TRACE_HISTORGRAM
+static MR_Next	MR_trace_cmd_histogram_all(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_histogram_exp(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_clear_histogram(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+#endif	/* MR_TRACE_HISTORGRAM */
+
+#ifdef MR_USE_MINIMAL_MODEL
+static MR_Next	MR_trace_cmd_gen_stack(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+#endif /* MR_USE_MINIMAL_MODEL */
+
+static MR_Next	MR_trace_cmd_nondet_stack(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_stack_regs(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_all_regs(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_table_io(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_proc_stats(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_label_stats(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_proc_body(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_print_optionals(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_save(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_quit(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+
+#ifdef MR_USE_DECLARATIVE_DEBUGGER
+static MR_Next	MR_trace_cmd_dd(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+static MR_Next	MR_trace_cmd_dd_dd(char **words, int word_count,
+			MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+			MR_Event_Details *event_details, MR_Code **jumpaddr);
+#endif /* MR_USE_DECLARATIVE_DEBUGGER */
+
 static	void	MR_maybe_print_spy_point(int slot, const char *problem);
 static	void	MR_print_unsigned_var(FILE *fp, const char *var,
 			MR_Unsigned value);
@@ -972,7 +1173,7 @@
 
 /*
 ** IMPORTANT: if you add any new commands, you will need to
-**	(a) include them in MR_trace_valid_command_list, defined below.
+**	(a) include them in MR_trace_command_infos, defined below.
 **	(b) document them in doc/user_guide.texi
 */
 
@@ -981,11 +1182,7 @@
 	MR_Event_Info *event_info, MR_Event_Details *event_details,
 	MR_Code **jumpaddr)
 {
-	const MR_Label_Layout	*layout;
-	MR_Word 		*saved_regs;
-
-	layout = event_info->MR_event_sll;
-	saved_regs = event_info->MR_saved_regs;
+	const MR_Trace_Command_Info	*cmd_info;
 
 	/*
 	** The code for many commands calls getopt, and getopt may print to
@@ -996,7 +1193,24 @@
 
 	fflush(MR_mdb_out);
 
-	if (MR_streq(words[0], "step")) {
+	cmd_info = MR_trace_valid_command(words[0]);
+	if (cmd_info != NULL) {
+		return (*cmd_info->MR_cmd_function)(words, word_count, cmd,
+			event_info, event_details, jumpaddr);
+	} else {
+		fflush(MR_mdb_out);
+		fprintf(MR_mdb_err, "Unknown command `%s'. "
+			"Give the command `help' for help.\n", words[0]);
+	}
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_step(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;
 
 		cmd->MR_trace_strict = MR_FALSE;
@@ -1018,7 +1232,15 @@
 		} else {
 			MR_trace_usage("forward", "step");
 		}
-	} else if (MR_streq(words[0], "goto")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_goto(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;
 
 		cmd->MR_trace_strict = MR_TRUE;
@@ -1042,7 +1264,15 @@
 		} else {
 			MR_trace_usage("forward", "goto");
 		}
-	} else if (MR_streq(words[0], "next")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_next(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_Unsigned	depth = event_info->MR_call_depth;
 		int		stop_depth;
 		int		n;
@@ -1073,7 +1303,15 @@
 			cmd->MR_trace_stop_depth = stop_depth;
 			return STOP_INTERACTING;
 		}
-	} else if (MR_streq(words[0], "finish")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_finish(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_Unsigned	depth = event_info->MR_call_depth;
 		int		stop_depth;
 		int		n;
@@ -1104,7 +1342,15 @@
 			cmd->MR_trace_stop_depth = stop_depth;
 			return STOP_INTERACTING;
 		}
-	} else if (MR_streq(words[0], "fail")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_fail(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_Determinism	detism = event_info->MR_event_sll->
 					MR_sll_entry->MR_sle_detism;
 		MR_Unsigned	depth = event_info->MR_call_depth;
@@ -1153,7 +1399,15 @@
 			cmd->MR_trace_stop_depth = stop_depth;
 			return STOP_INTERACTING;
 		}
-	} else if (MR_streq(words[0], "exception")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_exception(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		cmd->MR_trace_strict = MR_TRUE;
 		cmd->MR_trace_print_level = MR_default_print_level;
 		if (! MR_trace_options_strict_print(cmd, &words, &word_count,
@@ -1170,7 +1424,15 @@
 		} else {
 			MR_trace_usage("forward", "return");
 		}
-	} else if (MR_streq(words[0], "return")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_return(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		cmd->MR_trace_strict = MR_TRUE;
 		cmd->MR_trace_print_level = MR_default_print_level;
 		if (! MR_trace_options_strict_print(cmd, &words, &word_count,
@@ -1187,7 +1449,15 @@
 		} else {
 			MR_trace_usage("forward", "return");
 		}
-	} else if (MR_streq(words[0], "forward")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_forward(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		cmd->MR_trace_strict = MR_TRUE;
 		cmd->MR_trace_print_level = MR_default_print_level;
 		if (! MR_trace_options_strict_print(cmd, &words, &word_count,
@@ -1208,7 +1478,15 @@
 		} else {
 			MR_trace_usage("forward", "forward");
 		}
-	} else if (MR_streq(words[0], "mindepth")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_mindepth(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		int	newdepth;
 
 		cmd->MR_trace_strict = MR_TRUE;
@@ -1226,7 +1504,15 @@
 		} else {
 			MR_trace_usage("forward", "mindepth");
 		}
-	} else if (MR_streq(words[0], "maxdepth")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_maxdepth(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		int	newdepth;
 
 		cmd->MR_trace_strict = MR_TRUE;
@@ -1244,7 +1530,15 @@
 		} else {
 			MR_trace_usage("forward", "maxdepth");
 		}
-	} else if (MR_streq(words[0], "continue")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_continue(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		cmd->MR_trace_strict = MR_FALSE;
 		cmd->MR_trace_print_level = (MR_Trace_Cmd_Type) -1;
 		if (! MR_trace_options_strict_print(cmd, &words, &word_count,
@@ -1271,7 +1565,15 @@
 		} else {
 			MR_trace_usage("forward", "continue");
 		}
-	} else if (MR_streq(words[0], "retry")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_retry(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;
 		int		ancestor_level;
 		const char	*problem;
@@ -1334,8 +1636,13 @@
 		}
 
 		MR_fatal_error("unrecognized retry result");
+}
 
-	} else if (MR_streq(words[0], "level")) {
+static MR_Next
+MR_trace_cmd_level(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;
 		MR_bool	detailed;
 
@@ -1352,7 +1659,15 @@
 		} else {
 			MR_trace_usage("browsing", "level");
 		}
-	} else if (MR_streq(words[0], "up")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_up(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;
 		MR_bool	detailed;
 
@@ -1374,7 +1689,15 @@
 		} else {
 			MR_trace_usage("browsing", "up");
 		}
-	} else if (MR_streq(words[0], "down")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_down(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;
 		MR_bool	detailed;
 
@@ -1396,7 +1719,15 @@
 		} else {
 			MR_trace_usage("browsing", "down");
 		}
-	} else if (MR_streq(words[0], "vars")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_vars(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			const char	*problem;
 
@@ -1408,7 +1739,15 @@
 		} else {
 			MR_trace_usage("browsing", "vars");
 		}
-	} else if (MR_streq(words[0], "print")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_print(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_Browse_Format	format;
 		int			n;
 
@@ -1468,7 +1807,15 @@
 		} else {
 			MR_trace_usage("browsing", "print");
 		}
-	} else if (MR_streq(words[0], "browse")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_browse(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_Browse_Format	format;
 		int			n;
 
@@ -1525,9 +1872,22 @@
 		} else {
 			MR_trace_usage("browsing", "browse");
 		}
-	} else if (MR_streq(words[0], "stack")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_stack(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	const MR_Label_Layout	*layout;
+	MR_Word 		*saved_regs;
 		MR_bool	detailed;
 
+	layout = event_info->MR_event_sll;
+	saved_regs = event_info->MR_saved_regs;
+
 		detailed = MR_FALSE;
 		if (! MR_trace_options_detailed(&detailed,
 				&words, &word_count, "browsing", "stack"))
@@ -1550,13 +1910,29 @@
 		} else {
 			MR_trace_usage("browsing", "stack");
 		}
-	} else if (MR_streq(words[0], "current")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_current(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			MR_trace_event_print_internal_report(event_info);
 		} else {
 			MR_trace_usage("browsing", "current");
 		}
-	} else if (MR_streq(words[0], "set")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_set(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_Browse_Format	format;
 		MR_Word			print_set;
 		MR_Word			browse_set;
@@ -1582,7 +1958,15 @@
 		{
 			MR_trace_usage("browsing", "set");
 		}
-	} else if (MR_streq(words[0], "view")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_view(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		const char		*window_cmd = NULL;
 		const char		*server_cmd = NULL;
 		const char		*server_name = NULL;
@@ -1614,7 +1998,16 @@
 
 			MR_trace_maybe_sync_source_window(event_info, verbose);
 		}
-	} else if (MR_streq(words[0], "break")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_break(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	const MR_Label_Layout	*layout;
 		MR_Proc_Spec		spec;
 		MR_Spy_When		when;
 		MR_Spy_Action		action;
@@ -1626,6 +2019,8 @@
 		int			breakline;
 		const char		*problem;
 
+	layout = event_info->MR_event_sll;
+
 		if (word_count == 2 && MR_streq(words[1], "info")) {
 			int	i;
 			int	count;
@@ -1808,7 +2203,15 @@
 		} else {
 			MR_trace_usage("breakpoint", "break");
 		}
-	} else if (MR_streq(words[0], "ignore")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_ignore(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;
 		MR_Spy_Ignore_When	ignore_when;
 		int			ignore_count;
@@ -1870,7 +2273,15 @@
 		} else {
 			MR_trace_usage("breakpoint", "ignore");
 		}
-	} else if (MR_streq(words[0], "enable")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_enable(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 == 2 && MR_trace_is_number(words[1], &n)) {
 			if (0 <= n && n < MR_spy_point_next
@@ -1919,7 +2330,15 @@
 		} else {
 			MR_trace_usage("breakpoint", "enable");
 		}
-	} else if (MR_streq(words[0], "disable")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_disable(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 == 2 && MR_trace_is_number(words[1], &n)) {
@@ -1971,7 +2390,15 @@
 		} else {
 			MR_trace_usage("breakpoint", "disable");
 		}
-	} else if (MR_streq(words[0], "delete")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_delete(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 == 2 && MR_trace_is_number(words[1], &n)) {
@@ -2026,7 +2453,15 @@
 		} else {
 			MR_trace_usage("breakpoint", "delete");
 		}
-	} else if (MR_streq(words[0], "register")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_register(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_bool	verbose;
 
 		if (! MR_trace_options_quiet(&verbose, &words, &word_count,
@@ -2038,21 +2473,78 @@
 		} else {
 			MR_trace_usage("breakpoint", "register");
 		}
-	} else if (MR_streq(words[0], "modules")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_modules(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			MR_register_all_modules_and_procs(MR_mdb_out, MR_TRUE);
 			MR_dump_module_list(MR_mdb_out);
 		} else {
 			MR_trace_usage("breakpoint", "modules");
 		}
-	} else if (MR_streq(words[0], "procedures")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_procedures(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			MR_register_all_modules_and_procs(MR_mdb_out, MR_TRUE);
 			MR_dump_module_procs(MR_mdb_out, words[1]);
 		} else {
 			MR_trace_usage("breakpoint", "procedures");
 		}
-	} else if (MR_streq(words[0], "printlevel")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_query(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	MR_trace_query(MR_NORMAL_QUERY, MR_mmc_options,
+		word_count - 1, words + 1);
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_cc_query(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	MR_trace_query(MR_CC_QUERY, MR_mmc_options,
+		word_count - 1, words + 1);
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_io_query(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	MR_trace_query(MR_IO_QUERY, MR_mmc_options,
+		word_count - 1, words + 1);
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_printlevel(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			if (MR_streq(words[1], "none")) {
 				MR_default_print_level = MR_PRINT_LEVEL_NONE;
@@ -2101,16 +2593,15 @@
 		} else {
 			MR_trace_usage("parameter", "printlevel");
 		}
-	} else if (MR_streq(words[0], "query")) {
-		MR_trace_query(MR_NORMAL_QUERY, MR_mmc_options,
-			word_count - 1, words + 1);
-	} else if (MR_streq(words[0], "cc_query")) {
-		MR_trace_query(MR_CC_QUERY, MR_mmc_options,
-			word_count - 1, words + 1);
-	} else if (MR_streq(words[0], "io_query")) {
-		MR_trace_query(MR_IO_QUERY, MR_mmc_options,
-			word_count - 1, words + 1);
-	} else if (MR_streq(words[0], "mmc_options")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_mmc_options(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		size_t len;
 		size_t i;
 
@@ -2130,8 +2621,16 @@
 		}
 		MR_mmc_options[len] = '\0';
 
-	} else if (MR_streq(words[0], "scroll")) {
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_scroll(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 == 2) {
 			if (MR_streq(words[1], "off")) {
 				MR_scroll_control = MR_FALSE;
@@ -2167,7 +2666,15 @@
 		} else {
 			MR_trace_usage("parameter", "scroll");
 		}
-	} else if (MR_streq(words[0], "context")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_context(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			if (MR_streq(words[1], "none")) {
 				MR_context_position = MR_CONTEXT_NOWHERE;
@@ -2207,7 +2714,15 @@
 		} else {
 			MR_trace_usage("parameter", "context");
 		}
-	} else if (MR_streq(words[0], "scope")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_scope(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			if (MR_streq(words[1], "all")) {
 				MR_default_breakpoint_scope = MR_SPY_ALL;
@@ -2242,7 +2757,15 @@
 		} else {
 			MR_trace_usage("parameter", "scope");
 		}
-	} else if (MR_streq(words[0], "echo")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_echo(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			if (MR_streq(words[1], "off")) {
 				MR_echo_commands = MR_FALSE;
@@ -2278,7 +2801,15 @@
 		} else {
 			MR_trace_usage("parameter", "echo");
 		}
-	} else if (MR_streq(words[0], "alias")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_alias(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			MR_trace_print_all_aliases(MR_mdb_out, MR_FALSE);
 		} else if (word_count == 2) {
@@ -2297,7 +2828,15 @@
 					words[2]);
 			}
 		}
-	} else if (MR_streq(words[0], "unalias")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_unalias(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			if (MR_trace_remove_alias(words[1])) {
 				if (MR_trace_internal_interacting) {
@@ -2315,7 +2854,15 @@
 		} else {
 			MR_trace_usage("parameter", "unalias");
 		}
-	} else if (MR_streq(words[0], "document_category")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_document_category(char **words, int word_count,
+	MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+	MR_Event_Details *event_details, MR_Code **jumpaddr)
+{
 		int		slot;
 		const char	*msg;
 		const char	*help_text;
@@ -2334,7 +2881,15 @@
 					"%s.\n", words[2], msg);
 			}
 		}
-	} else if (MR_streq(words[0], "document")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_document(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		int		slot;
 		const char	*msg;
 		const char	*help_text;
@@ -2355,7 +2910,15 @@
 					words[3], words[1], msg);
 			}
 		}
-	} else if (MR_streq(words[0], "help")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_help(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			MR_trace_help();
 		} else if (word_count == 2) {
@@ -2365,22 +2928,17 @@
 		} else {
 			MR_trace_usage("help", "help");
 		}
-	} else if (MR_streq(words[0], "proc_body")) {
-		const MR_Proc_Layout	*entry;
 
-		entry = event_info->MR_event_sll->MR_sll_entry;
-		if (entry->MR_sle_proc_rep == NULL) {
-			fprintf(MR_mdb_out,
-				"current procedure has no body info\n");
-		} else {
-			MR_trace_browse_internal(
-				ML_goal_rep_type(),
-				(MR_Word) entry->MR_sle_proc_rep,
-				MR_BROWSE_CALLER_PRINT,
-				MR_BROWSE_DEFAULT_FORMAT);
-		}
+	return KEEP_INTERACTING;
+}
+
 #ifdef	MR_TRACE_HISTOGRAM
-	} else if (MR_streq(words[0], "histogram_all")) {
+
+static MR_Next
+MR_trace_cmd_histogram_all(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			FILE	*fp;
 
@@ -2406,7 +2964,15 @@
 		} else {
 			MR_trace_usage("exp", "histogram_all");
 		}
-	} else if (MR_streq(words[0], "histogram_exp")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_histogram_exp(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			FILE	*fp;
 
@@ -2432,20 +2998,67 @@
 		} else {
 			MR_trace_usage("exp", "histogram_exp");
 		}
-	} else if (MR_streq(words[0], "clear_histogram")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_clear_histogram(char **words, int word_count,
+	MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+	MR_Event_Details *event_details, MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			int i;
+
 			for (i = 0; i <= MR_trace_histogram_hwm; i++) {
 				MR_trace_histogram_exp[i] = 0;
 			}
 		} else {
 			MR_trace_usage("exp", "clear_histogram");
 		}
+
+	return KEEP_INTERACTING;
+}
+
 #endif	/* MR_TRACE_HISTOGRAM */
-	} else if (MR_streq(words[0], "nondet_stack")) {
+
+#ifdef	MR_USE_MINIMAL_MODEL
+
+static MR_Next
+MR_trace_cmd_gen_stack(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	if (word_count == 1) {
+		MR_bool	saved_tabledebug;
+
+		MR_trace_init_modules();
+		saved_tabledebug = MR_tabledebug;
+		MR_tabledebug = MR_TRUE;
+		MR_print_gen_stack(MR_mdb_out);
+		MR_tabledebug = saved_tabledebug;
+	} else {
+		MR_trace_usage("developer", "gen_stack");
+	}
+
+	return KEEP_INTERACTING;
+}
+
+#endif
+
+static MR_Next
+MR_trace_cmd_nondet_stack(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	const MR_Label_Layout	*layout;
+	MR_Word 		*saved_regs;
 		MR_bool	detailed;
 
+	layout = event_info->MR_event_sll;
+	saved_regs = event_info->MR_saved_regs;
 		detailed = MR_FALSE;
+
 		if (! MR_trace_options_detailed(&detailed,
 			&words, &word_count, "browsing", "nondet_stack"))
 		{
@@ -2470,27 +3083,37 @@
 		} else {
 			MR_trace_usage("developer", "nondet_stack");
 		}
-#ifdef	MR_USE_MINIMAL_MODEL
-	} else if (MR_streq(words[0], "gen_stack")) {
-		if (word_count == 1) {
-			MR_bool	saved_tabledebug;
 
-			MR_trace_init_modules();
-			saved_tabledebug = MR_tabledebug;
-			MR_tabledebug = MR_TRUE;
-			MR_print_gen_stack(MR_mdb_out);
-			MR_tabledebug = saved_tabledebug;
-		} else {
-			MR_trace_usage("developer", "gen_stack");
-		}
-#endif
-	} else if (MR_streq(words[0], "stack_regs")) {
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_stack_regs(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	MR_Word 		*saved_regs;
+
+	saved_regs = event_info->MR_saved_regs;
+
 		if (word_count == 1) {
 			MR_print_stack_regs(MR_mdb_out, saved_regs);
 		} else {
 			MR_trace_usage("developer", "stack_regs");
 		}
-	} else if (MR_streq(words[0], "all_regs")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_all_regs(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	MR_Word 		*saved_regs;
+
+	saved_regs = event_info->MR_saved_regs;
+
 		if (word_count == 1) {
 			MR_print_stack_regs(MR_mdb_out, saved_regs);
 			MR_print_heap_regs(MR_mdb_out, saved_regs);
@@ -2503,7 +3126,15 @@
 		} else {
 			MR_trace_usage("developer", "all_regs");
 		}
-	} else if (MR_streq(words[0], "table_io")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_table_io(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE)
 			{
@@ -2571,7 +3202,15 @@
 		} else {
 			MR_trace_usage("developer", "table_io");
 		}
-	} else if (MR_streq(words[0], "proc_stats")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_proc_stats(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			MR_proc_layout_stats(MR_mdb_out);
 		} else if (word_count == 2) {
@@ -2591,7 +3230,15 @@
 		} else {
 			MR_trace_usage("developer", "proc_stats");
 		}
-	} else if (MR_streq(words[0], "label_stats")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_label_stats(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 1) {
 			MR_label_layout_stats(MR_mdb_out);
 		} else if (word_count == 2) {
@@ -2611,7 +3258,37 @@
 		} else {
 			MR_trace_usage("developer", "label_stats");
 		}
-	} else if (MR_streq(words[0], "print_optionals")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_proc_body(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
+	const MR_Proc_Layout	*entry;
+
+	entry = event_info->MR_event_sll->MR_sll_entry;
+	if (entry->MR_sle_proc_rep == NULL) {
+		fprintf(MR_mdb_out,
+			"current procedure has no body info\n");
+	} else {
+		MR_trace_browse_internal(
+			ML_goal_rep_type(),
+			(MR_Word) entry->MR_sle_proc_rep,
+			MR_BROWSE_CALLER_PRINT,
+			MR_BROWSE_DEFAULT_FORMAT);
+	}
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_print_optionals(char **words, int word_count,
+	MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+	MR_Event_Details *event_details, MR_Code **jumpaddr)
+{
 		if (word_count == 2 && MR_streq(words[1], "off")) {
 			MR_print_optionals = MR_FALSE;
 			MR_trace_set_level(MR_trace_current_level(),
@@ -2627,7 +3304,15 @@
 		fprintf(MR_mdb_out,
 			"optional values are %s being printed\n",
 			MR_print_optionals? "" : "not");
-	} else if (MR_streq(words[0], "source")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_source(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_bool	ignore_errors;
 
 		ignore_errors = MR_FALSE;
@@ -2646,7 +3331,15 @@
 		} else {
 			MR_trace_usage("misc", "source");
 		}
-	} else if (MR_streq(words[0], "save")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_save(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count == 2) {
 			FILE	*fp;
 			MR_bool	found_error;
@@ -2700,7 +3393,15 @@
 		} else {
 			MR_trace_usage("misc", "save");
 		}
-	} else if (MR_streq(words[0], "quit")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_quit(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_bool	confirmed;
 
 		confirmed = MR_FALSE;
@@ -2742,8 +3443,17 @@
 		} else {
 			MR_trace_usage("misc", "quit");
 		}
+
+	return KEEP_INTERACTING;
+}
+
 #ifdef	MR_USE_DECLARATIVE_DEBUGGER
-	} else if (MR_streq(words[0], "dd")) {
+
+static MR_Next
+MR_trace_cmd_dd(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		if (word_count != 1) {
 			fflush(MR_mdb_out);
 			fprintf(MR_mdb_err,
@@ -2757,7 +3467,15 @@
 				return STOP_INTERACTING;
 			}
 		}
-        } else if (MR_streq(words[0], "dd_dd")) {
+
+	return KEEP_INTERACTING;
+}
+
+static MR_Next
+MR_trace_cmd_dd_dd(char **words, int word_count, MR_Trace_Cmd_Info *cmd,
+	MR_Event_Info *event_info, MR_Event_Details *event_details,
+	MR_Code **jumpaddr)
+{
 		MR_Trace_Mode	trace_mode;
 		const char	*filename;
 
@@ -2780,15 +3498,12 @@
 				return STOP_INTERACTING;
 			}
 		}
-#endif  /* MR_USE_DECLARATIVE_DEBUGGER */
-	} else {
-		fflush(MR_mdb_out);
-		fprintf(MR_mdb_err, "Unknown command `%s'. "
-			"Give the command `help' for help.\n", words[0]);
-	}
+
 	return KEEP_INTERACTING;
 }
 
+#endif  /* MR_USE_DECLARATIVE_DEBUGGER */
+
 static void
 MR_maybe_print_spy_point(int slot, const char *problem)
 {
@@ -4196,109 +4911,159 @@
 static const char *const	MR_trace_quit_cmd_args[] =
 		{"-y", NULL};
 
-static const MR_Trace_Command_Info	MR_trace_valid_command_list[] =
+static const MR_Trace_Command_Info	MR_trace_command_infos[] =
 {
 	/*
 	** The first two fields of this block should be the same
 	** as in the file doc/mdb_command_list.
 	*/
 
+	{ "forward", "step", MR_trace_cmd_step,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "goto", MR_trace_cmd_goto,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "next", MR_trace_cmd_next,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "finish", MR_trace_cmd_finish,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "exception", MR_trace_cmd_exception,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "return", MR_trace_cmd_return,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "forward", MR_trace_cmd_forward,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "mindepth", MR_trace_cmd_mindepth,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "maxdepth", MR_trace_cmd_maxdepth,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+	{ "forward", "continue", MR_trace_cmd_continue,
+		MR_trace_movement_cmd_args, MR_trace_null_completer },
+
+	{ "backward", "retry", MR_trace_cmd_retry,
+		NULL, MR_trace_null_completer },
+
+	{ "browsing", "level", MR_trace_cmd_level,
+		MR_trace_stack_cmd_args, MR_trace_null_completer },
+	{ "browsing", "up", MR_trace_cmd_up,
+		MR_trace_stack_cmd_args, MR_trace_null_completer },
+	{ "browsing", "down", MR_trace_cmd_down,
+		MR_trace_stack_cmd_args, MR_trace_null_completer },
+	{ "browsing", "vars", MR_trace_cmd_vars,
+		NULL, MR_trace_null_completer },
+	{ "browsing", "print", MR_trace_cmd_print,
+		MR_trace_print_cmd_args, MR_trace_var_completer },
+	{ "browsing", "browse", MR_trace_cmd_browse,
+		MR_trace_print_cmd_args, MR_trace_var_completer },
+	{ "browsing", "stack", MR_trace_cmd_stack,
+		MR_trace_stack_cmd_args, MR_trace_null_completer },
+	{ "browsing", "current", MR_trace_cmd_current,
+		NULL, MR_trace_null_completer },
+	{ "browsing", "set", MR_trace_cmd_set,
+		MR_trace_set_cmd_args, MR_trace_null_completer },
+	{ "browsing", "view", MR_trace_cmd_view,
+		MR_trace_view_cmd_args, MR_trace_null_completer },
+
+	{ "breakpoint", "break", MR_trace_cmd_break,
+		MR_trace_break_cmd_args, MR_trace_breakpoint_completer },
+	{ "breakpoint", "ignore", MR_trace_cmd_ignore,
+		MR_trace_ignore_cmd_args, MR_trace_null_completer },
+	{ "breakpoint", "enable", MR_trace_cmd_enable,
+		NULL, MR_trace_null_completer },
+	{ "breakpoint", "disable", MR_trace_cmd_disable,
+		NULL, MR_trace_null_completer },
+	{ "breakpoint", "delete", MR_trace_cmd_delete,
+		NULL, MR_trace_null_completer },
+	{ "breakpoint", "register", MR_trace_cmd_register,
+		NULL, MR_trace_null_completer },
+	{ "breakpoint", "modules", MR_trace_cmd_modules,
+		NULL, MR_trace_null_completer },
+	{ "breakpoint", "procedures", MR_trace_cmd_procedures,
+		NULL, MR_trace_module_completer },
+
 	/*
 	** XXX For queries we should complete on all modules, not
 	** just those that were compiled with tracing enabled.
 	*/
-	{ "queries", "query", NULL, MR_trace_module_completer },
-	{ "queries", "cc_query", NULL, MR_trace_module_completer },
-	{ "queries", "io_query", NULL, MR_trace_module_completer },
-	{ "forward", "step", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "goto", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "next", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "finish", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "exception", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "return", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "forward", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "mindepth", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "maxdepth", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "forward", "continue", MR_trace_movement_cmd_args,
-					MR_trace_null_completer },
-	{ "backward", "retry", NULL, MR_trace_null_completer },
-	{ "browsing", "vars", NULL, MR_trace_null_completer },
-	{ "browsing", "print", MR_trace_print_cmd_args,
-					MR_trace_var_completer },
-	{ "browsing", "browse", MR_trace_print_cmd_args,
-					MR_trace_var_completer },
-	{ "browsing", "stack", MR_trace_stack_cmd_args,
-					MR_trace_null_completer },
-	{ "browsing", "up", MR_trace_stack_cmd_args,
-					MR_trace_null_completer },
-	{ "browsing", "down", MR_trace_stack_cmd_args,
-					MR_trace_null_completer },
-	{ "browsing", "level", MR_trace_stack_cmd_args,
-					MR_trace_null_completer },
-	{ "browsing", "current", NULL, MR_trace_null_completer },
-	{ "browsing", "set", MR_trace_set_cmd_args, MR_trace_null_completer },
-	{ "browsing", "view", MR_trace_view_cmd_args,
-					MR_trace_null_completer },
-	{ "breakpoint", "break", MR_trace_break_cmd_args,
-					MR_trace_breakpoint_completer },
-	{ "breakpoint", "ignore", MR_trace_ignore_cmd_args,
-					MR_trace_null_completer },
-	{ "breakpoint", "enable", NULL, MR_trace_null_completer },
-	{ "breakpoint", "disable", NULL, MR_trace_null_completer },
-	{ "breakpoint", "delete", NULL, MR_trace_null_completer },
-	{ "breakpoint", "modules", NULL, MR_trace_null_completer },
-	{ "breakpoint", "procedures", NULL, MR_trace_module_completer },
-	{ "breakpoint", "register", NULL, MR_trace_null_completer },
-	{ "parameter", "mmc_options", NULL, MR_trace_null_completer },
-	{ "parameter", "printlevel", MR_trace_printlevel_cmd_args,
-					MR_trace_null_completer },
-	{ "parameter", "echo", MR_trace_on_off_args, MR_trace_null_completer },
-	{ "parameter", "scroll", MR_trace_on_off_args,
-					MR_trace_null_completer },
-	{ "parameter", "context", MR_trace_context_cmd_args,
-					MR_trace_null_completer },
-	{ "parameter", "scope", MR_trace_scope_cmd_args,
-					MR_trace_null_completer },
-	{ "parameter", "alias", NULL, MR_trace_command_completer },
-	{ "parameter", "unalias", NULL, MR_trace_alias_completer },
-	{ "help", "document_category", NULL, MR_trace_null_completer },
-	{ "help", "document", NULL, MR_trace_null_completer },
-	{ "help", "help", NULL, MR_trace_help_completer },
+	{ "queries", "query", MR_trace_cmd_query,
+		NULL, MR_trace_module_completer },
+	{ "queries", "cc_query", MR_trace_cmd_cc_query,
+		NULL, MR_trace_module_completer },
+	{ "queries", "io_query", MR_trace_cmd_io_query,
+		NULL, MR_trace_module_completer },
+
+	{ "parameter", "printlevel", MR_trace_cmd_printlevel,
+		MR_trace_printlevel_cmd_args, MR_trace_null_completer },
+	{ "parameter", "mmc_options", MR_trace_cmd_mmc_options,
+		NULL, MR_trace_null_completer },
+	{ "parameter", "scroll", MR_trace_cmd_scroll,
+		MR_trace_on_off_args, MR_trace_null_completer },
+	{ "parameter", "context", MR_trace_cmd_context,
+		MR_trace_context_cmd_args, MR_trace_null_completer },
+	{ "parameter", "scope", MR_trace_cmd_scope,
+		MR_trace_scope_cmd_args, MR_trace_null_completer },
+	{ "parameter", "echo", MR_trace_cmd_echo,
+		MR_trace_on_off_args, MR_trace_null_completer },
+	{ "parameter", "alias", MR_trace_cmd_alias,
+		NULL, MR_trace_command_completer },
+	{ "parameter", "unalias", MR_trace_cmd_unalias,
+		NULL, MR_trace_alias_completer },
+
+	{ "help", "document_category", MR_trace_cmd_document_category,
+		NULL, MR_trace_null_completer },
+	{ "help", "document", MR_trace_cmd_document,
+		NULL, MR_trace_null_completer },
+	{ "help", "help", MR_trace_cmd_help,
+		NULL, MR_trace_help_completer },
+
 #ifdef	MR_TRACE_HISTOGRAM
-	{ "exp", "histogram_all", NULL, MR_trace_filename_completer },
-	{ "exp", "histogram_exp", NULL, MR_trace_filename_completer },
-	{ "exp", "clear_histogram", NULL, MR_trace_null_completer },
+	{ "exp", "histogram_all", MR_trace_cmd_histogram_all,
+		NULL, MR_trace_filename_completer },
+	{ "exp", "histogram_exp", MR_trace_cmd_histogram_exp,
+		NULL, MR_trace_filename_completer },
+	{ "exp", "clear_histogram", MR_trace_cmd_clear_histogram,
+		NULL, MR_trace_null_completer },
 #endif
-	{ "developer", "nondet_stack", MR_trace_stack_cmd_args,
-					MR_trace_null_completer },
+
 #ifdef	MR_USE_MINIMAL_MODEL
-	{ "developer", "gen_stack", NULL, MR_trace_null_completer },
+	{ "developer", "gen_stack", MR_trace_cmd_gen_stack,
+		NULL, MR_trace_null_completer },
 #endif
-	{ "developer", "stack_regs", NULL, MR_trace_null_completer },
-	{ "developer", "all_regs", NULL, MR_trace_null_completer },
-	{ "developer", "table_io", MR_trace_table_io_cmd_args,
-					MR_trace_null_completer },
-	{ "developer", "proc_stats", NULL, MR_trace_filename_completer },
-	{ "developer", "label_stats", NULL, MR_trace_filename_completer },
-	{ "developer", "print_optionals", MR_trace_on_off_args,
-					MR_trace_null_completer },
-	{ "misc", "source", MR_trace_source_cmd_args,
-					MR_trace_filename_completer },
-	{ "misc", "save", NULL, MR_trace_filename_completer },
-	{ "misc", "quit", MR_trace_quit_cmd_args, NULL},
+	{ "developer", "nondet_stack", MR_trace_cmd_nondet_stack,
+		MR_trace_stack_cmd_args, MR_trace_null_completer },
+	{ "developer", "stack_regs", MR_trace_cmd_stack_regs,
+		NULL, MR_trace_null_completer },
+	{ "developer", "all_regs", MR_trace_cmd_all_regs,
+		NULL, MR_trace_null_completer },
+	{ "developer", "table_io", MR_trace_cmd_table_io,
+		MR_trace_table_io_cmd_args, MR_trace_null_completer },
+	{ "developer", "proc_stats", MR_trace_cmd_proc_stats,
+		NULL, MR_trace_filename_completer },
+	{ "developer", "label_stats", MR_trace_cmd_label_stats,
+		NULL, MR_trace_filename_completer },
+	{ "developer", "proc_body", MR_trace_cmd_proc_body,
+		NULL, MR_trace_null_completer },
+	{ "developer", "print_optionals", MR_trace_cmd_print_optionals,
+		MR_trace_on_off_args, MR_trace_null_completer },
+
+	{ "misc", "source", MR_trace_cmd_source,
+		MR_trace_source_cmd_args, MR_trace_filename_completer },
+	{ "misc", "save", MR_trace_cmd_save,
+		NULL, MR_trace_filename_completer },
+	{ "misc", "quit", MR_trace_cmd_quit,
+		MR_trace_quit_cmd_args, NULL},
+
+	{ "dd", "dd", MR_trace_cmd_dd,
+		NULL, MR_trace_null_completer},
+	{ "dd", "dd_dd", MR_trace_cmd_dd_dd,
+		NULL, MR_trace_filename_completer},
+
 	/* End of doc/mdb_command_list. */
-	{ NULL, "NUMBER", NULL, MR_trace_null_completer },
-	{ NULL, "EMPTY", NULL, MR_trace_null_completer },
-	{ NULL, NULL, NULL, MR_trace_null_completer },
+	{ NULL, "NUMBER", NULL,
+		NULL, MR_trace_null_completer },
+	{ NULL, "EMPTY", NULL,
+		NULL, MR_trace_null_completer },
+	{ NULL, NULL, NULL,
+		NULL, MR_trace_null_completer },
 };
 
 MR_bool 
@@ -4311,8 +5076,8 @@
 	if (!command_info) {
 		return MR_FALSE;
 	} else {
-		*completer = command_info->MR_trace_command_arg_completer;
-		*fixed_args = command_info->MR_trace_command_arg_strings;
+		*completer = command_info->MR_cmd_arg_completer;
+		*fixed_args = command_info->MR_cmd_arg_strings;
 		return MR_TRUE;
 	}
 }
@@ -4322,15 +5087,9 @@
 {
 	int	i;
 
-	for (i = 0;
-		MR_trace_valid_command_list[i].MR_trace_command_name != NULL;
-		i++)
-	{
-		if (MR_streq(
-			MR_trace_valid_command_list[i].MR_trace_command_name,
-			word))
-		{
-			return &MR_trace_valid_command_list[i];
+	for (i = 0; MR_trace_command_infos[i].MR_cmd_name != NULL; i++) {
+		if (MR_streq(MR_trace_command_infos[i].MR_cmd_name, word)) {
+			return &MR_trace_command_infos[i];
 		}
 	}
 
@@ -4355,10 +5114,10 @@
 		const char *command;
 		const char *category;
 
-		category = MR_trace_valid_command_list[command_index].
-					MR_trace_command_category;
-		command = MR_trace_valid_command_list[command_index].
-					MR_trace_command_name;
+		category = MR_trace_command_infos[command_index].
+					MR_cmd_category;
+		command = MR_trace_command_infos[command_index].
+					MR_cmd_name;
 		command_index++;
 		*data = (void *) command_index;
 
cvs diff: Diffing util
--------------------------------------------------------------------------
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