[m-dev.] for review: resolving ambiguity in the mdb "break" c ommand

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Aug 28 14:21:27 AEDT 2000


On 25-Aug-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> `break -A' would certainly be handy.

Ask, and ye shall receive.

This is for review by anyone.

Add options to debugger's "break" command to deal with ambiguities in
procedure specifications without user interaction. These should be especially
useful in .mdbrc files.

trace/mercury_trace_internal.c:
	Implement the new functionality

doc/user_guide.texi:
	Document the new functionality.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.216
diff -u -r1.216 user_guide.texi
--- doc/user_guide.texi	2000/08/25 09:53:24	1.216
+++ doc/user_guide.texi	2000/08/25 13:09:22
@@ -2122,12 +2122,20 @@
 specify the action to be taken at the break point.
 @sp 1
 By default, the initial state of the break point is @samp{stop}.
- at item break [-PSaei] @var{proc-spec}
+ at item break [-AOPSaei] @var{proc-spec}
 @c <module name> <predicate name> [<arity> [<mode> [<predfunc>]]]
 Puts a break point on the specified procedure.
-If the specification matches more than one procedure,
-you will be asked whether you want to put a breakpoint on all of them,
-or just one (and if so, which one).
+ at sp 1
+The options @samp{-A} or @samp{--select-all},
+and @samp{-O} or @samp{--select-one}
+sepect the action to be taken
+if the specification matches more than one procedure.
+If you have specified option @samp{-A} or @samp{--select-all},
+mdb will put a breakpoint on all matched procedures,
+whereas if you have specified option @samp{-O} or @samp{--select-one},
+mdb will report an error.
+By default, mdb will ask you whether you want to put a breakpoint
+on all matched procedures or just one, and if so, which one.
 @sp 1
 The options @samp{-P} or @samp{--print}, and @samp{-S} or @samp{--stop}
 specify the action to be taken at the break point,
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/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/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.77
diff -u -r1.77 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	2000/08/26 17:47:02	1.77
+++ trace/mercury_trace_internal.c	2000/08/28 01:49:02
@@ -140,6 +140,10 @@
 
 #endif	/* MR_USE_DECLARATIVE_DEBUGGER */
 
+typedef enum {
+	MR_MULTIMATCH_ASK, MR_MULTIMATCH_ALL, MR_MULTIMATCH_ONE
+} MR_MultiMatch;
+
 static	void	MR_trace_internal_ensure_init(void);
 static	void	MR_trace_internal_init_from_env(void);
 static	void	MR_trace_internal_init_from_local(void);
@@ -158,8 +162,9 @@
 static	bool	MR_trace_options_strict_print(MR_Trace_Cmd_Info *cmd,
 			char ***words, int *word_count,
 			const char *cat, const char *item);
-static	bool	MR_trace_options_when_action(MR_Spy_When *when,
-			MR_Spy_Action *action, char ***words, int *word_count,
+static	bool	MR_trace_options_when_action_multi(MR_Spy_When *when,
+			MR_Spy_Action *action, MR_MultiMatch *multi_match,
+			char ***words, int *word_count,
 			const char *cat, const char *item);
 static	bool	MR_trace_options_quiet(bool *verbose,
 			char ***words, int *word_count,
@@ -956,6 +961,7 @@
 		MR_Proc_Spec	spec;
 		MR_Spy_When	when;
 		MR_Spy_Action	action;
+		MR_MultiMatch	multi_match;
 		const char	*file;
 		int		line;
 		int		breakline;
@@ -982,8 +988,10 @@
 
 		when = MR_SPY_INTERFACE;
 		action = MR_SPY_STOP;
-		if (! MR_trace_options_when_action(&when, &action,
-				&words, &word_count, "breakpoint", "break"))
+		multi_match = MR_MULTIMATCH_ASK;
+		if (! MR_trace_options_when_action_multi(&when, &action,
+				&multi_match, &words, &word_count,
+				"breakpoint", "break"))
 		{
 			; /* the usage message has already been printed */
 		} else if (word_count == 2 && streq(words[1], "here")) {
@@ -1009,6 +1017,16 @@
 				slot = MR_add_proc_spy_point(when, action,
 					matches.match_procs[0], NULL);
 				MR_print_spy_point(slot);
+			} else if (multi_match == MR_MULTIMATCH_ALL) {
+				int	i;
+
+				for (i = 0; i < matches.match_proc_next; i++) {
+					slot = MR_add_proc_spy_point(
+						when, action,
+						matches.match_procs[i],
+						NULL);
+					MR_print_spy_point(slot);
+				}
 			} else {
 				char	buf[80];
 				int	i;
@@ -1026,6 +1044,10 @@
 						matches.match_procs[i]);
 				}
 
+				if (multi_match == MR_MULTIMATCH_ONE) {
+					return KEEP_INTERACTING;
+				}
+
 				sprintf(buf, "\nWhich do you want to put "
 					"a breakpoint on (0-%d or *)? ",
 					matches.match_proc_next - 1);
@@ -1853,25 +1875,28 @@
 	return TRUE;
 }
 
-static struct MR_option MR_trace_when_action_opts[] =
+static struct MR_option MR_trace_when_action_multi_opts[] =
 {
 	{ "all",	FALSE,	NULL,	'a' },
 	{ "entry",	FALSE,	NULL,	'e' },
 	{ "interface",	FALSE,	NULL,	'i' },
 	{ "print",	FALSE,	NULL,	'P' },
 	{ "stop",	FALSE,	NULL,	'S' },
+	{ "select-all",	FALSE,	NULL,	'A' },
+	{ "select-one",	FALSE,	NULL,	'O' },
 	{ NULL,		FALSE,	NULL,	0 }
 };
 
 static bool
-MR_trace_options_when_action(MR_Spy_When *when, MR_Spy_Action *action,
-	char ***words, int *word_count, const char *cat, const char *item)
+MR_trace_options_when_action_multi(MR_Spy_When *when, MR_Spy_Action *action,
+	MR_MultiMatch *multi_match, char ***words, int *word_count,
+	const char *cat, const char *item)
 {
 	int	c;
 
 	MR_optind = 0;
 	while ((c = MR_getopt_long(*word_count, *words, "PSaei",
-			MR_trace_when_action_opts, NULL)) != EOF)
+			MR_trace_when_action_multi_opts, NULL)) != EOF)
 	{
 		switch (c) {
 
@@ -1885,6 +1910,14 @@
 
 			case 'i':
 				*when = MR_SPY_INTERFACE;
+				break;
+
+			case 'A':
+				*multi_match = MR_MULTIMATCH_ALL;
+				break;
+
+			case 'O':
+				*multi_match = MR_MULTIMATCH_ONE;
 				break;
 
 			case 'P':
cvs diff: Diffing trax
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list