Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bdb subshell issues #1

Open
delameter opened this issue Aug 28, 2022 · 1 comment
Open

bdb subshell issues #1

delameter opened this issue Aug 28, 2022 · 1 comment

Comments

@delameter
Copy link
Contributor

Hi.
Ran into interesting behaviour of your shell debugger.
Test script is:

#!/bin/bash
cd "$(dirname "$(readlink -f "$0")")" || exit 127
echo Testing
echo Testing
echo 123

Line 2 is a common way of loading resources relative to script (at least Im using it that way:)

The issue is: when you are setting/deleting breakpoints while running subshells, your changes to breakpoints are local and will be lost after returning to the original script, at least that's what I guess.
Example:

$ bdb test.sh    
bdb> trace
bdb> ba true
bdb> +(test.sh:2): cd "$(dirname "$(readlink -f "$0")")"
bdb> +(test.sh:2): dirname "$(readlink -f "$0")"
bdb> bl
     1  true
bdb> bd 1
# after ^ this there should be no breakpoints
bdb> +(test.sh:2): readlink -f "$0"
+(test.sh:3): echo Testing
# however it persists:
bdb> Testing
+(test.sh:4): echo Testing
bdb> Testing
+(test.sh:5): echo 123
bdb> bl 1
     1  true
bdb> 123

Not sure if thats an issue though.

PS Спасибо, в любом случае скрипт полезный, и с год назад мне бы он ооочень пригодился)

@kt97679
Copy link
Owner

kt97679 commented Aug 29, 2022

Hi, thank you for using bdb! I think you nailed the root cause of the observed behavior - it is because of the subshells. In the subshell we inherit context of the parent shell so we have all breakpoints defined before starting subshell. Deleting breakpoint in the subshell context will not change parent context so I fully agree this can be confusing. I'm afraid the only thing that can be done is to document this somewhere. In theory we can detect that we are in the subshell and issue warning while adding/deleting breakpoints, but I'm afraid this will add complexity to the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants