public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* misc extended scripting bits
@ 2007-11-09  9:43 Mike Frysinger
  2007-11-09 14:07 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2007-11-09  9:43 UTC (permalink / raw)
  To: gdb

[-- 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 --]

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

end of thread, other threads:[~2007-11-13 22:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-09  9:43 misc extended scripting bits Mike Frysinger
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

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).