[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

sbcl tracing methods

Jim Newton

4/25/2016 11:22:00 AM

If I trace a generic function in sbcl, the trace output contains the printed representation
of the arguments, and also the generic function name. But I don't see a way (from the trace output)
to figure out which methods are actually being called.

I've gone through my program, and inserted format calls into each of the methods I'm interested
int to print out the specializer names of the arguments. But it seems there ought to be an
easier way.

Can anyone make a suggestion?

13 Answers

Mirko

4/25/2016 1:31:00 PM

0

On Monday, April 25, 2016 at 7:21:38 AM UTC-4, Jim Newton wrote:
> If I trace a generic function in sbcl, the trace output contains the printed representation
> of the arguments, and also the generic function name. But I don't see a way (from the trace output)
> to figure out which methods are actually being called.
>
> I've gone through my program, and inserted format calls into each of the methods I'm interested
> int to print out the specializer names of the arguments. But it seems there ought to be an
> easier way.
>
> Can anyone make a suggestion?

I find the same situation in CCL (and used the same approach that you did). I assume that is because the methods are combined into an effective method.

There may be a compilation option. But I did not look into that.

Mirko

Teemu Likonen

4/25/2016 3:19:00 PM

0

Jim Newton [2016-04-25 04:21:33-07] wrote:

> I've gone through my program, and inserted format calls into each of
> the methods I'm interested int to print out the specializer names of
> the arguments. But it seems there ought to be an easier way.

Maybe just one :AROUND method for some generic class helps. It could
print (type-of ...) or (class-of ...) of its arguments and call
(call-next-method).

--
/// Teemu Likonen - .-.. <https://github.com/tl... //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///

Pascal J. Bourguignon

4/25/2016 9:33:00 PM

0

Jim Newton <jimka.issy@gmail.com> writes:

> If I trace a generic function in sbcl, the trace output contains the printed representation
> of the arguments, and also the generic function name. But I don't see a way (from the trace output)
> to figure out which methods are actually being called.
>
> I've gone through my program, and inserted format calls into each of the methods I'm interested
> int to print out the specializer names of the arguments. But it seems there ought to be an
> easier way.
>
> Can anyone make a suggestion?

You could use cl-stepper.

It displays the methods specialized on C for the generic function MOO as
"function (moo c)".


(defpackage "EXAMPLE-CL-STEPPER-METHODS"
(:use "CL-STEPPER"))
(in-package "EXAMPLE-CL-STEPPER-METHODS")

(defgeneric moo (o))

(defclass a ()
())
(defclass b (a)
())
(defclass c (b)
())

(defmethod moo ((o a)) 'a)
(defmethod moo ((o b)) (cons 'b (call-next-method)))
(defmethod moo ((o c)) (cons 'c (call-next-method)))

(step (moo (make-instance 'c)) :trace)

(Will evaluate (moo (make-instance 'c))
(Will evaluate (make-instance 'c)
Evaluation of (make-instance 'c) returned one result ==> #<c #x3020022C069D>)
(Entering function (moo c)
(Bind o to #<c #x3020022C069D>)
(Will evaluate (cons 'c (call-next-method))
(Will evaluate (call-next-method)
(Entering function (moo b)
(Bind o to #<c #x3020022C069D>)
(Will evaluate (cons 'b (call-next-method))
(Will evaluate (call-next-method)
(Entering function (moo a)
(Bind o to #<c #x3020022C069D>)
Exiting function (moo a) returned one result ==> a)
Evaluation of (call-next-method) returned one result ==> a)
Evaluation of (cons 'b (call-next-method)) returned one result ==> (b . a))
Exiting function (moo b) returned one result ==> (b . a))
Evaluation of (call-next-method) returned one result ==> (b . a))
Evaluation of (cons 'c (call-next-method)) returned one result ==> (c b . a))
Exiting function (moo c) returned one result ==> (c b . a))
Evaluation of (moo (make-instance 'c)) returned one result ==> (c b . a))

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Jim Newton

4/26/2016 8:07:00 AM

0



> Maybe just one :AROUND method for some generic class helps. It could
> print (type-of ...) or (class-of ...) of its arguments and call
> (call-next-method).


Hi Teemu, is that different than the information provided in the trace output?

Jim Newton

4/26/2016 8:09:00 AM

0


>
> You could use cl-stepper.
>



HI Pascal, will cl-stepper help me if i'm not calling the function from the repl. My
function in question is called quite deep in the calling hierarchy of a GUI application.

Pascal J. Bourguignon

4/26/2016 6:02:00 PM

0

Jim Newton <jimka.issy@gmail.com> writes:

>>
>> You could use cl-stepper.
>>
>
>
>
> HI Pascal, will cl-stepper help me if i'm not calling the function
> from the repl. My function in question is called quite deep in the
> calling hierarchy of a GUI application.

Yes. What matters for cl-stepper, is that you compile the function with
using the CL-STEPPER package instead of the CL package.

CL-stepper can trace and step into any CL code that you can edit (change
CL to CL-STEPPER) and re-compile. (It is a "source level"
tracer/stepper, (and it could be made into a "source level" debugger)).

Code that is not compiled with cl-stepper will appear like a primitive,
or as you you stepped over it.



--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Jim Newton

4/27/2016 9:44:00 AM

0

Where can I get it cl-stepper?

Norbert_Paul

4/27/2016 10:22:00 AM

0

Jim Newton wrote:
> Where can I get it cl-stepper?
https://www.google.de/search?q=...
as a first guess

Jim Newton

4/27/2016 2:55:00 PM

0

On Wednesday, April 27, 2016 at 12:22:28 PM UTC+2, Norbert_Paul wrote:
> Jim Newton wrote:
> > Where can I get it cl-stepper?
> https://www.google.de/search?q=...
> as a first guess

Yes it's a good first guess. But perhaps Pascal can suggest the correct guess?

Pascal J. Bourguignon

4/27/2016 6:01:00 PM

0

Jim Newton <jimka.issy@gmail.com> writes:

> Where can I get it cl-stepper?

From quicklisp:

(ql:quickload :com.informatimago.common-lisp.lisp.stepper)
(defpackage "TEST-CL-STEPPER"
(:use "CL-STEPPER"))
(in-package "TEST-CL-STEPPER")
(defun fact (x) (if (< x 1) 1 (* x (fact (- x 1)))))
(step (fact 4) :trace)

==>

;Compiler warnings :
; In #1=an anonymous lambda form#2= inside #1##2##1##2##1##2#fact: Undefined function fact
(Will evaluate (fact 4)
(Entering function fact
(Bind x to 4)
(Will evaluate (if (< x 1) 1 (* x (fact #)))
(Will evaluate (< x 1)
(x ==> 4)
Evaluation of (< x 1) returned one result ==> nil)
(Will evaluate (* x (fact (- x 1)))
(x ==> 4)
(Will evaluate (fact (- x 1))
(Will evaluate (- x 1)
(x ==> 4)
Evaluation of (- x 1) returned one result ==> 3)
(Entering function fact
(Bind x to 3)
(Will evaluate (if (< x 1) 1 (* x (fact #)))
(Will evaluate (< x 1)
(x ==> 3)
Evaluation of (< x 1) returned one result ==> nil)
(Will evaluate (* x (fact (- x 1)))
(x ==> 3)
(Will evaluate (fact (- x 1))
(Will evaluate (- x 1)
(x ==> 3)
Evaluation of (- x 1) returned one result ==> 2)
(Entering function fact
(Bind x to 2)
(Will evaluate (if (< x 1) 1 (* x (fact #)))
(Will evaluate (< x 1)
(x ==> 2)
Evaluation of (< x 1) returned one result ==> nil)
(Will evaluate (* x (fact (- x 1)))
(x ==> 2)
(Will evaluate (fact (- x 1))
(Will evaluate (- x 1)
(x ==> 2)
Evaluation of (- x 1) returned one result ==> 1)
(Entering function fact
(Bind x to 1)
(Will evaluate (if (< x 1) 1 (* x (fact #)))
(Will evaluate (< x 1)
(x ==> 1)
Evaluation of (< x 1) returned one result ==> nil)
(Will evaluate (* x (fact (- x 1)))
(x ==> 1)
(Will evaluate (fact (- x 1))
(Will evaluate (- x 1)
(x ==> 1)
Evaluation of (- x 1) returned one result ==> 0)
(Entering function fact
(Bind x to 0)
(Will evaluate (if (< x 1) 1 (* x (fact #)))
(Will evaluate (< x 1)
(x ==> 0)
Evaluation of (< x 1) returned one result ==> t)
Evaluation of (if (< x 1) 1 (* x (fact #))) returned one result ==> 1)
Exiting function fact returned one result ==> 1)
Evaluation of (fact (- x 1)) returned one result ==> 1)
Evaluation of (* x (fact (- x 1))) returned one result ==> 1)
Evaluation of (if (< x 1) 1 (* x (fact #))) returned one result ==> 1)
Exiting function fact returned one result ==> 1)
Evaluation of (fact (- x 1)) returned one result ==> 1)
Evaluation of (* x (fact (- x 1))) returned one result ==> 2)
Evaluation of (if (< x 1) 1 (* x (fact #))) returned one result ==> 2)
Exiting function fact returned one result ==> 2)
Evaluation of (fact (- x 1)) returned one result ==> 2)
Evaluation of (* x (fact (- x 1))) returned one result ==> 6)
Evaluation of (if (< x 1) 1 (* x (fact #))) returned one result ==> 6)
Exiting function fact returned one result ==> 6)
Evaluation of (fact (- x 1)) returned one result ==> 6)
Evaluation of (* x (fact (- x 1))) returned one result ==> 24)
Evaluation of (if (< x 1) 1 (* x (fact #))) returned one result ==> 24)
Exiting function fact returned one result ==> 24)
Evaluation of (fact 4) returned one result ==> 24)
24

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk