Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Abhijit Halder <abhijit.k.halder@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: pedro@codesourcery.com, gdb-patches@sourceware.org,
	sergiodj@redhat.com, 	jan.kratochvil@redhat.com,
	tromey@redhat.com
Subject: Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
Date: Wed, 31 Aug 2011 12:42:00 -0000	[thread overview]
Message-ID: <CAOhZP9wU_Q=E2JRGda47X9vg0FhAMVJh+O_=XHWBVZdmL7KJ-Q@mail.gmail.com> (raw)
In-Reply-To: <E1QyiXJ-0006Oi-VO@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]

On Wed, Aug 31, 2011 at 4:30 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Wed, 31 Aug 2011 14:13:49 +0530
>> From: Abhijit Halder <abhijit.k.halder@gmail.com>
>> Cc: pedro@codesourcery.com, gdb-patches@sourceware.org, sergiodj@redhat.com,
>>       jan.kratochvil@redhat.com, tromey@redhat.com
>>
>> >> +@samp{print dd_tbl} is passed to the shell command @samp{sed 's/@}/\n/g' | @
>> >> +grep ".test_dd" | tr ',' '\n'} for processing.
>> >
>> > I would suggest to add that the example does not use `|' as a
>> > delimiter to allow the shell command to use it in its usual shell
>> > semantics.
>> >
>> In the above example one can use `|' as the delimiter. it will not
>> break anything syntactically but will not be readable much, hence I
>> avoided using `|' as delimiter. Do we need to mention that here?
>
> We don't _have_ to mention that, but I think it's a good idea, because
> the natural choice of the delimiter is the normal pipe character.
>
Okay I got it. Made that change, please comment on it.

>> I made the corrections as suggested. Please review this:
>
> OK, thanks.
>

[-- Attachment #2: gdb-pipe-command-doc.patch --]
[-- Type: text/x-patch, Size: 2554 bytes --]

diff -rup src/gdb/doc/ChangeLog dst/gdb/doc/ChangeLog
--- src/gdb/doc/ChangeLog	2011-08-27 20:35:38.459934029 +0530
+++ dst/gdb/doc/ChangeLog	2011-08-31 13:33:59.188118016 +0530
@@ -1,3 +1,7 @@
+2011-08-29  Abhijit Halder  <abhijit.k.halder@gmail.com>
+
+	* gdb.texinfo (Shell Commands): Add pipe command.
+
 2011-08-25  Andrew Oakley  <andrew@ado.is-a-geek.net>
 
 	* gdb.texinfo (Types In Python): Document 'bitpos' for enums.
diff -rup src/gdb/doc/gdb.texinfo dst/gdb/doc/gdb.texinfo
--- src/gdb/doc/gdb.texinfo	2011-08-26 21:11:39.938354007 +0530
+++ dst/gdb/doc/gdb.texinfo	2011-08-31 18:04:11.348118042 +0530
@@ -1367,6 +1367,52 @@ Execute the @code{make} program with the
 arguments.  This is equivalent to @samp{shell make @var{make-args}}.
 @end table
 
+If you want to process the output of a @value{GDBN} command using some shell
+command or some script, that can be done by using the command @code{pipe}.
+
+@table @code
+@kindex pipe
+@item pipe @var{dlim} @var{gdbcmd} @var{dlim} @var{shellcmd}
+@var{dlim} is a string of arbitrary length, containing no whitespace and no
+leading @samp{-}, acts as a separator between a @value{GDBN} command
+@var{gdbcmd} and a shell command @var{shellcmd}.  The shell command should be
+in compliance with the syntax of the default shell.  The @var{dlim} pattern
+should not appear in @var{gdbcomd} otherwise the parsing will fail; although it
+may appear in @var{shellcmd}. 
+@end table
+
+@smallexample
+(@value{GDBP}) @b{ptype dd_tbl}
+type = struct dd @{
+    int dd_handle;
+    const char *dd_name;
+    int dd_major;
+    int dd_minor;
+    void *dd_code;
+    void *dd_data;
+@} [1024]
+(@value{GDBP}) @b{pipe <br> print dd_tbl <br> sed 's/@}/\n/g' | grep @
+"\.test_dd" | tr ',' '\n'}
+
+  @{dd_handle = 10
+  dd_name = 0x8048538 ".test_dd"
+  dd_major = 100
+  dd_minor = 0
+  dd_code = 0xcc
+  dd_data = 0x80
+@end smallexample
+
+In the above example @samp{<br>} acts as a delimiter.  The output of
+@samp{print dd_tbl} is passed to the shell command @samp{sed 's/@}/\n/g' | @
+grep ".test_dd" | tr ',' '\n'} for processing.  @samp{|} could be one natural
+choise of using as the delimiter.  In the above we avoided the same for
+readability purpose.
+
+In the given example the output of @value{GDBN} command @samp{print dd_tbl} is
+huge and not well formated.  The use of shell commands like @command{sed},
+@command{tr} and @command{grep} ease the searching of desired pattern and hence
+ease debugging.
+
 @node Logging Output
 @section Logging Output
 @cindex logging @value{GDBN} output

  reply	other threads:[~2011-08-31 12:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 11:43 Abhijit Halder
2011-08-26 12:18 ` Eli Zaretskii
2011-08-28  8:52   ` Abhijit Halder
2011-08-28  9:25     ` Eli Zaretskii
2011-08-28  9:51     ` Eli Zaretskii
2011-08-28 10:12       ` Eli Zaretskii
2011-08-30 13:58         ` Abhijit Halder
2011-08-30 14:27           ` Pedro Alves
2011-08-30 14:32             ` Abhijit Halder
2011-08-30 14:49               ` Abhijit Halder
2011-08-30 16:38                 ` Abhijit Halder
2011-08-30 18:07                   ` Eli Zaretskii
2011-08-31  8:44                     ` Abhijit Halder
2011-08-31 11:01                       ` Eli Zaretskii
2011-08-31 12:42                         ` Abhijit Halder [this message]
2011-08-31 13:26                           ` Eli Zaretskii
2011-08-30 18:09                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOhZP9wU_Q=E2JRGda47X9vg0FhAMVJh+O_=XHWBVZdmL7KJ-Q@mail.gmail.com' \
    --to=abhijit.k.halder@gmail.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=pedro@codesourcery.com \
    --cc=sergiodj@redhat.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox