How to use trace without stepping through and how to set breakpoints

281 views
Skip to first unread message

mar...@wunderlich.com

unread,
Jul 16, 2014, 5:03:43 PM7/16/14
to swi-p...@googlegroups.com
Hi all,

This is my first posting to the list, so please bear with me in case these questions seem trivial. I have several years experience in software development, but I am just getting started with Prolog. Currently, I am working my way through an existing project that implements modell theoretic semantics. Two questions have come up (so far):

1. To understand how the code works, I would like to be able to trace Prolog's execution, but without having to actually step through every single line. Is there a way to just get the output of trace withough stepping through? I would have thought the debug command does that, but I get no trace output.

2. Is there a way to set a breakpoint in the DCG files? That is, can I somehow mark a DCG rule in such a way that prolog will pause execution at that point and (preferably) switch into trace mode? This would be very helpful to skip over the irrelevant portions of the PL files and the DCG.

I am using SWI Prolog 6.6.5 on Mac OS 10.8.5. (I also tried to use the Eclipse plugin PDT, but the console view didn't work for me).

Thanks a lot in advance.

Cheers,

Martin

m00nlight

unread,
Jul 16, 2014, 10:52:42 PM7/16/14
to mar...@wunderlich.com, swi-p...@googlegroups.com
Hi Martin,

You can use SWI-Prolog guitrace command to invoke the GUI tracer, which can set break point.
Just in the SWI-Prolog prompt type in guitrace. The trace the program you want to debug as
usual, you will see a GUI window, which you can set breakpoint as the picture below. Then you
can just run the program to the position of the breakpoint.




--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Visit this group at http://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.



--m00nlight

m00nlight

unread,
Jul 16, 2014, 10:57:22 PM7/16/14
to mar...@wunderlich.com, swi-p...@googlegroups.com
Hi Martin,

Sorry the previous email does not contain the paste picture, the attachment is the
screen shot of the gui trace.
--
--m00nlight
guitrace.png

Michael Hendricks

unread,
Jul 17, 2014, 9:18:57 AM7/17/14
to mar...@wunderlich.com, swi-p...@googlegroups.com
On Wed, Jul 16, 2014 at 3:03 PM, <mar...@wunderlich.com> wrote:
2. Is there a way to set a breakpoint in the DCG files? That is, can I somehow mark a DCG rule in such a way that prolog will pause execution at that point and (preferably) switch into trace mode? This would be very helpful to skip over the irrelevant portions of the PL files and the DCG.

After running guitracer/0 (I have it enabled in ~/.plrc), then you can insert the trace/0 goal in your program where you want it to pause execution and begin tracing.  For example:

foo -->
    thing,
    stuff,
    { trace },  % tracing only starts once reaching here
    part_that_needs_tracing.

-- 
Michael
Reply all
Reply to author
Forward
0 new messages