提问人:Zaida 提问时间:11/16/2023 更新时间:11/16/2023 访问量:29
在 Windows 中使用 WSL Ubuntu 的 Visual Studio Code 的 Bash 调试器不会在断点处停止
Bash debugger of Visual Studio Code using WSL Ubuntu in Windows does not stop in breakpoints
问:
我在使用 WSL 扩展在 Visual Studio Code 中调试 Bash 脚本时遇到问题。尽管在我的 Bash 脚本中设置了断点,但调试器运行脚本时不会在任何断点处停止。
据我了解,我已经在远程 WSL 中安装了所有需要的扩展:Ubuntu-20.04。我还按照建议设置了bashdb扩展。这是我的launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (simplest configuration)",
"program": "${file}",
"showDebugOutput": true,
"terminalKind": "integrated",
"trace": true
}
]
}
我尝试将 更改为 ,但行为是一样的。它运行,但不会在断点处停止。
这是我一直在运行的脚本来测试它:terminalKind
debugConsole
#!/usr/bin/env bash
export NICE_VAR=10
export ANOTHER_VAR=20
for i in {0..25..5}
do
export NICE_VAR=$((NICE_VAR+i)) # BREAKPOINT
echo $NICE_VAR
done
for ((i=1;i<=25;i+=1))
do
export ANOTHER_VAR=$((ANOTHER_VAR+i)) # BREAKPOINT
echo $ANOTHER_VAR
done
if [ $ANOTHER_VAR -gt $NICE_VAR ]
then
echo "ANOTHER bigger than nice" # BREAKPOINT
else
echo "Nice is bigger or equal"
fi
在调试控制台上检查输出时,可以识别断点的位置,但随后会显示“未设置断点”。这是按包含断点的行过滤的输出:
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":
{"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":false,"supportsEvaluateForHovers":
true,"supportsStepBack":false,"supportsSetVariable":false}}
##1 sourceFrom client: setBreakpoints({"source":{"name":"Debugging_test.sh","path":"../Debugging_test.sh"},
"lines":[7,13,19],"breakpoints":[{"line":7},{"line":13},{"line":19}],"sourceModified":false})
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":
"No breakpoints have been set.\n"}}
No breakpoints have been set.
To client: {"seq":0,"type":"response","request_seq":6,"command":"setBreakpoints","success":true,"body":
{"breakpoints":[{"verified":true,"line":null,"id":null},{"verified":true,"line":null,"id":null},{"verified":
true,"line":null,"id":null}]}}
From client: setExceptionBreakpoints({"filters":[]})
To client: {"seq":0,"type":"response","request_seq":7,"command":"setExceptionBreakpoints","success":true}
我已经尝试了此处指示的解决方案:https://stackoverflow.com/a/44068717/18255654 但它似乎特定于C++并且没有改变行为。是否有人遇到过类似的问题,或者可以深入了解为什么断点可能不起作用?
答: 暂无答案
评论