* Less verbose Python commands
@ 2010-01-10 8:05 Daniel Colascione
2010-01-10 8:14 ` Daniel Colascione
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Colascione @ 2010-01-10 8:05 UTC (permalink / raw)
To: gdb-patches
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
import os, sys, gdb
# Using this
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,
'invoke': invoke_func })()
return func
return decorator
# We can more easily write commands that look like this:
def register():
@command('fiber', gdb.COMMAND_DATA, gdb.COMPLETE_NONE, True)
def func(argument, from_tty):
print "Hi, I'm a fiber prefix!"
@command('fiber list', gdb.COMMAND_DATA)
def func(argument, from_tty):
print "List fibers here"
# Less verbose, isn't it?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)
iEYEARECAAYFAktJiTQACgkQ17c2LVA10VsB+wCg27MtSJmw7sQAuJsTW5u/gPQ8
pAQAn0F/2oOW/r5M1iDY8AQOl6ZaWPVh
=cbAs
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Less verbose Python commands
2010-01-10 8:05 Less verbose Python commands Daniel Colascione
@ 2010-01-10 8:14 ` Daniel Colascione
2010-01-11 21:32 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Colascione @ 2010-01-10 8:14 UTC (permalink / raw)
To: gdb-patches
-----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-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Less verbose Python commands
2010-01-10 8:14 ` Daniel Colascione
@ 2010-01-11 21:32 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2010-01-11 21:32 UTC (permalink / raw)
To: Daniel Colascione; +Cc: gdb-patches
>>>>> "Daniel" == Daniel Colascione <daniel@censorshipresearch.org> writes:
Daniel> Err, this version propagates docstrings to command help too:
Nice.
Do you have an assignment on file? If not, email me and I can get you
started on that.
To put this in we'd need to merge in the code to add a Python library to
gdb. We'll have to do this eventually though...
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-11 21:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-10 8:05 Less verbose Python commands Daniel Colascione
2010-01-10 8:14 ` Daniel Colascione
2010-01-11 21:32 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox