[m-rev.] for review: allow search mode to be changed in DD

Ian MacLarty maclarty at cs.mu.OZ.AU
Fri Aug 19 00:41:02 AEST 2005


For review by anyone.

Estimated hours taken: 12
Branches: main

Allow the search mode to be changed from within the declarative debugger.

Make binary search independent of subterm dependency tracking.  The
user can now perform a binary search along the path between the current
question and the root of the search space using the command `mode binary'
(or `m b').

browser/declarative_analyser.m:
	Make reask_last_question fail instead of throwing an exception
	if there is no last question.  If it fails we
	recompute the question.  This happens when the user
	resumes with a new search mode.

	Do not return an analyser response when showing info, since we can
	just call reask_last_question.

	Make set_fallback_search_mode set the last_search_question field to
	no.  This will force the question to be recomputed with the new
	search strategy when analysis continues.

	Add change_search_mode which handles the users request to change the
	current search mode from within a declarative debugging session.

	Do not perform a binary search after tracking a subterm unless
	instructed to do so by the user.

browser/declarative_debugger.m:
	Allow search mode changes to be undone.
	Handle the new change_search oracle response.
	Handle the fact that reask_last_question is now semidet.

browser/declarative_oracle.m:
	Add a change_search oracle response.
	Add a predicate to indicate which oracle responses are undoable.

browser/declarative_user.m:
	Add a change_search user response.

doc/user_guide.texi:
	Rephrase the description of the undo command to take into account that
	search mode changes can be undone.
	Add a section about the binary search mode.
	Rearrange some text and reword some sentences slightly.

tests/debugger/mdb_command_test.inp:
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/binary_search.exp:
tests/debugger/declarative/binary_search.exp2:
tests/debugger/declarative/binary_search.inp:
tests/debugger/declarative/binary_search.inp2:
tests/debugger/declarative/change_search.exp:
tests/debugger/declarative/change_search.inp:
tests/debugger/declarative/change_search.m:
tests/debugger/declarative/info.exp:
tests/debugger/declarative/info.inp:
	Test the `mode' command and do not expect the declarative debugger to
	automatically go into binary search mode once it has tracked a subterm.

Index: browser/declarative_analyser.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_analyser.m,v
retrieving revision 1.28
diff -u -r1.28 declarative_analyser.m
--- browser/declarative_analyser.m	28 Jul 2005 06:44:06 -0000	1.28
+++ browser/declarative_analyser.m	18 Aug 2005 09:00:04 -0000
@@ -21,6 +21,7 @@
 :- import_module mdb.declarative_debugger.
 :- import_module mdb.declarative_edt.
 :- import_module mdb.declarative_oracle.
+:- import_module mdb.declarative_user.

 :- import_module io.
 :- import_module std_util.
@@ -98,26 +99,34 @@
 	% re-asked.
 	%
 :- pred reask_last_question(S::in, analyser_state(T)::in,
-	analyser_response(T)::out) is det <= mercury_edt(S, T).
+	analyser_response(T)::out) is semidet <= mercury_edt(S, T).

 	% Continue analysis after the oracle has responded with an
 	% answer.
-	%
+ 	%
 :- pred continue_analysis(S::in, oracle_state::in, decl_answer(T)::in,
 	analyser_response(T)::out, analyser_state(T)::in,
 	analyser_state(T)::out) is det <= mercury_edt(S, T).

+	% Change the current search mode of the analyser and return the
+	% next question using the new search mode.
+	%
+:- pred change_search_mode(S::in, oracle_state::in, user_search_mode::in,
+	analyser_state(T)::in, analyser_state(T)::out,
+	analyser_response(T)::out) is det <= mercury_edt(S, T).
+
 	% Display information about the current question and the state
 	% of the search to the supplied output stream.
 	%
 :- pred show_info(S::in, io.output_stream::in, analyser_state(T)::in,
-	analyser_response(T)::out, io::di, io::uo) is det <= mercury_edt(S, T).
+	io::di, io::uo) is det <= mercury_edt(S, T).

 	% Revise the current analysis.  This is done when a bug determined
 	% by the analyser has been overruled by the oracle.
 	%
-:- pred revise_analysis(S::in, analyser_response(T)::out, analyser_state(T)::in,
-	analyser_state(T)::out) is det <= mercury_edt(S, T).
+:- pred revise_analysis(S::in, analyser_response(T)::out,
+	analyser_state(T)::in, analyser_state(T)::out) is det
+	<= mercury_edt(S, T).

 	% Return information within the analyser state that is intended for
 	% debugging the declarative debugger itself.
@@ -190,7 +199,6 @@
 				% an excluded part of the search tree.
 			maybe(suspect_id)
 		)
-
 			%
 			% Perform a binary search on a path in the search space
 			% between a suspect and an ancestor of the suspect.
@@ -329,7 +337,8 @@

 set_fallback_search_mode(FallBackSearchMode, !Analyser) :-
 	!:Analyser = !.Analyser ^ fallback_search_mode := FallBackSearchMode,
-	!:Analyser = !.Analyser ^ search_mode := FallBackSearchMode.
+	!:Analyser = !.Analyser ^ search_mode := FallBackSearchMode,
+	!:Analyser = !.Analyser ^ last_search_question := no.

 debug_analyser_state(Analyser, Analyser ^ debug_origin).

@@ -371,22 +380,23 @@
 		)
 	;
 		AnalysisType = resume_previous,
-		decide_analyser_response(Store, Oracle, Response, !Analyser)
+		(
+			reask_last_question(Store, !.Analyser, Response0)
+		->
+			Response = Response0
+		;
+			decide_analyser_response(Store, Oracle, Response,
+				!Analyser)
+		)
 	).

 reask_last_question(Store, Analyser, Response) :-
 	MaybeLastQuestion = Analyser ^ last_search_question,
-	(
-		MaybeLastQuestion = yes(suspect_and_reason(SuspectId, _)),
-		SearchSpace = Analyser ^ search_space,
-		Node = get_edt_node(SearchSpace, SuspectId),
-		edt_question(Store, Node, OracleQuestion),
-		Response = oracle_question(OracleQuestion)
-	;
-		MaybeLastQuestion = no,
-		throw(internal_error("reask_last_question",
-			"no last question"))
-	).
+	MaybeLastQuestion = yes(suspect_and_reason(SuspectId, _)),
+	SearchSpace = Analyser ^ search_space,
+	Node = get_edt_node(SearchSpace, SuspectId),
+	edt_question(Store, Node, OracleQuestion),
+	Response = oracle_question(OracleQuestion).

 continue_analysis(Store, Oracle, Answer, Response, !Analyser) :-
 	(
@@ -398,7 +408,29 @@
 		throw(internal_error("continue_analysis",
 			"received answer to unasked question"))
 	),
-	!:Analyser = !.Analyser ^ last_search_question := no,
+	decide_analyser_response(Store, Oracle, Response, !Analyser).
+
+change_search_mode(Store, Oracle, UserMode, !Analyser, Response) :-
+	(
+		UserMode = top_down,
+		set_fallback_search_mode(top_down, !Analyser)
+	;
+		UserMode = divide_and_query,
+		set_fallback_search_mode(divide_and_query, !Analyser)
+	;
+		UserMode = binary,
+		(
+			!.Analyser ^ last_search_question =
+				yes(suspect_and_reason(SuspectId, _)),
+			setup_binary_search(!.Analyser ^ search_space,
+				SuspectId, SearchMode),
+			!:Analyser = !.Analyser ^ search_mode := SearchMode
+		;
+			!.Analyser ^ last_search_question = no,
+			throw(internal_error("change_search_mode",
+				"binary mode requested, but no last question"))
+		)
+	),
 	decide_analyser_response(Store, Oracle, Response, !Analyser).

 :- pred process_answer(S::in, decl_answer(T)::in, suspect_id::in,
@@ -757,8 +789,7 @@
 			SearchResponse = question(BindingSuspectId,
 				binding_node(PrimOpType, FileName, LineNo,
 					MaybePath, ProcLabel, no)),
-			setup_binary_search(!.SearchSpace, BindingSuspectId,
-				NewMode)
+ 			NewMode = FallBackSearchMode
 		;
 			(
 				LastUnknown = yes(Unknown),
@@ -768,8 +799,7 @@
 					FileName, LineNo, MaybePath, ProcLabel,
 					yes),
 				SearchResponse = question(Unknown, Reason),
-				setup_binary_search(!.SearchSpace,
-					Unknown, NewMode)
+				NewMode = FallBackSearchMode
 			;
 				search(Store, Oracle,
 					!SearchSpace, FallBackSearchMode,
@@ -785,7 +815,7 @@
 		->
 			SearchResponse = question(Unknown,
 				subterm_no_proc_rep),
-			setup_binary_search(!.SearchSpace, Unknown, NewMode)
+			NewMode = FallBackSearchMode
 		;
 			search(Store, Oracle, !SearchSpace,
 				FallBackSearchMode, FallBackSearchMode,
@@ -833,8 +863,7 @@
 			->
 				SearchResponse = question(Unknown,
 					binding_node_eliminated),
-				setup_binary_search(!.SearchSpace,
-					Unknown, NewMode)
+				NewMode = FallBackSearchMode
 			;
 				search(Store, Oracle,
 					!SearchSpace, FallBackSearchMode,
@@ -857,7 +886,7 @@
 		)
 	).

-	% setup_binary_search(SearchSpace, SuspectId, Response, SearchMode).
+	% setup_binary_search(SearchSpace, SuspectId, SearchMode).
 	% Sets up the search mode to do a binary search between SuspectId
 	% and either the root of the search space if a suspect has
 	% previously been marked erroneous, or the topmost node if no suspect
@@ -1250,7 +1279,7 @@
 reason_to_string(revise) = "this node is being revised, because of "
 	++ "an unsuccessful previous bug search.".

-show_info(Store, OutStream, Analyser, Response, !IO) :-
+show_info(Store, OutStream, Analyser, !IO) :-
 	SearchSpace = Analyser ^ search_space,
 	some [!FieldNames, !Data] (
 		!:FieldNames = [],
@@ -1330,10 +1359,7 @@
 	ReasonSent = "The current question was chosen because " ++ ReasonStr,
 	WrappedReason = string.word_wrap(ReasonSent, 72),
  	io.format(OutStream, "%s\n%s\n", [s(InfoMessage), s(WrappedReason)],
-		!IO),
-	Node = get_edt_node(SearchSpace, LastId),
-	edt_question(Store, Node, OracleQuestion),
-	Response = oracle_question(OracleQuestion).
+		!IO).

 :- func search_mode_to_string(search_mode) = string.

Index: browser/declarative_debugger.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_debugger.m,v
retrieving revision 1.62
diff -u -r1.62 declarative_debugger.m
--- browser/declarative_debugger.m	9 Aug 2005 07:13:59 -0000	1.62
+++ browser/declarative_debugger.m	18 Aug 2005 07:46:40 -0000
@@ -453,7 +453,7 @@
 	query_oracle(Question, OracleResponse, FromUser, Oracle0, Oracle, !IO),
 	(
 		FromUser = yes,
-		OracleResponse = oracle_answer(_)
+		oracle_response_undoable(OracleResponse)
 	->
 		push_diagnoser(!Diagnoser)
 	;
@@ -508,7 +508,24 @@
 handle_oracle_response(Store, show_info(OutStream), Response, !Diagnoser, !IO)
 		:-
 	Analyser = !.Diagnoser ^ analyser_state,
-	show_info(wrap(Store), OutStream, Analyser, AnalyserResponse, !IO),
+	show_info(wrap(Store), OutStream, Analyser, !IO),
+	( reask_last_question(wrap(Store), Analyser, AnalyserResponse0) ->
+		AnalyserResponse = AnalyserResponse0
+	;
+		throw(internal_error("handle_oracle_response",
+			"no last question when got show_info request"))
+	),
+	debug_analyser_state(Analyser, MaybeOrigin),
+	handle_analyser_response(Store, AnalyserResponse, MaybeOrigin,
+		Response, !Diagnoser, !IO).
+
+handle_oracle_response(Store, change_search(Mode), Response, !Diagnoser, !IO)
+		:-
+	Analyser0 = !.Diagnoser ^ analyser_state,
+	Oracle = !.Diagnoser ^ oracle_state,
+	change_search_mode(wrap(Store), Oracle, Mode, Analyser0, Analyser,
+		AnalyserResponse),
+	!:Diagnoser = !.Diagnoser ^ analyser_state := Analyser,
 	debug_analyser_state(Analyser, MaybeOrigin),
 	handle_analyser_response(Store, AnalyserResponse, MaybeOrigin,
 		Response, !Diagnoser, !IO).
@@ -523,8 +540,14 @@
 			!.Diagnoser ^ oracle_state),
 		io.write_string(OutStream, "Undo stack empty.\n", !IO)
 	),
-	reask_last_question(wrap(Store), !.Diagnoser ^ analyser_state,
-		AnalyserResponse),
+	( reask_last_question(wrap(Store), !.Diagnoser ^ analyser_state,
+		AnalyserResponse0)
+	->
+		AnalyserResponse = AnalyserResponse0
+	;
+		throw(internal_error("handle_oracle_response",
+			"no last question when got undo request"))
+	),
 	debug_analyser_state(!.Diagnoser ^ analyser_state, MaybeOrigin),
 	handle_analyser_response(Store, AnalyserResponse, MaybeOrigin,
 		Response, !Diagnoser, !IO).
Index: browser/declarative_oracle.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_oracle.m,v
retrieving revision 1.45
diff -u -r1.45 declarative_oracle.m
--- browser/declarative_oracle.m	9 Aug 2005 07:13:59 -0000	1.45
+++ browser/declarative_oracle.m	15 Aug 2005 08:31:34 -0000
@@ -29,6 +29,7 @@
 :- import_module mdb.browser_info.
 :- import_module mdb.declarative_debugger.
 :- import_module mdb.declarative_execution.
+:- import_module mdb.declarative_user.
 :- import_module mdb.help.
 :- import_module mdbcomp.prim_data.

@@ -42,12 +43,15 @@
 :- type oracle_response(T)
 	--->	oracle_answer(decl_answer(T))
 	;	show_info(io.output_stream)
+	;	change_search(user_search_mode)
 			% Ask the diagnoser to revert to the
 			% last question it asked.
 	;	undo
 	;	exit_diagnosis(T)
 	;	abort_diagnosis.

+:- pred oracle_response_undoable(oracle_response(T)::in) is semidet.
+
 	% The oracle state.  This is threaded around the declarative
 	% debugger.
 	%
@@ -151,7 +155,6 @@

 :- implementation.

-:- import_module mdb.declarative_user.
 :- import_module mdb.util.
 :- import_module mdbcomp.prim_data.

@@ -227,6 +230,9 @@
 		UserResponse = show_info(OutStream),
 		OracleResponse = show_info(OutStream)
 	;
+		UserResponse = change_search(Mode),
+		OracleResponse = change_search(Mode)
+	;
 		UserResponse = exit_diagnosis(Node),
 		OracleResponse = exit_diagnosis(Node)
 	;
@@ -741,3 +747,12 @@
 	User0 = !.Oracle ^ user_state,
 	set_user_testing_flag(Testing, User0, User),
 	!:Oracle = !.Oracle ^ user_state := User.
+
+%-----------------------------------------------------------------------------%
+
+oracle_response_undoable(oracle_answer(_)).
+oracle_response_undoable(change_search(_)).
+
+%-----------------------------------------------------------------------------%
+:- end_module mdb.declarative_oracle.
+%-----------------------------------------------------------------------------%
Index: browser/declarative_user.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_user.m,v
retrieving revision 1.51
diff -u -r1.51 declarative_user.m
--- browser/declarative_user.m	9 Aug 2005 07:14:00 -0000	1.51
+++ browser/declarative_user.m	13 Aug 2005 16:40:02 -0000
@@ -35,11 +35,18 @@
 			% about the state of the search and the current
 			% question to the given output stream.
 	;	show_info(io.output_stream)
+			% Request that a new search strategy be used.
+	;	change_search(user_search_mode)
 			% The user wants to undo the last answer they gave.
 	;	undo
 	;	exit_diagnosis(T)
 	;	abort_diagnosis.

+:- type user_search_mode
+	--->	top_down
+	;	divide_and_query
+	;	binary.
+
 :- type user_state.

 :- pred user_state_init(io.input_stream::in, io.output_stream::in,
@@ -286,6 +293,8 @@
 	print_chosen_io_actions(MaybeIoActions, From, To, !.User, !IO),
 	query_user(UserQuestion, Response, !User, !IO).

+handle_command(change_search(Mode), _, change_search(Mode), !User, !IO).
+
 handle_command(ask, UserQuestion, Response, !User, !IO) :-
 	!:User = !.User ^ display_question := yes,
 	query_user(UserQuestion, Response, !User, !IO).
@@ -787,6 +796,9 @@
 			% The user wants the current question re-asked.
 	;	ask

+			% Change the current search strategy.
+	;	change_search(user_search_mode)
+
 			% Abort this diagnosis session.
 	;	quit

@@ -876,6 +888,8 @@
 cmd_handler("set",		set_arg_cmd).
 cmd_handler("t",		trust_arg_cmd).
 cmd_handler("trust",		trust_arg_cmd).
+cmd_handler("mode",		search_mode_cmd).
+cmd_handler("m",		search_mode_cmd).
 cmd_handler("undo",		one_word_cmd(undo)).

 :- func one_word_cmd(user_command::in, list(string)::in) = (user_command::out)
@@ -922,6 +936,17 @@

 trust_arg_cmd([]) = trust_predicate.
 trust_arg_cmd(["module"]) = trust_module.
+
+:- func search_mode_cmd(list(string)::in) = (user_command::out) is semidet.
+
+search_mode_cmd(["top-down"]) 		= change_search(top_down).
+search_mode_cmd(["top_down"]) 		= change_search(top_down).
+search_mode_cmd(["td"]) 		= change_search(top_down).
+search_mode_cmd(["divide-and-query"])	= change_search(divide_and_query).
+search_mode_cmd(["divide_and_query"])	= change_search(divide_and_query).
+search_mode_cmd(["dq"])			= change_search(divide_and_query).
+search_mode_cmd(["binary"])		= change_search(binary).
+search_mode_cmd(["b"])			= change_search(binary).

 :- func help_cmd(list(string)::in) = (user_command::out) is semidet.

Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.449
diff -u -r1.449 user_guide.texi
--- doc/user_guide.texi	9 Aug 2005 07:14:00 -0000	1.449
+++ doc/user_guide.texi	18 Aug 2005 09:11:09 -0000
@@ -4135,9 +4135,13 @@
 Skip this question and ask a different one if possible.
 @sp 1
 @item undo
-Reset the state of the declarative debugger to what it was before the most
-recent `yes', `no', `inadmissible', `trust', `skip' or `mark' answer that has
-not already been undone.
+Reset the state of the declarative debugger to the state it was in when
+the question that came before the current question, and that hasn't already
+been undone, was asked.
+ at sp 1
+ at item mode [ top-down | divide-and-query | binary ]
+Change the current search mode.  The search modes may be abbreviated to
+ at samp{td}, @samp{dq} and @samp{b} respectively.
 @sp 1
 @item browse [--xml] [@var{n}]
 Start the interactive term browser and browse the @var{n}th argument
@@ -4279,49 +4283,42 @@
 @node Search Modes
 @subsection Search Modes

-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
- at samp{dd} command.  See @ref{Declarative debugging mdb commands} for
-information on how to do this.
+The declarative debugger can operate in one of several modes when
+searching for a bug.  The user can specify which mode to use by giving the
+ at samp{--search-mode} option to the @samp{dd} command (see
+ at ref{Declarative debugging mdb commands}) or with the @samp{mode} declarative
+debugger command (see @ref{Declarative debugging commands}).

- at subsubsection Top-down Search
+ at subsubsection Top-down Mode

 Using this mode the declarative debugger will ask about the children of the
-last atom whose assertion was false.  This makes the search more predictable
+last question the user answered @samp{no} to.  The child calls will be asked
+about in the order they were executed.  This makes the search more predictable
 from the user's point of view as the questions will more or less follow the
 program execution.  The drawback of top-down search is that it may require a
 lot of questions to be answered before a bug is found, especially with deeply
-recursive program runs.
+recursive programs.

 This search mode is used by default when no other mode is specified.

- at subsubsection Divide and Query Search
+ at subsubsection Divide and Query Mode

-With this search mode the declarative debugger will attempt to halve the size of
-the search space with each question.  In many cases this will result in the
+With this search mode the declarative debugger will attempt to halve the size
+of the search space with each question.  In many cases this will result in the
 bug being found after O(log(N)) questions where N is the number of events
 between the event where the @samp{dd} command was given and the corresponding
- at samp{CALL} event.  This makes the search feasible for deeply recursive runs
+ at samp{CALL} event.  This makes the search feasible for long running programs
 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.
+ at subsubsection Binary Search Mode

-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.
+The user may ask the declarative debugger to do a binary search along the
+path in the call tree between the current question and the question that the
+user last answered @samp{no} to.  This is useful, for example, when a
+recursive predicate is producing incorrect output, but the base case is
+correct.

 @node Improving the search
 @subsection Improving the search
@@ -4445,6 +4442,23 @@
 predicates and functions in the same module as the predicate or function in the
 current question.  See the @samp{trust} command in
 @ref{Declarative debugging commands}.
+
+ 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.

 @c ----------------------------------------------------------------------------

Index: tests/debugger/mdb_command_test.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/mdb_command_test.inp,v
retrieving revision 1.45
diff -u -r1.45 mdb_command_test.inp
--- tests/debugger/mdb_command_test.inp	9 Aug 2005 07:14:01 -0000	1.45
+++ tests/debugger/mdb_command_test.inp	18 Aug 2005 10:25:21 -0000
@@ -4,6 +4,7 @@
 trust                xyzzy xyzzy xyzzy xyzzy xyzzy
 skip                 xyzzy xyzzy xyzzy xyzzy xyzzy
 undo                 xyzzy xyzzy xyzzy xyzzy xyzzy
+mode                 xyzzy xyzzy xyzzy xyzzy xyzzy
 browse               xyzzy xyzzy xyzzy xyzzy xyzzy
 print                xyzzy xyzzy xyzzy xyzzy xyzzy
 set                  xyzzy xyzzy xyzzy xyzzy xyzzy
Index: tests/debugger/declarative/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/Mmakefile,v
retrieving revision 1.78
diff -u -r1.78 Mmakefile
--- tests/debugger/declarative/Mmakefile	28 Jul 2005 06:44:10 -0000	1.78
+++ tests/debugger/declarative/Mmakefile	18 Aug 2005 08:40:45 -0000
@@ -18,6 +18,7 @@
 	closure_dependency	\
 	comp_gen		\
 	confirm_abort		\
+	change_search		\
 	deep_warning		\
 	dependency		\
 	dependency2		\
@@ -234,6 +235,11 @@

 confirm_abort.out: confirm_abort confirm_abort.inp
 	$(MDB) ./confirm_abort < confirm_abort.inp > confirm_abort.out 2>&1 \
+	|| { grep . $@ /dev/null; exit 1; }
+
+change_search.out: change_search change_search.inp
+	$(MDB_STD) ./change_search < change_search.inp \
+		> change_search.out 2>&1 \
 	|| { grep . $@ /dev/null; exit 1; }

 deep_warning.out: deep_warning deep_warning.inp
Index: tests/debugger/declarative/binary_search.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/binary_search.exp,v
retrieving revision 1.4
diff -u -r1.4 binary_search.exp
--- tests/debugger/declarative/binary_search.exp	20 May 2005 05:40:21 -0000	1.4
+++ tests/debugger/declarative/binary_search.exp	18 Aug 2005 08:34:54 -0000
@@ -13,27 +13,27 @@
 Valid? b 1
 browser> mark
 silly_even(0, yes)
-Valid? y
-sillier_even(504, yes)
+Valid? mode binary
+sillier_even(502, yes)
 Valid? y
 silly_even(771, yes)
 Valid? n
-sillier_even(657, yes)
-Valid? n
-silly_even(600, yes)
-Valid? y
-silly_even(627, yes)
+sillier_even(655, yes)
 Valid? n
-silly_even(616, yes)
+sillier_even(600, yes)
 Valid? y
-sillier_even(621, yes)
+sillier_even(627, yes)
 Valid? n
-silly_even(618, yes)
+silly_even(614, yes)
 Valid? y
 sillier_even(619, yes)
 Valid? n
+sillier_even(618, yes)
+Valid? y
 silly_even(619, yes)
 Valid? n
+silly_even(618, yes)
+Valid? y
 Found incorrect contour:
 silly_even(618, yes)
 silly_even(619, yes)
@@ -79,13 +79,15 @@
 browser> cd 1
 browser> mark
 add1s([10], [11])
-Valid? y
+Valid? mode binary
 add1s([5, 6, 7, 8, 9, 10], [6, ...])
 Valid? n
-add1s([7, 8, 9, 10], [8, 9, 10, ...])
+add1s([8, 9, 10], [9, 10, 11])
 Valid? y
 add1s([6, 7, 8, 9, 10], [7, 8, ...])
 Valid? n
+add1s([7, 8, 9, 10], [8, 9, 10, ...])
+Valid? y
 Found incorrect contour:
 add1s([7, 8, 9, 10], [8, 9, 10, ...])
 add1s([6, 7, 8, 9, 10], [7, 8, ...])
Index: tests/debugger/declarative/binary_search.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/binary_search.exp2,v
retrieving revision 1.4
diff -u -r1.4 binary_search.exp2
--- tests/debugger/declarative/binary_search.exp2	20 May 2005 05:40:21 -0000	1.4
+++ tests/debugger/declarative/binary_search.exp2	18 Aug 2005 10:19:34 -0000
@@ -13,27 +13,27 @@
 Valid? b 1
 browser> mark
 silly_even(0, yes)
-Valid? y
-sillier_even(504, yes)
+Valid? mode binary
+sillier_even(502, yes)
 Valid? y
 silly_even(771, yes)
 Valid? n
-sillier_even(657, yes)
-Valid? n
-silly_even(600, yes)
-Valid? y
-silly_even(627, yes)
+sillier_even(655, yes)
 Valid? n
-silly_even(616, yes)
+sillier_even(600, yes)
 Valid? y
-sillier_even(621, yes)
+sillier_even(627, yes)
 Valid? n
-silly_even(618, yes)
+silly_even(614, yes)
 Valid? y
 sillier_even(619, yes)
 Valid? n
+sillier_even(618, yes)
+Valid? y
 silly_even(619, yes)
 Valid? n
+silly_even(618, yes)
+Valid? y
 Found incorrect contour:
 >(619, 0)
 -(619, 1) = 618
@@ -83,7 +83,7 @@
 browser> cd 1
 browser> mark
 add1s([10], [11])
-Valid? y
+Valid? mode binary
 add1s([5, 6, 7, 8, 9, 10], [6, ...])
 Valid? y
 add1s([2, 3, 4, 5, 6, 7, 8, 9, ...], [|]/2)
Index: tests/debugger/declarative/binary_search.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/binary_search.inp,v
retrieving revision 1.3
diff -u -r1.3 binary_search.inp
--- tests/debugger/declarative/binary_search.inp	20 May 2005 05:40:21 -0000	1.3
+++ tests/debugger/declarative/binary_search.inp	18 Aug 2005 10:11:08 -0000
@@ -7,7 +7,7 @@
 dd -d 3 -n 7
 b 1
 mark
-y
+mode binary
 y
 n
 n
@@ -17,7 +17,7 @@
 n
 y
 n
-n
+y
 y
 trust binary_search_1
 break b
@@ -40,9 +40,10 @@
 ls
 cd 1
 mark
-y
+mode binary
 n
 y
 n
+y
 y
 c
Index: tests/debugger/declarative/binary_search.inp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/binary_search.inp2,v
retrieving revision 1.3
diff -u -r1.3 binary_search.inp2
--- tests/debugger/declarative/binary_search.inp2	20 May 2005 05:40:21 -0000	1.3
+++ tests/debugger/declarative/binary_search.inp2	18 Aug 2005 10:16:46 -0000
@@ -7,7 +7,7 @@
 dd -d 3 -n 7
 b 1
 mark
-y
+mode binary
 y
 n
 n
@@ -17,7 +17,7 @@
 n
 y
 n
-n
+y
 y
 trust binary_search_1
 break b
@@ -40,7 +40,7 @@
 ls
 cd 1
 mark
-y
+mode binary
 y
 n
 y
Index: tests/debugger/declarative/change_search.exp
===================================================================
RCS file: tests/debugger/declarative/change_search.exp
diff -N tests/debugger/declarative/change_search.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/change_search.exp	18 Aug 2005 08:46:19 -0000
@@ -0,0 +1,95 @@
+      E1:     C1 CALL pred change_search.main/2-0 (det) change_search.m:13
+mdb> mdb> Contexts will not be printed.
+mdb> echo on
+Command echo enabled.
+mdb> break mylast
+ 0: + stop  interface pred change_search.mylast/2-0 (det)
+mdb> continue
+      E2:     C2 CALL pred change_search.mylast/2-0 (det)
+mdb> finish -n
+      E3:     C2 EXIT pred change_search.mylast/2-0 (det)
+mdb> set format pretty
+mdb> set depth 10
+mdb> dd
+mylast([1, 2, 3, 4, 5, 6, 7, 8, ...], no)
+Valid? info
+Context of current question : change_search.m:20 (change_search.m:14)
+Search mode                 : top down
+Number of suspect events    : 4,000
+The current question was chosen because this is the node where the `dd'
+command was issued.
+dd> no
+mylast([2, 3, 4, 5, 6, 7, 8, 9, ...], no)
+Valid? info
+Context of current question : change_search.m:20 (change_search.m:22)
+Search mode                 : top down
+Number of suspect events    : 4,000
+The current question was chosen because this is the next node in the
+top-down search.
+dd> mode dq
+mylast([501, 502, 503, 504, 505, 506, 507, 508, ...], no)
+Valid? info
+Context of current question   : change_search.m:20 (change_search.m:22)
+Search mode                   : divide and query
+Estimated questions remaining : 12
+Number of suspect events      : 4,000
+The current question was chosen because this node divides the suspect
+area into two regions of 2,000 and 2,000 events each.
+dd> no
+mylast([751, 752, 753, 754, 755, 756, 757, 758, ...], no)
+Valid? info
+Context of current question   : change_search.m:20 (change_search.m:22)
+Search mode                   : divide and query
+Estimated questions remaining : 11
+Number of suspect events      : 2,000
+The current question was chosen because this node divides the suspect
+area into two regions of 1,000 and 1,000 events each.
+dd> pd
+      E4:     C3 EXIT pred change_search.mylast/2-0 (det)
+mdb> stack
+   0  751* pred change_search.mylast/2-0 (det)
+ 751       pred change_search.main/2-0 (det)
+mdb> retry 750
+      E2:     C2 CALL pred change_search.mylast/2-0 (det)
+mdb> p
+mylast([1, 2, 3, 4, 5, 6, 7, 8, ...], _)
+mdb> dd -r
+mylast([751, 752, 753, 754, 755, 756, 757, 758, ...], no)
+Valid? browse 2
+browser> mark
+mylast([1000], no)
+Valid? info
+Context of current question   : change_search.m:20 (change_search.m:22)
+Search mode                   : divide and query
+Estimated questions remaining : 10
+Number of suspect events      : 1,000
+The current question was chosen because the marked subterm was bound by
+the unification inside the predicate change_search.mylast/2
+(change_search.m:21). The path to the subterm in the atom is 2.
+dd> pd
+      E5:     C4 EXIT pred change_search.mylast/2-0 (det)
+mdb> dd -r
+mylast([1000], no)
+Valid? info
+Context of current question   : change_search.m:20 (change_search.m:22)
+Search mode                   : divide and query
+Estimated questions remaining : 10
+Number of suspect events      : 1,000
+The current question was chosen because the marked subterm was bound by
+the unification inside the predicate change_search.mylast/2
+(change_search.m:21). The path to the subterm in the atom is 2.
+dd> mode binary
+mylast([875, 876, 877, 878, 879, 880, 881, 882, ...], no)
+Valid? mode top_down
+mylast([752, 753, 754, 755, 756, 757, 758, 759, ...], no)
+Valid? undo
+mylast([875, 876, 877, 878, 879, 880, 881, 882, ...], no)
+Valid? undo
+dd> mode divide_and_query
+mylast([876, 877, 878, 879, 880, 881, 882, 883, ...], no)
+Valid? n
+mylast([939, 940, 941, 942, 943, 944, 945, 946, ...], no)
+Valid? q
+Diagnosis aborted.
+      E5:     C4 EXIT pred change_search.mylast/2-0 (det)
+mdb> quit -y
Index: tests/debugger/declarative/change_search.inp
===================================================================
RCS file: tests/debugger/declarative/change_search.inp
diff -N tests/debugger/declarative/change_search.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/change_search.inp	18 Aug 2005 08:39:36 -0000
@@ -0,0 +1,35 @@
+register --quiet
+context none
+echo on
+break mylast
+continue
+finish -n
+set format pretty
+set depth 10
+dd
+info
+no
+info
+mode dq
+info
+no
+info
+pd
+stack
+retry 750
+p
+dd -r
+browse 2
+mark
+info
+pd
+dd -r
+info
+mode binary
+mode top_down
+undo
+undo
+mode divide_and_query
+n
+q
+quit -y
Index: tests/debugger/declarative/change_search.m
===================================================================
RCS file: tests/debugger/declarative/change_search.m
diff -N tests/debugger/declarative/change_search.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/declarative/change_search.m	9 Jul 2005 10:44:31 -0000
@@ -0,0 +1,22 @@
+:- module change_search.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module list, int, std_util.
+
+main(!IO) :-
+	mylast(1 .. 1000, L),
+	io.write(L, !IO),
+	io.nl(!IO).
+
+:- pred mylast(list(T)::in, maybe(T)::out) is det.
+
+mylast([], no).
+mylast([_], no). % Bug
+mylast([_, H2 | T], L) :- mylast([H2 | T], L).
Index: tests/debugger/declarative/info.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/info.exp,v
retrieving revision 1.4
diff -u -r1.4 info.exp
--- tests/debugger/declarative/info.exp	20 May 2005 05:40:26 -0000	1.4
+++ tests/debugger/declarative/info.exp	18 Aug 2005 08:35:27 -0000
@@ -59,21 +59,21 @@
 last([108], t(108))
 Valid? info
 Context of current question : info.m:43 (info.m:45)
-Search mode                 : binary search on path
+Search mode                 : top down
 Number of suspect events    : 21
 The current question was chosen because the marked subterm was bound by
 the unification inside the predicate info.last/2 (info.m:43). The path
 to the subterm in the atom is 2.
-dd> y
-last([104, 105, 106, 107, 108], t(108))
+dd> mode binary
+last([105, 106, 107, 108], t(108))
 Valid? info
 Context of current question : info.m:43 (info.m:45)
 Search mode                 : binary search on path
-Number of suspect events    : 18
+Number of suspect events    : 21
 The current question was chosen because this node divides a path of
-length 6 into two paths of length 3 and 3.
+length 7 into two paths of length 3 and 4.
 dd> n
-last([106, 107, 108], t(108))
+last([107, 108], t(108))
 Valid? info
 Context of current question : info.m:43 (info.m:45)
 Search mode                 : binary search on path
@@ -83,10 +83,10 @@
 dd> b 1
 browser> cd 1
 browser> mark
-last([105, 106, 107, 108], t(108))
+last([106, 107, 108], t(108))
 Valid? info
 Context of current question : info.m:43 (info.m:45)
-Search mode                 : binary search on path
+Search mode                 : top down
 Number of suspect events    : 6
 The current question was chosen because tracking of the marked subterm
 was stopped here, because the binding node lies in a portion of the tree
@@ -110,7 +110,7 @@
 f(0, "lala") = t(t(t("lala")))
 Valid? info
 Context of current question : info.m:51 (info.m:34)
-Search mode                 : binary search on path
+Search mode                 : top down
 Number of suspect events    : 6
 The current question was chosen because the marked subterm was bound by
 the unification inside the function info.f/3 (info.m:52). The path to
@@ -129,7 +129,7 @@
 fproc(1) = 2
 Valid? info
 Context of current question : info.m:57 (info.m:37)
-Search mode                 : binary search on path
+Search mode                 : top down
 Number of suspect events    : 6
 The current question was chosen because the marked subterm was bound by
 the foreign procedure call inside the function info.fproc/2 (info.m:57).
Index: tests/debugger/declarative/info.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/info.inp,v
retrieving revision 1.4
diff -u -r1.4 info.inp
--- tests/debugger/declarative/info.inp	20 May 2005 05:40:26 -0000	1.4
+++ tests/debugger/declarative/info.inp	18 Aug 2005 06:12:30 -0000
@@ -20,7 +20,7 @@
 b 2
 mark
 info
-y
+mode binary
 info
 n
 info

--------------------------------------------------------------------------
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