microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.45k stars 1.53k forks source link

GDB debugger in C/C++ Extension Not Functioning #7037

Open ghost opened 3 years ago

ghost commented 3 years ago

Type: Debugger

GDB debugger not hitting breakpoints, non-stop at entry, no variable list, and shows a "matches multiple schemas when only one must validate" error.

Describe the bug

I created my tasks.json and launch.json following the official guide, but the debugger won't stop at breakpoints, and my variable list is also empty. I also set the "StopAtEntry" to true, but it doesn't seem like it has added a breakpoint or actually stopped at main. I also got the feedback of "Matches multiple schemas when only one must validate" which I can't figure out. My VS Code is working remotely linking my WSL, and all my extensions are installed both on my end and the Linux end.

To Reproduce { // 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": [ { "name": "gcc_debug", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "gcc build active file", "miDebuggerPath": "/usr/bin/gdb" } ] } Steps to reproduce the behavior:

  1. Go to the .c file you want to debug and set breakpoints
  2. Click on start debugging
  3. See error

Additional context If applicable, please include logging by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your launch.json Add any other context about the problem here including log or error messages in your Debug Console or Output windows.

sean-mcmanus commented 3 years ago

@WardenGnaw Any info on this?

WardenGnaw commented 3 years ago

Please add the engine logs by by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your launch.json

ghost commented 3 years ago

Please add the engine logs by by adding "logging": { "engineLogging": true, "trace": true, "traceResponse": true } in your launch.json

--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (168) LaunchOptions{\"name\":\"gcc_debug\",\"type\":\"cppdbg\",\"request\":\"launch\",\"program\":\"/home/yw780/2021_0s_211/pa2/isTree/isTree\",\"args\":[],\"stopAtEntry\":true,\"cwd\":\"/home/yw780/2021_0s_211\",\"environment\":[],\"externalConsole\":true,\"MIMode\":\"gdb\",\"setupCommands\":[{\"description\":\"Enable pretty-printing for gdb\",\"text\":\"-enable-pretty-printing\",\"ignoreFailures\":true}],\"preLaunchTask\":\"gcc build active file\",\"miDebuggerPath\":\"/usr/bin/gdb\",\"logging\":{\"engineLogging\":true,\"trace\":true,\"traceResponse\":true},\"configurationTarget\":5,\"sessionId\":\"3d155603-730e-41b3-a887-94ebb2eace43\"}\n"},"seq":2} 1: (168) LaunchOptions{"name":"gcc_debug","type":"cppdbg","request":"launch","program":"/home/yw780/2021_0s_211/pa2/isTree/isTree","args":[],"stopAtEntry":true,"cwd":"/home/yw780/2021_0s_211","environment":[],"externalConsole":true,"MIMode":"gdb","setupCommands":[{"description":"Enable pretty-printing for gdb","text":"-enable-pretty-printing","ignoreFailures":true}],"preLaunchTask":"gcc build active file","miDebuggerPath":"/usr/bin/gdb","logging":{"engineLogging":true,"trace":true,"traceResponse":true},"configurationTarget":5,"sessionId":"3d155603-730e-41b3-a887-94ebb2eace43"} --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (282) DbgCmd:echo $$ > /tmp/Microsoft-MIEngine-Pid-wka35yz0.5ia ; cd \"/home/yw780/2021_0s_211/pa2/isTree\" ; DbgTerm=tty ; set -o monitor ; trap 'rm \"/tmp/Microsoft-MIEngine-In-zkwlbmuz.1tq\" \"/tmp/Microsoft-MIEngine-Out-5rye28ps.s6v\" \"/tmp/Microsoft-MIEngine-Pid-wka35yz0.5ia\" \"/tmp/Microsoft-MIEngine-Cmd-jp40hbeg.k4d\"' EXIT ; \"/usr/bin/gdb\" --interpreter=mi --tty=$DbgTerm < \"/tmp/Microsoft-MIEngine-In-zkwlbmuz.1tq\" > \"/tmp/Microsoft-MIEngine-Out-5rye28ps.s6v\" & clear; pid=$! ; echo $pid > \"/tmp/Microsoft-MIEngine-Pid-wka35yz0.5ia\" ; wait $pid; \n"},"seq":4} 1: (282) DbgCmd:echo $$ > /tmp/Microsoft-MIEngine-Pid-wka35yz0.5ia ; cd "/home/yw780/2021_0s_211/pa2/isTree" ; DbgTerm=tty ; set -o monitor ; trap 'rm "/tmp/Microsoft-MIEngine-In-zkwlbmuz.1tq" "/tmp/Microsoft-MIEngine-Out-5rye28ps.s6v" "/tmp/Microsoft-MIEngine-Pid-wka35yz0.5ia" "/tmp/Microsoft-MIEngine-Cmd-jp40hbeg.k4d"' EXIT ; "/usr/bin/gdb" --interpreter=mi --tty=$DbgTerm < "/tmp/Microsoft-MIEngine-In-zkwlbmuz.1tq" > "/tmp/Microsoft-MIEngine-Out-5rye28ps.s6v" & clear; pid=$! ; echo $pid > "/tmp/Microsoft-MIEngine-Pid-wka35yz0.5ia" ; wait $pid; --> C (runInTerminal-6): {"type":"request","command":"runInTerminal","arguments":{"kind":"external","title":"cppdbg: isTree","cwd":"","args":["/bin/sh","/tmp/Microsoft-MIEngine-Cmd-jp40hbeg.k4d"],"env":{}},"seq":6} --> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (309) Wait for connection completion.\n"},"seq":8} 1: (309) Wait for connection completion.

Here is what I get from the debug console. Please inform if this is the log info you wanted.

WardenGnaw commented 3 years ago

From the logs, it looks like the runInTerminal request that connects to your external window is failing. If you switch to using the integrated VS Code terminal by setting externalConsole":false.

Does it work?

ghost commented 3 years ago

From the logs, it looks like the runInTerminal request that connects to your external window is failing. If you switch to using the integrated VS Code terminal by setting externalConsole":false.

Does it work?

I uninstall the terminal extension but nothing has changed. Or should I go to somewhere else to change the default terminal? Otherwise, I should be using the VS Code integrated one.