Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Jim Blandy <jimb@red-bean.com>
Cc: Thiago Jung Bauermann <bauerman@br.ibm.com>, gdb ml <gdb@sourceware.org>
Subject: Re: repo to work on python scripting support
Date: Tue, 25 Mar 2008 19:18:00 -0000	[thread overview]
Message-ID: <m3hceuofgq.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20080325183004.GA20107@caradoc.them.org> (Daniel Jacobowitz's message of "Tue\, 25 Mar 2008 14\:30\:05 -0400")

>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:

Jim> On Tue, Mar 25, 2008 at 11:18:12AM -0700, Jim Blandy wrote:
Jim> I don't know the most Pythonish way of doing things, but it seems to
Jim> me that Python could register not functions, but objects, to be
Jim> callable with $().

Daniel> Hmm, I've worked with some packages that did similar things using
Daniel> mandatory docstrings.

We could use decorators.

    http://wiki.python.org/moin/PythonDecorators

Well, assuming they exist.  I'm not really that up on the current
state of Python.


For this particular thing I would be just as happy with some explicit
constructor thing:

class Strcmp(GdbFunction):
  def __init__(self):
    Strcmp.__init__(self, 'strcmp', 'ee')

  def invoke(expr1, expr2):
    lalala


You could also use a real data structure and named constants:

    Strcmp.__init__(self, 'strcmp', (gdb.EXPRESSION, gdb.EXPRESSION))

.. or what have you.

Aside from the interactive spec, the current gdb-python support for
command objects already works this way.  A command subclass has to
pass in the user-visible command name at construction time.

FWIW here's the code I wrote to override "edit" and turn it into an
annotation-based command:

class Edit(gdb.Command):
    def __init__(self):
        gdb.Command.__init__(self, "edit", gdb.COMMAND_NONE)

    def invoke(self, arg, fromtty):
        if gdb.show('annotate') > -1:
            loc = gdb.decode_line(arg)
            if loc:
                loc = loc[0]
                if loc.symtab.to_fullname():
                    print "\n\x1a\x1asource %s:%d:0:beg:0x0" \
                        % (loc.symtab.to_fullname(), loc.get_line())

# Install it.
Edit()



Just to be clear, I don't really want to consider anything in this
area as fixed.  Advice and input about how everything should fit
together is really helpful.

Tom


  parent reply	other threads:[~2008-03-25 18:52 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-16  0:42 Thiago Jung Bauermann
2008-03-16  2:55 ` Tom Tromey
2008-03-24 17:16   ` Thiago Jung Bauermann
2008-03-25 11:45     ` Tom Tromey
2008-03-25 13:53       ` Daniel Jacobowitz
2008-03-25 18:37         ` Jim Blandy
2008-03-25 18:52           ` Daniel Jacobowitz
2008-03-25 18:53             ` Jim Blandy
2008-03-25 19:18             ` Tom Tromey [this message]
2008-03-27  6:41               ` Jim Blandy
2008-03-27 17:57                 ` Paul Koning
2008-03-25 19:31           ` Paul Koning
2008-03-25 20:18             ` Tom Tromey
2008-03-25 20:31               ` Paul Koning
2008-03-26  3:23                 ` Tom Tromey
2008-03-26 12:55                 ` Jim Blandy
2008-03-26 17:29                   ` Paul Koning
2008-03-26 17:58                     ` Daniel Jacobowitz
2008-03-26 18:41                     ` Tom Tromey
2008-03-26 20:04                       ` Paul Koning
2008-03-26 22:45                     ` Jim Blandy
2008-03-26 18:05       ` Doug Evans
2008-03-26 18:13         ` Daniel Jacobowitz
2008-03-26 18:25           ` Tom Tromey
2008-03-26 18:41             ` Daniel Jacobowitz
2008-03-26 18:55               ` Tom Tromey
2008-03-26 20:57                 ` Daniel Jacobowitz
2008-03-26 21:01                 ` Thiago Jung Bauermann
2008-03-27 14:11           ` Jim Blandy
2008-03-27 16:49             ` Paul Koning
2008-03-26 18:23         ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3hceuofgq.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=bauerman@br.ibm.com \
    --cc=gdb@sourceware.org \
    --cc=jimb@red-bean.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox