[m-rev.] for review: when resuming dd session don't always set search mode
Ian MacLarty
maclarty at cs.mu.OZ.AU
Thu May 5 11:14:40 AEST 2005
On Sat, 30 Apr 2005, Mark Brown wrote:
> On 30-Apr-2005, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
> > For review by anyone.
> >
> > Estimated hours taken: 1
> > Branches: main
> >
> > When resuming a declarative debugging session set the search mode only
> > if it is explicitly given as an option.
>
> You should make it clear in the "Search Modes" section of the User's Guide
> exactly how long a specified search mode lasts. That is, you should
> explicitly point out that when resuming, the search mode will be the same
> as before, but when starting a new session it will go back to the default
> (if that is in fact the intent; if not, you will need to fix the code).
>
That is the intent and I have now documented this. I've also added
doc/user_guide.texi to the CVS log.
> > Index: trace/mercury_trace_internal.c
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
> > retrieving revision 1.202
> > diff -u -r1.202 mercury_trace_internal.c
> > --- trace/mercury_trace_internal.c 29 Apr 2005 01:03:29 -0000 1.202
> > +++ trace/mercury_trace_internal.c 30 Apr 2005 11:43:38 -0000
> > @@ -5658,7 +5658,7 @@
> >
> > MR_trace_decl_assume_all_io_is_tabled = MR_FALSE;
> > MR_edt_depth_step_size = MR_TRACE_DECL_INITIAL_DEPTH;
> > - search_mode = MR_trace_get_default_search_mode();
> > + search_mode = (MR_Word) -1;
> > MR_trace_decl_in_dd_dd_mode = MR_FALSE;
>
> I'm not sure it is okay to use a sentinel value here, given that the trace
> directory doesn't actually determine the representation of MR_Words. To be
> sure, it would be better to pass a boolean argument to MR_trace_options_dd
> which says whether or not a search mode was explicitly given.
>
MR_trace_options_dd now returns a boolean flag, search_mode_was_set, which
I now use instead.
Here's the interdiff:
diff -u trace/mercury_trace_internal.c trace/mercury_trace_internal.c
--- trace/mercury_trace_internal.c 30 Apr 2005 11:43:38 -0000
+++ trace/mercury_trace_internal.c 3 May 2005 06:48:53 -0000
@@ -597,7 +597,8 @@
int *word_count, const char *cat, const char *item);
static MR_bool MR_trace_options_dd(MR_bool *assume_all_io_is_tabled,
MR_Integer *depth_step_size,
- MR_Decl_Search_Mode *search_mode, MR_bool *new_session,
+ MR_Decl_Search_Mode *search_mode,
+ MR_bool *search_mode_was_set, MR_bool *new_session,
char ***words, int *word_count, const char *cat,
const char *item);
static MR_bool MR_trace_options_type_ctor(MR_bool *print_rep,
@@ -5654,16 +5655,17 @@
MR_Code **jumpaddr)
{
MR_Decl_Search_Mode search_mode;
+ MR_bool search_mode_was_set = MR_FALSE;
MR_bool new_session = MR_TRUE;
MR_trace_decl_assume_all_io_is_tabled = MR_FALSE;
MR_edt_depth_step_size = MR_TRACE_DECL_INITIAL_DEPTH;
- search_mode = (MR_Word) -1;
+ search_mode = MR_trace_get_default_search_mode();
MR_trace_decl_in_dd_dd_mode = MR_FALSE;
if (! MR_trace_options_dd(&MR_trace_decl_assume_all_io_is_tabled,
- &MR_edt_depth_step_size, &search_mode, &new_session,
- &words, &word_count, "dd", "dd"))
+ &MR_edt_depth_step_size, &search_mode, &search_mode_was_set,
+ &new_session, &words, &word_count, "dd", "dd"))
{
; /* the usage message has already been printed */
} else if (word_count == 1) {
@@ -5673,11 +5675,10 @@
"mdb: dd doesn't work after `unhide_events on'.\n");
return KEEP_INTERACTING;
}
- if (search_mode != (MR_Word) -1) {
+ if (search_mode_was_set) {
MR_trace_decl_set_fallback_search_mode(search_mode);
} else if (new_session) {
- MR_trace_decl_set_fallback_search_mode(
- MR_trace_get_default_search_mode());
+ MR_trace_decl_set_fallback_search_mode(search_mode);
}
if (MR_trace_start_decl_debug(MR_TRACE_DECL_DEBUG,
NULL, new_session, cmd, event_info, event_details, jumpaddr))
@@ -5699,6 +5700,7 @@
MR_Trace_Mode trace_mode;
const char *filename;
MR_Decl_Search_Mode search_mode;
+ MR_bool search_mode_was_set = MR_FALSE;
MR_bool new_session = MR_TRUE;
MR_trace_decl_assume_all_io_is_tabled = MR_FALSE;
@@ -5707,8 +5709,8 @@
MR_trace_decl_in_dd_dd_mode = MR_TRUE;
if (! MR_trace_options_dd(&MR_trace_decl_assume_all_io_is_tabled,
- &MR_edt_depth_step_size, &search_mode, &new_session,
- &words, &word_count, "dd", "dd_dd"))
+ &MR_edt_depth_step_size, &search_mode, &search_mode_was_set,
+ &new_session, &words, &word_count, "dd", "dd_dd"))
{
; /* the usage message has already been printed */
} else if (word_count <= 2) {
@@ -5719,11 +5721,10 @@
trace_mode = MR_TRACE_DECL_DEBUG;
filename = (const char *) NULL;
}
- if (search_mode != (MR_Word) -1) {
+ if (search_mode_was_set) {
MR_trace_decl_set_fallback_search_mode(search_mode);
} else if (new_session) {
- MR_trace_decl_set_fallback_search_mode(
- MR_trace_get_default_search_mode());
+ MR_trace_decl_set_fallback_search_mode(search_mode);
}
if (MR_trace_start_decl_debug(trace_mode, filename,
new_session, cmd, event_info, event_details, jumpaddr))
@@ -6970,7 +6971,8 @@
static MR_bool
MR_trace_options_dd(MR_bool *assume_all_io_is_tabled,
MR_Integer *depth_step_size, MR_Decl_Search_Mode *search_mode,
- MR_bool *new_session, char ***words, int *word_count, const char *cat,
+ MR_bool *search_mode_was_set, MR_bool *new_session,
+ char ***words, int *word_count, const char *cat,
const char *item)
{
int c;
@@ -6993,9 +6995,11 @@
break;
case 's':
- if (! MR_trace_is_valid_search_mode_string(MR_optarg,
+ if (MR_trace_is_valid_search_mode_string(MR_optarg,
search_mode))
{
+ *search_mode_was_set = MR_TRUE;
+ } else {
MR_trace_usage(cat, item);
return MR_FALSE;
}
only in patch2:
--- doc/user_guide.texi 2 May 2005 04:21:14 -0000 1.433
+++ doc/user_guide.texi 5 May 2005 01:07:48 -0000
@@ -4234,10 +4234,7 @@
Currently the declarative debugger can operate in one of two modes when
searching for a bug. The mode to use can be specified as an option to the
@samp{dd} command. See @ref{Declarative debugging mdb commands} for
-information on how to do this. The specified search mode will always be used
-unless a subterm is marked or the user hasn't answered `no' to any questions
-yet (In which case top-down search is used until `no' is answered to at least
-one question).
+information on how to do this.
@subsubsection Top-down Search
@@ -4260,6 +4257,23 @@
where top-down search would require an unreasonably large number of questions
to be answered. However, the questions may appear to come from unrelated parts
of the program which can make them harder to answer.
+
+ at subsubsection When different search modes are used
+
+If a search mode is given when invoking the declarative debugger then that
+search mode will be used, unless (a) a subterm is marked during the session,
+in which case the subterm is tracked to its origin, or (b) the user
+hasn't answered @samp{no} to any questions yet,
+in which case top-down search is used until @samp{no} is answered to at least
+one question.
+
+If you do not specify a search mode when giving the @samp{dd} command then the
+behaviour depends on wether the @samp{--resume} option is present. If it is
+then the previous search mode will be used, otherwise top-down search will
+be used.
+
+You can check the search mode used to find a particular question by issuing
+an @samp{info} command at the question prompt in the declarative debugger.
@node Improving the search
@subsection Improving the search
--------------------------------------------------------------------------
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