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

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Sun, 18 Dec 2022 23:39:42 +0000
Hi Christophe,

After reading Kish's answer, and re-reading your question, I think you are in 
fact looking for the *breakpoint* facility. This allows you to stop the debugger 
at a particular line in the code. The documentation may be a bit brief on that.

The easiest way to set a breakpoint is with TkEclipse's tracer:

  * open the tracer
  * start executing your toplevel goal
  * the tracer will immediately stop at the first CALL
  * in the "Source Context" tab, navigate to the source location where you want
    to stop
  * to the left of the code you see a gutter with grey # symbols -- these are
    the locations where you can set a breakpoint
  * click on the # symbol to enable/disable a breakpoint (enabled ones are red)
  * click Leap to continue execution
  * the tracer will stop at the breakpoint

Tracer with breakpoint


Breakpoints can also be set via the command like, e.g.

?- spy "buggy.ecl":5.
breakpoint added to line 5 of file /homes/jschimpf/Playground/buggy.ecl in 
predicate eclipse : p / 0
Yes (0.00s cpu)


Hope that's what you needed,
-- Joachim


On 15/12/2022 23:44, Kish Shen wrote:
> 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/>
>     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
>
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
Received on Sun Dec 18 2022 - 23:56:28 CET

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