Subject: [clisp-list] How to dump a backtrace to a log file

From: "Thomas F. Burdick" <[email-masked]>
Date: Fri Oct 10 14:25:05 2003

Is this possible?  When running clisp (2.70) as a she-bang script
interpreter, I'd like to be able to print any errors to a log file,
followed by a :bt5 backtrace.  The first part's easy.  Before I go
converting my code to use tfblisp:defun, does anyone have a better
idea?

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'

---

From: "John K. Hinsdale" <[email-masked]>
Date: Wed Oct 15 15:57:04 2003

I use this function to capture the call stack as a string.  Then one
can print it, log it to a file, etc.

; GET-STACK-AS-STRING - Get the stack as a string for inclusion error message
(defun get-stack-as-string (&optional (nskip 0))
  ; Skip to first relevant EVAL frame
  (do* ((result (make-string-output-stream))
	(mode 4)
	(frame (system::the-frame) (system::frame-up-1 frame mode))
	(last (system::frame-up frame 5))
	(count 0 (1+ count))
	(at-last nil))
       (at-last (get-output-stream-string result))
       (cond ((< count nskip) )
	     ((= count nskip)
	      (system::describe-frame result frame)
	      (setf mode 5))
	     ((equal frame last)
	      (setf at-last t))
	     (t
	      (system::describe-frame result frame)))))