This is the mail archive of the gdb-patches@sourceware.org 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, doc RFA] Add ability to set random attributes in python objfiles,progspaces


> From: Doug Evans <dje@google.com>
> Date: Thu, 09 Oct 2014 12:08:09 -0700
> 
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -9,6 +9,7 @@
>  
>    ** You can now access frame registers from Python scripts.
>    ** New attribute 'producer' for gdb.Symtab objects.
> +  ** You can now add attributes to gdb.Objfile and gdb.Progspace objects.

This part is OK.

> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -3356,6 +3356,10 @@ The @code{frame_filters} attribute is a dictionary of frame filter
>  objects.  @xref{Frame Filter API}, for more information.
>  @end defvar
>  
> +One may add arbitrary attributes to @code{gdb.Progspace} objects.

Add how?  If this is done by "usual" Python ways, please say so.

> +This is useful if for example one needs to do some extra record keeping
> +associated with the progspace.

Please add commas where they are needed in this sentence.

> +One may add arbitrary attributes to @code{gdb.Objfile} objects.
> +This is useful if for example one needs to do some extra record keeping
> +associated with the objfile.

Same comments here.

> +In this contrived example we record the time when @value{GDBN}
> +loaded the objfile.
> +
> +@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

If this is related to adding attributes, then I'd like the text say
that more explicitly.  Alternatively, some comment in the example that
mentions "attributes" could do.

Btw, why do we only support adding attributes for these 2 types of
objects?  Why not for any object?

Thanks.


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