This is the mail archive of the
mailing list for the GDB project.
Re: Searching for pattern in memory from GDB?
- From: Michael Snyder <msnyder at redhat dot com>
- To: gdb at sources dot redhat dot com
- Cc: jnordby at caspiannetworks dot com
- Date: Thu, 11 Apr 2002 14:20:54 -0700
- Subject: Re: Searching for pattern in memory from GDB?
- Newsgroups: cygnus.gdb
- Organization: Red Hat, Inc.
- References: <3CB1E451.CFCA2BE2@caspiannetworks.com>
James Nordby wrote:
> 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
> of the trace buffer, I could look for that with gdb and use gdb to
> 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
Or, you could just write a gdb macro, something like
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