public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* varargs in TUI defined functions ?
@ 2010-05-26  8:31 Martin Oberhuber
  2010-05-26 15:26 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Oberhuber @ 2010-05-26  8:31 UTC (permalink / raw)
  To: gdb

As a gdb commandline (text UI) user, I want to define a command that can take a variable number of arguments. I want to use this to create wrapper scripts for common operations. Example:

    # Simplified "run" convenience function
    define r
        if (0 == $argc)
            run -port default
        else
            run $arg*
        end
    end
 
This request is old, I found a reference in the mailing list archives from
2000: http://sourceware.org/ml/gdb/2000-q1/msg00019.html 
 
But at the moment there seems to be still no solution according to latest 
docs: http://sourceware.org/gdb/current/onlinedocs/gdb/Define.html#Define 
 
At the moment, there is $argc and $arg0 ... $arg9, but what I'm missing
is a builtin convenience variable that holds the entire list of arguments.
Syntax could be any of
   $argv    (like in C main())
   $args    (like in C va_args)
   $*       (like in Shellscripts)
   $arg*    (mixture of $arg and *)
 
I have been told that somewhere out in the wild there is a patch providing the "$*" and "$#" convenience variables as a gdb extension, but could not find this anywhere. Could anybody point me at places to look at, or provide any background information?

-- 
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/atbrowser

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: varargs in TUI defined functions ?
  2010-05-26  8:31 varargs in TUI defined functions ? Martin Oberhuber
@ 2010-05-26 15:26 ` Tom Tromey
  2010-05-28 16:42   ` Martin Oberhuber
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2010-05-26 15:26 UTC (permalink / raw)
  To: Martin Oberhuber; +Cc: gdb

>>>>> "Martin" == Martin Oberhuber <Martin.Oberhuber@gmx.at> writes:

Martin> As a gdb commandline (text UI) user, I want to define a command
Martin> that can take a variable number of arguments. I want to use this
Martin> to create wrapper scripts for common operations. Example:

Martin> But at the moment there seems to be still no solution according
Martin> to latest docs:
Martin> http://sourceware.org/gdb/current/onlinedocs/gdb/Define.html#Define

You can do it quite easily using Python.

Martin> At the moment, there is $argc and $arg0 ... $arg9, but what I'm
Martin> missing is a builtin convenience variable that holds the entire
Martin> list of arguments.

I'd also be amenable to a patch adding this.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: varargs in TUI defined functions ?
  2010-05-26 15:26 ` Tom Tromey
@ 2010-05-28 16:42   ` Martin Oberhuber
  2010-06-08 21:01     ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Oberhuber @ 2010-05-28 16:42 UTC (permalink / raw)
  To: tromey; +Cc: gdb

Hello Tom,

many thanks for your answer!

> > As a gdb commandline (text UI) user, I want to define a command
> > that can take a variable number of arguments.
> > http://sourceware.org/gdb/current/onlinedocs/gdb/Define.html#Define
> 
> You can do it quite easily using Python.

Well I know Python but I don't really know how gdb makes use of it, so I'm kinda lost with this suggestion... can you give any more pointers or an example?

Also, what minimum version of gdb would I have to use for Python to be available for doing this? My Linux distro seems not to be fully up-to-date.

> > At the moment, there is $argc and $arg0 ... $arg9, but what I'm
> > missing is a builtin convenience variable that holds the entire
> > list of arguments.
> 
> I'd also be amenable to a patch adding this.

At the moment, I'm most interested what kind of naming convention for such a "varargs argument" the gdb community would like best:

   $argv    (like in C main(), and related to $argc)
   $args    (like in C va_args)
   $*       (like in Shellscripts)
   $arg*    (mixture of $arg and *)
   ... anything else?

Many Thanks!
Martin
-- 
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/atbrowser

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: varargs in TUI defined functions ?
  2010-05-28 16:42   ` Martin Oberhuber
@ 2010-06-08 21:01     ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2010-06-08 21:01 UTC (permalink / raw)
  To: Martin Oberhuber; +Cc: gdb

>>>>> "Martin" == Martin Oberhuber <Martin.Oberhuber@gmx.at> writes:

Martin> many thanks for your answer!

No problem... and I'm sorry for the long delay in this response.

Tom> You can do it quite easily using Python.

Martin> Well I know Python but I don't really know how gdb makes use of
Martin> it, so I'm kinda lost with this suggestion... can you give any
Martin> more pointers or an example?

You can write a new command in Python, see the gdb.Command class in the
gdb documentation.

Martin> Also, what minimum version of gdb would I have to use for Python
Martin> to be available for doing this? My Linux distro seems not to be
Martin> fully up-to-date.

7.0.

Martin> At the moment, I'm most interested what kind of naming
Martin> convention for such a "varargs argument" the gdb community would
Martin> like best:
Martin>    $argv    (like in C main(), and related to $argc)
Martin>    $args    (like in C va_args)
Martin>    $*       (like in Shellscripts)
Martin>    $arg*    (mixture of $arg and *)
Martin>    ... anything else?

I would say $argv, but really I would be ok with any of the first 3.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-06-08 21:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-26  8:31 varargs in TUI defined functions ? Martin Oberhuber
2010-05-26 15:26 ` Tom Tromey
2010-05-28 16:42   ` Martin Oberhuber
2010-06-08 21:01     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).