microsoft / microsoft/vscode-cpptools
GDB commands often fail with 'No symbol "someSymbol" in current context.'
@WardenGnaw is already working on this.
Since Apr 1, 2020.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Type: Debugger
Describe the bug
- OS and Version: Debian 9
- VS Code Version: 1.43.2
- C/C++ Extension Version: 27.0
- Other extensions you installed (and if the issue persists after disabling them): None
- A clear and concise description of what the bug is.
When debugging I find that when I first try to execute a gdb command with -exec, I get the error 'No symbol "someSymbol" in current context.' even though that variable is clearly in scope. If I hover over the variable or execute a non-gdb command first, and then execute the gdb command, that fixes the problem.
I attached a small repro where I can reproduce the problem by doing the following:
- Add a breakpoint inside Widget::doStuff
- Start debugging and switch away from the "Run/Debug" view before hitting the breakpoint. Go to the explorer view, for example.
- After hitting the breakpoint, try running '-exec p a' in the debug console and note that it doesn't work
- Switch back to the "Run/Debug" view and execute a gdb command. It works now.
This reproduces very frequently when trying to debug our project at work. I noticed that it happens most often when trying to print a member variable from within a method. Local variables often work. I attached the log output after following the above repro steps on my work example.
Compile the repro with g++ -g main.cpp and debug with the following launch.json:
{
"name": "Debug Repro",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/gdb"
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.