newbie question: debugging technique

From: chenyu (chenyu468_at_yahoo.com)
Date: 02/16/04


Date: 16 Feb 2004 01:03:01 -0800

Hello everyone,
I am writing the "depth-first search" program and found the debugging
is difficult to me when recursion is used and program is a little
long.

%my program:
depthfirst1([Head|CandidatePath],[Head|CandidatePath]):-
        goal(Head),!.
depthfirst1([Head|CandidatePath],Solution):-
        s(Head,Next),
        not(member(Next,[Head|CandidatePath])),
        depthfirst1(CandidatePath,Solution).

s(Queens,[Queen|Queens]):-
        member(Queen,[1,2,3,4,5,6,7,8]),
        noattack(Queen,Queens,1).
goal([_,_,_,_,_,_,_,_]).

solve2(Node,Solution):-
        depthfirst1([Node],Solution).

%my goal
solve2([],X).

My goal always return me "No".
1. Therefore I want to check every time "depthfirst1"'s unify result,
then decide at which level the error happens?
   1.1 Does my debugging logic is correct?
   1.2 Does it mean to trace "unify port" of predicate "depthfirst1"?
   1.3 could I write trace(depthfirst1,+unify),trace,solve2([],X)?

2. What's the difference between trace point and spy point?

Thank you for your attention.
kind regards
chenyu



Relevant Pages

  • Re: Want function or class that uses reflection to iterate over properties in custom object
    ... use a "real" IDE with debugging support. ... > Why don't you use the debugger instead of writing debug code. ... I build and extend a lot of custom objects, ... I've learned that you can do this using reflection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: segmentation fault - code attached
    ... It is used in VLSI for debugging and waveform dump in ... I was writing a library for the format. ... > `struct Var'. ... Artie Gold -- Austin, Texas ...
    (comp.lang.c)
  • Re: ANSI C compliance
    ... > Writing a significant chunk of embedded code. ... > workstation and debugging it there because there were far better tools ... I used some stubs for platform specific functionality. ... C++ Faq: http://www.parashift.com/c++-faq-lite ...
    (comp.lang.c)
  • Re: segmentation fault - code attached
    ... > segmentation fault when executing calloc. ... It is used in VLSI for debugging and waveform dump in ... I was writing a library for the format. ... allocated enough space for a pointer to `struct Var' not an instance of ...
    (comp.lang.c)
  • Re: Gallery Pagination Result Problem
    ... I use Altova XML Spy Home Edition when writing simple XML scripts, and it has the added benefit of validating the XML and pointing out errors against the DTD. ... Is there such a free program for writing PHP that has a good debugging mode or validation? ... And if I'm not using a debugger, I've found strategically placed echo statements do wonders for debugging. ...
    (comp.lang.php)