* Update find command help and search memory docs
@ 2017-11-26 15:45 Dominik Czarnota
2017-11-26 17:44 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Dominik Czarnota @ 2017-11-26 15:45 UTC (permalink / raw)
To: gdb-patches
Hey,
This patch updates `find` command help and docs description to show
how to search for not null terminated strings when current language's
strings includes it.
It addresses an issue I have opened here:
https://sourceware.org/bugzilla/show_bug.cgi?id=21945 and so it can be
closed.
Thanks,
Dominik aka 'disconnect3d'
gdb/ChangeLog:
PR gdb/21945
* findcmd.c (_initialize_mem_search), gdb/doc/gdb.texinfo: Update
find command description.
* doc/gdb.texinfo: Update search memory description and example.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 00451d243d..5b9946a9cf 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -11920,6 +11920,8 @@ giant words (eight bytes)
All values are interpreted in the current language.
This means, for example, that if the current source language is C/C@t{++}
then searching for the string ``hello'' includes the trailing '\0'.
+The null terminator can be removed from searching by using casts,
+e.g.: @samp{{char[5]}"hello"}.
If the value size is not specified, it is taken from the
value's type in the current language.
@@ -11969,7 +11971,11 @@ you get during debugging:
(gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o'
0x8049567 <hello.1620>
0x804956d <hello.1620+6>
-2 patterns found
+2 patterns found.
+(gdb) find &hello[0], +sizeof(hello), {char[5]}"hello"
+0x8049567 <hello.1620>
+0x804956d <hello.1620+6>
+2 patterns found.
(gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l'
0x8049567 <hello.1620>
1 pattern found
diff --git a/gdb/findcmd.c b/gdb/findcmd.c
index b43fefc06d..ff6088eac1 100644
--- a/gdb/findcmd.c
+++ b/gdb/findcmd.c
@@ -293,7 +293,9 @@ and if not specified the size is taken from the
type of the expression\n\
in the current language.\n\
Note that this means for example that in the case of C-like languages\n\
a search for an untyped 0x42 will search for \"(int) 0x42\"\n\
-which is typically four bytes.\n\
+which is typically four bytes, and a search for a string \"hello\" will\n\
+include the tralinig '\\0'. The null terminator can be removed from\n\
+searching by using casts, e.g.: {char[5]}\"hello\".\n\
\n\
The address of the last match is stored as the value of \"$_\".\n\
Convenience variable \"$numfound\" is set to the number of matches."),
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Update find command help and search memory docs 2017-11-26 15:45 Update find command help and search memory docs Dominik Czarnota @ 2017-11-26 17:44 ` Eli Zaretskii 2017-11-26 20:41 ` Dominik Czarnota 0 siblings, 1 reply; 5+ messages in thread From: Eli Zaretskii @ 2017-11-26 17:44 UTC (permalink / raw) To: Dominik Czarnota; +Cc: gdb-patches > From: Dominik Czarnota <dominik.b.czarnota@gmail.com> > Date: Sun, 26 Nov 2017 16:44:30 +0100 > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 00451d243d..5b9946a9cf 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -11920,6 +11920,8 @@ giant words (eight bytes) > All values are interpreted in the current language. > This means, for example, that if the current source language is C/C@t{++} > then searching for the string ``hello'' includes the trailing '\0'. > +The null terminator can be removed from searching by using casts, > +e.g.: @samp{{char[5]}"hello"}. > > If the value size is not specified, it is taken from the > value's type in the current language. > @@ -11969,7 +11971,11 @@ you get during debugging: > (gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o' > 0x8049567 <hello.1620> > 0x804956d <hello.1620+6> > -2 patterns found > +2 patterns found. > +(gdb) find &hello[0], +sizeof(hello), {char[5]}"hello" > +0x8049567 <hello.1620> > +0x804956d <hello.1620+6> > +2 patterns found. > (gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l' > 0x8049567 <hello.1620> > 1 pattern found This part is OK. > diff --git a/gdb/findcmd.c b/gdb/findcmd.c > index b43fefc06d..ff6088eac1 100644 > --- a/gdb/findcmd.c > +++ b/gdb/findcmd.c > @@ -293,7 +293,9 @@ and if not specified the size is taken from the > type of the expression\n\ > in the current language.\n\ > Note that this means for example that in the case of C-like languages\n\ > a search for an untyped 0x42 will search for \"(int) 0x42\"\n\ > -which is typically four bytes.\n\ > +which is typically four bytes, and a search for a string \"hello\" will\n\ > +include the tralinig '\\0'. The null terminator can be removed from\n\ ^^ Two spaces here, please. Thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Update find command help and search memory docs 2017-11-26 17:44 ` Eli Zaretskii @ 2017-11-26 20:41 ` Dominik Czarnota 2017-11-27 3:26 ` Eli Zaretskii 0 siblings, 1 reply; 5+ messages in thread From: Dominik Czarnota @ 2017-11-26 20:41 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches Changed space after dot into two and fixed a typo `tralinig` -> `trailing`. gdb/ChangeLog: PR gdb/21945 * findcmd.c (_initialize_mem_search), gdb/doc/gdb.texinfo: Update find command description. * doc/gdb.texinfo: Update search memory description and example. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 00451d243d..5b9946a9cf 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -11920,6 +11920,8 @@ giant words (eight bytes) All values are interpreted in the current language. This means, for example, that if the current source language is C/C@t{++} then searching for the string ``hello'' includes the trailing '\0'. +The null terminator can be removed from searching by using casts, +e.g.: @samp{{char[5]}"hello"}. If the value size is not specified, it is taken from the value's type in the current language. @@ -11969,7 +11971,11 @@ you get during debugging: (gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o' 0x8049567 <hello.1620> 0x804956d <hello.1620+6> -2 patterns found +2 patterns found. +(gdb) find &hello[0], +sizeof(hello), {char[5]}"hello" +0x8049567 <hello.1620> +0x804956d <hello.1620+6> +2 patterns found. (gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l' 0x8049567 <hello.1620> 1 pattern found diff --git a/gdb/findcmd.c b/gdb/findcmd.c index b43fefc06d..ff6088eac1 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -293,7 +293,9 @@ and if not specified the size is taken from the type of the expression\n\ in the current language.\n\ Note that this means for example that in the case of C-like languages\n\ a search for an untyped 0x42 will search for \"(int) 0x42\"\n\ -which is typically four bytes.\n\ +which is typically four bytes, and a search for a string \"hello\" will\n\ +include the trailing '\\0'. The null terminator can be removed from\n\ +searching by using casts, e.g.: {char[5]}\"hello\".\n\ \n\ The address of the last match is stored as the value of \"$_\".\n\ Convenience variable \"$numfound\" is set to the number of matches."), 2017-11-26 18:43 GMT+01:00 Eli Zaretskii <eliz@gnu.org>: >> From: Dominik Czarnota <dominik.b.czarnota@gmail.com> >> Date: Sun, 26 Nov 2017 16:44:30 +0100 >> >> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo >> index 00451d243d..5b9946a9cf 100644 >> --- a/gdb/doc/gdb.texinfo >> +++ b/gdb/doc/gdb.texinfo >> @@ -11920,6 +11920,8 @@ giant words (eight bytes) >> All values are interpreted in the current language. >> This means, for example, that if the current source language is C/C@t{++} >> then searching for the string ``hello'' includes the trailing '\0'. >> +The null terminator can be removed from searching by using casts, >> +e.g.: @samp{{char[5]}"hello"}. >> >> If the value size is not specified, it is taken from the >> value's type in the current language. >> @@ -11969,7 +11971,11 @@ you get during debugging: >> (gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o' >> 0x8049567 <hello.1620> >> 0x804956d <hello.1620+6> >> -2 patterns found >> +2 patterns found. >> +(gdb) find &hello[0], +sizeof(hello), {char[5]}"hello" >> +0x8049567 <hello.1620> >> +0x804956d <hello.1620+6> >> +2 patterns found. >> (gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l' >> 0x8049567 <hello.1620> >> 1 pattern found > > This part is OK. > >> diff --git a/gdb/findcmd.c b/gdb/findcmd.c >> index b43fefc06d..ff6088eac1 100644 >> --- a/gdb/findcmd.c >> +++ b/gdb/findcmd.c >> @@ -293,7 +293,9 @@ and if not specified the size is taken from the >> type of the expression\n\ >> in the current language.\n\ >> Note that this means for example that in the case of C-like languages\n\ >> a search for an untyped 0x42 will search for \"(int) 0x42\"\n\ >> -which is typically four bytes.\n\ >> +which is typically four bytes, and a search for a string \"hello\" will\n\ >> +include the tralinig '\\0'. The null terminator can be removed from\n\ > ^^ > Two spaces here, please. > > Thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Update find command help and search memory docs 2017-11-26 20:41 ` Dominik Czarnota @ 2017-11-27 3:26 ` Eli Zaretskii 2017-11-27 3:48 ` Simon Marchi 0 siblings, 1 reply; 5+ messages in thread From: Eli Zaretskii @ 2017-11-27 3:26 UTC (permalink / raw) To: Dominik Czarnota; +Cc: gdb-patches > From: Dominik Czarnota <dominik.b.czarnota@gmail.com> > Date: Sun, 26 Nov 2017 21:40:30 +0100 > Cc: gdb-patches@sourceware.org > > Changed space after dot into two and fixed a typo `tralinig` -> `trailing`. > > > > gdb/ChangeLog: > > PR gdb/21945 > * findcmd.c (_initialize_mem_search), gdb/doc/gdb.texinfo: Update > find command description. > * doc/gdb.texinfo: Update search memory description and example. OK. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Update find command help and search memory docs 2017-11-27 3:26 ` Eli Zaretskii @ 2017-11-27 3:48 ` Simon Marchi 0 siblings, 0 replies; 5+ messages in thread From: Simon Marchi @ 2017-11-27 3:48 UTC (permalink / raw) To: Eli Zaretskii, Dominik Czarnota; +Cc: gdb-patches On 2017-11-26 10:26 PM, Eli Zaretskii wrote: >> From: Dominik Czarnota <dominik.b.czarnota@gmail.com> >> Date: Sun, 26 Nov 2017 21:40:30 +0100 >> Cc: gdb-patches@sourceware.org >> >> Changed space after dot into two and fixed a typo `tralinig` -> `trailing`. >> >> >> >> gdb/ChangeLog: >> >> PR gdb/21945 >> * findcmd.c (_initialize_mem_search), gdb/doc/gdb.texinfo: Update >> find command description. >> * doc/gdb.texinfo: Update search memory description and example. > > OK. > I tried to build the doc and got this: /home/simark/src/binutils-gdb/gdb/doc/gdb.texinfo:11924: misplaced { /home/simark/src/binutils-gdb/gdb/doc/gdb.texinfo:11924: misplaced } /home/simark/src/binutils-gdb/gdb/doc/gdb.texinfo:11975: misplaced { /home/simark/src/binutils-gdb/gdb/doc/gdb.texinfo:11975: misplaced } It is necessary to escape the { and } with a @. Also, the doc changes should be mentioned in the ChangeLog in the doc directory (the closest to the changed files in the tree). Also, when changing something in the texinfo documents, we try to mention the section, like this: * gdb.texinfo (Search Memory): Update description and example about how to search a string without NULL terminator. Thanks for the patch, I fixed those small issues and pushed this: From ee9a09e959a5b7c152cc72028d4f6c879bc901c9 Mon Sep 17 00:00:00 2001 From: Dominik Czarnota <dominik.b.czarnota@gmail.com> Date: Sun, 26 Nov 2017 22:42:18 -0500 Subject: [PATCH] Update find command help and search memory docs This patch updates the `find` command help and docs description to show how to search for not null terminated strings when current language's strings includes it. gdb/ChangeLog: PR gdb/21945 * findcmd.c (_initialize_mem_search): Update find command help text. gdb/doc/ChangeLog: PR gdb/21945 * gdb.texinfo (Search Memory): Update description and example about how to search a string without NULL terminator. --- gdb/ChangeLog | 6 ++++++ gdb/doc/ChangeLog | 6 ++++++ gdb/doc/gdb.texinfo | 8 +++++++- gdb/findcmd.c | 4 +++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b3032ed7d8..6134efc09c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-11-26 Dominik Czarnota <dominik.b.czarnota@gmail.com> + + PR gdb/21945 + * findcmd.c (_initialize_mem_search): Update find command help + text. + 2017-11-26 Simon Marchi <simon.marchi@polymtl.ca> * python/python.c (do_start_initialization): Change progname diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 988b7b8d87..2a1eb76d15 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-26 Dominik Czarnota <dominik.b.czarnota@gmail.com> + + PR gdb/21945 + * gdb.texinfo (Search Memory): Update description and example + about how to search a string without NULL terminator. + 2017-11-24 Joel Brobecker <brobecker@adacore.com> * gdb.texinfo (GDB/MI Ada Exception Information): Document diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 00451d243d..675f6e7bc8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -11920,6 +11920,8 @@ giant words (eight bytes) All values are interpreted in the current language. This means, for example, that if the current source language is C/C@t{++} then searching for the string ``hello'' includes the trailing '\0'. +The null terminator can be removed from searching by using casts, +e.g.: @samp{@{char[5]@}"hello"}. If the value size is not specified, it is taken from the value's type in the current language. @@ -11969,7 +11971,11 @@ you get during debugging: (gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o' 0x8049567 <hello.1620> 0x804956d <hello.1620+6> -2 patterns found +2 patterns found. +(gdb) find &hello[0], +sizeof(hello), @{char[5]@}"hello" +0x8049567 <hello.1620> +0x804956d <hello.1620+6> +2 patterns found. (gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l' 0x8049567 <hello.1620> 1 pattern found diff --git a/gdb/findcmd.c b/gdb/findcmd.c index b43fefc06d..d437b56d92 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -293,7 +293,9 @@ and if not specified the size is taken from the type of the expression\n\ in the current language.\n\ Note that this means for example that in the case of C-like languages\n\ a search for an untyped 0x42 will search for \"(int) 0x42\"\n\ -which is typically four bytes.\n\ +which is typically four bytes, and a search for a string \"hello\" will\n\ +include the trailing '\\0'. The null terminator can be removed from\n\ +searching by using casts, e.g.: {char[5]}\"hello\".\n\ \n\ The address of the last match is stored as the value of \"$_\".\n\ Convenience variable \"$numfound\" is set to the number of matches."), -- 2.15.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-11-27 3:48 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-11-26 15:45 Update find command help and search memory docs Dominik Czarnota 2017-11-26 17:44 ` Eli Zaretskii 2017-11-26 20:41 ` Dominik Czarnota 2017-11-27 3:26 ` Eli Zaretskii 2017-11-27 3:48 ` Simon Marchi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox