From: Dan Nicolaescu <dann@ics.uci.edu>
To: gdb@sourceware.org
Subject: using $argc for variable number of args functions
Date: Mon, 21 Nov 2005 01:17:00 -0000 [thread overview]
Message-ID: <200511210116.jAL1GvTp003778@scanner2.ics.uci.edu> (raw)
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
reply other threads:[~2005-11-21 1:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200511210116.jAL1GvTp003778@scanner2.ics.uci.edu \
--to=dann@ics.uci.edu \
--cc=gdb@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).