This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Less verbose Python commands
- From: Daniel Colascione <daniel at censorshipresearch dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 10 Jan 2010 03:13:52 -0500
- Subject: Re: Less verbose Python commands
- References: <hic1fj$18s$1@ger.gmane.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 1/10/10 3:00 AM, Daniel Colascione wrote:
> [snip]
Err, this version propagates docstrings to command help too:
def command(*init_args):
def decorator(func):
def init_func(self):
gdb.Command.__init__(self, *init_args)
def invoke_func(self, argument, from_tty):
func(argument, from_tty)
type('Command_' + init_args[0].replace(' ', '_'),
(gdb.Command,),
{ '__init__': init_func,
'__doc__': func.__doc__,
'invoke': invoke_func })()
return func
return decorator
@command('tracked', COMMAND_DATA, COMPLETE_NONE, True)
def func(argument, from_tty):
"Commands having to do with tracked things"
@command('tracked types', COMMAND_DATA)
def func(argument, from_tty):
"List the types of objects which are tracked"
print parse_and_eval('2+2')
# etc.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)
iEYEARECAAYFAktJjEAACgkQ17c2LVA10VutRwCgucOLY5Vn8aNS2+XZZUpSZUaA
AfUAn0m+MbHAcrC1LuL3jrdPH17QO1st
=Y4db
-----END PGP SIGNATURE-----