microsoft / vscode-cpptools

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

Launching the debugger in mode "gdb" hangs forever #3353

Open brunnerant opened 5 years ago

brunnerant commented 5 years ago

System information: -OS: Windows 10 -VS code version: 1.32.3 -Extension: C/C++, version 0.22.1 -Compiler/debugger version: MinGW.org GCC-8.2.0-3

Bug description: When launching the debugger, configured in mode "gdb", the blue bar is loading forever and nothing happens. I already tried to enable logging but nothing is output to the VS code debug console. However when setting externalConsole to false, the following line is printed in the integrated terminal:

env "c:\Users\brunn\.vscode\extensions\ms-vscode.cpptools-0.22.1\debugAdapters\bin\WindowsDebugLauncher.exe" --stdin=Microsoft-MIEngine-In-fyz0vlaa.gej --stdout=Microsoft-MIEngine-Out-0aiqcb4f.wbn --stderr=Microsoft-MIEngine-Error-gvbsagt3.yu1 --pid=Microsoft-MIEngine-Pid-aqbc4pf3.3dh --dbgExe=C:/Data/Programmes/MinGW/bin/gdb.exe --interpreter=mi

However, this command never terminates and it seems like something goes wrong during the execution of that command.

{
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/main.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/Data/Programmes/MinGW/bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false
                }
            ]
 }
WardenGnaw commented 5 years ago

The env "c:\Users\brunn\.vscode\extensions\ms-vscode.cpptools-0.22.1\debugAdapters\bin\WindowsDebugLauncher.exe" --stdin=Microsoft-MIEngine-In-fyz0vlaa.gej --stdout=Microsoft-MIEngine-Out-0aiqcb4f.wbn --stderr=Microsoft-MIEngine-Error-gvbsagt3.yu1 --pid=Microsoft-MIEngine-Pid-aqbc4pf3.3dh --dbgExe=C:/Data/Programmes/MinGW/bin/gdb.exe --interpreter=mi command is only used when externalConsole is set to false. If it still hangs while set to true, theres another issue.

Can you enable logging and share the logs here?

Does running C:/Data/Programmes/MinGW/bin/gdb.exe also start GDB?

brunnerant commented 5 years ago

Here is the output in the debug console when enabling logging: Running executable [New Thread 9652.0x1710] [New Thread 9652.0x28cc] error return ../../gdb-7.6.1/gdb/windows-nat.c:1275 was 5

And to answer your second question, yes, the path you gave me successfully launches GDB.

thelastlin commented 5 years ago

Have the same problem here.

-OS: Windows 10 [18362.30] -VSCode Version: 1.33.0 -Extension: C/C++, version 0.22.2-insiders -Compiler/debugger version: 7.3.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)

Here is show in PS console:

& 'c:\Users\thelastline\.vscode\extensions\ms-vscode.cpptools-0.22.2-insiders\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-32u4u1hm.n1x' '--stdout=Microsoft-MIEngine-Out-1h4dx2de.qce' '--stderr=Microsoft-MIEngine-Error-cde2kxmr.24f' '--pid=Microsoft-MIEngine-Pid-v0jahlrg.d5x' '--dbgExe=D:\BuildTools\mingw-w64\mingw64\bin\gdb.exe' '--interpreter=mi'

And it never terminate, programs(need debug) doesn't launch, too. Run D:\BuildTools\mingw-w64\mingw64\bin\gdb.exe manually and it's looks good. Try to set externalConsole to true, still hang and can't debug programs.

Enable logging with Here, get nothing.


update: I disable unicode support on Windows codepage settings, now it works. Maybe like Issue 1527.

sususu98 commented 5 years ago

@thelastlin thank you

phanthaiduong22 commented 4 years ago

Have the same problem here.

-OS: Windows 10 [18362.30] -VSCode Version: 1.33.0 -Extension: C/C++, version 0.22.2-insiders -Compiler/debugger version: 7.3.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)

Here is show in PS console:

& 'c:\Users\thelastline\.vscode\extensions\ms-vscode.cpptools-0.22.2-insiders\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-32u4u1hm.n1x' '--stdout=Microsoft-MIEngine-Out-1h4dx2de.qce' '--stderr=Microsoft-MIEngine-Error-cde2kxmr.24f' '--pid=Microsoft-MIEngine-Pid-v0jahlrg.d5x' '--dbgExe=D:\BuildTools\mingw-w64\mingw64\bin\gdb.exe' '--interpreter=mi'

And it never terminate, programs(need debug) doesn't launch, too. Run D:\BuildTools\mingw-w64\mingw64\bin\gdb.exe manually and it's looks good. Try to set externalConsole to true, still hang and can't debug programs.

Enable logging with Here, get nothing.

=============== ` update: I disable unicode support on Windows codepage settings, now it works. Maybe like Issue 1527.

how did you do that?

lizhijian-cn commented 4 years ago

Have the same problem here. -OS: Windows 10 [18362.30] -VSCode Version: 1.33.0 -Extension: C/C++, version 0.22.2-insiders -Compiler/debugger version: 7.3.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project) Here is show in PS console:

& 'c:\Users\thelastline\.vscode\extensions\ms-vscode.cpptools-0.22.2-insiders\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-32u4u1hm.n1x' '--stdout=Microsoft-MIEngine-Out-1h4dx2de.qce' '--stderr=Microsoft-MIEngine-Error-cde2kxmr.24f' '--pid=Microsoft-MIEngine-Pid-v0jahlrg.d5x' '--dbgExe=D:\BuildTools\mingw-w64\mingw64\bin\gdb.exe' '--interpreter=mi'

And it never terminate, programs(need debug) doesn't launch, too. Run D:\BuildTools\mingw-w64\mingw64\bin\gdb.exe manually and it's looks good. Try to set externalConsole to true, still hang and can't debug programs. Enable logging with Here, get nothing.

` update: I disable unicode support on Windows codepage settings, now it works. Maybe like Issue 1527.

how did you do that?

just like this

peitschie commented 4 years ago

I had this issue, and it turned out to be caused by having the NoMachine server (https://www.nomachine.com) installed on my Windows box. Once I uninstalled NoMachine, I could suddenly debug again.

Perhaps something about how NoMachine hooks into processes and windows was interfering with the STDOUT/STDERR redirection behaviour in VSCode?

UC101 commented 2 years ago

I had this issue, and it turned out to be caused by having the NoMachine server (https://www.nomachine.com) installed on my Windows box. Once I uninstalled NoMachine, I could suddenly debug again.

Perhaps something about how NoMachine hooks into processes and windows was interfering with the STDOUT/STDERR redirection behaviour in VSCode?

I solved this similarly, I had Yori installed, removed it and it works fine now.

y0-gesh commented 2 years ago

& 'c:\Users\MyPC.vscode\extensions\ms-vscode.cpptools-1.9.8-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-ittb4hsp.wwn' '--stdout=Microsoft-MIEngine-Out-4mifsdp0.zhk' '--stderr=Microsoft-MIEngine-Error-wvrj15b5.oq3' '--pid=Microsoft-MIEngine-Pid-fhvgjas0.jnc' '--dbgExe=C:\msys64\mingw64\bin\gdb.exe' '--interpreter=mi' The program runs cpp file but not c language!

GrauBlitz commented 1 year ago

& 'c:\Users\MyPC.vscode\extensions\ms-vscode.cpptools-1.9.8-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-ittb4hsp.wwn' '--stdout=Microsoft-MIEngine-Out-4mifsdp0.zhk' '--stderr=Microsoft-MIEngine-Error-wvrj15b5.oq3' '--pid=Microsoft-MIEngine-Pid-fhvgjas0.jnc' '--dbgExe=C:\msys64\mingw64\bin\gdb.exe' '--interpreter=mi' The program runs cpp file but not c language!

I have the same issues, it just hangs on this command, no information, nothing.

mildstorm commented 1 year ago

Reference) https://gist.github.com/robotdad/63c4f23f061a9f988f1a66948d672e50

I tested my BMP(Black Magic Probe) debugger. (https://black-magic.org/index.html) 1) It works in STM32CubeIDE with arm-none-eabi-gdb without problem. 2) But it doesn't work in Visual Studio Code with arm-none-eabi-gdb.


Test Settings

1) code runner extension

image

2) launch.json ` "name": "Black Magic Probe",

  "type": "cppdbg",

  "request": "launch",

  "cwd": "${workspaceFolder}",

  "MIMode": "gdb",

  "program": "${workspaceRoot}\\build\\debug\\build\\BluePill.elf",

  "miDebuggerPath": "arm-none-eabi-gdb.exe",

  "customLaunchSetupCommands": [

    {

      "text": "target extended-remote COM8"

    },

    {

      "text": "monitor swdp_scan"

    },

    {

      "text": "attach 1"

    },

    {

      "text": "file BluePill.elf"

    },

    {

      "text": "load"

    }

  ]

`

Problem : After "text": "attach 1", it hangs.

image image image