[m-rev.] for review: allow preds to be trusted during decl debugging session
Ian MacLarty
maclarty at cs.mu.OZ.AU
Thu Dec 30 16:35:27 AEDT 2004
For review by anybody.
Estimated hours taken: 2
Branches: main
Allow `trust' as declarative debugger question response. The user may respond
with simply `trust' in which case the current predicate or function will be
trusted, or `trust module' in which case the module the current question
relates to will be trusted.
browser/declarative_oracle.m
If the user response is trust_predicate or trust_module then
add the predicate/function or module to the list of trusted objects
and return an `ignore' response to the analyser.
browser/declarative_user.m
Handle `trust' command and add it to the help messgae.
doc/user_guide.texi
Document `trust' and `trust module' declarative debugger commands.
tests/debugger/declarative/trust.exp
tests/debugger/declarative/trust.inp
Test the `trust' and `trust module' commands.
Index: browser/declarative_oracle.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_oracle.m,v
retrieving revision 1.29
diff -u -r1.29 declarative_oracle.m
--- browser/declarative_oracle.m 19 Nov 2004 11:54:16 -0000 1.29
+++ browser/declarative_oracle.m 30 Dec 2004 03:27:20 -0000
@@ -171,6 +171,20 @@
^ kb_current := Current)
^ kb_revised := Revised
;
+ UserResponse = trust_predicate(Question),
+ Atom = get_decl_question_atom(Question),
+ add_trusted_pred_or_func(Atom ^ proc_layout, !Oracle),
+ OracleResponse = oracle_answer(
+ ignore(get_decl_question_node(Question)))
+ ;
+ UserResponse = trust_module(Question),
+ Atom = get_decl_question_atom(Question),
+ ProcId = get_proc_id_from_layout(Atom ^ proc_layout),
+ get_pred_attributes(ProcId, Module, _, _, _),
+ add_trusted_module(Module, !Oracle),
+ OracleResponse = oracle_answer(
+ ignore(get_decl_question_node(Question)))
+ ;
UserResponse = exit_diagnosis(Node),
OracleResponse = exit_diagnosis(Node)
;
Index: browser/declarative_user.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_user.m,v
retrieving revision 1.32
diff -u -r1.32 declarative_user.m
--- browser/declarative_user.m 19 Nov 2004 11:54:17 -0000 1.32
+++ browser/declarative_user.m 30 Dec 2004 02:47:34 -0000
@@ -27,6 +27,8 @@
:- type user_response(T)
---> user_answer(decl_question(T), decl_answer(T))
+ ; trust_predicate(decl_question(T))
+ ; trust_module(decl_question(T))
; exit_diagnosis(T)
; abort_diagnosis.
@@ -191,6 +193,14 @@
),
query_user(UserQuestion, Response, !User, !IO).
+handle_command(trust_predicate, UserQuestion, trust_predicate(Question),
+ !User, !IO) :-
+ Question = get_decl_question(UserQuestion).
+
+handle_command(trust_module, UserQuestion, trust_module(Question),
+ !User, !IO) :-
+ Question = get_decl_question(UserQuestion).
+
handle_command(browse_io(ActionNum), UserQuestion, Response,
!User, !IO) :-
Question = get_decl_question(UserQuestion),
@@ -500,6 +510,9 @@
% this point.
; set(maybe_option_table(setting_option), setting)
% Set a browser option.
+ ; trust_predicate % Trust the predicate being asked
+ % about.
+ ; trust_module % Trust the module being asked about.
; abort % Abort this diagnosis session.
; help % Request help before answering.
; empty_command % User just pressed return.
@@ -516,6 +529,13 @@
"\tn\tno\t\tthe node is incorrect\n",
"\ti\tinadmissible\tthe input arguments are out of range\n",
"\ts\tskip\t\tskip this question\n",
+ "\tt [module]\ttrust [module]\tTrust the predicate/function ",
+ "about\n",
+ "\t\twhich the currect question is being asked. If the word\n",
+ "\t\t`module' is given as an argument then trust all the\n",
+ "\t\tpredicates/functions in the same module as the\n",
+ "\t\tpredicate/function about which the currect question is\n",
+ "\t\tbeing asked.\n",
"\tb [<n>]\tbrowse [<n>]\tbrowse the atom, or its nth argument\n",
"\tb io <n>\tbrowse io <n>\tbrowse the atom's nth I/O action\n",
"\tp <n>\tprint <n>\tprint the nth argument of the atom\n",
@@ -600,6 +620,8 @@
cmd_handler("p", print_arg_cmd).
cmd_handler("print", print_arg_cmd).
cmd_handler("set", set_arg_cmd).
+cmd_handler("t", trust_arg_cmd).
+cmd_handler("trust", trust_arg_cmd).
:- func one_word_cmd(user_command::in, list(string)::in) = (user_command::out)
is semidet.
@@ -628,6 +650,11 @@
set_arg_cmd(ArgWords) = set(MaybeOptionTable, Setting) :-
ArgWords \= [],
parse.parse(["set" | ArgWords], set(MaybeOptionTable, Setting)).
+
+:- func trust_arg_cmd(list(string)::in) = (user_command::out) is semidet.
+
+trust_arg_cmd([]) = trust_predicate.
+trust_arg_cmd(["module"]) = trust_module.
string_to_range(Arg, From, To) :-
( string__to_int(Arg, Num) ->
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.404
diff -u -r1.404 user_guide.texi
--- doc/user_guide.texi 20 Dec 2004 01:15:48 -0000 1.404
+++ doc/user_guide.texi 30 Dec 2004 05:28:38 -0000
@@ -3767,6 +3767,17 @@
@sp 1
@item inadmissible
Answer that the call is inadmissible.
+ at sp 1
+ at item trust
+Answer that the predicate or function the question is about does not contain
+any bugs. However predicates or functions called by this predicate/function
+may contain bugs. The debugger will not ask you anymore questions about the
+predicate or function the current question is about.
+ at sp 1
+ at item trust module
+Answer that the module the current question relates to doesn't contain any
+bugs. No more questions about any predicates or functions from this module
+will be asked.
@item skip
Skip this question and ask a different one if possible.
@sp 1
@@ -3982,7 +3993,7 @@
is a good idea to trust standard library modules imported by a program being
debugged.
-The declarative debugger must be told which predicates/functions it can trust
+The declarative debugger can be told which predicates/functions it can trust
before the @samp{dd} command is given. This is done using the @samp{trust},
@samp{trusted} and @samp{untrust} commands at the mdb prompt (see
@ref{Declarative debugging mdb commands} for details on how to use these
@@ -3992,6 +4003,12 @@
settings for mdb (see @ref{Mercury debugger invocation}). Trusted
predicates will also be exported with a @samp{save} command (see
@ref{Miscellaneous commands}).
+
+During the declarative debugging session the user may tell the
+declarative debugger to trust the predicate or function the current question
+is about or to trust all predicates and functions in the same module as the
+predicate or function the current question is about. See the @samp{trust}
+command in @ref{Declarative debugging commands}.
@c ----------------------------------------------------------------------------
Index: tests/debugger/declarative/trust.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/trust.exp,v
retrieving revision 1.6
diff -u -r1.6 trust.exp
--- tests/debugger/declarative/trust.exp 29 Nov 2004 11:34:35 -0000 1.6
+++ tests/debugger/declarative/trust.exp 30 Dec 2004 04:54:31 -0000
@@ -67,6 +67,8 @@
mdb: no such trusted object
mdb> untrust 99
mdb: no such trusted object
+mdb> untrust 5
+mdb> untrust 6
mdb> step
E2: C2 CALL pred trust.dostuff/2-0 (cc_multi)
mdb> finish
@@ -74,6 +76,12 @@
mdb> dd
dostuff(w("aaabbb"), '=')
Valid? n
+w_cmp('=', w("aaB"), w("aAB"))
+Valid? trust
+concat(w("aaa"), w("bbb"), w("aaabbb"))
+Valid? trust module
+IntroducedFrom__pred__w_cmp__15__1(w("aaB"), w("aAB"), '=')
+Valid? trust module
Found incorrect contour:
dostuff(w("aaabbb"), '=')
Is this a bug? y
Index: tests/debugger/declarative/trust.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/trust.inp,v
retrieving revision 1.4
diff -u -r1.4 trust.inp
--- tests/debugger/declarative/trust.inp 29 Nov 2004 11:34:35 -0000 1.4
+++ tests/debugger/declarative/trust.inp 30 Dec 2004 03:51:14 -0000
@@ -26,9 +26,14 @@
trusted
untrust 4
untrust 99
+untrust 5
+untrust 6
step
finish
dd
n
+trust
+trust module
+trust module
y
continue
--------------------------------------------------------------------------
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