[m-dev.] source-to-source debugger proposal
Peter Wang
novalazy at gmail.com
Fri Sep 28 17:45:13 AEST 2007
As requested by Julien.
The idea is to implement a four port debugger by doing a
source-to-source transformation on the HLDS. For the usual member
predicate, we would transform it to something roughly like the
following:
:- pred mem(T, list(T)).
:- mode mem(out, in) is nondet.
mem(E, L) :-
GetVarsA = (pred(Vars::out) is det :-
Vars = [
"E" - unbound,
"L" - bound(univ(L))
]
),
(
impure handle_event(event_call, ... ),
member(E0, L), % body of member
(
GetVarsB = (pred(Vars::out) is det :-
Vars = [
"E" - bound(univ(E0)),
"L" - bound(univ(L))
]
),
...
impure handle_event(event_exit, ... , allow_retry, RetryB),
(
RetryB = yes,
mem(E, L)
;
RetryB = no,
E = E0
)
;
impure handle_event(event_redo, ... ),
fail
)
;
impure handle_event(event_fail, ... , allow_retry, Retry),
(
Retry = yes,
mem(E, L)
;
Retry = no,
fail
)
).
The handle_event calls would conditionally stop the program execution
and give the user a debugger prompt. At exit and fail ports the user
can hit retry, causing the procedure to be reexecuted.
The GetVars closures are to be stored in a shadow stack (the maintenance
of which I did not show). Then the user can print out and browse the
variables in each stack frame.
Ian also has an idea that the handle_event predicate can be overriden
to implement other tools.
Peter
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions: mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the developers
mailing list