Lisp HUG Maillist Archive

Getting a backtrace programmatically.

Is there any way of getting LW to print a backtrace programmatically?
I found dbg:bug-backtrace, but this seems to only print anything if
you're actually in the debugger.  What I want to be able to do is
something like:

    (handler-bind
       ((error #'(lambda (e)
                   ...print backtrace but do not transfer control...)))
     ...forms...)

So I can cause it to print a backtrace without interfering with other
handlers.

--tim


Re: Getting a backtrace programmatically.

Tim Bradshaw <tfb@cley.com> writes:

> Is there any way of getting LW to print a backtrace programmatically?
> I found dbg:bug-backtrace, but this seems to only print anything if
> you're actually in the debugger.  What I want to be able to do is
> something like:
> 
>     (handler-bind
>        ((error #'(lambda (e)
>                    ...print backtrace but do not transfer control...)))
>      ...forms...)
> 
> So I can cause it to print a backtrace without interfering with other
> handlers.

yes, insert something like this into your lambda:

  (mp:map-process-backtrace 
   mp:*current-process*
   (lambda(x)(print x)(terpri)))

-- 
  (espen)


Re: Getting a backtrace programmatically.

"Marc Battyani" <marc.battyani@fractalconcept.com> writes:

> Where do you find all these functions ? Do you play with apropos,
> function-lamba-list, etc. or is there a manual I should read ?

The process-backtrace stuff is actually in the manual (MP chapter
of the reference manual).

-- 
  (espen)


Updated at: 2020-12-10 09:02 UTC