Files
mercury/tests/debugger/declarative/undo.exp
Ian MacLarty 420272e7c4 Implement `undo' command in the declarative debugger.
Estimated hours taken: 6
Branches: main

Implement `undo' command in the declarative debugger.
The `undo' command takes the debugger back to the state it was in before the
last answer was given (`skip' is counted as an answer in this case).

browser/declarative_analyser.m:
	Add an interface predicate which allows us to get the last question
	asked by the analyser.

	Do not handle `show_info' in process_answer, since `show_info' is
	no longer considered an answer (see below).

browser/declarative_debugger.m:
	Make `show_info' an oracle response, instead of an oracle answer,
	since it doesn't affect the search space.

	Get rid of diagnoser_{get,set}_{analyser,oracle}, because they serve
	no abstraction purpose and maintaining them is a pain.

	Add a new field to the diagnoser which records the state of the
	diagnoser before the previous oracle answer.  This turns the
	diagnoser into a stack.  Add predicates to push and pop
	diagnosers from this stack.

	Push the current diagnoser onto the stack when an oracle answer
	is received from the user.
	Pop the previous diagnoser when the `undo' command is issued.

browser/declarative_oracle.m:
	Add `undo' to the set of possible oracle responses.

	Add a predicate which makes the current knowledge base of one oracle
	the revised knowledge base of another oracle.

	Fix a spelling mistake.

	Add a predicate to get the output stream used to communicate with the
	user.

	Report whether an answer came directly from the user or not in
	query_oracle.

browser/declarative_user.m:
	Add the `undo' user response.

	Add a predicate to get the output stream used to communicate with the
	user.  This is used by the diagnoser to print a "Undo stack empty"
	message.

doc/user_guide.texi
	Document the new command.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/undo.exp:
tests/debugger/declarative/undo.inp:
tests/debugger/declarative/undo.m:
	Test the new command.
2005-07-28 06:44:11 +00:00

53 lines
1.0 KiB
Plaintext

E1: C1 CALL pred undo.main/2-0 (det) undo.m:13
mdb> mdb> Contexts will not be printed.
mdb> echo on
Command echo enabled.
mdb> step
E2: C2 CALL pred undo.sum/2-0 (det)
mdb> finish
E3: C2 EXIT pred undo.sum/2-0 (det)
mdb> dd
sum([1, 2, 3, 4, 5, 6], 21)
Valid? no
sum([2, 3, 4, 5, 6], 20)
Valid? undo
sum([1, 2, 3, 4, 5, 6], 21)
Valid? [no] undo
Undo stack empty.
sum([1, 2, 3, 4, 5, 6], 21)
Valid? [no]
sum([2, 3, 4, 5, 6], 20)
Valid? no
sum([3, 4, 5, 6], 18)
Valid?
sum([4, 5, 6], 15)
Valid? undo
sum([3, 4, 5, 6], 18)
Valid?
sum([4, 5, 6], 15)
Valid? no
sum([5, 6], 11)
Valid? no
sum([6], 6)
Valid? pd
E4: C3 EXIT pred undo.sum/2-0 (det)
mdb> dd -r
sum([6], 6)
Valid? undo
sum([5, 6], 11)
Valid? [no] undo
sum([4, 5, 6], 15)
Valid? [no] undo
sum([3, 4, 5, 6], 18)
Valid? undo
sum([2, 3, 4, 5, 6], 20)
Valid? [no] undo
sum([1, 2, 3, 4, 5, 6], 21)
Valid? [no] undo
Undo stack empty.
sum([1, 2, 3, 4, 5, 6], 21)
Valid? [no] q
Diagnosis aborted.
E4: C3 EXIT pred undo.sum/2-0 (det)
mdb> quit -y