This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb output pipelining to shell (was: Re: PATCH)


On Tuesday 12 July 2011 21:30:00, Mike Frysinger wrote:
> On Tue, Jul 12, 2011 at 15:25, Tom Tromey wrote:
> >>>>>> "Abhijit" == Abhijit Halder writes:
> > Abhijit> How if we just put a condition check whether the entered string after
> > Abhijit> pipe (|) is numeric. [...]
> >
> > I was too terse yesterday.  The big problem with any generic approach is
> > that GDB syntax is free-form: each command defines its own syntax.  So,
> > for any syntax you think up, there is a decent chance that it already
> > means something to some command, or could.
> >
> > This doesn't mean it is impossible, just difficult.
> 
> i was also pondering reversing the order.  rather than being a suffix
> that gets mucked up in syntax, add a pass through.  but that too can
> get ugly.
> 
> pipe <command to pipe into> <normal command> <command args>
> (gdb) pipe "vim -" thread apply all bt

Another option would be to still have a normal order pipe
command, and have the user specify the splitting character,
kind of like a grandchild of sed's s/// vs s,,, etc, and 
cat EOF pattern.  So, you'd have:

  pipe SPLITTER_TOKEN

the usual | would work:

 (gdb) pipe | bt | vim -

if necessary due to conflict, use a different token:

 (gdb) pipe , p 1 | 2 , vim -

or:

 (gdb) pipe PIPE p 1 | 2 PIPE vim -

etc.

WDYT?

I think I like this better than comming up with some
syntax that we need to make sure works not just with C,
but all supported languages.  (and hope no future supported
language adds a conflict).

We can tweak the syntax a bit to support
options to the pipe command.  E.g, define that
the pipe command always ends with a lone '-' before
the gdb command chain, and -t for pipe token, then:

No -t switch, assume `|' pipe token:

 (gdb) pipe - bt | vim -

Specify alternate pipe token:

 (gdb) pipe -t PIPE - p 1 | 2 PIPE vim -

Pass some other option to `pipe':

 (gdb) pipe --some-option - bt | vim -

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]