microsoft / microsoft/vscode-cpptools

GDB commands often fail with 'No symbol "someSymbol" in current context.'

Aperta
#5,235 6 commenti 7 reazioni 1 assegnatario Vedi su GitHub

@WardenGnaw ci sta già lavorando.

Dal 1/4/2020.

bug debugger
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

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:

  1. Add a breakpoint inside Widget::doStuff
  2. Start debugging and switch away from the "Run/Debug" view before hitting the breakpoint. Go to the explorer view, for example.
  3. After hitting the breakpoint, try running '-exec p a' in the debug console and note that it doesn't work
  4. 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.

log.txt
repro.zip

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"
    }

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.