17

I want to make me a small GUI version of the GDB command line program on Linux to make debugging of small C programs more easier. There may exists already some especially in IDEs but I want to make it for fun and get better known to GDB.

Now I wanted to know whether GDB has a API so I can access GDB commands directly from code and I don't have to make a detour through the terminal for example with popen.

If there does not exists such a API from GDB, whats the simplest way to start GDB hidden and send commands to it, retrieve outputs from it?

Paul Rooney
  • 20,879
  • 9
  • 40
  • 61
Michael
  • 595
  • 5
  • 19
  • 1
    There is some useful information here about this: https://sourceware.org/gdb/papers/libgdb2/libgdb_toc.html – πάντα ῥεῖ Oct 03 '15 at 09:46
  • 4
    This seems like a perfectly valid question. It isn't asking for a recommendation at all but for (1) whether there is an api, and (2) an example. And it happens to have a valid answer which was gone and deleted! :( quite sad. This shows up first on google. Even with all arguments, this still serves as an excellent resource. – gideon Jul 25 '16 at 11:42
  • 1
    Related: [Writing Front End for GDB](https://stackoverflow.com/q/16771393/4975230) – jrh Aug 13 '18 at 14:04
  • 1
    **Warning:** It looks like the top google result, libgdb, [has been abandoned for years](https://sourceware.org/ml/gdb-patches/2009-03/msg00676.html); It looks like GDB MI is a better option. – jrh Aug 13 '18 at 14:09

1 Answers1

13

Many IDEs such as Eclipse and KDevelop use GDB MI (Machine Interface). It is line based machine oriented text interface to GDB. See full list here: https://sourceware.org/gdb/wiki/GDB%20Front%20Ends.

See these links to get started with GDB MI:

ks1322
  • 33,961
  • 14
  • 109
  • 164