You really want to use the GDB / MI protocol to write the GDB interface, but maybe read this up instead of the old one you contacted.
GDB / MI Session Example
(Easily edited version of this section from the GDB manual)
Running GDB with MI Command Interpreter
$ gdb -q --interpreter=mi2 =thread-group-added,id="i1" (gdb)
File / bin / true
-file-exec-and-symbols /bin/true ^done (gdb)
Main section
-break-insert main ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004014c0",func="main",file="true.c",fullname="/usr/src/debug/coreutils-8.17/src/true.c",line="59",times="0",original-location="main"} (gdb)
Mileage and breakpoint
-exec-run =thread-group-started,id="i1",pid="2275" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1" =library-loaded,id="/lib64/libc.so.6",target-name="/lib64/libc.so.6",host-name="/lib64/libc.so.6",symbols-loaded="0",thread-group="i1" =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004014c0",func="main",file="true.c",fullname="/usr/src/debug/coreutils-8.17/src/true.c",line="59",times="1",original-location="main"} *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x00000000004014c0",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffde98"}],file="true.c",fullname="/usr/src/debug/coreutils-8.17/src/true.c",line="59"},thread-id="1",stopped-threads="all",core="1" (gdb)
Proceed
-exec-continue ^running *running,thread-id="1" (gdb) =thread-exited,id="1",group-id="i1" =thread-group-exited,id="i1",exit-code="0" *stopped,reason="exited-normally"
Exit GDB
(gdb) -gdb-exit ^exit
Existing GDB / MI Clients
There are several implementations of the GDB / MI client in C, C ++, Java, Python. I have listed a few that are easy for me to read:
- Inactive libmigdb project ( sample program , public interfaces ). The good news is trying to create a reusable C library. The bad news is that it is not properly supported, for example. I think it lacks non-stop GDB support and support for catchpoint commands, functions that your use case will probably need.
- python-gdb-mi - Enough readable if you know Python
- The C ++ GDB / MI client code in QtCreator is also quite readable, although it is written as part of the abstraction layer to support several debugger engines.
You can also view this list of GDB interfaces.