Searching for pattern in memory from GDB?
Michael Snyder
msnyder@redhat.com
Thu Apr 11 14:45:00 GMT 2002
James Nordby wrote:
>
> Hi,
>
> I'm trying to put together a fast, internal-circular-buffer-type tracing
> package. I want to get able to extract the traces from either a running
> program or a core file, but our binaries are normally sent out stripped.
> I thought if I put a word or two with a particular pattern at the
> beginning
> of the trace buffer, I could look for that with gdb and use gdb to
> format
> the rest of the buffer.
>
> Do you know of any way to say 'search for pattern in <BSS,heap> space'
> in gdb?
>
> If not, can you think of any other way to find a buffer in a stripped
> binary?
Or, you could just write a gdb macro, something like
define search
set $start = (char *) $arg0
set $end = (char *) $arg1
set $pattern = (int) $arg2
set $p = $start
while $p < $end
if (*(int *) $p) == $pattern
printf "pattern 0x%x found at 0x$x\n", $pattern, $p
end
set $p++
end
end
More information about the Gdb
mailing list