This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: [patch] Add argc variable to cli script


On Wed, Apr 06, 2005 at 08:17:56PM +0200, Th Klein wrote:
> Hello,
> 
> This patch adds the readonly variable $argc into the cli.
> So the following example script file data:

There are a number of things I don't like about your implementation,
mostly minor, but I'm not going to give you a point-by-point review -
particularly since I don't think you have a GDB copyright assignment on
file.  If there's a consensus about the feature, I can easily enough
reimplement it.  I'll also need to write an Expect test case and
documentation.

I'll volunteer to do that if other developers agree that this is a
desirable feature.  Does anyone else have an opinion?  It seems like a
reasonable incremental addition to the CLI to me.

> 
> ###################################################################
> # example file script.tst
> #
> define hexarg_echo
> 	if ($argc <= 0)
> 		printf "no args given\n"
> 	else
> 		if ($argc == 1)
> 			printf "0x%8.8x\n", $arg0
> 		else
> 			if ($argc >= 12)
> 				printf  "(%d) 0x%8.8x .. 0x%8.8x\n", $argc, $arg0, $arg11
> 				print $arg0
> 				print $arg9
> 				print $arg10
> 			else
> 				printf  "0x%8.8x 0x%8.8x\n", $arg0 ,$arg1
> 			end
> 		end
> 	end
> end
> document hexarg_echo
> simple $argc example
> end
> #
> ##################################################################
> 
> can be use like this:
> 
> 	(gdb) source script.tst
> 	(gdb) hexarg_echo
> 	no args given
> 	(gdb) hexarg_echo 0
> 	0x00000000
> 	(gdb) hexarg_echo 0 1 2 3 4 5 6 7 8 9 10
> 	0x00000000 0x00000001
> 	(gdb) hexarg_echo 0 1 2 3 4 5 6 7 8 9 10 11
> 	(12) 0x00000000 .. 0x0000000b
> 	$1 = 0
> 	$2 = 9
> 	$3 = 10
> 	(gdb) hexarg_echo 0 1 2 3 4 5 6 7 8 9 10 11 12
> 	(13) 0x00000000 .. 0x0000000b
> 	$4 = 0
> 	$5 = 9
> 	$6 = 10
> 
> Regards,
> Thomas


-- 
Daniel Jacobowitz
CodeSourcery, LLC


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