* using $argc for variable number of args functions
@ 2005-11-21 1:17 Dan Nicolaescu
0 siblings, 0 replies; only message in thread
From: Dan Nicolaescu @ 2005-11-21 1:17 UTC (permalink / raw)
To: gdb
If one wants to use $args to implement a variable number of arguments
function a lot of code needs to be written.
For example a function that prints the values of some variables that
could be used like:
p var1
pr
pr var1
pr var1 var2 var3
etc etc
The pr function would have to be written like:
(I hope I am not missing something that would allow some simplification)
define pr
if $argc == 0
debug_print ($)
end
if $argc == 1
debug_print ($arg0)
end
if $argc == 2
debug_print ($arg0)
debug_print ($arg1)
end
if $argc == 3
debug_print ($arg0)
debug_print ($arg1)
debug_print ($arg3)
end
... etc etc
It would be nice if a "shift" command would be available to shift the
positional arguments, the same way as it is done in shells. Then the
above function could be written like:
define pr
if $argc == 0
debug_print ($)
end
while $argc > 0
debug_print ($arg0)
shift
end
end
I don't know if the above is even possible in gdb...
Thanks
--dan
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-11-21 1:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-21 1:17 using $argc for variable number of args functions Dan Nicolaescu
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).