Monday, June 21, 2010

GDB patches

Patches to add commands to the gdb debugger

GDB is a very portable and useful debugger, but it lacks some basic funcionality like search for a pattern of memory and fill regions with a value. In this page i will be publishing a series of patches to add that funcionality to the GDB debugger, hopefully in a portable way.

1. Search and Fill

Update 12-7-2008:

I found a much better and simpler way to search and fill in gdb without patching if you are using a modern libc:

Search any byte sequence:
(gdb) call memmem (addr,lenght,bytesequence,length_bytesequence)

That's all, it will return the address if the sequence was found.

The same about filling:

(gdb) call memset(bla bla)

you get the idea...


BTW, this is the older version: is a patch to the gdb and is slower, but it can search over the entire address space:
The patch is very small and only adds the "search" and "fill" command. Should be applied to the GDB 6.6 source:

Old Search and fill patch

2. Breakpoint commands external editor

This is a patch to allow editing the commands attached to a breakpoint using an external editor. The editor follows the behavior of the "edit" command, using /bin/ex, or the content of the enviroment variable "EDITOR". Should be used like this:

(gdb) command 1

Edits in the old way, but:

(gdb) command 1 edit

spawns the external editor. (I recommend setting EDITOR to 'vi')

The patch should be applied to the gdb 6.8 source tree.

Commands patch


(under review)

3. Show breakpoints in source listing

This simple patch allows breakpoints to be displayed when using the "list" command. The breakpont number is displayed in the corresponding line. This patch should be applied to the gdb 6.8 source tree:

Breakpoints in listing patch (Not submitted yet)

4. ptracediff

Not really a patch but a simple tool for a "contest": ptracediff.c

No comments:

Post a Comment

Big brother is watching