From: rif

Subject: looking at local variables when debugging

Date: 2003-4-7 13:54


I'm having some difficulties viewing local variables.  In a file I
have the following functions:

(defun zero-mean-frame (frame &key (s-p *current-speech-params*))
  (declare (type frame frame))
  (let* ((sum 0)
	 (start (frame-start frame))
	 (length (frame-length frame))
	 (end (+ start length))
	 (raw (frame-raw-data frame)))
    (declare (type fixnum sum))
    (blarg)
    (break "Break 1")
    (fixfor (i start end)
	    (setf sum (+ sum (aref raw i))))
    (format t  "Sum = ~A~%" sum)
    (break "Break 2")
    (let ((avg (/ (coerce sum 'df) length))
	  (zero-meaned (cached-frame-array (frame-size s-p))))
      (declare (type df-vec zero-meaned))
      (break "Break 3")
      (fixtimes (i length)
		(setf (aref zero-meaned i) (- (aref raw (+ i start)) avg)))
      (princ zero-meaned)
      zero-meaned)))

(defun blarg () nil)

The file is compiled with (declaim (optimize (debug 3) (safety 3)
(speed 1))) at the top, which implies to me that all live variables
should be visible with a :local at each breakpoint.

The call to blarg is there in an attempt to force stack allocation
rather than register allocation, as suggested in Section 6.5 of
debugging.htm.  (I'm on linux on an 86 box, and I actually have no
idea if register allocation is even possible on this architecture.  As
far as I can tell, commenting out the call to blarg() makes no
difference in the results I present below, providing superficial evidence
that register allocation isn't happening here.)

So what variables are live at each breakpoint? What I would expect to see:
Break 1: start length end raw sum
Break 2: start length raw sum
Break 3: start length raw avg zero-meaned

What I seem to be seeing:
Break 1: NONE
Break 2: sum
Break 3: start length end raw sum

(These are not including the arguments to the function, which are
always there of course.)

Included below is the transcript.  Any help in understanding this is
most appreciated.

Break: Break 1

Restart actions (select using :continue):
 0: return from break.
 1: Return to Top Level (an "abort" restart).
 2: Abort entirely from this process.
[1c] CL-USER(31): :local 
Compiled lexical environment:
0(REQUIRED): CEPSTRAL::FRAME: #S(CEPSTRAL::FRAME :RAW-DATA #(-8 -16 -32 -16 -16 -8 -8 -16 -16 -16 ...) :START 0 :LENGTH 200)
1(KEYWORD): CEPSTRAL::S-P: :UNSUPPLIED
11(LOCAL): CEPSTRAL::FRAME: #S(CEPSTRAL::FRAME :RAW-DATA #(-8 -16 -32 -16 -16 -8 -8 -16 -16 -16 ...) :START 0 :LENGTH 200)
[1c] CL-USER(32): :cont 0
Sum = -1568
Break: Break 2

Restart actions (select using :continue):
 0: return from break.
 1: Return to Top Level (an "abort" restart).
 2: Abort entirely from this process.
[1c] CL-USER(33): :local
Compiled lexical environment:
0(REQUIRED): CEPSTRAL::FRAME: #S(CEPSTRAL::FRAME :RAW-DATA #(-8 -16 -32 -16 -16 -8 -8 -16 -16 -16 ...) :START 0 :LENGTH 200)
1(KEYWORD): CEPSTRAL::S-P: :UNSUPPLIED
5(LOCAL): CEPSTRAL::S-P:
   #S(CEPSTRAL::SPEECH-PARAMS :WINDOW-SIZE 200 :FRAME-SIZE 256 :WINDOW-MOVE 80 :LO-FREQ 0.0d0 :HI-FREQ 1.0d0 :CEP-LIFTER 22 :APPEND-DELTAS T :APPEND-ENERGY T
                              :PRE-EMPHASIZE-P T :PRE-EMPHASIZE-COEFF 0.97d0 :USE-HAMMING T :CEPSTRAL-MEAN-SUBTRACT-P T :SAMPLE-RATE 8000 :NUM-FILTERS 24 :NUM-CEPSTRAL 14
                              :DELTA-FRAMES 2 :ENERGY-NORMALIZE-P T :SILENCE-FLOOR 50.0d0 :ENERGY-SCALE 0.1d0)
6(LOCAL): CEPSTRAL::SUM: -1568
11(LOCAL): CEPSTRAL::FRAME: #S(CEPSTRAL::FRAME :RAW-DATA #(-8 -16 -32 -16 -16 -8 -8 -16 -16 -16 ...) :START 0 :LENGTH 200)
[1c] CL-USER(34): :cont 0
Break: Break 3

Restart actions (select using :continue):
 0: return from break.
 1: Return to Top Level (an "abort" restart).
 2: Abort entirely from this process.
[1c] CL-USER(35): :local
Compiled lexical environment:
0(REQUIRED): CEPSTRAL::FRAME: #S(CEPSTRAL::FRAME :RAW-DATA #(-8 -16 -32 -16 -16 -8 -8 -16 -16 -16 ...) :START 0 :LENGTH 200)
1(KEYWORD): CEPSTRAL::S-P: :UNSUPPLIED
2(LOCAL): CEPSTRAL::START: 0
3(LOCAL): CEPSTRAL::RAW: #(-8 -16 -32 -16 -16 -8 -8 -16 -16 -16 ...)
4(LOCAL): LENGTH: 200
5(LOCAL): CEPSTRAL::S-P:
   #S(CEPSTRAL::SPEECH-PARAMS :WINDOW-SIZE 200 :FRAME-SIZE 256 :WINDOW-MOVE 80 :LO-FREQ 0.0d0 :HI-FREQ 1.0d0 :CEP-LIFTER 22 :APPEND-DELTAS T :APPEND-ENERGY T
                              :PRE-EMPHASIZE-P T :PRE-EMPHASIZE-COEFF 0.97d0 :USE-HAMMING T :CEPSTRAL-MEAN-SUBTRACT-P T :SAMPLE-RATE 8000 :NUM-FILTERS 24 :NUM-CEPSTRAL 14
                              :DELTA-FRAMES 2 :ENERGY-NORMALIZE-P T :SILENCE-FLOOR 50.0d0 :ENERGY-SCALE 0.1d0)
6(LOCAL): CEPSTRAL::SUM: -1568
17(LOCAL): CEPSTRAL::END: 200
[1c] CL-USER(36):