Trepan-Debuggers / zshdb

gdb-like "trepan" debugger for zsh
GNU General Public License v3.0
295 stars 23 forks source link

Incorrect invocation `info variables -p` resumes execution of debugged script #39

Closed jansorg closed 10 months ago

jansorg commented 1 year ago

The (bashdb-based) debugger integration of BashSupport Pro executes info variables -p to print variables. This command isn't yet available in zshdb (which is okay, I'll hopefully add it in a PR), but executing it resumes the execution of the debugged script. IMHO executing an unknown or invalid command should only print an error and not resume execution.

# cat test.sh 
echo hello
echo world

# zshdb ./test.sh 
zsh debugger, zshdb, release 1.1.2

Copyright 2008-2011, 2014, 2016-2019 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.

(/home/jansorg/test.sh:1):
echo hello
zshdb<0> info variables -p
** Don't know how to list variable type: -p
** Need to specify a variable class which is one of: 
** array, export, fixed, float, function, hash, integer, or readonly
hello
world
Program terminated. Type 's' or 'R' to restart.
zshdb<1> 
jansorg commented 1 year ago

My guess is that these variables should be local, because otherwise the state variables won't ever be reset. But I'm not sure I'm getting all of this code...

https://github.com/rocky/zshdb/blob/master/lib/processor.sh#L76-L77

rocky commented 1 year ago

IMHO executing an unknown or invalid command should only print an error and not resume execution.

I believe this is no longer the case, and was fixed around commit 713bb9350aa761c0a9a397396cafcb79471f6578.

My guess is that these variables should be local, because otherwise the state variables won't ever be reset. But I'm not sure I'm getting all of this code... https://github.com/rocky/zshdb/blob/master/lib/processor.sh#L76-L77

These are variables that are used by the debugger REPL loop to tell indicate whether on exit of the debugger read-eval-print we should go back into the debugged program or skip execution of the next zsh instruction of the debugged program.

rocky commented 1 year ago

I just looked at info variables in zshdb. It works differently, probably because this is the way zsh prefers to organize variable lookup. However the underlying command used in bash: declare -p does exist and seems to do the same thing.

jansorg commented 10 months ago

The bug reported by this issue seems to fixed with master. Closing this now.