Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Phil Muldoon <pmuldoon@redhat.com>
Cc: gdb-patches@sourceware.org,    eliz@gnu.org
Subject: Re: [PATCH, doc RFA] Add ability to set random attributes in python objfiles,progspaces
Date: Fri, 10 Oct 2014 17:35:00 -0000	[thread overview]
Message-ID: <21560.6392.457864.907695@ruffy2.mtv.corp.google.com> (raw)
In-Reply-To: <54379223.3080305@redhat.com>

Phil Muldoon writes:
 > Maybe add a small example here as you did with gdb.Objfile?  Or maybe
 > an xref.  One of my goals in the next year is to add (and backfill in
 > existing documentation) more example led documentation for Python.
 > Sometimes an example speaks (ten) thousand words!

I couldn't think of a simple one.

 > > +@smallexample
 > > +(gdb) python
 > > +import datetime
 > > +def new_objfile_handler (event):
 > > +    event.new_objfile.time_loaded = datetime.datetime.today ()
 > > +gdb.events.new_objfile.connect (new_objfile_handler)
 > > +end
 > > +(gdb) file ./hello
 > > +Reading symbols from ./hello...done.
 > > +(gdb) python print gdb.objfiles()[0].time_loaded
 > > +2014-10-09 11:41:36.770345
 > > +@end smallexample
 > 
 > This is really awesome example. (Linking in from comment above).
 > Thanks for taking the time out to provide a "useful" example that is
 > also simple.

Yeah, this one was simple enough and educational enough
that it was worth the time and effort.

 > >  A @code{gdb.Objfile} object has the following methods:
 > > 
 > >  @defun Objfile.is_valid ()
 > > diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
 > > index df29691..32bceee 100644
 > > --- a/gdb/python/py-objfile.c
 > > +++ b/gdb/python/py-objfile.c
 > > @@ -30,6 +30,9 @@ typedef struct
 > >    /* The corresponding objfile.  */
 > >    struct objfile *objfile;
 > > 
 > > +  /* Dictionary holding user-added attributes.  */
 > > +  PyObject *dict;
 > > +
 > 
 > My only nit here is the naming.  dict is kind of generic.  I know it
 > follows on from the fields code :( Even though you wrote a comment,
 > later use in the code means (say a year from now), I have to
 > remember what this mysterious "dict" is.

Note that this is also __dict__ from the Python side.
I'd use the name __dict__ here for clarity, but I can't. :-)
[compiler's namespace]

I can certainly add __dict__ to the comment though.

 > Thanks for this patch.  It seems really useful (and in implementation
 > fairly simple to implement).  I wonder if there are other objects in
 > Python that could benefit from the ability to arbitrarily record
 > keep?

Like all things in gdb/python, things get added on a demand basis.
[This observation extends to more pieces of gdb than just gdb/python.
I'm happy to change the rules, but I do insist on there being
no double standards. :-)]


  reply	other threads:[~2014-10-10 17:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <yjt27g09qcx2.fsf@ruffy.mtv.corp.google.com>
2014-10-09 19:10 ` Doug Evans
2014-10-10  7:58 ` Eli Zaretskii
2014-10-10 17:21   ` Doug Evans
2014-10-10  8:00 ` Phil Muldoon
2014-10-10 17:35   ` Doug Evans [this message]
2014-10-10 18:25     ` Phil Muldoon
2014-10-17 20:29       ` Doug Evans
2014-10-18  5:40         ` Eli Zaretskii
2014-10-21 16:53           ` Doug Evans
2014-10-21 18:23             ` Phil Muldoon
2014-10-31  0:07               ` Doug Evans

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=21560.6392.457864.907695@ruffy2.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pmuldoon@redhat.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