gdb debug error (exit code 134 (0x86) on MacOS (11.2.3))

Viewed 609

I've used gdb on windows so far without any problems. Now I've switched to MacOS. After successfully following the guide (https://www.ics.uci.edu/~pattis/common/handouts/macmingweclipse/allexperimental/mac-gdb-install.html) I am getting the error exit code 134 (0x86), when debugging through VS Code.

Using Big Sur 11.2.3 and VSCode 1.54.3, gdb 10.1

So far I've tried adjusting the .json files within my workspace, without any success:

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "gcc - Build and debug active file - mac",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/local/bin/gdb",
            "setupCommands": [
                {
                  "description": "Enable pretty-printing for gdb",
                  "text": "-enable-pretty-printing",
                  "ignoreFailures": true
                }
              ],
            "preLaunchTask": "C/C++: gcc mac"
        }
    ]
}

I'm using a shared workspace with windows, hence the "C/C++: gcc mac" prelaunch task. I tried googling for a solution but haven't found anything solved, as the one post I has been closed because of inactivity. also here is my engine logging:

1: (155) LaunchOptions{"name":"gcc - Build and debug active file - mac","type":"cppdbg","request":"launch","program":"/Users/asargon/Documents/Coding/C-Coding\\annesophie2","args":[],"stopAtEntry":false,"cwd":"/Users/asargon/Documents/Coding/C-Coding","environment":[],"externalConsole":false,"MIMode":"gdb","miDebuggerPath":"/usr/local/bin/gdb","setupCommands":[{"description":"Enable pretty-printing for gdb","text":"-enable-pretty-printing","ignoreFailures":true}],"preLaunchTask":"C/C++: gcc mac","logging":{"engineLogging":true},"__configurationTarget":5,"__sessionId":"e17ea5e6-28b1-4d7a-a871-4d1680682aee"}
1: (314) codeSign-stderr: Executable=/usr/local/Cellar/gdb/10.1_1/bin/gdb
1: (318) Starting: "/usr/local/bin/gdb" --interpreter=mi
1: (334) DebuggerPid=64932
1: (647) ->=thread-group-added,id="i1"
1: (648) ->~"GNU gdb (GDB) 10.1\n"
1: (649) ->~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
1: (649) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
1: (649) ->~"\nType \"show copying\" and \"show warranty\" for details.\n"
1: (650) ->~"This GDB was configured as \"x86_64-apple-darwin20.2.0\".\n"
1: (650) ->~"Type \"show configuration\" for configuration details.\n"
1: (650) ->~"For bug reporting instructions, please see:\n"
1: (650) ->~"<https://www.gnu.org/software/gdb/bugs/>.\n"
1: (650) ->~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
1: (650) ->~"\n\n"
1: (650) ->~"For help, type \"help\".\n"
1: (650) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (650) ->=cmd-param-changed,param="startup-with-shell",value="off"
1: (650) ->(gdb)
1: (655) <-1001-gdb-set target-async on
1: (656) ->1001^done
1: (656) ->(gdb)
1: (657) 1001: elapsed time 3
1: (669) <-1002-enable-pretty-printing

I also tried debugging through the terminal, but I am getting the taskgated error, which makes no sense, because gdb was codesigned by me, following the guide in the stack overflow post and if I try to codesign it it says it already is.:

Reading symbols from ./testcode...
Reading symbols from /Users/asargon/Documents/Coding/C-Coding/testcode.dSYM/Contents/Resources/DWARF/annesophie2...
(gdb) break 5
Breakpoint 1 at 0x100003e77: file testcode.c, line 5.
(gdb) run
Starting program: /Users/asargon/Documents/Coding/C-Coding/testcode
Unable to find Mach task port for process-id 92670: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
(gdb) quit

I've now tried signing and debuggin with csrutil off, but that didn't helo either. it was suggested by this https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d

1 Answers

Try installing CodeLLDB Extension. Then it should detect your project

Related