Writing Front End for GDB

I want to write a GUI-based debugger wrapped in GDB. Because, I do not want the program to stop after the observation points or break points. Instead, it should redirect data such as file name, line number, new value and material to the file and continue execution.

I'm pretty bad at scripting. So, I want the starting point to start developing an interface for GDB. As far as I understand, this link http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_211.html is not clear for beginners in this activity?

Hope I get some help with C / C ++ development.

+7
source share
4 answers

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.

+11
source

Since you have already specified the gdb / mi interface, perhaps an existing solution may give you an idea of ​​how to satisfy your needs. Here is a list of existing interfaces. Look at their approaches and how they address various issues.

Another approach that may be useful is automatic sessions. Do not prevent you from writing gdb gui, but such automation can be a good start to get the necessary steps and, possibly, can also be used as a start. Perhaps creating a script session and running gdb with it. gdb -x to load the batch file.

Here's a link to automation: What are the best ways to automate a GDB debugging session?

Hope this helps. Good luck

+2
source

Although creating new GUI tools gives you more knowledge, I suggest you get involved in eclipe and modify to suit your needs. This saves you time as well as more flexibility.

+1
source

Programming a gdb wrapper to achieve your goal is a way to work hard.

See how you can execute a script when hitting a breakpoint: gdb scripting: execute commands at the selected breakpoint

Also pay attention to gdb breakpoints: http://sourceware.org/gdb/onlinedocs/gdb/Tracepoints.html

+1
source

All Articles