* find command with gdb v7.0
@ 2009-10-27 14:32 James Pandavan
2009-10-27 18:40 ` Paul Pluzhnikov
0 siblings, 1 reply; 4+ messages in thread
From: James Pandavan @ 2009-10-27 14:32 UTC (permalink / raw)
To: gdb
Hi,
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.
Thanks,
James Pandavan
----------------------------------------------------------------------------------------------------------
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
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:
<http://www.gnu.org/software/gdb/bugs/>...
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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: find command with gdb v7.0
2009-10-27 14:32 find command with gdb v7.0 James Pandavan
@ 2009-10-27 18:40 ` Paul Pluzhnikov
2009-10-27 19:27 ` Doug Evans
0 siblings, 1 reply; 4+ messages in thread
From: Paul Pluzhnikov @ 2009-10-27 18:40 UTC (permalink / raw)
To: James Pandavan; +Cc: gdb, Doug Evans
On Tue, Oct 27, 2009 at 3:07 AM, James Pandavan
<james.pandavan@googlemail.com> 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
> <http://gnu.org/licenses/gpl.html>
> 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:
> <http://www.gnu.org/software/gdb/bugs/>...
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: find command with gdb v7.0
2009-10-27 18:40 ` Paul Pluzhnikov
@ 2009-10-27 19:27 ` Doug Evans
2009-10-28 5:07 ` James Pandavan
0 siblings, 1 reply; 4+ messages in thread
From: Doug Evans @ 2009-10-27 19:27 UTC (permalink / raw)
To: Paul Pluzhnikov; +Cc: James Pandavan, gdb
On Tue, Oct 27, 2009 at 11:36 AM, Paul Pluzhnikov
<ppluzhnikov@google.com> wrote:
< [...] the manual doesn't explicitly say the terminating
> NUL is included in the search pattern.
Well, it does, but perhaps it's in a place that's easily missed.
> I think removing the trailing NUL is a better fix; one could always put
> it back with
>
> find greet,+100,"gentleman",'\0'
Or "gentleman\0".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: find command with gdb v7.0
2009-10-27 19:27 ` Doug Evans
@ 2009-10-28 5:07 ` James Pandavan
0 siblings, 0 replies; 4+ messages in thread
From: James Pandavan @ 2009-10-28 5:07 UTC (permalink / raw)
To: Doug Evans; +Cc: Paul Pluzhnikov, gdb
Doug Evans wrote:
> On Tue, Oct 27, 2009 at 11:36 AM, Paul Pluzhnikov
> <ppluzhnikov@google.com> wrote:
> < [...] the manual doesn't explicitly say the terminating
>
>> NUL is included in the search pattern.
>>
>
> Well, it does, but perhaps it's in a place that's easily missed.
>
>
I could see the '\0' termination assumption for c/c++ mentioned in the
doc now. Don't know how I missed it before. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-27 20:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-27 14:32 find command with gdb v7.0 James Pandavan
2009-10-27 18:40 ` Paul Pluzhnikov
2009-10-27 19:27 ` Doug Evans
2009-10-28 5:07 ` James Pandavan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox