* [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
@ 2011-08-26 11:43 Abhijit Halder
2011-08-26 12:18 ` Eli Zaretskii
0 siblings, 1 reply; 17+ messages in thread
From: Abhijit Halder @ 2011-08-26 11:43 UTC (permalink / raw)
To: gdb-patches
Cc: Eli Zaretskii, Sergio Durigan Junior, Jan Kratochvil, Tom Tromey,
Pedro Alves
[-- Attachment #1: Type: text/plain, Size: 189 bytes --]
Hi,
I am creating this new thread as the earlier threads went very long.
This patch contains code change, test-cases and documentation as well.
Please review this.
Thanks,
Abhijit Halder
[-- Attachment #2: gdb-pipe-command.patch --]
[-- Type: text/x-patch, Size: 12975 bytes --]
diff -rup src/gdb/ChangeLog dst/gdb/ChangeLog
--- src/gdb/ChangeLog 2011-08-14 07:27:51.502233004 +0530
+++ dst/gdb/ChangeLog 2011-08-24 22:16:45.326146038 +0530
@@ -1,3 +1,13 @@
+2011-08-29 Abhijit Halder <abhijit.k.halder@gmail.com>
+
+ Implementation of pipe to make I/O communication
+ between gdb and shell.
+
+ * NEWS: Add news item for the new command "pipe".
+ * pipe.c: New file.
+ * Makefile.in (SFILES): Add pipe.c.
+ (COMMON_OBS): Add pipe.o.
+
2011-08-12 Doug Evans <dje@google.com>
* NEWS: Mention new "type" attribute of python gdb.Symbol objects.
diff -rup src/gdb/doc/ChangeLog dst/gdb/doc/ChangeLog
--- src/gdb/doc/ChangeLog 2011-08-14 07:27:53.158233001 +0530
+++ dst/gdb/doc/ChangeLog 2011-08-24 22:37:01.722146068 +0530
@@ -1,3 +1,7 @@
+2011-08-29 Abhijit Halder <abhijit.k.halder@gmail.com>
+
+ * gdb.texinfo (pipe command): New node.
+
2011-08-12 Doug Evans <dje@google.com>
* gdb.texinfo (Symbols In Python): Document symbol.type.
diff -rup src/gdb/doc/gdb.texinfo dst/gdb/doc/gdb.texinfo
--- src/gdb/doc/gdb.texinfo 2011-08-14 07:27:53.242233001 +0530
+++ dst/gdb/doc/gdb.texinfo 2011-08-25 00:02:42.166145990 +0530
@@ -156,6 +156,7 @@ software in general. We will miss him.
* GDB/MI:: @value{GDBN}'s Machine Interface.
* Annotations:: @value{GDBN}'s annotation interface.
* JIT Interface:: Using the JIT debugging interface.
+* Output Redirection:: Redirecting @value{GDBN}'s command output to shell
* GDB Bugs:: Reporting bugs in @value{GDBN}
@@ -30958,6 +30959,24 @@ Set @code{action_flag} to @code{JIT_UNRE
If the JIT frees or recompiles code without unregistering it, then @value{GDBN}
and the JIT will leak the memory used for the associated symbol files.
+@node Output Redirection
+@chapter Redirecting @value{GDBN}'s Command Output to the Shell
+
+@value{GDBN}'s command output can be redirected to the shell using @code{pipe}
+command for further processing. This enables inline processing of the output of
+a particular @value{GDBN} command without explicitly invoking the @code{shell}
+command. Further, there is no need to store the output of the @value{GDBN}
+command in any file to pass it to the shell. Even if the environment variable
+@code{SHELL} is set, the default shell (@file{/bin/sh} on Unix systems,
+@file{COMMAND.COM} on MS-DOS, etc.) is used. The @code{pipe} command expects
+in its argument a delimiter string (without having any whitespace), followed by
+a @value{GDBN} command, followed by the same delimiter string and finally a
+shell command. The delimiter should not contain any leading `-'.
+
+@smallexample
+(@value{GDBP}) @b{pipe | thread apply all bt | cat >./analyze_threads.log}
+@end smallexample
+
@node GDB Bugs
@chapter Reporting Bugs in @value{GDBN}
@cindex bugs in @value{GDBN}
diff -rup src/gdb/Makefile.in dst/gdb/Makefile.in
--- src/gdb/Makefile.in 2011-07-27 23:55:26.000000000 +0530
+++ dst/gdb/Makefile.in 2011-08-14 07:31:15.802233004 +0530
@@ -713,7 +713,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
objc-exp.y objc-lang.c \
objfiles.c osabi.c observer.c osdata.c \
opencl-lang.c \
- p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
+ p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c pipe.c printcmd.c \
proc-service.list progspace.c \
prologue-value.c psymtab.c \
regcache.c reggroups.c remote.c remote-fileio.c reverse.c \
@@ -870,7 +870,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
mi-common.o \
event-loop.o event-top.o inf-loop.o completer.o \
gdbarch.o arch-utils.o gdbtypes.o osabi.o copying.o \
- memattr.o mem-break.o target.o parse.o language.o buildsym.o \
+ memattr.o mem-break.o target.o parse.o pipe.o language.o buildsym.o \
findcmd.o \
std-regs.o \
signals.o \
diff -rup src/gdb/NEWS dst/gdb/NEWS
--- src/gdb/NEWS 2011-08-14 07:27:51.582233000 +0530
+++ dst/gdb/NEWS 2011-08-14 07:50:38.562234498 +0530
@@ -64,6 +64,9 @@
* New commands "info macros", and "info definitions" have been added.
+* New command "pipe" has been added to make GDB command output available to the
+ shell for processing.
+
* Changed commands
watch EXPRESSION mask MASK_VALUE
diff -rup src/gdb/pipe.c dst/gdb/pipe.c
--- src/gdb/pipe.c 2011-07-29 15:15:26.078048517 +0530
+++ dst/gdb/pipe.c 2011-08-23 22:38:53.320364947 +0530
@@ -0,0 +1,227 @@
+/* Everything about pipe, for GDB.
+
+ Copyright (C) 2011 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "defs.h"
+#include <ctype.h>
+#include "gdb_string.h"
+#include "ui-file.h"
+#include "ui-out.h"
+#include "cli/cli-utils.h"
+#include "gdbcmd.h"
+#include "libiberty.h"
+#include "exceptions.h"
+
+#if defined(__MINGW32__)
+# define SHELL "cmd.exe"
+# define OPTION_TO_SHELL "/c"
+#else
+# define SHELL "/bin/sh"
+# define OPTION_TO_SHELL "-c"
+#endif
+
+/* Structure to encapsulate all entities associated with pipe. */
+
+struct pipe_obj
+{
+ /* The delimiter to separate out gdb-command and shell-command. This can be
+ any arbitrary string without containing any whitespace. There should not
+ be any leading '-' in the delimiter. */
+ char *dlim;
+
+ /* The gdb-command. */
+ char *gdb_cmd;
+
+ /* The shell-command. */
+ char *shell_cmd;
+
+ /* The gdb-side stream pointer to the pipe. */
+ FILE *handle;
+
+ /* The pex object used to create pipeline between gdb and shell. */
+ struct pex_obj *pex;
+};
+
+/* Destruct pipe object referenced by ARG. */
+
+static void
+destruct_pipe (void *arg)
+{
+ struct pipe_obj *pipe = (struct pipe_obj *) arg;
+
+ if (pipe->handle != NULL)
+ fclose (pipe->handle);
+
+ if (pipe->pex != NULL)
+ {
+ int status;
+
+ /* Wait till the process on the other side of the pipe completes its
+ job before closing its file descriptors. */
+ pex_get_status (pipe->pex, 1, &status);
+
+ if (!WIFEXITED (status))
+ warning (_("Execution of shell-command `%s' may not be completed"),
+ pipe->shell_cmd);
+
+ pex_free (pipe->pex);
+ }
+
+ xfree (pipe->dlim);
+ xfree (pipe);
+}
+
+/* Construct a pipe object by parsing argument ARG to the pipe command. */
+
+static struct pipe_obj *
+construct_pipe (const char *arg)
+{
+ char *p, *t;
+ struct pipe_obj *pipe = NULL;
+ struct cleanup *cleanup;
+
+ if (arg == NULL)
+ error (_("No argument is specified"));
+
+ pipe = XCNEW (struct pipe_obj);
+ cleanup = make_cleanup (destruct_pipe, pipe);
+
+ p = xstrdup (arg);
+ pipe->dlim = p;
+
+ if (*pipe->dlim == '-')
+ error (_("Delimiter pattern should not start with '-'"));
+
+ t = skip_to_space (p);
+ p = skip_spaces (t);
+
+ if (*p == '\0')
+ error (_("No gdb-command is specified"));
+
+ *t = '\0';
+ pipe->gdb_cmd = p;
+
+ for (;;)
+ {
+ t = skip_to_space (p);
+
+ if (*t == '\0')
+ error (_("No shell-command is specified"));
+
+ /* Check whether the token separated by whitespace matches with
+ delimiter. */
+ if (memcmp (p, pipe->dlim, (t - p)) == 0
+ && pipe->dlim[t - p] == '\0')
+ {
+ *p = '\0';
+ pipe->shell_cmd = skip_spaces (t);
+ break;
+ }
+
+ p = skip_spaces (t);
+ }
+
+ discard_cleanups (cleanup);
+ return pipe;
+}
+
+/* Run execute_command for PIPE and FROM_TTY. Write output to the pipe, do not
+ display it to the screen. */
+
+static void
+execute_command_to_pipe (struct pipe_obj *pipe, int from_tty)
+{
+ char *argv[4];
+ struct cleanup *cleanup;
+ struct ui_file *fp;
+ int status;
+ const char *errmsg;
+ volatile struct gdb_exception exception;
+
+ argv[0] = SHELL;
+ argv[1] = OPTION_TO_SHELL;
+ argv[2] = pipe->shell_cmd;
+ argv[3] = NULL;
+
+ pipe->pex = pex_init (PEX_USE_PIPES, argv[0], NULL);
+ pipe->handle = pex_input_pipe (pipe->pex, 0);
+
+ if (pipe->handle == NULL)
+ error (_("Failed to create pipe"));
+
+ errmsg = pex_run (pipe->pex, PEX_LAST, argv[0], argv, NULL, NULL, &status);
+
+ if (errmsg != NULL)
+ error (_("Failed to execute shell-command `%s' on pipe: %s %s"),
+ pipe->shell_cmd, errmsg, safe_strerror (status));
+
+ /* GDB_STDOUT should be better already restored during these
+ restoration callbacks. */
+ cleanup = set_batch_flag_and_make_cleanup_restore_page_info ();
+ fp = stdio_fileopen (pipe->handle);
+ make_cleanup_ui_file_delete (fp);
+ make_cleanup_restore_ui_file (&gdb_stdout);
+ make_cleanup_restore_ui_file (&gdb_stderr);
+ make_cleanup_restore_ui_file (&gdb_stdlog);
+ make_cleanup_restore_ui_file (&gdb_stdtarg);
+ make_cleanup_restore_ui_file (&gdb_stdtargerr);
+
+ if (ui_out_redirect (current_uiout, fp) < 0)
+ warning (_("Current output protocol does not support redirection"));
+ else
+ make_cleanup_ui_out_redirect_pop (current_uiout);
+
+ gdb_stdout = fp;
+ gdb_stderr = fp;
+ gdb_stdlog = fp;
+ gdb_stdtarg = fp;
+ gdb_stdtargerr = fp;
+
+ TRY_CATCH (exception, RETURN_MASK_ERROR)
+ {
+ execute_command (pipe->gdb_cmd, from_tty);
+ }
+
+ if (exception.reason < 0)
+ exception_print (gdb_stderr, exception);
+
+ do_cleanups (cleanup);
+}
+
+/* Execute the pipe command with argument ARG and FROM_TTY. */
+
+static void
+pipe_command (char *arg, int from_tty)
+{
+ struct pipe_obj *pipe = construct_pipe (arg);
+ struct cleanup *cleanup = make_cleanup (destruct_pipe, pipe);
+
+ execute_command_to_pipe (pipe, from_tty);
+ do_cleanups (cleanup);
+}
+
+/* Module initialization. */
+
+void
+_initialize_pipe (void)
+{
+ add_cmd ("pipe", no_class, pipe_command, _("\
+Create pipe to pass gdb-command output to the shell for processing.\n\
+Arguments are a delimiter, followed by a gdb-command, then the same delimiter \
+again and finally a shell-command. The delimiter can be any string \
+containing no whitespace and should not have any leading '-'."),
+ &cmdlist);
+}
diff -rup src/gdb/testsuite/ChangeLog dst/gdb/testsuite/ChangeLog
--- src/gdb/testsuite/ChangeLog 2011-08-14 07:27:53.706232999 +0530
+++ dst/gdb/testsuite/ChangeLog 2011-08-24 22:25:47.670145996 +0530
@@ -1,3 +1,7 @@
+2011-08-29 Abhijit Halder <abhijit.k.halder@gmail.com>
+
+ * gdb.base/pipe.exp: New file.
+
2011-08-12 Doug Evans <dje@google.com>
* gdb.python/py-symbol.exp: Add test for symbol.type.
diff -rup src/gdb/testsuite/gdb.base/pipe.exp dst/gdb/testsuite/gdb.base/pipe.exp
--- src/gdb/testsuite/gdb.base/pipe.exp 2011-08-16 22:37:45.969351119 +0530
+++ dst/gdb/testsuite/gdb.base/pipe.exp 2011-08-23 21:51:20.408367391 +0530
@@ -0,0 +1,52 @@
+# Copyright 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#
+# test gdb pipe commands
+#
+
+set test "pipe"
+set tempfile ${objdir}/${subdir}/${test}.x
+
+gdb_exit
+gdb_start
+
+gdb_test "pipe" "No argument is specified"
+gdb_test "pipe |" "No gdb-command is specified"
+gdb_test "pipe -x" "Delimiter pattern should not start with '-'"
+gdb_test "pipe | print 'x'" "No shell-command is specified"
+gdb_test "pipe | print 'x' |< cat" "No shell-command is specified"
+gdb_test "pipe |< print 'x' | cat" "No shell-command is specified"
+gdb_test "pipe | print 'x' >| cat" "No shell-command is specified"
+gdb_test "pipe >| print 'x' | cat" "No shell-command is specified"
+gdb_test "pipe | print 'x' | cat" " = 120 'x'"
+gdb_test "pipe | print 'x' | cat | cat" " = 120 'x'"
+
+file delete $tempfile
+gdb_test_no_output "pipe | p 'x' | cat >$tempfile"
+if ![file exists $tempfile] then {
+ perror "$tempfile does not exist."
+ return 0
+} else {
+ set fp [open $tempfile r]
+ set fdata [read $fp]
+ close $fp
+ regsub -all {\$[0-9]+} $fdata {} pattern
+ if ![string match $pattern " = 120 'x'\n"] then {
+ fail $test
+ } else {
+ pass $test
+ }
+}
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-26 11:43 [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell Abhijit Halder
@ 2011-08-26 12:18 ` Eli Zaretskii
2011-08-28 8:52 ` Abhijit Halder
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2011-08-26 12:18 UTC (permalink / raw)
To: Abhijit Halder; +Cc: gdb-patches, sergiodj, jan.kratochvil, tromey, pedro
> Date: Fri, 26 Aug 2011 17:13:28 +0530
> From: Abhijit Halder <abhijit.k.halder@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, Sergio Durigan Junior <sergiodj@redhat.com>,
> Jan Kratochvil <jan.kratochvil@redhat.com>, Tom Tromey <tromey@redhat.com>,
> Pedro Alves <pedro@codesourcery.com>
>
> I am creating this new thread as the earlier threads went very long.
> This patch contains code change, test-cases and documentation as well.
Thanks.
> +@node Output Redirection
> +@chapter Redirecting @value{GDBN}'s Command Output to the Shell
I'd rather not make this a new chapter. I think a subsection of the
Input/Output node is a much better place.
> +@value{GDBN}'s command output can be redirected to the shell using @code{pipe}
^^^^^^^^^^^^
"to a shell command", I think.
> Even if the environment variable
> +@code{SHELL} is set, the default shell (@file{/bin/sh} on Unix systems,
> +@file{COMMAND.COM} on MS-DOS, etc.) is used.
This might be seen by some as a
> The @code{pipe} command expects
> +in its argument a delimiter string (without having any whitespace), followed by
> +a @value{GDBN} command, followed by the same delimiter string and finally a
> +shell command. The delimiter should not contain any leading `-'.
> +
> +@smallexample
> +(@value{GDBP}) @b{pipe | thread apply all bt | cat >./analyze_threads.log}
> +@end smallexample
Please explain which part is the "delimiter" here. Since you are
using the "normal" shell pipe character `|', the above explanation
about the delimiter string will raise a few brows. A word about why
you need something beyond the usual `|' would also be nice.
In addition, I think we should explain which parts of the command are
passed to the shell verbatim and which parts are processed by GDB. If
the last part ("cat >./analyze_threads.log") is passed to the shell,
then it must use the shell syntax (e.g., backslashes on MS-DOS/Windows).
Finally, can we have a more useful example than just redirecting the
output to a file? Such redirection can be achieved without this
command at all.
Please also remove the @b markup, it is not used anywhere in the
examples we have in the manual.
> +* New command "pipe" has been added to make GDB command output available to the
> + shell for processing.
"available to shell commands"
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
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
0 siblings, 2 replies; 17+ messages in thread
From: Abhijit Halder @ 2011-08-28 8:52 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, sergiodj, jan.kratochvil, tromey, pedro
On Fri, Aug 26, 2011 at 5:48 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Fri, 26 Aug 2011 17:13:28 +0530
>> From: Abhijit Halder <abhijit.k.halder@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>, Sergio Durigan Junior <sergiodj@redhat.com>,
>> Jan Kratochvil <jan.kratochvil@redhat.com>, Tom Tromey <tromey@redhat.com>,
>> Pedro Alves <pedro@codesourcery.com>
>>
>> I am creating this new thread as the earlier threads went very long.
>> This patch contains code change, test-cases and documentation as well.
>
> Thanks.
>
>> +@node Output Redirection
>> +@chapter Redirecting @value{GDBN}'s Command Output to the Shell
>
> I'd rather not make this a new chapter. I think a subsection of the
> Input/Output node is a much better place.
>
Actually I could not find such section. Can someone please direct me
to the appropriate section?
>> +@value{GDBN}'s command output can be redirected to the shell using @code{pipe}
> ^^^^^^^^^^^^
> "to a shell command", I think.
Yes. I will correct this.
>
>> Even if the environment variable
>> +@code{SHELL} is set, the default shell (@file{/bin/sh} on Unix systems,
>> +@file{COMMAND.COM} on MS-DOS, etc.) is used.
>
> This might be seen by some as a
>
Sorry I am getting this. Please give me some more context.
>> The @code{pipe} command expects
>> +in its argument a delimiter string (without having any whitespace), followed by
>> +a @value{GDBN} command, followed by the same delimiter string and finally a
>> +shell command. The delimiter should not contain any leading `-'.
>> +
>> +@smallexample
>> +(@value{GDBP}) @b{pipe | thread apply all bt | cat >./analyze_threads.log}
>> +@end smallexample
>
> Please explain which part is the "delimiter" here. Since you are
> using the "normal" shell pipe character `|', the above explanation
> about the delimiter string will raise a few brows. A word about why
> you need something beyond the usual `|' would also be nice.
>
Sure.
> In addition, I think we should explain which parts of the command are
> passed to the shell verbatim and which parts are processed by GDB. If
> the last part ("cat >./analyze_threads.log") is passed to the shell,
> then it must use the shell syntax (e.g., backslashes on MS-DOS/Windows).
>
Sure.
> Finally, can we have a more useful example than just redirecting the
> output to a file? Such redirection can be achieved without this
> command at all.
>
Sure. I will try to provide some useful application.
> Please also remove the @b markup, it is not used anywhere in the
> examples we have in the manual.
>
Ok, I think when we need to show the command output along with the
command itself, the only the command has to be within @b markup.
>> +* New command "pipe" has been added to make GDB command output available to the
>> + shell for processing.
>
> "available to shell commands"
>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-28 8:52 ` Abhijit Halder
@ 2011-08-28 9:25 ` Eli Zaretskii
2011-08-28 9:51 ` Eli Zaretskii
1 sibling, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2011-08-28 9:25 UTC (permalink / raw)
To: Abhijit Halder; +Cc: gdb-patches, sergiodj, jan.kratochvil, tromey, pedro
> Date: Sun, 28 Aug 2011 14:21:43 +0530
> From: Abhijit Halder <abhijit.k.halder@gmail.com>
> Cc: gdb-patches@sourceware.org, sergiodj@redhat.com, jan.kratochvil@redhat.com, tromey@redhat.com, pedro@codesourcery.com
>
> >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Even if the environment variable
> >> +@code{SHELL} is set, the default shell (@file{/bin/sh} on Unix systems,
> >> +@file{COMMAND.COM} on MS-DOS, etc.) is used.
> >
> > This might be seen by some as a
> >
> Sorry I am getting this. Please give me some more context.
It was supposed to be deleted, please ignore this part.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
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
1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2011-08-28 9:51 UTC (permalink / raw)
To: Abhijit Halder; +Cc: gdb-patches, sergiodj, jan.kratochvil, tromey, pedro
> Date: Sun, 28 Aug 2011 14:21:43 +0530
> From: Abhijit Halder <abhijit.k.halder@gmail.com>
> Cc: gdb-patches@sourceware.org, sergiodj@redhat.com, jan.kratochvil@redhat.com,
> tromey@redhat.com, pedro@codesourcery.com
>
> >> +@node Output Redirection
> >> +@chapter Redirecting @value{GDBN}'s Command Output to the Shell
> >
> > I'd rather not make this a new chapter. Â I think a subsection of the
> > Input/Output node is a much better place.
> >
> Actually I could not find such section. Can someone please direct me
> to the appropriate section?
Search for this:
@node Input/Output
@section Your Program's Input and Output
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-28 9:51 ` Eli Zaretskii
@ 2011-08-28 10:12 ` Eli Zaretskii
2011-08-30 13:58 ` Abhijit Halder
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2011-08-28 10:12 UTC (permalink / raw)
To: abhijit.k.halder; +Cc: gdb-patches, sergiodj, jan.kratochvil, tromey, pedro
> Date: Sun, 28 Aug 2011 05:50:49 -0400
> From: Eli Zaretskii <eliz@gnu.org>
> CC: gdb-patches@sourceware.org, sergiodj@redhat.com, jan.kratochvil@redhat.com, tromey@redhat.com, pedro@codesourcery.com
> Reply-to: Eli Zaretskii <eliz@gnu.org>
>
> > Date: Sun, 28 Aug 2011 14:21:43 +0530
> > From: Abhijit Halder <abhijit.k.halder@gmail.com>
> > Cc: gdb-patches@sourceware.org, sergiodj@redhat.com, jan.kratochvil@redhat.com,
> > tromey@redhat.com, pedro@codesourcery.com
> >
> > >> +@node Output Redirection
> > >> +@chapter Redirecting @value{GDBN}'s Command Output to the Shell
> > >
> > > I'd rather not make this a new chapter. Â I think a subsection of the
> > > Input/Output node is a much better place.
> > >
> > Actually I could not find such section. Can someone please direct me
> > to the appropriate section?
>
> Search for this:
>
> @node Input/Output
> @section Your Program's Input and Output
An even better place is this:
@node Shell Commands
@section Shell Commands
Sorry that I didn't think about this before.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-28 10:12 ` Eli Zaretskii
@ 2011-08-30 13:58 ` Abhijit Halder
2011-08-30 14:27 ` Pedro Alves
0 siblings, 1 reply; 17+ messages in thread
From: Abhijit Halder @ 2011-08-30 13:58 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, sergiodj, jan.kratochvil, tromey, pedro
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]
On Sun, Aug 28, 2011 at 3:41 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sun, 28 Aug 2011 05:50:49 -0400
>> From: Eli Zaretskii <eliz@gnu.org>
>> CC: gdb-patches@sourceware.org, sergiodj@redhat.com, jan.kratochvil@redhat.com, tromey@redhat.com, pedro@codesourcery.com
>> Reply-to: Eli Zaretskii <eliz@gnu.org>
>>
>> > Date: Sun, 28 Aug 2011 14:21:43 +0530
>> > From: Abhijit Halder <abhijit.k.halder@gmail.com>
>> > Cc: gdb-patches@sourceware.org, sergiodj@redhat.com, jan.kratochvil@redhat.com,
>> > tromey@redhat.com, pedro@codesourcery.com
>> >
>> > >> +@node Output Redirection
>> > >> +@chapter Redirecting @value{GDBN}'s Command Output to the Shell
>> > >
>> > > I'd rather not make this a new chapter. I think a subsection of the
>> > > Input/Output node is a much better place.
>> > >
>> > Actually I could not find such section. Can someone please direct me
>> > to the appropriate section?
>>
>> Search for this:
>>
>> @node Input/Output
>> @section Your Program's Input and Output
>
> An even better place is this:
>
> @node Shell Commands
> @section Shell Commands
>
> Sorry that I didn't think about this before.
>
Hi,
I have made the corrections in the doc section. Please review the same.
Thanks,
Abhijit Halder
[-- Attachment #2: gdb-pipe-command-doc.patch --]
[-- Type: text/x-patch, Size: 2818 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-28 16:24:53.024714073 +0530
@@ -1,3 +1,7 @@
+2011-08-29 Abhijit Halder <abhijit.k.halder@gmail.com>
+
+ * gdb.texinfo (pipe command): New node.
+
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-30 18:39:03.200191037 +0530
@@ -1367,6 +1367,53 @@ 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}. You
+don't even need to get a shell for that. The same could be achieved by
+enabling logging and redirecting the output of @value{GDBN} command to some
+file and then processing the file content by invoking a shell using
+@code{shell} command. But this incurs higher costs as the explicit invokation
+of shell involves execution of its startup scripts and locating the file
+containing @value{GDBN}'s command output involves directory lookup; even though
+OS may optimize these processes by its cache mechanism.
+
+@table @code
+@item pipe @var{args}
+The @var{args} consists of a delimiter followed by a @value{GDBN} command,
+followed by the same delimiter and finally a shell command. The delimiter is a
+string of arbitrary length, containing no whitespace and no leading '-', acts
+as a separator between a @value{GDBN} command and a shell command. The shell
+command should be in compliance with the syntax of the default shell.
+@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{@var{<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.
+
+In the given example the output of @value{GDBN} command is huge and not well
+formated. The use of shell commands like ``sed'', ``tr'' and ``grep'' ease
+the searching of desired pattern and hence ease debugging.
+
@node Logging Output
@section Logging Output
@cindex logging @value{GDBN} output
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-30 13:58 ` Abhijit Halder
@ 2011-08-30 14:27 ` Pedro Alves
2011-08-30 14:32 ` Abhijit Halder
0 siblings, 1 reply; 17+ messages in thread
From: Pedro Alves @ 2011-08-30 14:27 UTC (permalink / raw)
To: Abhijit Halder
Cc: Eli Zaretskii, gdb-patches, sergiodj, jan.kratochvil, tromey
On Tuesday 30 August 2011 14:58:02, Abhijit Halder wrote:
> +@table @code
> +@item pipe @var{args}
I suggest writing this as something like:
@item pipe @var{delim} @var{gdbcmd} @var{delim} @var{shellcmd}
and then adjust the text a bit to refer to the variables by name.
The syntax is more immediately obvious this way.
> +The @var{args} consists of a delimiter followed by a @value{GDBN} command,
> +followed by the same delimiter and finally a shell command. The delimiter is a
> +string of arbitrary length, containing no whitespace and no leading '-', acts
> +as a separator between a @value{GDBN} command and a shell command. The shell
> +command should be in compliance with the syntax of the default shell.
> +@end table
--
Pedro Alves
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-30 14:27 ` Pedro Alves
@ 2011-08-30 14:32 ` Abhijit Halder
2011-08-30 14:49 ` Abhijit Halder
0 siblings, 1 reply; 17+ messages in thread
From: Abhijit Halder @ 2011-08-30 14:32 UTC (permalink / raw)
To: Pedro Alves; +Cc: Eli Zaretskii, gdb-patches, sergiodj, jan.kratochvil, tromey
On Tue, Aug 30, 2011 at 7:57 PM, Pedro Alves <pedro@codesourcery.com> wrote:
> On Tuesday 30 August 2011 14:58:02, Abhijit Halder wrote:
>> +@table @code
>> +@item pipe @var{args}
>
> I suggest writing this as something like:
>
> @item pipe @var{delim} @var{gdbcmd} @var{delim} @var{shellcmd}
>
> and then adjust the text a bit to refer to the variables by name.
> The syntax is more immediately obvious this way.
>
>> +The @var{args} consists of a delimiter followed by a @value{GDBN} command,
>> +followed by the same delimiter and finally a shell command. The delimiter is a
>> +string of arbitrary length, containing no whitespace and no leading '-', acts
>> +as a separator between a @value{GDBN} command and a shell command. The shell
>> +command should be in compliance with the syntax of the default shell.
>> +@end table
>
> --
> Pedro Alves
>
Sure. I am going to change this.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
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:09 ` Eli Zaretskii
0 siblings, 2 replies; 17+ messages in thread
From: Abhijit Halder @ 2011-08-30 14:49 UTC (permalink / raw)
To: Pedro Alves; +Cc: Eli Zaretskii, gdb-patches, sergiodj, jan.kratochvil, tromey
On Tue, Aug 30, 2011 at 8:01 PM, Abhijit Halder
<abhijit.k.halder@gmail.com> wrote:
> On Tue, Aug 30, 2011 at 7:57 PM, Pedro Alves <pedro@codesourcery.com> wrote:
>> On Tuesday 30 August 2011 14:58:02, Abhijit Halder wrote:
>>> +@table @code
>>> +@item pipe @var{args}
>>
>> I suggest writing this as something like:
>>
>> @item pipe @var{delim} @var{gdbcmd} @var{delim} @var{shellcmd}
>>
>> and then adjust the text a bit to refer to the variables by name.
>> The syntax is more immediately obvious this way.
>>
>>> +The @var{args} consists of a delimiter followed by a @value{GDBN} command,
>>> +followed by the same delimiter and finally a shell command. The delimiter is a
>>> +string of arbitrary length, containing no whitespace and no leading '-', acts
>>> +as a separator between a @value{GDBN} command and a shell command. The shell
>>> +command should be in compliance with the syntax of the default shell.
>>> +@end table
>>
>> --
>> Pedro Alves
>>
>
> Sure. I am going to change this.
>
Hi all,
In gdb.texinfo file I have seen @cindex and @kindex markup. Someone
please tell me the significance of them.
Secondly, the example I have used is from a sample code written by me
just for this purpose. This should not have any licensing issue I
hope.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-30 14:49 ` Abhijit Halder
@ 2011-08-30 16:38 ` Abhijit Halder
2011-08-30 18:07 ` Eli Zaretskii
2011-08-30 18:09 ` Eli Zaretskii
1 sibling, 1 reply; 17+ messages in thread
From: Abhijit Halder @ 2011-08-30 16:38 UTC (permalink / raw)
To: Pedro Alves; +Cc: Eli Zaretskii, gdb-patches, sergiodj, jan.kratochvil, tromey
[-- Attachment #1: Type: text/plain, Size: 1491 bytes --]
On Tue, Aug 30, 2011 at 8:18 PM, Abhijit Halder
<abhijit.k.halder@gmail.com> wrote:
> On Tue, Aug 30, 2011 at 8:01 PM, Abhijit Halder
> <abhijit.k.halder@gmail.com> wrote:
>> On Tue, Aug 30, 2011 at 7:57 PM, Pedro Alves <pedro@codesourcery.com> wrote:
>>> On Tuesday 30 August 2011 14:58:02, Abhijit Halder wrote:
>>>> +@table @code
>>>> +@item pipe @var{args}
>>>
>>> I suggest writing this as something like:
>>>
>>> @item pipe @var{delim} @var{gdbcmd} @var{delim} @var{shellcmd}
>>>
>>> and then adjust the text a bit to refer to the variables by name.
>>> The syntax is more immediately obvious this way.
>>>
>>>> +The @var{args} consists of a delimiter followed by a @value{GDBN} command,
>>>> +followed by the same delimiter and finally a shell command. The delimiter is a
>>>> +string of arbitrary length, containing no whitespace and no leading '-', acts
>>>> +as a separator between a @value{GDBN} command and a shell command. The shell
>>>> +command should be in compliance with the syntax of the default shell.
>>>> +@end table
>>>
>>> --
>>> Pedro Alves
>>>
>>
>> Sure. I am going to change this.
>>
>
> Hi all,
>
> In gdb.texinfo file I have seen @cindex and @kindex markup. Someone
> please tell me the significance of them.
> Secondly, the example I have used is from a sample code written by me
> just for this purpose. This should not have any licensing issue I
> hope.
>
Changes as suggested by Pedro.
Regards,
Abhijit Halder
[-- Attachment #2: gdb-pipe-command-doc.patch --]
[-- Type: text/x-patch, Size: 2745 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-28 16:24:53.024714073 +0530
@@ -1,3 +1,7 @@
+2011-08-29 Abhijit Halder <abhijit.k.halder@gmail.com>
+
+ * gdb.texinfo (pipe command): New node.
+
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-30 20:09:24.120190599 +0530
@@ -1367,6 +1367,53 @@ 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}. You
+don't even need to get a shell for that. The same could be achieved by
+enabling logging and redirecting the output of @value{GDBN} command to some
+file and then processing the file content by invoking a shell using
+@code{shell} command. But this incurs higher costs as the explicit invokation
+of shell involves execution of its startup scripts and locating the file
+containing @value{GDBN}'s command output involves directory lookup; even though
+OS may optimize these processes by its cache mechanism.
+
+@table @code
+@item pipe @var{dlim} @var{gdbcmd} @var{dlim} @var{shellcmd}
+@var{dlim} is a string of arbitrary length, containing no whitespace and no
+leading '-', 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.
+@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{@var{<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.
+
+In the given example the output of @value{GDBN} command is huge and not well
+formated. The use of shell commands like ``sed'', ``tr'' and ``grep'' ease
+the searching of desired pattern and hence ease debugging.
+
@node Logging Output
@section Logging Output
@cindex logging @value{GDBN} output
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-30 16:38 ` Abhijit Halder
@ 2011-08-30 18:07 ` Eli Zaretskii
2011-08-31 8:44 ` Abhijit Halder
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2011-08-30 18:07 UTC (permalink / raw)
To: Abhijit Halder; +Cc: pedro, gdb-patches, sergiodj, jan.kratochvil, tromey
> Date: Tue, 30 Aug 2011 22:08:22 +0530
> From: Abhijit Halder <abhijit.k.halder@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org, sergiodj@redhat.com,
> jan.kratochvil@redhat.com, tromey@redhat.com
>
> + * gdb.texinfo (pipe command): New node.
You didn't write a new node, you just added text to the existing node.
So you should state the name of that node in the parentheses.
> +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}. You
> +don't even need to get a shell for that. The same could be achieved by
> +enabling logging and redirecting the output of @value{GDBN} command to some
> +file and then processing the file content by invoking a shell using
> +@code{shell} command. But this incurs higher costs as the explicit invokation
> +of shell involves execution of its startup scripts and locating the file
> +containing @value{GDBN}'s command output involves directory lookup; even though
> +OS may optimize these processes by its cache mechanism.
I would drop this part, and leave only the first sentence. We don't
need to justify commands in the manual.
> +@table @code
> +@item pipe @var{dlim} @var{gdbcmd} @var{dlim} @var{shellcmd}
You need a "@kindex pipe" here, to index this command as we do with
all other commands.
> +@var{dlim} is a string of arbitrary length, containing no whitespace and no
> +leading '-', acts as a separator between a @value{GDBN} command @var{gdbcmd}
^^^
@samp{-}
> +In the above example @samp{@var{<br>}} acts as a delimiter. The output of
Just @samp{<br>}, without @var.
> +@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 given example the output of @value{GDBN} command is huge and not well
> +formated. The use of shell commands like ``sed'', ``tr'' and ``grep'' ease
Please use @command{sed}, @command{tr}, etc.
Thanks.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-30 18:07 ` Eli Zaretskii
@ 2011-08-31 8:44 ` Abhijit Halder
2011-08-31 11:01 ` Eli Zaretskii
0 siblings, 1 reply; 17+ messages in thread
From: Abhijit Halder @ 2011-08-31 8:44 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: pedro, gdb-patches, sergiodj, jan.kratochvil, tromey
[-- Attachment #1: Type: text/plain, Size: 2687 bytes --]
On Tue, Aug 30, 2011 at 11:36 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Tue, 30 Aug 2011 22:08:22 +0530
>> From: Abhijit Halder <abhijit.k.halder@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org, sergiodj@redhat.com,
>> jan.kratochvil@redhat.com, tromey@redhat.com
>>
>> + * gdb.texinfo (pipe command): New node.
>
> You didn't write a new node, you just added text to the existing node.
> So you should state the name of that node in the parentheses.
>
Sorry, I missed editing this part.
>> +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}. You
>> +don't even need to get a shell for that. The same could be achieved by
>> +enabling logging and redirecting the output of @value{GDBN} command to some
>> +file and then processing the file content by invoking a shell using
>> +@code{shell} command. But this incurs higher costs as the explicit invokation
>> +of shell involves execution of its startup scripts and locating the file
>> +containing @value{GDBN}'s command output involves directory lookup; even though
>> +OS may optimize these processes by its cache mechanism.
>
> I would drop this part, and leave only the first sentence. We don't
> need to justify commands in the manual.
>
>> +@table @code
>> +@item pipe @var{dlim} @var{gdbcmd} @var{dlim} @var{shellcmd}
>
> You need a "@kindex pipe" here, to index this command as we do with
> all other commands.
>
>> +@var{dlim} is a string of arbitrary length, containing no whitespace and no
>> +leading '-', acts as a separator between a @value{GDBN} command @var{gdbcmd}
> ^^^
> @samp{-}
>
>> +In the above example @samp{@var{<br>}} acts as a delimiter. The output of
>
> Just @samp{<br>}, without @var.
>
>> +@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?
>
>> +In the given example the output of @value{GDBN} command is huge and not well
>> +formated. The use of shell commands like ``sed'', ``tr'' and ``grep'' ease
>
> Please use @command{sed}, @command{tr}, etc.
>
> Thanks.
>
I made the corrections as suggested. Please review this:
Thanks,
Abhijit Halder
[-- Attachment #2: gdb-pipe-command-doc.patch --]
[-- Type: text/x-patch, Size: 2291 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 13:43:45.836117888 +0530
@@ -1367,6 +1367,48 @@ 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.
+@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.
+
+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
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-31 8:44 ` Abhijit Halder
@ 2011-08-31 11:01 ` Eli Zaretskii
2011-08-31 12:42 ` Abhijit Halder
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2011-08-31 11:01 UTC (permalink / raw)
To: Abhijit Halder; +Cc: pedro, gdb-patches, sergiodj, jan.kratochvil, tromey
> 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.
> I made the corrections as suggested. Please review this:
OK, thanks.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-31 11:01 ` Eli Zaretskii
@ 2011-08-31 12:42 ` Abhijit Halder
2011-08-31 13:26 ` Eli Zaretskii
0 siblings, 1 reply; 17+ messages in thread
From: Abhijit Halder @ 2011-08-31 12:42 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: pedro, gdb-patches, sergiodj, jan.kratochvil, tromey
[-- 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
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-31 12:42 ` Abhijit Halder
@ 2011-08-31 13:26 ` Eli Zaretskii
0 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2011-08-31 13:26 UTC (permalink / raw)
To: Abhijit Halder; +Cc: pedro, gdb-patches, sergiodj, jan.kratochvil, tromey
> Date: Wed, 31 Aug 2011 18:12:31 +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
>
> Okay I got it. Made that change, please comment on it.
This version is fine with me, thanks.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell.
2011-08-30 14:49 ` Abhijit Halder
2011-08-30 16:38 ` Abhijit Halder
@ 2011-08-30 18:09 ` Eli Zaretskii
1 sibling, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2011-08-30 18:09 UTC (permalink / raw)
To: Abhijit Halder; +Cc: pedro, gdb-patches, sergiodj, jan.kratochvil, tromey
> Date: Tue, 30 Aug 2011 20:18:41 +0530
> From: Abhijit Halder <abhijit.k.halder@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org, sergiodj@redhat.com,
> jan.kratochvil@redhat.com, tromey@redhat.com
>
> In gdb.texinfo file I have seen @cindex and @kindex markup. Someone
> please tell me the significance of them.
Each one adds an entry to a different index: @cindex to the Concept
Index section, @kindex to the Command Index.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2011-08-31 13:26 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26 11:43 [PATCH][TEST-CASE][DOC] Implementation of pipe to pass GDB's command output to the shell 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
2011-08-31 13:26 ` Eli Zaretskii
2011-08-30 18:09 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox