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: [RFC - Python] New ObjFile event


>>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes:

Kevin> following this discussion at
Kevin> http://sourceware.org/ml/gdb/2011-03/msg00136.html, I would like to
Kevin> suggest a patch for the Python event system. Based on the ''exited",
Kevin> "cont", ... events, this patch allows a python script to register an
Kevin> interest to the loading of new object files in the debuggee. GDB
Kevin> observer "observer_attach_new_objfile" is used to trigger the Python
Kevin> callback.

It seems like a good idea.

Do you have copyright assignment paperwork in place?  If not, let me
know and I can get you started.  This is a requirement before we can
accept a non-trivial patch.

Kevin> and, likewise, allows Python's "gdb.current_objfile ()" to return
Kevin> the current object file.

I'm ambivalent about this part.

It seems to me that the objfile should be an attribute of the event.
Also setting it globally is ok, if you really want that, but it isn't a
necessity.

Kevin> There is still one thing I'm not happy with in the code, it's how to
Kevin> 'properly' access "gdbpy_current_objfile" ? I commented out "static"
Kevin> and declared it "extern" when I needed it, but that's certainly not
Kevin> the best way:

Dropping the `static' is ok.  GDB is already full of this kind of thing.

Kevin> please let me know what you thing about it

Looks pretty good!

Here are some notes on the patch itself.  In addition to these, this
patch needs a ChangeLog entry, a documentation update, and a test case.

Kevin> +extern struct objfile *gdbpy_current_objfile;

Should be in python-internal.h.

Kevin> +static void
Kevin> +python_new_objfile (struct objfile *objfile)

New functions need an introductory comment.

Kevin> +  /* Will be NULL when clearing the symtab. */
Kevin> +  if (objfile)
Kevin> +    cleanup = ensure_python_env (get_objfile_arch (objfile), current_language);

Is this comment stale?  It doesn't seem relevant.  When can objfile==NULL?

Kevin> -
Kevin> +  observer_attach_new_objfile (python_new_objfile);
Kevin> +  

Gratuitous whitespace change.

Kevin> int
Kevin> emit_new_objfile_event (struct objfile *objfile)
Kevin> {
Kevin>   PyObject *event;
[...]
Kevin>   event = create_new_objfile_event_object ();
Kevin>   if (event)
Kevin>     return evpy_emit_event (event, gdb_py_events.newobjfile);
Kevin>   return -1;

I think this should attach the objfile to the event object.

Tom


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