[m-rev.] for review: add --reset-kb option to mdb dd command
Ian MacLarty
maclarty at csse.unimelb.edu.au
Wed Jun 6 12:49:35 AEST 2007
Sorry for sending this multiple times. I've removed the changes to
boehm_gc/libatomic_ops-1.2/configure from the diff now.
Ian.
For review by anyone.
Estimated hours taken: 1
Branches: main
Add a --reset-kb option to the mdb `dd' command. The new option resets the
declarative debugger's knowledge base of previous question answers.
NEWS:
Mention the new option.
Move an item that was in the wrong place.
browser/declarative_debugger.m:
browser/declarative_oracle.m:
Export a procedure to reset the oracle's knowledge base.
doc/user_guide.texi:
Document the new option.
tests/debugger/declarative/oracle_db.exp:
tests/debugger/declarative/oracle_db.inp:
Test the new option.
trace/mercury_trace_cmd_dd.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
Add the new option.
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.464
diff -u -r1.464 NEWS
--- NEWS 1 Jun 2007 12:54:10 -0000 1.464
+++ NEWS 5 Jun 2007 07:04:06 -0000
@@ -209,6 +209,8 @@
* A `track' mdb command has been added.
+* The `dd' command now accepts a `--reset-kb' option.
+
DETAILED LISTING
================
@@ -285,6 +287,14 @@
io.seek_binary_input/5, io.seek_binary_output/5,
io.binary_input_stream_offset/4 and io.binary_output_stream_offset/4.
+Changes to the Mercury debugger:
+
+* A `track' mdb command has been added. This command invokes the declarative
+ debugger and executes it's `track' command, before returning to the mdb
+ prompt.
+
+* The `dd' command now accepts a `--reset-kb' option. This option resets
+ the declarative debugger's knowledge base of previous question answers.
NEWS for Mercury 0.13.1
-----------------------
@@ -651,12 +661,5 @@
optimal set of compiler flags for a given program. The search
algorithm used is a genetic algorithm, which can run in parallel over
multiple hosts (by default, 1).
-
-Changes to the Mercury debugger:
-
-* A `track' mdb command has been added. This command invokes the declarative
- debugger and executes it's `track' command, before returning to the mdb
- prompt.
-
For news about earlier versions, see the HISTORY file.
Index: browser/declarative_debugger.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_debugger.m,v
retrieving revision 1.73
diff -u -r1.73 declarative_debugger.m
--- browser/declarative_debugger.m 1 Dec 2006 15:03:43 -0000 1.73
+++ browser/declarative_debugger.m 5 Jun 2007 07:04:06 -0000
@@ -618,6 +618,19 @@
SearchMode, Analyser0, Analyser),
!:Diagnoser = !.Diagnoser ^ analyser_state := Analyser.
+:- pred reset_knowledge_base(
+ diagnoser_state(trace_node_id)::in,
+ diagnoser_state(trace_node_id)::out) is det.
+
+:- pragma foreign_export("C",
+ mdb.declarative_debugger.reset_knowledge_base(in, out),
+ "MR_DD_decl_reset_knowledge_base").
+
+reset_knowledge_base(!Diagnoser) :-
+ Oracle0 = !.Diagnoser ^ oracle_state,
+ reset_oracle_knowledge_base(Oracle0, Oracle),
+ !Diagnoser ^ oracle_state := Oracle.
+
:- func top_down_search_mode = mdb.declarative_analyser.search_mode.
top_down_search_mode = mdb.declarative_analyser.top_down_search_mode.
Index: browser/declarative_oracle.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_oracle.m,v
retrieving revision 1.57
diff -u -r1.57 declarative_oracle.m
--- browser/declarative_oracle.m 19 Jan 2007 07:03:58 -0000 1.57
+++ browser/declarative_oracle.m 5 Jun 2007 07:04:06 -0000
@@ -158,6 +158,11 @@
:- pred set_oracle_testing_flag(bool::in, oracle_state::in, oracle_state::out)
is det.
+ % Reset the oracle's knowledge base.
+ %
+:- pred reset_oracle_knowledge_base(oracle_state::in, oracle_state::out)
+ is det.
+
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -705,6 +710,13 @@
User0 = !.Oracle ^ user_state,
set_user_testing_flag(Testing, User0, User),
!:Oracle = !.Oracle ^ user_state := User.
+
+%-----------------------------------------------------------------------------%
+
+reset_oracle_knowledge_base(!Oracle) :-
+ oracle_kb_init(EmptyKB),
+ !Oracle ^ kb_revised := !.Oracle ^ kb_current,
+ !Oracle ^ kb_current := EmptyKB.
%-----------------------------------------------------------------------------%
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.522
diff -u -r1.522 user_guide.texi
--- doc/user_guide.texi 30 May 2007 05:15:06 -0000 1.522
+++ doc/user_guide.texi 5 Jun 2007 07:04:07 -0000
@@ -3977,7 +3977,7 @@
@ref{Declarative debugging} for details.
@sp 1
@table @code
- at item dd [-r] [-n at var{nodes}] [-s at var{search-mode}] [-p at var{passfile}] [-f at var{failfile}]
+ at item dd [-r] [-R] [-n at var{nodes}] [-s at var{search-mode}] [-p at var{passfile}] [-f at var{failfile}]
@c @item dd [--assume-all-io-is-tabled] [-d at var{depth}] [-t]
@c [--debug [filename]]
@c The --assume-all-io-is-tabled option is for developers only. Specifying it
@@ -4029,6 +4029,12 @@
The @samp{--search-mode} option may be used with the @samp{--resume} option
to change the search mode of a previously started declarative debugging
session.
+ at sp 1
+Use the @samp{-R} or @samp{--reset-kb} option to reset the declarative
+debugger's knowledge base.
+The declarative debugger will then not use any previous answers you gave,
+and will reask previous questions if it needs to.
+This option does not affect what predicates or modules are trusted.
@sp 1
The arguments supplied to the @samp{--pass-trace-counts} (or @samp{-p}) and
@samp{--fail-trace-counts} (or @samp{-f}) options are either trace count
Index: tests/debugger/declarative/oracle_db.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/oracle_db.exp,v
retrieving revision 1.12
diff -u -r1.12 oracle_db.exp
--- tests/debugger/declarative/oracle_db.exp 29 Mar 2006 00:57:46 -0000 1.12
+++ tests/debugger/declarative/oracle_db.exp 5 Jun 2007 07:04:07 -0000
@@ -20,5 +20,17 @@
a(99, 99, 99)
Is this a bug? yes
10: 2 2 EXIT pred oracle_db.a/3-0 (semidet) oracle_db.m:19 (oracle_db.m:9)
+mdb> dd -R
+a(99, 99, 99)
+Valid? [no] no
+b(99)
+Valid? [yes] yes
+Found incorrect contour:
+b(99)
+b(99)
+b(99)
+a(99, 99, 99)
+Is this a bug? yes
+ 10: 2 2 EXIT pred oracle_db.a/3-0 (semidet) oracle_db.m:19 (oracle_db.m:9)
mdb> continue
yes.
Index: tests/debugger/declarative/oracle_db.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/oracle_db.inp,v
retrieving revision 1.7
diff -u -r1.7 oracle_db.inp
--- tests/debugger/declarative/oracle_db.inp 20 May 2005 05:40:28 -0000 1.7
+++ tests/debugger/declarative/oracle_db.inp 5 Jun 2007 07:04:07 -0000
@@ -7,5 +7,8 @@
no
yes
yes
+dd -R
+no
+yes
+yes
continue
-
Index: trace/mercury_trace_cmd_dd.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_cmd_dd.c,v
retrieving revision 1.2
diff -u -r1.2 mercury_trace_cmd_dd.c
--- trace/mercury_trace_cmd_dd.c 29 Nov 2006 05:18:34 -0000 1.2
+++ trace/mercury_trace_cmd_dd.c 5 Jun 2007 07:04:07 -0000
@@ -40,7 +40,8 @@
MR_bool *search_mode_requires_trace_counts,
char **pass_trace_counts_file,
char **fail_trace_counts_file,
- MR_bool *new_session, MR_bool *testing, MR_bool *debug,
+ MR_bool *new_session, MR_bool *reset_kb,
+ MR_bool *testing, MR_bool *debug,
char ***words, int *word_count);
/****************************************************************************/
@@ -52,6 +53,7 @@
MR_DeclSearchMode search_mode;
MR_bool search_mode_was_set = MR_FALSE;
MR_bool new_session = MR_TRUE;
+ MR_bool reset_kb = MR_FALSE;
MR_bool search_mode_requires_trace_counts = MR_FALSE;
char *pass_trace_counts_file;
char *fail_trace_counts_file;
@@ -73,7 +75,8 @@
&search_mode, &search_mode_was_set,
&search_mode_requires_trace_counts,
&pass_trace_counts_file, &fail_trace_counts_file, &new_session,
- &testing, &MR_trace_decl_debug_debugger_mode, &words, &word_count))
+ &reset_kb, &testing, &MR_trace_decl_debug_debugger_mode, &words,
+ &word_count))
{
; /* the usage message has already been printed */
} else if (word_count <= 2) {
@@ -115,6 +118,10 @@
MR_trace_decl_set_fallback_search_mode(search_mode);
}
+ if (reset_kb) {
+ MR_trace_decl_reset_knowledge_base();
+ }
+
if (MR_trace_start_decl_debug(decl_mode, filename, new_session, cmd,
event_info, jumpaddr))
{
@@ -251,10 +258,11 @@
/****************************************************************************/
const char *const MR_trace_dd_cmd_args[] =
- { "-s", "-a", "-d", "-n", "--search-mode",
- "--assume-all-io-is-tabled", "--depth", "--nodes",
- "td", "top_down", "dq" "divide_and_query", "sdq",
- "suspicion_divide_and_query", NULL };
+ { "-a", "-d", "-n", "-r", "-R", "-s",
+ "--assume-all-io-is-tabled", "--depth", "--nodes",
+ "--reset-kb", "--resume", "--search-mode",
+ "dq" "divide_and_query", "sdq", "suspicion_divide_and_query",
+ "td", "top_down", NULL };
/****************************************************************************/
@@ -263,16 +271,16 @@
{ "assume-all-io-is-tabled", MR_no_argument, NULL, 'a' },
{ "debug", MR_no_argument, NULL, 'z' },
{ "depth", MR_required_argument, NULL, 'd' },
+ { "fail-trace-counts", MR_required_argument, NULL, 'f' },
+ { "fail-trace-count", MR_required_argument, NULL, 'f' },
{ "nodes", MR_required_argument, NULL, 'n' },
- { "resume", MR_no_argument, NULL, 'r' },
- { "search-mode", MR_required_argument, NULL, 's' },
{ "pass-trace-counts", MR_required_argument, NULL, 'p' },
{ "pass-trace-count", MR_required_argument, NULL, 'p' },
- { "fail-trace-counts", MR_required_argument, NULL, 'f' },
- { "fail-trace-count", MR_required_argument, NULL, 'f' },
+ { "reset-kb", MR_no_argument, NULL, 'R' },
{ "resume", MR_no_argument, NULL, 'r' },
+ { "search-mode", MR_required_argument, NULL, 's' },
{ "test", MR_no_argument, NULL, 't' },
- { NULL, MR_no_argument, NULL, 0 }
+ { NULL, MR_no_argument, NULL, 0 }
};
static MR_bool
@@ -281,13 +289,13 @@
MR_DeclSearchMode *search_mode, MR_bool *search_mode_was_set,
MR_bool *search_mode_requires_trace_counts,
char **pass_trace_counts_file, char **fail_trace_counts_file,
- MR_bool *new_session, MR_bool *testing, MR_bool *debug,
- char ***words, int *word_count)
+ MR_bool *new_session, MR_bool *reset_kb, MR_bool *testing,
+ MR_bool *debug, char ***words, int *word_count)
{
int c;
MR_optind = 0;
- while ((c = MR_getopt_long(*word_count, *words, "ad:f:n:p:rs:tz",
+ while ((c = MR_getopt_long(*word_count, *words, "ad:f:n:p:rRs:tz",
MR_trace_dd_opts, NULL)) != EOF)
{
switch (c) {
@@ -320,6 +328,10 @@
case 'r':
*new_session = MR_FALSE;
+ break;
+
+ case 'R':
+ *reset_kb = MR_TRUE;
break;
case 's':
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.110
diff -u -r1.110 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c 2 May 2007 02:16:01 -0000 1.110
+++ trace/mercury_trace_declarative.c 5 Jun 2007 07:04:07 -0000
@@ -1439,6 +1439,16 @@
}
void
+MR_trace_decl_reset_knowledge_base()
+{
+ MR_trace_decl_ensure_init();
+ MR_TRACE_CALL_MERCURY(
+ MR_DD_decl_reset_knowledge_base(
+ MR_trace_front_end_state, &MR_trace_front_end_state);
+ );
+}
+
+void
MR_trace_decl_set_testing_flag(MR_bool testing)
{
MR_trace_decl_ensure_init();
Index: trace/mercury_trace_declarative.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.h,v
retrieving revision 1.30
diff -u -r1.30 mercury_trace_declarative.h
--- trace/mercury_trace_declarative.h 29 Nov 2006 05:18:37 -0000 1.30
+++ trace/mercury_trace_declarative.h 5 Jun 2007 07:04:07 -0000
@@ -85,6 +85,12 @@
MR_DeclSearchMode search_mode);
/*
+** MR_trace_decl_reset_knowledge_base resets the oracle's knowledge base.
+*/
+
+extern void MR_trace_decl_reset_knowledge_base(void);
+
+/*
** This function checks to see if the supplied string is a valid
** search mode. If it is then it returns MR_TRUE and sets
** the value at search_mode to the corresponding search mode.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list