Re: [RFC - Python] New ObjFile event

Phil Muldoon
2011-03-28T08:49:37Z

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

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

Just a few nits. I am not a maintainer, so please don't take this as any
form of blessing ;)

> + py-value.o \
> + py-newobjfileevent.o
>
> SUBDIR_PYTHON_SRCS = \
> python/python.c \
> @@ -326,7 +327,8 @@
> python/py-threadevent.c \
> python/py-type.c \
> python/py-utils.c \
> - python/py-value.c
> + python/py-value.c \
> + python/py-newobjfileevent.c

I'm not sure on the status of 8.3 file naming conventions, whether they
matter anymore.

> +extern struct objfile *gdbpy_current_objfile;
> +static void
> +python_new_objfile (struct objfile *objfile)
> +{
> + struct cleanup *cleanup;
> +
> + /* Will be NULL when clearing the symtab. */
> + if (objfile)
> + cleanup = ensure_python_env (get_objfile_arch (objfile), current_language);
> + else
> + cleanup = ensure_python_env (get_current_arch (), current_language);
> +
> + gdbpy_current_objfile = objfile;
> +
> + if (emit_new_objfile_event (objfile) < 0)
> + gdbpy_print_stack ();

The emit_new_objfile_event function seems to be missing?

> -static struct objfile *gdbpy_current_objfile;
> + source_python_script_for_objfile and new_objfile callbacks; it is NULL at
> + other times. */
> +/*static*/ struct objfile *gdbpy_current_objfile;

I realize this is something you are unsure of, but if you decide to emit
'static' can you remove the comment too.

> /* Set the current objfile to OBJFILE and then read STREAM,FILE as
> Python code. */
> @@ -1074,6 +1075,7 @@
> gdbpy_initialize_continue_event ();
> gdbpy_initialize_exited_event ();
> gdbpy_initialize_thread_event ();
> + gdbpy_initialize_new_objfile_event() ;

Needs a space after event and before the bracket.

Cheers

Phil