Re: GDB C API -- does such a thing exist?

Bob Rossi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <20141016140154.GA11459@linux>
On Thu, Oct 16, 2014 at 02:20:25PM +0300, Ömer Sinan Ağacan wrote:
> Do we have a C API for GDB? Something that allows me to run all the
> GDB commands/functions that I can run in GDB prompt, but without
> messing with GDB prompt?
> 
> Python API is not great for what I want to do. I want to run GDB
> inside a program, search for some specific currently-running
> processes, attach to them, add some breakpoints etc. although all of
> those are possible with Python API, 1) I'm not huge fan of the
> language 2) I feel like most things would be a lot easier if I could
> use a C API that allows me to drive GDB itself.

There is not. Your options are to use the GDB/MI interface or use the
python api.

If you want to use the GDB/MI interface, congratulations, you have to
read and interpret the spec, find all the bugs in it, write a parser
to support all the cases and test it against old and new versions of
GDB. It's a daunting task, I know, I'm working on it.
  https://github.com/brasko/gdbwire
I don't expect to be done implementing and testing this for a long time.

If you want to use the GDB python interface you need to understand that
many GDB deployments do not have the python interpreter built into them.
Also, I'm not sure anyone has successfully tried to control GDB through
the python interface while allowing the user to use the cli interface.
Not sure if this is your goal.

Both of these approaches are possible, but not for the faint of heart.

Good luck!
Bob Rossi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.