microsoft / microsoft/vscode-cpptools

Debug console hangs when trying to execute multiline gdb commands

Open
#3,666 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
Extension version: 0.23.1
GDB Version: 8.2.1
VS Code version: 1.33.1
OS: Linux x64 5.0.9-arch1-1-ARCH
The bug

So I know I can send commands to gdb using the -exec prefix. However, some gdb commands seem to require entering multiple lines (I couldn't find any delimiters for them), and when they're used with -exec, the console seems to hang.

When I try to send multiline command lines line-by-line, after entering the first one, the console just hangs, here's the log:

-exec while $ctr++<10
not available
<--   C (evaluate-29): {"command":"evaluate","arguments":{"expression":"-exec while $ctr++<10\n","frameId":1000,"context":"repl"},"type":"request","seq":29}
--> E (output): {"event":"output","body":{"category":"console","output":"1: (253496) <-1197-interpreter-exec console \"while $ctr++<10\"\n"},"seq":3648,"type":"event"}
1: (253496) <-1197-interpreter-exec console "while $ctr++<10"
--> E (output): {"event":"output","body":{"category":"console","output":"1: (253498) ->~\" >\"\n"},"seq":3650,"type":"event"}
1: (253498) ->~" >"`

After this, typing further lines of the command (prefixed with -exec or not) does nothing (there's no output either). Even clicking the stop button doesn't make gdb exit, the only thing I can do is to manually kill the gdb process.

I've also tried using Shift+Enter to send multiline command, and while it doesn't hang this time, it doesn't work either:

-exec while $ctr++<10
p $ctr
end
<--   C (evaluate-28): {"command":"evaluate","arguments":{"expression":"-exec while $ctr++<10\np $ctr\nend\n","frameId":1000,"context":"repl"},"type":"request","seq":28}
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103563) <-1196-interpreter-exec console \"while $ctr++<10\np $ctr\nend\"\n"},"seq":3608,"type":"event"}
1: (103563) <-1196-interpreter-exec console "while $ctr++<10
p $ctr
end"
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103575) ->1196^error,msg=\"Problem parsing arguments: interpreter-exec console \\\"while $ctr++<10\"\n"},"seq":3610,"type":"event"}
1: (103575) ->1196^error,msg="Problem parsing arguments: interpreter-exec console \"while $ctr++<10"
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103576) 1196: elapsed time 13\n"},"seq":3612,"type":"event"}
1: (103576) 1196: elapsed time 13
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103577) ->(gdb)\n"},"seq":3614,"type":"event"}
1: (103577) ->(gdb)
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103578) ->&\"p $ctr\\n\"\n"},"seq":3616,"type":"event"}
1: (103578) ->&"p $ctr\n"
--> E (output): {"event":"output","body":{"category":"stdout","output":"p $ctr\n\n"},"seq":3618,"type":"event"}
p $ctr
--> E (output): {"event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/Evaluate","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"16.1.10504.1","VS.Diagnostics.Debugger.HostVersion":"16.1.10504.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Evaluate.Duration":58.0,"VS.Diagnostics.Debugger.Evaluate.IsError":false,"VS.Diagnostics.Debugger.Evaluate.ExecuteInConsole":true}},"seq":3620,"type":"event"}
--> R (evaluate-28): {"request_seq":28,"success":true,"command":"evaluate","body":{"result":"","variablesReference":0},"seq":3622,"type":"response"}
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103683) ->~\"$1 = void\"\n"},"seq":3624,"type":"event"}
1: (103683) ->~"$1 = void"
--> E (output): {"event":"output","body":{"category":"stdout","output":"$1 = void"},"seq":3626,"type":"event"}
$1 = void
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103688) ->~\"\\n\"\n"},"seq":3628,"type":"event"}
1: (103688) ->~"\n"
--> E (output): {"event":"output","body":{"category":"stdout","output":"\n"},"seq":3630,"type":"event"}

--> E (output): {"event":"output","body":{"category":"console","output":"1: (103692) ->^done\n"},"seq":3632,"type":"event"}
1: (103692) ->^done
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103695) ->(gdb)\n"},"seq":3634,"type":"event"}
1: (103695) ->(gdb)
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103699) ->&\"end\\\"\\n\"\n"},"seq":3636,"type":"event"}
1: (103699) ->&"end\"\n"
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103709) ->&\"This command cannot be used at the top level.\\n\"\n"},"seq":3638,"type":"event"}
1: (103709) ->&"This command cannot be used at the top level.\n"
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103711) ->^error,msg=\"This command cannot be used at the top level.\"\n"},"seq":3640,"type":"event"}
1: (103711) ->^error,msg="This command cannot be used at the top level."
--> E (output): {"event":"output","body":{"category":"console","output":"1: (103716) Send Event AD7MessageEvent\n"},"seq":3642,"type":"event"}
1: (103716) Send Event AD7MessageEvent
--> E (output): {"event":"output","body":{"category":"stderr","output":"ERROR: This command cannot be used at the top level.\n"},"seq":3644,"type":"event"}
1: (103720) ->(gdb)
ERROR: This command cannot be used at the top level.
Workaround

Multiline commands work when using the gdb.execute function in Python, so this works (but it's ugly...):

-exec python gdb.execute('set $ctr=0\nwhile $ctr++<10\np $ctr\nend')

However I am still reporting this because I think the console shouldn't hang, even if the user tries to use an unimplemented feature.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the hang from the debug console using the reported multiline -exec while command, then compare it with the Shift+Enter request and the gdb.execute workaround. No source file or test is named; done means multiline input no longer leaves the console or GDB stuck, including graceful handling of unsupported input.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.