From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10250 invoked by alias); 27 Oct 2009 18:36:23 -0000 Received: (qmail 10241 invoked by uid 22791); 27 Oct 2009 18:36:23 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Oct 2009 18:36:16 +0000 Received: from spaceape24.eur.corp.google.com (spaceape24.eur.corp.google.com [172.28.16.76]) by smtp-out.google.com with ESMTP id n9RIaDWZ032089 for ; Tue, 27 Oct 2009 11:36:14 -0700 Received: from pwj12 (pwj12.prod.google.com [10.241.219.76]) by spaceape24.eur.corp.google.com with ESMTP id n9RIaAdX018944 for ; Tue, 27 Oct 2009 11:36:11 -0700 Received: by pwj12 with SMTP id 12so299264pwj.7 for ; Tue, 27 Oct 2009 11:36:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.114.253.38 with SMTP id a38mr9023681wai.113.1256668570228; Tue, 27 Oct 2009 11:36:10 -0700 (PDT) In-Reply-To: <4AE6C656.5070007@googlemail.com> References: <4AE6C656.5070007@googlemail.com> Date: Tue, 27 Oct 2009 18:40:00 -0000 Message-ID: <8ac60eac0910271136x5375b901m8f085001a531eb62@mail.gmail.com> Subject: Re: find command with gdb v7.0 From: Paul Pluzhnikov To: James Pandavan Cc: gdb@sourceware.org, Doug Evans Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-10/txt/msg00391.txt.bz2 On Tue, Oct 27, 2009 at 3:07 AM, James Pandavan wrote: > I wanted to try out the new find command wivh gdb v7.0. I used the example > given in this page > (http://sourceware.org/gdb/current/onlinedocs/gdb_11.html#SEC91). I just > added one line (line no 5) to the example given. It looks like the search > doesn't start at given location. > > In the attached output, you can see that the find command says it couldn't > find the first word or part of it, but is able to find the second word. Is > it a bug, or am I doing something wrong? > > (gdb) find greet,+100,"greetings" > Pattern not found. > (gdb) find greet,+100,"ings" > Pattern not found. This currently searches for a sequence of bytes 'i', 'n', 'g', 's', '\0'. There is in fact no such sequence of bytes in your program, which is why you get "not found" answer. I'll grant you that it is not what one might reasonably expect, and the manual doesn't explicitly say the terminating NUL is included in the search pattern. I think removing the trailing NUL is a better fix; one could always put it back with find greet,+100,"gentleman",'\0' if one is really interested in the string with terminating NUL, whereas currently you'd have to spell each byte separately, which is rather inconvenient: (gdb) p greet $1 = 0x4005a8 "greetings gentleman" (gdb) find greet,+100,'g','r','e','e','t','i','n','g','s' 0x4005a8 1 pattern found. Feel free to open a GDB enhancement request for this. > > Thanks, > James Pandavan > > ---------------------------------------------------------------------------------------------------------- > > GNU gdb (GDB) 7.0-ubuntu > Copyright (C) 2009 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "x86_64-linux-gnu". > For bug reporting instructions, please see: > ... > Reading symbols from > /tmp/gdb/gdb_7.0-0ubuntu1_amd64/data/usr/bin/a.out...done. > (gdb) break main > Breakpoint 1 at 0x4005f4: file test.cpp, line 5. > (gdb) list 3,12 > 3 int main() > 4 { > 5 char * greet="greetings gentleman"; > 6 static char hello[] = "hello-hello"; > 7 static struct { char c; short s; int i; } > 8 __attribute__ ((packed)) mixed > 9 = { 'c', 0x1234, 0x87654321 }; > 10 printf ("%s\n", hello); > 11 return(0); > 12 } > (gdb) run > > Breakpoint 1, main () at test.cpp:5 > 5 char * greet="greetings gentleman"; > (gdb) n > 10 printf ("%s\n", hello); > (gdb) p greet > $1 = 0x4006fc "greetings gentleman" > (gdb) find greet,+100,"greetings" > Pattern not found. > (gdb) find greet,+100,"ings" > Pattern not found. > (gdb) find greet,+100,"gentleman" > 0x400706 > 1 pattern found. > (gdb) > > > > > -- Paul Pluzhnikov