vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Unable to start debugging. Unexpected GDB output from command "-exec-run"

Open Omcsesz opened this issue 2 years ago • 6 comments

Environment

  • OS and version: Windows_NT x64 10.0.19045
  • VS Code: 1.77.3 (user setup)
  • C/C++ extension: v1.14.5
  • OS and version of remote machine (if applicable): none
  • GDB / LLDB version: GNU gdb (GDB) 13.1

Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:

  1. Create a simple helloworld project, with the "code ." command
  2. Create a main.c file in the project with the following content:
#include <stdio.h>

void main(void){
    printf("Hello World!\n");
}
  1. Open debug view
  2. Click on start debugging (F5)
  3. See the following error message: errorMessage

Debugger Configurations

tasks.json:
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\\cygwin64\\bin\\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
launch.json:
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "C/C++ Runner: Debug Session",
      "type": "cppdbg",
      "targetArchitecture": "x64",
      "request": "launch",
      "args": [],
      "stopAtEntry": false,
      "externalConsole": true,
      "cwd": "c:/Users/Omar Sweidan/source/helloworld",
      "program": "c:/Users/Omar Sweidan/source/helloworld/main.exe",
      "MIMode": "gdb",
      "miDebuggerPath": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    },
    {
      "name": "(Windows) Launch",
      "type": "cppvsdbg",
      "request": "launch",
      "program": "enter program name, for example ${workspaceFolder}/a.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${fileDirname}",
      "environment": [],
      "console": "externalTerminal"
    }
  ]
}

Debugger Logs

1: (810) <-logout
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (812) Send Event AD7ProgramDestroyEvent\r\n"},"seq":340}
1: (812) Send Event AD7ProgramDestroyEvent
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"The program 'c:\\Users\\Omar Sweidan\\source\\helloworld\\main.exe' has exited with code 0 (0x00000000).\r\n\r\n"},"seq":342}
The program 'c:\Users\Omar Sweidan\source\helloworld\main.exe' has exited with code 0 (0x00000000).

--> E (exited): {"type":"event","event":"exited","body":{"exitCode":0},"seq":344}
--> E (terminated): {"type":"event","event":"terminated","body":{},"seq":346}
--> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/DebugCompleted","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"17.4.21117.1","VS.Diagnostics.Debugger.HostVersion":"17.4.21117.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.DebugCompleted.BreakCounter":0}},"seq":348}
<--   C (disconnect-9): {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":9}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (826) <--gdb-exit\r\n"},"seq":351}
1: (826) <--gdb-exit
--> R (disconnect-9): {"type":"response","request_seq":9,"success":true,"command":"disconnect","body":{},"seq":353}

Other Extensions

No response

Additional Information

I would like to know if this is a bug in gdb, or the extensions. Also it would be good if the error would contain more information on what I did wrong.

Omcsesz avatar Apr 28 '23 16:04 Omcsesz

The debugger logs you provided do not match the one in the image. Could you share the logs in the scenario that you get the error?

WardenGnaw avatar May 02 '23 18:05 WardenGnaw

@WardenGnaw Here you have: error.log

Omcsesz avatar May 03 '23 08:05 Omcsesz

--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1732) ->1012^error,msg="During startup program exited with code 0xc0000135."\r\n"},"seq":298} 1: (1732) ->1012^error,msg="During startup program exited with code 0xc0000135."

0xc0000135 is dll not found. Do you have the C:\\cygwin64\\bin\\ in your environment path?

WardenGnaw avatar May 04 '23 18:05 WardenGnaw

@WardenGnaw No, I have c:\msys64\mingw64\bin instead.

Omcsesz avatar May 06 '23 20:05 Omcsesz

@WardenGnaw Any idea on what is going wrong here?

Omcsesz avatar May 28 '23 20:05 Omcsesz

Met the same problem, have no idea to locate the root issue, feel bad.

ype "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
[New Thread 2568.0x31f4]
[New Thread 2568.0x3564]
[Thread 2568.0x3564 exited with code 3221225785]
[Thread 2568.0x31f4 exited with code 3221225785]
[Thread 2568.0x2454 exited with code 3221225785]
[New Thread 2568.0x4850]
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". During startup program exited with code 0xc0000139.
The program 'D:\Github\libadwaita\build\src\adwaita-1-demo.exe' has exited with code 0 (0x00000000).

taozuhong avatar Aug 28 '24 06:08 taozuhong

I'm also facing this issue. Using VSCode. Any possible solutions or possible causes? I saw people comenting on the version of GDB, asking people to downgrade it to v9 or something...

Any suggestions?

Marcelo-Petrucelli avatar Dec 12 '24 10:12 Marcelo-Petrucelli

@WardenGnaw No, I have c:\msys64\mingw64\bin instead.

Put "c:\msys64\mingw64\bin;" at the very front of "PATH":

"environment": [
    {
        "name": "PATH",
        "value": "C:/msys64/mingw64/bin;${env:PATH};${command:qt-cpp.qtDir};"
    },
]

Otherwise, some DLLS might be loaded incorrectly (possibly with the same name as those in windows).

listenerri avatar Apr 21 '25 09:04 listenerri