From: Mike Frysinger <vapier@gentoo.org>
To: gdb@sourceware.org
Subject: misc extended scripting bits
Date: Fri, 09 Nov 2007 09:43:00 -0000 [thread overview]
Message-ID: <200711090443.30594.vapier@gentoo.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]
is there a way to do indirection of evaluating statements ? in other words,
is there an equivalent of the shell "eval" command ? so something like:
(gdb) set $cmd = "set $a 1"
(gdb) eval $cmd
(gdb) print $a
$a = 1
can you do default values with functions ? so instead of checking $argc all
the time and setting up the values by hand, a simple syntax for populating
args with default values. so this verbose block:
define myfunc
# myfunc address, [count], [inc]
if $argc == 1
set $count 10
else
set $count $arg1
end
if $argc == 2
set $inc 1
else
set $inc $arg2
end
set $i = 0
while $i < $count
printf "addr = %X\n", ($arg0 + $i)
set $i += $inc
end
end
would become:
define myfunc $arg1=10 $arg2=1
set $i = 0
while $i < $count
printf "addr = %X\n", ($arg0 + $i)
set $i += $inc
end
end
can you change the default "error" message on invalid number of arguments to
do the help ? i do something like
define useful
if $argc != 2
help useful
else
[do stuff here]
end
end
document useful
Usage: useful <arg1> <arg2>
The useful command is useful as it does things with <arg1> and <arg2>.
end
is there a way to hook into the repeat-on-return functionality ? gdb allows
you to control the repeat-on-return behavior via the "dont-repeat" command,
but there doesnt seem to be a way to detect whether the define is being
executed because it was called explicitly or the user is just hitting the
return key ... so i'd like to be able to do:
define moo
if $user_hit_return
set $_last_moo += 10
else
set $_last_moo = $arg0
end
printf "ARG0 = %x\n", $_last_moo
end
then i'd get the output:
(gdb) moo 5
ARG0 = 5
(gdb)
ARG0 = 15
(gdb)
ARG0 = 25
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]
next reply other threads:[~2007-11-09 9:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-09 9:43 Mike Frysinger [this message]
2007-11-09 14:07 ` Daniel Jacobowitz
2007-11-09 16:14 ` Mike Frysinger
2007-11-09 16:23 ` Daniel Jacobowitz
[not found] ` <c17be2b30711131035i42572619l277350467df29fc8@mail.gmail.com>
2007-11-13 21:08 ` Daniel Jacobowitz
2007-11-13 22:12 ` Cary Coutant
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=200711090443.30594.vapier@gentoo.org \
--to=vapier@gentoo.org \
--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