Re: Debugger : Can't see local variables when stepping
steve gonedes <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.general |
|---|---|
| Message-ID | <[email protected]> |
On 3/18/24 08:52, Jérôme Radix wrote:
> Thanks Martin.
>
> It works when using (BREAK) after declaring local variables.
> But does that mean that stepping through code using the debugger can't
> show new local variables declared after (BREAK) ?
> How can I have my local variables automatically detected/shown when
> stepping through code using the debugger, like in other languages debuggers?
(step (foo " I have my local variables au"))
also trace can be helpful.
and the all time favorite of all programmers!
(defmacro debugging-tre (tre msg &rest args)
`(when (tre-debugging ,tre)
(format *debug-io* ,msg ,@args)))
(defmacro debugging-rules (msg &rest args)
`(when *debugging-rules*
(format *debug-io* ,msg ,@args)))
(defun debug-tre (tre debugging context?)
(setf (tre-debugging tre) debugging
(defmacro debugging-tre (tre msg &rest args)
`(when (tre-debugging ,tre)
(format *debug-io* ,msg ,@args)))
(tre-debugging-contexts tre) context?))
;;; ex code
(defun build-rule (trigger body asn?)
(multiple-value-bind (pattern var test)
(parse-rule-trigger trigger)
(debugging-rules "~&;; BUILD-RULE trigger: ~a" pattern)
(debugging-rules "~%;; trigger-class: ~a" (get-trigger-dbclass trigger))
(debugging-rules "~%;;~4T Adding rule with triggers: ") (pprint trigger)
(debugging-rules "~%;;~4T And body:~%~2T ") (pprint-lambda
*debug-io* body)
(let ((match-procedure (generate-match-procedure pattern var test))
(body-procedure (generate-body-procedure pattern var body)))
(push match-procedure *rule-procedures*)
(push body-procedure *rule-procedures*)
`(insert-rule *tre* (get-dbclass *tre* ,(get-trigger-dbclass
trigger))
(function
;; return form to index rule
,(if *bound-vars*
`(lambda (P)
(,(cadr match-procedure) P ,@ *bound-vars*))
(cadr match-procedure)))
(function
;; body procedure
,(if *bound-vars*
(let ((tv (reverse (pattern-free-variables
trigger))))
`(lambda ,tv
(,(cadr body-procedure)
,@tv ,@(scratchout tv *bound-vars*))))
(cadr body-procedure)))
,asn?))))
>
> Regards,
> Jérôme.
>
>
> Le lun. 18 mars 2024 à 11:25, eMko <[email protected]
> <mailto:[email protected]>> a écrit :
>
> Hi,
>
> if you put `(break)` into the `let` form, you will be able to see
> the variable (tested with SBCL 2.4.1 on Windows, the Roswell build).
>
> (defun foo (var1)
> (let ((var2 (subseq var1 0 10)))
> (break)
> (dotimes (i 10 (fresh-line))
> (format t "~C" (char var2 i)))))
>
> SLY:
>
> break
> [Condition of type SIMPLE-CONDITION]
>
> Restarts:
> 0: [CONTINUE] Return from BREAK.
> 1: [RETRY] Retry SLY mREPL evaluation request.
> 2: [*ABORT] Return to SLY's top level.
> 3: [ABORT] abort thread (#<THREAD "sly-channel-1-mrepl-remote-1"
> RUNNING {1001160003}>)
>
> Backtrace:
> 0: (FOO "hello world")
> Locals:
> VAR1 = "hello world"
> VAR2 = "hello worl"
>
> Hope that helps.
>
> Martin
>
> On Mon, Mar 18, 2024 at 10:25 AM Jérôme Radix
> <[email protected] <mailto:[email protected]>> wrote:
>
> Hello,
>
> When using the debugger, I can't figure out how to see the value
> of I and VAR2 in my little test code, even with (debug 3)
> optimization setting:
> (defun foo (var1)
> (break)
> (let ((var2 (subseq var1 0 10)))
> (dotimes (i 10 (fresh-line))
> (format t "~C" (char var2 i)))))
>
> (foo "Hello World")
>
> Here is the transcript of my session, on linux
> 5.15.146.1-microsoft-standard-WSL2:
>
> $ sbcl --no-sysinit --no-userinit
> This is SBCL 2.3.4, an implementation of ANSI Common Lisp.
> More information about SBCL is available at
> <http://www.sbcl.org/ <http://www.sbcl.org/>>.
>
> SBCL is free software, provided as is, with absolutely no warranty.
> It is mostly in the public domain; some portions are provided under
> BSD-style licenses. See the CREDITS and COPYING files in the
> distribution for more information.
> * (declaim (optimize (debug 3)))
> NIL
> * (sb-ext:describe-compiler-policy)
> Basic qualities:
> COMPILATION-SPEED = 1
> DEBUG = 3
> SAFETY = 1
> SPACE = 1
> SPEED = 1
> INHIBIT-WARNINGS = 1
> Dependent qualities:
> SB-C::CHECK-CONSTANT-MODIFICATION = 1 -> 1 (maybe)
> SB-C::TYPE-CHECK = 1 -> 3 (full)
> SB-C::LET-CONVERSION = 1 -> 0 (off)
> SB-C:ALIEN-FUNCALL-SAVES-FP-AND-PC = 1 -> 3 (yes)
> SB-C:VERIFY-ARG-COUNT = 1 -> 3 (yes)
> SB-C::INSERT-DEBUG-CATCH = 1 -> 3 (yes)
> SB-C::RECOGNIZE-SELF-CALLS = 1 -> 0 (no)
> SB-C::FLOAT-ACCURACY = 1 -> 3 (full)
> SB-C:INSERT-STEP-CONDITIONS = 1 -> 3 (full)
> SB-C::COMPUTE-DEBUG-FUN = 1 -> 3 (yes)
> SB-C:STORE-SOURCE-FORM = 1 -> 3 (yes)
> SB-C::PRESERVE-SINGLE-USE-DEBUG-VARIABLES = 1 -> 3 (yes)
> SB-C::PRESERVE-CONSTANTS = 1 -> 0 (no)
> SB-C:INSERT-ARRAY-BOUNDS-CHECKS = 1 -> 3 (yes)
> SB-C::AREF-TRAPPING = 1 -> 0 (no)
> SB-C::STORE-XREF-DATA = 1 -> 3 (yes)
> SB-C:STORE-COVERAGE-DATA = 1 -> 0 (no)
> SB-C:INSTRUMENT-CONSING = 1 -> 1 (no)
> SB-C::STORE-CLOSURE-DEBUG-POINTER = 1 -> 0 (no)
> * (defun foo (var1)
> (break)
> (let ((var2 (subseq var1 0 10)))
> (dotimes (i 10 (fresh-line))
> (format t "~C" (char var2 i)))))
> FOO
> * (foo "Hello World")
>
> debugger invoked on a SIMPLE-CONDITION in thread
> #<THREAD tid=1590 "main thread" RUNNING {1001090003}>:
> break
>
> Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
>
> restarts (invokable by number or by possibly-abbreviated name):
> 0: [CONTINUE] Return from BREAK.
> 1: [ABORT ] Exit debugger, returning to top level.
>
> (FOO "Hello World")
> source: (BREAK)
> 0] start
> ; Evaluating call:
> ; (SUBSEQ VAR1 0 10)
> ; With arguments:
> ; "Hello World"
> ; 0
> ; 10
>
> 1] step
> ; (SUBSEQ VAR1 0 10) => "Hello Worl"
> ; Evaluating call:
> ; (+ I 1)
> ; With unknown arguments
> H
> 0] step
> ; Evaluating call:
> ; (+ I 1)
> ; With unknown arguments
> e
> 0] L
> VAR1 = "Hello World"
>
> ==> I want to see the value of I and VAR2. What am I doing wrong ?
> I've tried several combinations of (declaim (optimize (debug 3)
> (space 0) (safety 3) (speed 0))) with no difference in behavior.
>
> Thanks for your help.
>
> Regards,
> Jérôme.
> _______________________________________________
> Sbcl-help mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/sbcl-help
> <https://lists.sourceforge.net/lists/listinfo/sbcl-help>
>
_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help