Search code examples
gdbgdbserver

Equivalent of `handle` command for GDB/MI


I'm using VSCode to debug some things. It works via GDB/MI (gdbserver's protocol). In GDB you can ignore signals like this:

handle SIGPIPE nostop pass

How do I achieve the same thing with GDB/MI?


Solution

  • You're mixing ideas a little here. gdbserver talks to GDB using the Remote Protocol, which is unrelated to GDB/MI.

    GDB/MI is just one of GDB's command interpreters, the idea being that the output of GDB/MI commands is more structured, and easier for parsing by a frontend like VSCode or Eclipse.

    I don't believe there's any GDB/MI command for interacting with the signal handler settings.

    However, the GDB/MI interpreter will also accept all standard command line commands, and so, you can just use the handle SIGPIPE nostop pass command, like this:

    $ gdb -q -i mi
    =thread-group-added,id="i1"
    =cmd-param-changed,param="print pretty",value="on"
    (gdb) 
    handle SIGPIPE nostop pass
    &"handle SIGPIPE nostop pass\n"
    ~"Signal        Stop\tPrint\tPass to program\tDescription\n"
    ~"SIGPIPE       No\tYes\tYes\t\tBroken pipe\n"
    ^done
    (gdb) 
    

    The output from running commands this way is not as easy to parse, but it can be done.