This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

misc extended scripting bits


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: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]