[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Debugging functions



   Date: Mon, 29 Aug 88 13:10:06 PDT
   From: douglas@Think.COM

      Date: Tue, 23 Aug 88 14:14:56 EDT
      From: salem@Think.COM


	 Here is a functional version of the lucid debugger :L command so you
      can compose expressions using local vars. while inside the debugger.

      Up with functions !  Down with command processors !

      -- jim


      (export '(dbg-arg dbg-loc))

      (defun dbg-arg (index-or-name)
	"This is a LUCID version of the standard Symbolics DBG:ARG and DBG:LOC
      functions.  It is also similar to the lucid debugger `:L' command.  Called
      by a user from inside the debugger, it returns the value of the specified
      local variable for the current stack frame.  The argument is either an
      index number or the name of the local."

   One of the main ways I use (dbg:arg ..) in Symbolics land is to change the
   value of an arg to get a program to continue.  For example, 
	   (setf (dbg:arg 3) 'foo).  

   Is this possible in Lucid land?

   -dd

Yes and I've implemented it.  Thanks for a good suggestion.  The code follows.

Our latest set of Symbolics Compatibility tools for GMACS and Lucid are
available via anonymous ftp from think.com.  The files are named :
/public/symbolics-compatibility-package-1-0.tar
or compressed -> /public/symbolics-compatibility-package-1-0.tar.Z

TMCers:  This will be part of the standard Lucid band once the next version
is made.

-- jim

(defun set-dbg-arg (index-or-name value)
  "This is a LUCID version of the standard Symbolics (SETF (DBG:ARG . . .
and (SETF (DBG:LOC . . . functions.  It is also similar to the lucid debugger
`:S' command.  Called by a user from inside the debugger, it sets the value 
of the specified local variable for the current stack frame.  The first
argument is either an index number or the name of the local."
  (let* ((frame-index lucid::*frame-index*)
	 (env lucid::*frame-environment*)
	 (frame-length (lucid::stack-frame-length frame-index env))
	 (local-index nil)
	 )
    (declare (special lucid::*frame-environment* lucid::*frame-index*))
    (etypecase index-or-name
      ((integer 0)
       (cond ((< index-or-name frame-length)
	      (setq local-index index-or-name)
	      )
	     (t
	      (error "The index ~D is out of range.  There are only ~D local variables for this frame."
		     index-or-name frame-length)
	      )))
      (symbol
       (dotimes (i frame-length)
	 (let ((loc (lucid::debugger-locate-local frame-index env i))
	       )
	   (when (eq (lucid::stack-frame-local-name frame-index env loc)
		     index-or-name)
	     (setq local-index i)
	     (return nil)
	     )))
       (unless local-index
	 (error "The was no local variable named ~S in this stack frame."
		index-or-name))
       ))

    (lucid::set-stack-frame-local-value
      frame-index env (lucid::debugger-locate-local frame-index env local-index)
      value)
    ))

;;; DEFSETF's
(defsetf dbg-arg set-dbg-arg)
(defsetf dbg-loc set-dbg-arg)