From: Damien CASSOU
Subject: trace does not work has expected
Date: 
Message-ID: <422615d8$0$19346$8fcfb975@news.wanadoo.fr>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I can't made the trace function work properly :

| lisp
CMU Common Lisp CVS release-19a 19a-release-20040728 + minimal debian
patches, running on localhost
With core: /usr/lib/cmucl/lisp.core
Dumped on: Sun, 2005-01-30 21:22:21+01:00 on localhost
For support see http://www.cons.org/cmucl/support.html Send bug reports
to the debian BTS.
or to ········@debian.org
type (help) for help, (quit) to exit, and (demo) to see the demos

Loaded subsystems:
~    Python 1.1, target Intel x86
~    CLOS based on Gerd's PCL 2004/04/14 03:32:47
* (defun factorial (x)
~    (if (zerop x)
~        1
~        (* x (factorial (1- x)))))

FACTORIAL
* (trace factorial)

(FACTORIAL)
* (factorial 5)

~  0: (FACTORIAL 5)
~  0: FACTORIAL returned 120
120




As you can see, trace does not trace all the call but just the first. I
have tried :encapsulate but without success :



* (trace factorial :encapsulate t)
Warning:  Function FACTORIAL already TRACE'd, retracing it.

(FACTORIAL)
* (factorial 5)

~  0: (FACTORIAL 5)
~  0: FACTORIAL returned 120
120
* (trace factorial :encapsulate nil)
Warning:  Function FACTORIAL already TRACE'd, retracing it.



Error in function DEBUG-INTERNALS:MAKE-BREAKPOINT:
~   :function-end breakpoints are currently unsupported for
interpreted-debug-functions.
~   [Condition of type SIMPLE-ERROR]

Restarts:
~  0: [ABORT] Return to Top-Level.

Debug  (type H for help)

(DEBUG-INTERNALS:MAKE-BREAKPOINT
~ #<Closure Over Function "DEFUN TRACE-START-BREAKPOINT-FUN" {5805A829}>
~ #<Interpreted-Debug-Function FACTORIAL>
~ :KIND
~ :FUNCTION-START
~ ...)
Source:
; File: target:code/debug-int.lisp
(ERROR ":function-end breakpoints are currently unsupported ~
~             for interpreted-debug-functions.")
0] q

* (trace factorial :encapsulate :default)

(FACTORIAL)
* (factorial 5)

~  0: (FACTORIAL 5)
~  0: FACTORIAL returned 120
120


Have you an opinion ?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCJhXYyl2oT75/6woRAr42AJ9so4CAGV6PSHYiOAuLtUuSabRuYwCeNXcE
cdQEW8/mNVwWD5La+Rhb5WQ=
=T7xc
-----END PGP SIGNATURE-----

From: Thomas A. Russ
Subject: Re: trace does not work has expected
Date: 
Message-ID: <ymi3bvd2276.fsf@sevak.isi.edu>
Damien CASSOU <·············@laposte.net> writes:

> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> I can't made the trace function work properly :

Your efforts are being subverted by the compiler optimizations.
Unfortunately, these effects can vary by implementation.

> FACTORIAL
> * (trace factorial)
> 
> (FACTORIAL)
> * (factorial 5)
> 
> ~  0: (FACTORIAL 5)
> ~  0: FACTORIAL returned 120
> 120

A couple things you can try:

(declaim (optimize (debug 3) (speed 0)))

If that doesn't work, then perhaps you will need to add a NOTINLINE
declaration to your factorial function:

(defun factorial (n)
  (declare (notinline factorial))
  ...
  )



-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Raymond Toy
Subject: Re: trace does not work has expected
Date: 
Message-ID: <sxd7jkpvike.fsf@rtp.ericsson.se>
>>>>> "Damien" == Damien CASSOU <·············@laposte.net> writes:

    Damien> Hi,

    Damien> I can't made the trace function work properly :

[snip]

    Damien> * (defun factorial (x)
    Damien> ~    (if (zerop x)
    Damien> ~        1
    Damien> ~        (* x (factorial (1- x)))))

    Damien> FACTORIAL
    Damien> * (trace factorial)

    Damien> (FACTORIAL)
    Damien> * (factorial 5)

    Damien> ~  0: (FACTORIAL 5)
    Damien> ~  0: FACTORIAL returned 120
    Damien> 120

Look at the article written by Rob Warnock in comp.lang.lisp,
2005-02-15.  He has a nice explanation on what's happening.

Yes, I would consider this a bug in cmucl, but I'm not sure how to fix
it.

Ray
From: William Bland
Subject: Re: trace does not work has expected
Date: 
Message-ID: <pan.2005.03.02.19.42.55.659008@abstractnonsense.com>
On Wed, 02 Mar 2005 20:36:56 +0100, Damien CASSOU wrote:

> 
> Hi,
> 
> I can't made the trace function work properly :
> 

SBCL 0.8.18, running on Gentoo Linux:

; SLIME 2004-10-07
CL-USER> (defun factorial(x) (if (zerop x) 1 (* x (factorial (1- x)))))
FACTORIAL
CL-USER> (factorial 5)
120
CL-USER> (trace factorial)
(FACTORIAL)
CL-USER> (factorial 5)
  0: (FACTORIAL 5)
    1: (FACTORIAL 4)
      2: (FACTORIAL 3)
        3: (FACTORIAL 2)
          4: (FACTORIAL 1)
            5: (FACTORIAL 0)
            5: FACTORIAL returned 1
          4: FACTORIAL returned 1
        3: FACTORIAL returned 2
      2: FACTORIAL returned 6
    1: FACTORIAL returned 24
  0: FACTORIAL returned 120
120
CL-USER> 

Best wishes,
		Bill.
From: Damien CASSOU
Subject: Re: trace does not work has expected
Date: 
Message-ID: <42298fd3$0$828$8fcfb975@news.wanadoo.fr>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It seems to be an optimisation of cmucl. To debug a function, here is a
walkthrough :

* (defun factorial (x)
~    (declare (inline factorial))        ; function must be inlined
~    (if (zerop x)
~        1
~        (* x (factorial (1- x)))))

FACTORIAL
* (compile 'factorial)                  ; must be compiled
; Compiling LAMBDA (X):
; Compiling Top-Level Form:

FACTORIAL
NIL
NIL
* (trace factorial)                     ; has to be traced

(FACTORIAL)
* (factorial 5)

~  0: (FACTORIAL 5)
~    1: (FACTORIAL 4)
~      2: (FACTORIAL 3)
~        3: (FACTORIAL 2)
~          4: (FACTORIAL 1)
~            5: (FACTORIAL 0)
~            5: FACTORIAL returned 1     ; and it works
~          4: FACTORIAL returned 1
~        3: FACTORIAL returned 2
~      2: FACTORIAL returned 6
~    1: FACTORIAL returned 24
~  0: FACTORIAL returned 120
120
*

Thanks to those who have tried to help me and pointed me to the good
documentations (particularly Raymond Toy)

thanks
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCKY/Tyl2oT75/6woRArinAJ49kngHESldY4GwBc+0SOIctdONuQCdFxMF
1r1+V8ibcp14cwLfRPod0IQ=
=r9qJ
-----END PGP SIGNATURE-----