Re: [eclipse-clp-users] switching debugger on with trace

From: Kish Shen <kish.shen_at_...6...>
Date: Thu, 15 Dec 2022 23:44:49 +0000
Hi Chris,

In ECLiPSe, I don't think you can turn on the debugger and trace the
execution starting from there.
However, you can turn on the debugger for a specific goal by wrapping it
with trace/1 or debug.1. Using your example:

big_goal1,
trace(buggy_goal),
big_goal2.

If the debugger was off when you run the above query, then only buggy_goal
will be traced.
The difference between trace/1 and debug/1 is that the debugger is in creep
mode for trace/1 and will  stop immediately, while debug/1 will only stop
for a predicate with a spy point.

Running goals with the debugger on is much slower than without the
debugger, so using trace/1 and debug/1 avoids the overhead for goals you
are not debugging.
Is this the main reason why you want to trace the execution of buggy_goal?

If instead you are  interested in  tracing a specific call to buggy_goal in
your source code, you can set a breakpoint on it in TkECLiPSe's debugger.,
so that the debugger will stop only at the call port for that specific
call.

I am surprised that your mytrace/0 worked for you. As far as I can tell,
although mytrace/0 will turn on the debugger, the tracing will not start
from there, but only from your next top-level goal. You don't need to use
spy/1 to turn on the debugger - you can use the debugging flag for
set_flag./2, but this will also not start tracing immediately.

--Kish

On Thu, Dec 15, 2022 at 9:42 PM Chris Meudec <Chris.Meudec_at_...438...> wrote:

> I am reacquainting myself with ECLiPSe 7.0 after playing with SICSTUS for
> a while...
>
> I SICSTUS I can insert a call to the predicate 'trace' anywhere in my
> code, and the debugger will awake and waits for my instructions there.
>
> In ECLiPSe, trace seems to be a command, not a predicate, so I cannot do
> the same.
> spy/1 must be applied to a whole predicate so it cannot be used to switch
> the debugger in between predicate calls. set_flag/3 also require a
> predicate
>
> The best I can do to replicate that behaviour (after an hour of
> experimentation!) is to create my own mytrace/0 predicate:
>
> p :- big_goal1, mytrace, buggy_goal, big_goal2.
>
> big_goal1.
> buggy_goal.
> big_goal2.
>
> mytrace.
> :- spy mytrace/0.
>
> This works as expected: the debugger switches itself on and I can creep
> through the rest of the code.
> I could not get debug/1 on its own nor with set_flag/3 to work.
>
>
> Is there a better way?
>
> Thanks,
> Chris
> --
> Dr Chris Meudec <http://www.echancrure.eu/> (he/him) Maitrise, PhD, MA
> (T&L)
> Lecturer in Software Development
> E chris.meudec_at_...438... |  *setu.ie* <https://setu.ie/>
> [image: turn on images] <https://setu.ie/>
>
> Kilkenny Road Campus, Kilkenny Road, Carlow, R93 V960, Ireland
> Campas Bhóthar Chill Chainnigh, Bóthar Chill Chainnigh, Ceatharlach, R93
> V960, Éire
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>
Received on Thu Dec 15 2022 - 23:45:13 CET

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST