1

I keep getting Unexpected GDB output from command "-exec-run" error in the debug console while I try to run my c++ code which includes a custom class I made and takes a .txt file as an input in the same path.

I'm using the command g++ -g class.h class.cpp mycode.cpp -o mycode.exe in the terminal and just try to debug the code with F5.

I don't get this error when I'm executing a cpp file with no libraries included

Here is my launch.json file

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "(gdb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${fileDirname}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        },
        {
          "description": "Set Disassembly Flavor to Intel",
          "text": "-gdb-set disassembly-flavor intel",
          "ignoreFailures": true
        }
      ]
    }
  ]
}

I've heard downgrading gdb or g++ could help but I could not understand how can I downgrade them. If you think that's the solution a simple explanation for how to downgrade would be much appreciated.

Nejc Galof
  • 2,538
  • 3
  • 31
  • 70
Umut
  • 23
  • 5
  • 1
    Related: [https://stackoverflow.com/questions/60923232/error-unable-to-start-debugging-unexpected-gdb-output-from-command-exec-run](https://stackoverflow.com/questions/60923232/error-unable-to-start-debugging-unexpected-gdb-output-from-command-exec-run) – drescherjm Jan 13 '22 at 15:06
  • I can debug in VSCode with the current msys2 gdb with no changes to the launch.json – drescherjm Jan 13 '22 at 15:09
  • I don't have any non ascii characters in my code – Umut Jan 13 '22 at 15:10
  • I didn't mean the code I meant the path where you have your source files. Spaces and other utf characters can cause problems. – drescherjm Jan 13 '22 at 15:11
  • I had a space in my path. I got rid of it but the problem still persists. – Umut Jan 13 '22 at 15:16
  • @Umut If I understand you correctly your question is how to downgrade gdb because of this problem. Consider editing this question to the context you need. – Nejc Galof Jan 22 '22 at 10:43

0 Answers0