microsoft / vscode-cpptools

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

Can't find path for "MIDebuggerPath" option in Manjaro Linux #2971

Open antonxo opened 5 years ago

antonxo commented 5 years ago

Type: Debugger GDB

ISSUE I can't start debugging, I've tried different things, but it keeps telling me "Unable to start debugging. Launch options string provided by the project is invalid. Unable to determine path to debugger. Please specify the "MIDebuggerPath" option.

I've tried setting MIDebuggerPath to /usr/bin/ or usr/share and some other paths, but no luck.

My launch.json looks like this: { "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/04_printf/printf", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] },

]
}

Please, help me, I've already wasted 2 hours trying everything I could.

WardenGnaw commented 5 years ago

If you run gdb in a shell, does GDB start?

If so, what does which gdb return?

antonxo commented 5 years ago

Thank you for your quick reply! Apparently, bash: gdb: command not found. Sorry, I'm new to debugging and VS Code is my first experience. I guess I need to google "install gdb unix" now?

WardenGnaw commented 5 years ago

Yep. Manjaro seems to be a version of Arch that uses Pacman as the package manager. You can install gdb with pacman -S gdb. Once that is installed, you can use which gdb to get the path of GDB and use that as your MIDebuggerPath.

antonxo commented 5 years ago

I've installed gdb (and clang) and managed to get rid of the previous error message. Unfortunately, there's another problem now. When I launch debugger in VSCode it sort of starts but then I cannot do anything with it and the only active button in the control panel is the red square for 'stop'. I know how it works in general, I have VSCode for Mac in school, and it was super easy to set it up with Mac, but Linux is difficult for me. Do you have any suggestions? screenshot_2018-12-27_01-30-56

antonxo commented 5 years ago

And I've set a few breakpoints in the source file.

antonxo commented 5 years ago

I also compile with -g...

WardenGnaw commented 5 years ago

Can you enable logging and copy the output here?

antonxo commented 5 years ago

Here's the log: edited --> E (output): {"event":"output","body":{"category":"console","output":"1: (152) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'\n"},"seq":2,"type":"event"} 1: (152) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014' --> E (output): {"event":"output","body":{"category":"console","output":"1: (165) LaunchOptions ExePath='/home/void/Desktop/unit/04_printf/printf'\n"},"seq":4,"type":"event"} 1: (165) LaunchOptions ExePath='/home/void/Desktop/unit/04_printf/printf' --> E (output): {"event":"output","body":{"category":"console","output":"1: (165) LaunchOptions WorkingDirectory='/home/void/Desktop/unit/04_printf'\n"},"seq":6,"type":"event"} 1: (165) LaunchOptions WorkingDirectory='/home/void/Desktop/unit/04_printf' --> E (output): {"event":"output","body":{"category":"console","output":"1: (165) LaunchOptions ExeArguments=''\n"},"seq":8,"type":"event"} 1: (165) LaunchOptions ExeArguments='' --> E (output): {"event":"output","body":{"category":"console","output":"1: (166) LaunchOptions MIMode='gdb'\n"},"seq":10,"type":"event"} 1: (166) LaunchOptions MIMode='gdb' --> E (output): {"event":"output","body":{"category":"console","output":"1: (166) LaunchOptions MIDebuggerPath=''\n"},"seq":12,"type":"event"} 1: (166) LaunchOptions MIDebuggerPath='' --> E (output): {"event":"output","body":{"category":"console","output":"1: (166) LaunchOptions WaitDynamicLibLoad='false'\n"},"seq":14,"type":"event"} 1: (166) LaunchOptions WaitDynamicLibLoad='false' --> E (output): {"event":"output","body":{"category":"console","output":"1: (166) LaunchOptions ExternalConsole='true'\n"},"seq":16,"type":"event"} 1: (166) LaunchOptions ExternalConsole='true' --> E (output): {"event":"output","body":{"category":"console","output":"1: (167) LaunchOptions>\n"},"seq":18,"type":"event"} 1: (167) LaunchOptions> --> E (output): {"event":"output","body":{"category":"console","output":"1: (167) LaunchOptions\n"},"seq":20,"type":"event"} 1: (167) LaunchOptions --> E (output): {"event":"output","body":{"category":"console","output":"1: (279) DbgCmd:echo $$ > /tmp/Microsoft-MIEngine-Pid-ufhd91lh.yas ; cd /home/void/Desktop/unit/04_printf ; DbgTerm=tty ; set -o monitor ; trap 'rm /tmp/Microsoft-MIEngine-In-yocc5uri.6tq /tmp/Microsoft-MIEngine-Out-hv4b5cc5.0cm /tmp/Microsoft-MIEngine-Pid-ufhd91lh.yas /tmp/Microsoft-MIEngine-Cmd-a51mlss5.zlc' EXIT ; /usr/bin/gdb --interpreter=mi --tty=$DbgTerm < /tmp/Microsoft-MIEngine-In-yocc5uri.6tq > /tmp/Microsoft-MIEngine-Out-hv4b5cc5.0cm & clear; pid=$! ; echo $pid > /tmp/Microsoft-MIEngine-Pid-ufhd91lh.yas ; wait $pid; \n"},"seq":22,"type":"event"} 1: (279) DbgCmd:echo $$ > /tmp/Microsoft-MIEngine-Pid-ufhd91lh.yas ; cd /home/void/Desktop/unit/04_printf ; DbgTerm=tty ; set -o monitor ; trap 'rm /tmp/Microsoft-MIEngine-In-yocc5uri.6tq /tmp/Microsoft-MIEngine-Out-hv4b5cc5.0cm /tmp/Microsoft-MIEngine-Pid-ufhd91lh.yas /tmp/Microsoft-MIEngine-Cmd-a51mlss5.zlc' EXIT ; /usr/bin/gdb --interpreter=mi --tty=$DbgTerm < /tmp/Microsoft-MIEngine-In-yocc5uri.6tq > /tmp/Microsoft-MIEngine-Out-hv4b5cc5.0cm & clear; pid=$! ; echo $pid > /tmp/Microsoft-MIEngine-Pid-ufhd91lh.yas ; wait $pid; --> C (runInTerminal-24): {"command":"runInTerminal","arguments":{"kind":"external","title":"cppdbg: printf","cwd":"","args":["sh","/tmp/Microsoft-MIEngine-Cmd-a51mlss5.zlc"],"env":{}},"seq":24,"type":"request"} --> E (output): {"event":"output","body":{"category":"console","output":"1: (295) Wait for connection completion.\n"},"seq":26,"type":"event"} 1: (295) Wait for connection completion.

WardenGnaw commented 5 years ago

Looks like the connection is hanging. What version of GDB are you using?

leictreon commented 5 years ago

Hopefully ok to join onto this one - I have a similar problem. Debugging used work great, now it runs and completes but does not stop at breakpoints (they stay "red" don't turn unverified), and popup message "debug adapter process has terminated". Debugging with "-g -O2" Arch linux.GNU gdb (GDB) 8.2.1 here's my log (happy to help more!) Same thing happens when I switch to GCC 7.4.1 toolchain using CMake. Thanks!

[New Thread 0x155547a9f700 (LWP 7282)] --> E (thread): {"event":"thread","body":{"reason":"started","threadId":7282},"seq":69,"type":"event"} <-- C (threads-12): {"command":"threads","type":"request","seq":12} --> R (threads-12): {"request_seq":12,"success":true,"command":"threads","body":{"threads":[{"id":7273,"name":"fit_data"},{"id":7280,"name":"fit_data"},{"id":7281,"name":"fit_data"},{"id":7282,"name":"fit_data"}]},"seq":72,"type":"response"} --> E (output): {"event":"output","body":{"category":"stdout","output":"[Thread 0x155547a9f700 (LWP 7282) exited]\n"},"seq":74,"type":"event"} [Thread 0x155547a9f700 (LWP 7282) exited] --> E (thread): {"event":"thread","body":{"reason":"exited","threadId":7282},"seq":76,"type":"event"} --> E (output): {"event":"output","body":{"category":"stdout","output":"[Thread 0x155548065700 (LWP 7280) exited]\n"},"seq":78,"type":"event"} [Thread 0x155548065700 (LWP 7280) exited] --> E (thread): {"event":"thread","body":{"reason":"exited","threadId":7280},"seq":80,"type":"event"} --> E (output): {"event":"output","body":{"category":"stdout","output":"[Thread 0x15555368d7c0 (LWP 7273) exited]\n"},"seq":82,"type":"event"} [Thread 0x15555368d7c0 (LWP 7273) exited] --> E (thread): {"event":"thread","body":{"reason":"exited","threadId":7273},"seq":84,"type":"event"} --> E (output): {"event":"output","body":{"category":"stdout","output":"[Inferior 1 (process 7273) exited normally]\n"},"seq":86,"type":"event"} [Inferior 1 (process 7273) exited normally] --> E (thread): {"event":"thread","body":{"reason":"exited","threadId":7281},"seq":88,"type":"event"} --> E (output): {"event":"output","body":{"category":"console","output":"The program '/home/roconnell/code/FuelScanner/C++/rod_fit/build/fit_data' has exited with code 0 (0x00000000).\r\n\n"},"seq":90,"type":"event"} The program '/home/roconnell/code/FuelScanner/C++/rod_fit/build/fit_data' has exited with code 0 (0x00000000). --> E (exited): {"event":"exited","body":{"exitCode":0},"seq":92,"type":"event"} --> E (terminated): {"event":"terminated","body":{},"seq":94,"type":"event"} --> E (output): {"event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/DebugCompleted","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.51030.1","VS.Diagnostics.Debugger.HostVersion":"14.0.51030.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.DebugCompleted.BreakCounter":0}},"seq":96,"type":"event"} <-- C (disconnect-13): {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":13} --> R (disconnect-13): {"request_seq":13,"success":true,"command":"disconnect","body":{},"seq":99,"type":"response"}

antonxo commented 5 years ago

@leictreon, I solved my problem by switching the “externalConsole” value to “false”, however it seems like your issue is caused by something else.

leictreon commented 5 years ago

thanks - yes my console is also set to false.

EvgehaName commented 5 years ago

Thanks ! Your help helped me !! Very well !

eldaroid commented 5 years ago

Can you also help me please. What does it mean? Loaded '/usr/lib/system/libsystem_notify.dylib'. Symbols loaded. Loaded '/usr/lib/system/libsystem_sandbox.dylib'. Symbols loaded. Loaded '/usr/lib/system/libsystem_secinit.dylib'. Symbols loaded. Loaded '/usr/lib/system/libsystem_kernel.dylib'. Symbols loaded. Loaded '/usr/lib/system/libsystem_platform.dylib'. Symbols loaded. Loaded '/usr/lib/system/libsystem_pthread.dylib'. Symbols loaded. Loaded '/usr/lib/system/libsystem_symptoms.dylib'. Symbols loaded. Loaded '/usr/lib/system/libsystem_trace.dylib'. Symbols loaded. Loaded '/usr/lib/system/libunwind.dylib'. Symbols loaded. Loaded '/usr/lib/system/libxpc.dylib'. Symbols loaded. Loaded '/usr/lib/libobjc.A.dylib'. Symbols loaded. Loaded '/usr/lib/libc++abi.dylib'. Symbols loaded. Loaded '/usr/lib/libc++.1.dylib'. Symbols loaded. Loaded '/Users/eldaroid/Desktop/proga/school21/get_next_line/a.out'. Symbols loaded. The program '/Users/eldaroid/Desktop/proga/school21/get_next_line/a.out' has exited with code 0 (0x00000000).

antonxo commented 5 years ago

@eldaroid looks like your get_next_line started and exited without stopping on a breakpoint. If you haven't set a breakpoint in your code, then do. If you did, but it doesn't work - check that you compile with gcc using debug flags. If none of this helps - you should show your debug config in VSCode. P.S. hello from Kyiv 42 school)

eldaroid commented 5 years ago

Wow, it's cool indeed, can we move into russian language, because i can`t describe my troubles in english

nursinghoming commented 4 years ago

apt-get install gdb

rz1027 commented 2 years ago

I use Manjaro. First thing : pamac install gdb Install Code Runner (by formulahendry) Extension to OSS Run your c++ code with Ctrl Alt N (or the run button)