From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6064 invoked by alias); 11 Apr 2002 21:45:09 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 6046 invoked by uid 22784); 11 Apr 2002 21:45:08 -0000 From: Michael Snyder Newsgroups: cygnus.gdb Subject: Re: Searching for pattern in memory from GDB? Date: Thu, 11 Apr 2002 14:45:00 -0000 Organization: Red Hat, Inc. Message-ID: <3CB5FE36.2DF1449F@redhat.com> References: <3CB1E451.CFCA2BE2@caspiannetworks.com> NNTP-Posting-Host: reddwarf.sfbay.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: cronkite.cygnus.com 1018560770 12760 172.16.24.50 (11 Apr 2002 21:32:50 GMT) X-Complaints-To: postmaster@cygnus.com NNTP-Posting-Date: 11 Apr 2002 21:32:50 GMT Cc: jnordby@caspiannetworks.com X-Accept-Language: en To: gdb@sources.redhat.com DJ-Gateway: from newsgroup cygnus.gdb X-SW-Source: 2002-04/txt/msg00182.txt.bz2 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 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