[m-dev.] for review: new ports for the declarative debugger
Zoltan Somogyi
zs at cs.mu.OZ.AU
Tue Sep 14 11:50:38 AEST 1999
For review by Mark.
Add four new ports: entering the condition of an if-then-else, entering a
negation, and leaving a negation via success or failure. If --trace-decl
is enabled, generate these events, which the declarative debugger needs
in order to properly delimit negated contexts (which should cause a switch
from wrong answer to missing answer diagnosis and vice versa).
compiler/llds.m:
runtime/mercury_trace_base.h:
browser/debugger_interface.m:
Add the new event types.
compiler/llds_out.m:
Print the new event types.
compiler/trace.m:
Provide predicates to generate code for the new events if --trace-decl
is set.
Separate out the code for dealing with the trace_info data type.
compiler/ite_gen.m:
Call trace.m to (conditionally) generate code for the new events.
trace/mercury_trace_internal.c:
Print the names of the new ports when events of those types happen.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
Index: browser/debugger_interface.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/debugger_interface.m,v
retrieving revision 1.10
diff -u -b -r1.10 debugger_interface.m
--- debugger_interface.m 1999/05/21 14:38:19 1.10
+++ debugger_interface.m 1999/09/13 06:35:07
@@ -55,8 +55,12 @@
; exit
; redo
; fail
+ ; ite_cond
; ite_then
; ite_else
+ ; neg_enter
+ ; neg_success
+ ; neg_failure
; disj
; switch
; nondet_pragma_first
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/ite_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ite_gen.m,v
retrieving revision 1.62
diff -u -b -r1.62 ite_gen.m
--- ite_gen.m 1999/07/10 07:19:51 1.62
+++ ite_gen.m 1999/09/13 07:04:56
@@ -102,6 +102,7 @@
EffectResumeCode),
% Generate the condition
+ trace__maybe_generate_internal_event_code(CondGoal, CondTraceCode),
code_gen__generate_goal(CondCodeModel, CondGoal, CondCode),
code_info__ite_enter_then(HijackInfo, ThenNeckCode, ElseNeckCode),
@@ -171,6 +172,7 @@
tree(SaveTicketCode,
tree(PrepareHijackCode,
tree(EffectResumeCode,
+ tree(CondTraceCode,
tree(CondCode,
tree(ThenNeckCode,
tree(DiscardTicketCode,
@@ -185,7 +187,7 @@
tree(ElseTraceCode,
tree(ElseCode,
tree(ElseSaveCode,
- EndLabelCode)))))))))))))))))))
+ EndLabelCode))))))))))))))))))))
},
code_info__after_all_branches(StoreMap, MaybeEnd).
@@ -290,6 +292,7 @@
% Generate the negated goal as a semi-deterministic goal;
% it cannot be nondet, since mode correctness requires it
% to have no output vars.
+ trace__maybe_generate_internal_event_code(Goal, EnterTraceCode),
code_gen__generate_goal(model_semi, Goal, GoalCode),
code_info__ite_enter_then(HijackInfo, ThenNeckCode, ElseNeckCode),
@@ -303,6 +306,7 @@
( { CodeModel = model_det } ->
% the then branch will never be reached
{ DiscardTicketCode = empty },
+ { FailTraceCode = empty },
{ FailCode = empty }
;
code_info__remember_position(AfterNegatedGoal),
@@ -311,6 +315,8 @@
code_info__maybe_release_hp(MaybeHpSlot),
code_info__maybe_reset_discard_and_release_ticket(
MaybeTicketSlot, commit, DiscardTicketCode),
+ trace__maybe_generate_negated_event_code(Goal, neg_failure,
+ FailTraceCode),
code_info__generate_failure(FailCode),
% We want liveness after not(G) to be the same as
% after G. Information about what variables are where
@@ -327,6 +333,8 @@
code_info__maybe_restore_and_release_hp(MaybeHpSlot, RestoreHpCode),
code_info__maybe_reset_discard_and_release_ticket(
MaybeTicketSlot, undo, RestoreTicketCode),
+ trace__maybe_generate_negated_event_code(Goal, neg_success,
+ SuccessTraceCode),
{ Code =
tree(FlushCode,
@@ -334,14 +342,18 @@
tree(EffectResumeCode,
tree(SaveHpCode,
tree(SaveTicketCode,
+ tree(EnterTraceCode,
tree(GoalCode,
tree(ThenNeckCode,
tree(DiscardTicketCode,
+ tree(DiscardTicketCode,
+ tree(FailTraceCode,
tree(FailCode,
tree(ResumeCode,
tree(ElseNeckCode,
tree(RestoreTicketCode,
- RestoreHpCode))))))))))))
+ tree(RestoreHpCode,
+ SuccessTraceCode))))))))))))))))
}.
%---------------------------------------------------------------------------%
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.248
diff -u -b -r1.248 llds.m
--- llds.m 1999/08/24 08:51:59 1.248
+++ llds.m 1999/09/13 06:34:28
@@ -500,8 +500,12 @@
---> call
; exit
; fail
+ ; ite_cond
; ite_then
; ite_else
+ ; neg_enter
+ ; neg_success
+ ; neg_failure
; switch
; disj
; nondet_pragma_first
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.120
diff -u -b -r1.120 llds_out.m
--- llds_out.m 1999/08/24 08:52:00 1.120
+++ llds_out.m 1999/09/14 01:22:41
@@ -806,8 +806,12 @@
llds_out__trace_port_to_string(call, "MR_PORT_CALL").
llds_out__trace_port_to_string(exit, "MR_PORT_EXIT").
llds_out__trace_port_to_string(fail, "MR_PORT_FAIL").
+llds_out__trace_port_to_string(ite_cond, "MR_PORT_COND").
llds_out__trace_port_to_string(ite_then, "MR_PORT_THEN").
llds_out__trace_port_to_string(ite_else, "MR_PORT_ELSE").
+llds_out__trace_port_to_string(neg_enter, "MR_PORT_NEGENTER").
+llds_out__trace_port_to_string(neg_success, "MR_PORT_NEGSUCCESS").
+llds_out__trace_port_to_string(neg_failure, "MR_PORT_NEGFAILURE").
llds_out__trace_port_to_string(switch, "MR_PORT_SWITCH").
llds_out__trace_port_to_string(disj, "MR_PORT_DISJ").
llds_out__trace_port_to_string(nondet_pragma_first, "MR_PORT_PRAGMA_FIRST").
Index: compiler/trace.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.22
diff -u -b -r1.22 trace.m
--- trace.m 1999/08/24 08:52:06 1.22
+++ trace.m 1999/09/13 06:29:27
@@ -60,6 +60,10 @@
; exit
; fail.
+:- type negation_trace_port
+ ---> neg_success
+ ; neg_failure.
+
:- type nondet_pragma_trace_port
---> nondet_pragma_first
; nondet_pragma_later.
@@ -117,6 +121,12 @@
:- pred trace__maybe_generate_internal_event_code(hlds_goal::in,
code_tree::out, code_info::in, code_info::out) is det.
+ % If we are doing execution tracing, generate code for an trace event
+ % that represents leaving a negated goal (via success or failure).
+:- pred trace__maybe_generate_negated_event_code(hlds_goal::in,
+ negation_trace_port::in, code_tree::out,
+ code_info::in, code_info::out) is det.
+
% If we are doing execution tracing, generate code for a nondet
% pragma C code trace event.
:- pred trace__maybe_generate_pragma_event_code(nondet_pragma_trace_port::in,
@@ -155,6 +165,11 @@
% this port represents.
set(prog_var) % The pre-death set of this goal.
)
+ ; negation_end(
+ goal_path % The path of the goal whose end
+ % (one way or another) this port
+ % represents.
+ )
; nondet_pragma.
:- type trace_type
@@ -163,26 +178,6 @@
% that is true iff we were called from
% code with full tracing.
- % Information for tracing that is valid throughout the execution
- % of a procedure.
-:- type trace_info
- ---> trace_info(
- trace_type, % The trace level (which cannot be
- % none), and if it is shallow, the
- % lval of the slot that holds the
- % from-full flag.
- bool, % The value of --trace-internal.
- bool, % The value of --trace-return.
- maybe(label) % If we are generating redo events,
- % this has the label associated with
- % the fail event, which we then reserve
- % in advance, so we can put the
- % address of its layout struct
- % into the slot which holds the
- % layout for the redo event (the
- % two events have identical layouts).
- ).
-
trace__fail_vars(ModuleInfo, ProcInfo, FailVars) :-
proc_info_headvars(ProcInfo, HeadVars),
proc_info_argmodes(ProcInfo, Modes),
@@ -271,7 +266,7 @@
trace__setup(Globals, TraceSlotInfo, TraceInfo) -->
code_info__get_proc_model(CodeModel),
- { globals__lookup_bool_option(Globals, trace_return, TraceReturn) },
+ { globals__lookup_bool_option(Globals, trace_decl, TraceDecl) },
{ globals__lookup_bool_option(Globals, trace_redo, TraceRedo) },
(
{ TraceRedo = yes },
@@ -309,13 +304,14 @@
MaybeDeclSlots = no
},
{ TraceSlotInfo = trace_slot_info(MaybeFromFullSlot, MaybeDeclSlots) },
- { TraceInfo = trace_info(TraceType, TraceInternal, TraceReturn,
- MaybeRedoLayout) }.
+ { init_trace_info(TraceType, TraceInternal, TraceDecl,
+ MaybeRedoLayout, TraceInfo) }.
trace__generate_slot_fill_code(TraceInfo, TraceCode) -->
code_info__get_proc_model(CodeModel),
{
- TraceInfo = trace_info(TraceType, _, _, MaybeRedoLayoutSlot),
+ trace_info_get_trace_type(TraceInfo, TraceType),
+ trace_info_get_maybe_redo_layout_slot(TraceInfo, MaybeRedoLayoutSlot),
trace__event_num_slot(CodeModel, EventNumLval),
trace__call_num_slot(CodeModel, CallNumLval),
trace__call_depth_slot(CodeModel, CallDepthLval),
@@ -368,7 +364,7 @@
{
MaybeTraceInfo = yes(TraceInfo)
->
- TraceInfo = trace_info(TraceType, _, _, _),
+ trace_info_get_trace_type(TraceInfo, TraceType),
trace__call_depth_slot(CodeModel, CallDepthLval),
trace__stackref_to_string(CallDepthLval, CallDepthStr),
string__append_list([
@@ -393,11 +389,10 @@
code_info__get_maybe_trace_info(MaybeTraceInfo),
(
{ MaybeTraceInfo = yes(TraceInfo) },
- { TraceInfo = trace_info(_, yes, _, _) }
+ { trace_info_get_trace_internal(TraceInfo, yes) }
->
{ Goal = _ - GoalInfo },
{ goal_info_get_goal_path(GoalInfo, Path) },
- { goal_info_get_pre_deaths(GoalInfo, PreDeaths) },
{
Path = [LastStep | _],
(
@@ -407,18 +402,55 @@
LastStep = disj(_),
PortPrime = disj
;
+ LastStep = ite_cond,
+ PortPrime = ite_cond
+ ;
LastStep = ite_then,
PortPrime = ite_then
;
LastStep = ite_else,
PortPrime = ite_else
+ ;
+ LastStep = neg,
+ PortPrime = neg_enter
)
->
Port = PortPrime
;
error("trace__generate_internal_event_code: bad path")
},
- trace__generate_event_code(Port, internal(Path, PreDeaths),
+ (
+ { ( Port = ite_cond ; Port = neg_enter ) },
+ { trace_info_get_trace_decl(TraceInfo, no) }
+ ->
+ { Code = empty }
+ ;
+ { goal_info_get_pre_deaths(GoalInfo, PreDeaths) },
+ trace__generate_event_code(Port,
+ internal(Path, PreDeaths), TraceInfo,
+ _, _, Code)
+ )
+ ;
+ { Code = empty }
+ ).
+
+trace__maybe_generate_negated_event_code(Goal, NegPort, Code) -->
+ code_info__get_maybe_trace_info(MaybeTraceInfo),
+ (
+ { MaybeTraceInfo = yes(TraceInfo) },
+ { trace_info_get_trace_internal(TraceInfo, yes) },
+ { trace_info_get_trace_decl(TraceInfo, yes) }
+ ->
+ {
+ NegPort = neg_failure,
+ Port = neg_failure
+ ;
+ NegPort = neg_success,
+ Port = neg_success
+ },
+ { Goal = _ - GoalInfo },
+ { goal_info_get_goal_path(GoalInfo, Path) },
+ trace__generate_event_code(Port, negation_end(Path),
TraceInfo, _, _, Code)
;
{ Code = empty }
@@ -480,6 +512,10 @@
{ list__delete_elems(LiveVars0, RealPreDeathList, LiveVars) },
{ trace__path_to_string(Path, PathStr) }
;
+ { PortInfo = negation_end(Path) },
+ { LiveVars = LiveVars0 },
+ { trace__path_to_string(Path, PathStr) }
+ ;
{ PortInfo = nondet_pragma },
{ LiveVars = [] },
{ PathStr = "" }
@@ -740,3 +776,43 @@
).
%-----------------------------------------------------------------------------%
+
+ % Information for tracing that is valid throughout the execution
+ % of a procedure.
+:- type trace_info
+ ---> trace_info(
+ trace_type, % The trace level (which cannot be
+ % none), and if it is shallow, the
+ % lval of the slot that holds the
+ % from-full flag.
+ bool, % The value of --trace-internal.
+ bool, % The value of --trace-decl.
+ maybe(label) % If we are generating redo events,
+ % this has the label associated with
+ % the fail event, which we then reserve
+ % in advance, so we can put the
+ % address of its layout struct
+ % into the slot which holds the
+ % layout for the redo event (the
+ % two events have identical layouts).
+ ).
+
+:- pred init_trace_info(trace_type::in, bool::in, bool::in, maybe(label)::in,
+ trace_info::out) is det.
+
+:- pred trace_info_get_trace_type(trace_info::in, trace_type::out) is det.
+:- pred trace_info_get_trace_internal(trace_info::in, bool::out) is det.
+:- pred trace_info_get_trace_decl(trace_info::in, bool::out) is det.
+:- pred trace_info_get_maybe_redo_layout_slot(trace_info::in,
+ maybe(label)::out) is det.
+
+init_trace_info(TraceType, TraceInternal, TraceDecl,
+ MaybeRedoLayoutSlot,
+ trace_info(TraceType, TraceInternal, TraceDecl, MaybeRedoLayoutSlot)).
+
+trace_info_get_trace_type(trace_info(TraceType, _, _, _), TraceType).
+trace_info_get_trace_internal(trace_info(_, TraceInternal, _, _),
+ TraceInternal).
+trace_info_get_trace_decl(trace_info(_, _, TraceDecl, _), TraceDecl).
+trace_info_get_maybe_redo_layout_slot(trace_info(_, _, _, MaybeRedoLayoutSlot),
+ MaybeRedoLayoutSlot).
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/mercury_trace_base.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.h,v
retrieving revision 1.7
diff -u -b -r1.7 mercury_trace_base.h
--- mercury_trace_base.h 1999/05/14 02:25:07 1.7
+++ mercury_trace_base.h 1999/09/13 06:35:09
@@ -29,8 +29,12 @@
MR_PORT_EXIT,
MR_PORT_REDO,
MR_PORT_FAIL,
+ MR_PORT_COND,
MR_PORT_THEN,
MR_PORT_ELSE,
+ MR_PORT_NEGENTER,
+ MR_PORT_NEGSUCCESS, /* negated goal failed; negation succeeds */
+ MR_PORT_NEGFAILURE, /* negated goal succeeded; negation fails */
MR_PORT_DISJ,
MR_PORT_SWITCH,
MR_PORT_PRAGMA_FIRST,
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing trace
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.50
diff -u -b -r1.50 mercury_trace_internal.c
--- mercury_trace_internal.c 1999/08/16 05:35:27 1.50
+++ mercury_trace_internal.c 1999/09/13 07:11:45
@@ -2183,12 +2183,28 @@
port_name = "FAIL";
break;
+ case MR_PORT_COND:
+ port_name = "COND";
+ break;
+
case MR_PORT_THEN:
port_name = "THEN";
break;
case MR_PORT_ELSE:
port_name = "ELSE";
+ break;
+
+ case MR_PORT_NEGENTER:
+ port_name = "NENT";
+ break;
+
+ case MR_PORT_NEGSUCCESS:
+ port_name = "NSUC";
+ break;
+
+ case MR_PORT_NEGFAILURE:
+ port_name = "NFAI";
break;
case MR_PORT_DISJ:
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list