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

Relative paths #76

Closed
HexenZ opened this issue Jul 27, 2018 · 23 comments
Closed

Relative paths #76

HexenZ opened this issue Jul 27, 2018 · 23 comments

Comments

@HexenZ
Copy link

HexenZ commented Jul 27, 2018

Hi, I'm having an issue with vscode-bash-debug, maybe it's just a matter of misconfiguration but I don't know were to go and I'll appreciate help. Having the following scripts:

#file1.sh
#!/bin/bash

echo 'hello'

. ./file2.sh

#file2.sh
#!/bin/bash

echo 'world'

The debugger isn't able to debug file2.sh. But changing '. ./file2.sh' to '/absolute/path/file2.sh' works fine.

launch.json:

{
"version": "0.2.0",
"configurations": [
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (hardcoded script name)",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/file1.sh",
"showDebugOutput": true,
"trace": true,
"args": []
}
]
}

@HexenZ
Copy link
Author

HexenZ commented Aug 20, 2018

Any help please? Still looking for a solution

@rogalmic
Copy link
Owner

Sorry for late response:

  1. why there is space between dots?
    . ./file2.sh
  2. try :
    source ./file2.sh
    or
    source ../file2.sh
    depending the file location

@HexenZ
Copy link
Author

HexenZ commented Aug 21, 2018

Hi, thanks for answering. I'm really new to bash and I'm a bit lost with it. Anyway, the first "." of . ./file2.sh is similar to source (I don't know the difference and source ./file2.sh doesn't works neither). And I cannot replace because I have to maintain bash scripts of thousands lines that are using that "." not the example itself.

The thing is that . ./file2.sh actually works but the debugger won't stop at break points leading me to dismiss the tool for working until the problem is solved.

@rogalmic
Copy link
Owner

You are correct, dot works as well...

Which version of bashdb/bash do you have? (I successfully tried on 4.4.0-94 and also build 91 + bash 4.4.19)

You could try installing newest bashdb:
#67

@HexenZ
Copy link
Author

HexenZ commented Aug 21, 2018

I'm using

bash: GNU bash, versión 4.4.19(1)-release (x86_64-pc-linux-gnu)
bashdb: bashdb, release 4.4-0.94

We're using the same or am I wrong?

@rogalmic
Copy link
Owner

rogalmic commented Aug 21, 2018

Yes, we are using the same - this is interesting ...

Are you able to provide some snapshots + exact reproduction steps. Screen record would be ok as well. Can there be some issues with accessing the "sourced" file?

@HexenZ
Copy link
Author

HexenZ commented Aug 21, 2018

shot1
shot2
shot3

The steps are:

  1. Click 'Debug' -> 'Start Debugging'
  2. Press F5 (Continue)
  3. The script finishes and the result is printed:

shot4

As I allready said it stops at the first breakpoint placed at a1.sh line 3 (echo hello) but it doesn't at the second a2.sh line 3 (echo world).

I suppose that if there were problems accesing the file it wouldn't work with absolute path neither, maybe I'm wrong with that.

@rogalmic
Copy link
Owner

rogalmic commented Aug 21, 2018

OK, so the reason is now obvious. When setting breakpoint source path when debugging, it does not accept paths with spaces nor slashes "-".

I am talking "load" and "break" commands from http://bashdb.sourceforge.net/bashdb.html.

Unfortunately wrapping path in " or ' or ` does not seem to help when i change code of extension... Need to investigate more...

Please use path without "-" to verify this finding.

Just to keep as evidence, the failing call in different flavours:

** Expecting one filename parameter, Got 3.
bashdb<24> load "/mnt/c/Users/[aaa]/Documents/src/vscode-bash debug/tes-t me/test.sh"
** Expecting one filename parameter, Got 3.
bashdb<25> load '/mnt/c/Users/[aaa]/Documents/src/vscode-bash debug/tes-t me/test.sh'
** Expecting one filename parameter, Got 3.
bashdb<26> load `/mnt/c/Users/[aaa]/Documents/src/vscode-bash debug/tes-t me/test.sh`
** Expecting one filename parameter, Got 3.
bashdb<27> load `/mnt/c/Users/[aaa]/Documents/src/vscode-bash\ debug/tes-t\ me/test.sh`
** Expecting one filename parameter, Got 3.
bashdb<28> load (/mnt/c/Users/[aaa]/Documents/src/vscode-bash debug/tes-t me/test.sh)
** Expecting one filename parameter, Got 3.

(https://sourceforge.net/p/bashdb/code/ci/release-4.4-0.94/tree/command/load.sh) (line 30)

bashdb<13> load "/mnt/c/Users/[aaa]/Documents/src/vscode-bash-debug/tes-tme/aaa.sh"
File  loaded.
bashdb<14> info files
Source files which we have recorded info about:
  /mnt/c/Users/[aaa]/Documents/src/vscode-bash-debug/tes-tme/test.sh: /mnt/c/Users/[aaa]/Documents/src/vscode-bash-debug/tes-tme/test.sh, 1 lines
bashdb<15> break /mnt/c/Users/[aaa]/Documents/src/vscode-bash-debug/tes-tme/aaa.sh:3
** File "" not found in read-in files.
** See 'info files' for a list of known files and
** 'load' to read in a file.

@rogalmic
Copy link
Owner

Issue reported:
https://sourceforge.net/p/bashdb/bugs/54/

@HexenZ
Copy link
Author

HexenZ commented Aug 22, 2018

I've changed the path name from "/home/adrian/test-shell" to "/home/adrian/testshell" and still having the same issue, it stops at the first break point but ignores the second.

There must be something else.

@rogalmic
Copy link
Owner

Please attach debug console output, when launch.json configuration has :
"showDebugOutput": true,

@HexenZ
Copy link
Author

HexenZ commented Aug 22, 2018

This is the console output:

(/home/adrian/testshell/a1.sh:3):
3: echo hello
21518
############################################################
delete <>
** Undefined command "yes". Try "help".
File /home/adrian/testshell/a1.sh loaded.
</home/adrian/testshell/a1.sh:3>
Breakpoint 1 set in file /home/adrian/testshell/a1.sh, line 3.
</home/adrian/testshell/a1.sh:5>
Breakpoint 2 set in file /home/adrian/testshell/a1.sh, line 5.
############################################################
delete <>
** Undefined command "yes". Try "help".
File /home/adrian/testshell/a2.sh loaded.
</home/adrian/testshell/a2.sh:3>
Breakpoint 3 set in file /home/adrian/testshell/a2.sh, line 3.
############################################################
backtrace
->0 in file /home/adrian/testshell/a1.sh' at line 3 ##1 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99
##2 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-11391", "--", "/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 0 ############################################################ backtrace ->0 in file /home/adrian/testshell/a1.sh' at line 3
##1 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99 ##2 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-11391", "--", "/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 0
############################################################
Program stopped.
It stopped after being stepped.
Next statement to be run is:
echo hello
<$PWD>
/home/adrian/testshell
<$EUID>
1000
<$#>
1
<$0>
/usr/bin/bashdb
<$->
hBET
############################################################
continue
hello
Breakpoint 2 hit (1 times).
(/home/adrian/testshell/a1.sh:5):
5: . ./a2.sh
############################################################
backtrace
->0 in file /home/adrian/testshell/a1.sh' at line 5 ##1 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99
##2 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-11391", "--", "/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 0 ############################################################ backtrace ->0 in file /home/adrian/testshell/a1.sh' at line 5
##1 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99 ##2 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-11391", "--", "/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 0
############################################################
continue
Breakpoint 3 hit (1 times).
(/home/adrian/testshell/a2.sh:3):
3: echo 'world'
############################################################
backtrace
->0 in file ./a2.sh' at line 3 ##1 source("./a2.sh") called from file /home/adrian/testshell/a1.sh' at line 5
##2 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99 ##3 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-11391", "--", "/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 0
############################################################
backtrace
->0 in file ./a2.sh' at line 3 ##1 source("./a2.sh") called from file /home/adrian/testshell/a1.sh' at line 5
##2 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99 ##3 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-11391", "--", "/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 0
############################################################
Program stopped.
It stopped at breakpoint 3.
Next statement to be run is:
echo 'world'
<$PWD>
/home/adrian/testshell
<$EUID>
1000
<$#>
1
<$0>
/usr/bin/bashdb
<$->
hBET
############################################################
continue
world
Debugged program terminated normally. Use q to quit or R to restart.
bash: línea 18: 21520 Terminado (killed) "cat" "/tmp/vscode-bash-debug-fifo-11391" 1>&3 (dir ahora: ~)
bash: línea 18: 21521 Terminado (killed) "cat"
21522 | "bashdb" --quiet --tty "/tmp/vscode-bash-debug-fifo-11391" -- "/home/adrian/testshell/a1.sh"

@rogalmic
Copy link
Owner

Hmm, this is weird. Bashdb actually stops, and "continue" is sent by debugger:

Breakpoint 3 hit (1 times).
(/home/adrian/testshell/a2.sh:3):
3: echo 'world'
############################################################
backtrace
->0 in file ./a2.sh' at line 3 ##1 source("./a2.sh") called from file/home/adrian/testshell/a1.sh' at line 5
##2 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99 ##3 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-11391", "--", "/home/adrian/testshell/a1.sh") called from file/usr/bin/bashdb' at line 0
############################################################
backtrace
->0 in file ./a2.sh' at line 3 ##1 source("./a2.sh") called from file/home/adrian/testshell/a1.sh' at line 5
##2 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99 ##3 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-11391", "--", "/home/adrian/testshell/a1.sh") called from file/usr/bin/bashdb' at line 0
############################################################
Program stopped.
It stopped at breakpoint 3.

Can you see callstack when debugger stops and console shows:

->0 in file ./a2.sh' at line 3 ?

@HexenZ
Copy link
Author

HexenZ commented Aug 23, 2018

Yes, I've noticed that bashdb actually stops at the breakpoint and it seems that vs-code sends a "continue" instruction even if I'm running the option "Debug step by step".

Here's the callstack output:

->0 in file ./a2.sh' at line 3 (Unknown origin:3) ##1 source("./a2.sh") called from file /home/adrian/testshell/a1.sh' at line 5 (/home/adrian/testshell/a1.sh:5)
##2 source("/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 99 (/usr/bin/bashdb:99) ##3 main("--quiet", "--tty", "/tmp/vscode-bash-debug-fifo-13145", "--", "/home/adrian/testshell/a1.sh") called from file /usr/bin/bashdb' at line 0 (/usr/bin/bashdb:0)

I'm wondering... could it be an error with using $0 internally?

I got these vars at the watch list:

$PWD=/home/adrian/testshell
$0=/usr/bin/bashdb

@rogalmic
Copy link
Owner

I am a bit confused, since continue can only be sent by vscode to extension, there is no other path for that.

So it seems that vscode calls the extension's callback containing "continue" by itself, without any user action?

Are you using mouse to click the debugger buttons or "F5"/"F10"/"F11" ?

@HexenZ
Copy link
Author

HexenZ commented Aug 23, 2018

I'm using F5 most of the time or the "play like" arrow:
shot6
Anyway, every time I'm testing, I try every button or F* key.

@rogalmic
Copy link
Owner

What is the platform/system and VS code version?

I mean everything looks ok from debug session point of view, so we need to look for problem higher in stack...

@HexenZ
Copy link
Author

HexenZ commented Aug 24, 2018

SO: Ubuntu 18.04.1 LTS
VScode: 1.26.1

If you need any other info let me know :)

@rogalmic
Copy link
Owner

I installed Ubuntu on VM, i think i am able to reproduce the problem:
screenshot_20180824_121255

Notice that the uppermost element in callstack is grayed out, which means that relative path './a2.sh' is not working in linux. Seems that vscode working dir is different on linux. I will try to find a solution, possibly try to recover full path.

@rogalmic
Copy link
Owner

rogalmic commented Aug 24, 2018

Some changes that might help (updated):
bash-debug-0.2.2.vsix.zip

Please test via "install from vsix" option and give feedback:
image

@rogalmic
Copy link
Owner

@HexenZ
Copy link
Author

HexenZ commented Aug 27, 2018

Some changes that might help (updated):
bash-debug-0.2.2.vsix.zip

Please test via "install from vsix" option and give feedback:

Sorry for the late reply, I've been on a trip and had no time. The vsix is working like a miracle!

Really... really thank you a lot for all your help and patience rogalmic.

@rogalmic
Copy link
Owner

I should thank you for patience :). Anyway, now the changes are released.

For spaces to work in script path, bashdb upgrade will be needed, after it's next release (those scripts can also be updated manually with code fixes in /usr/share/bashdb/* ).

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