Re: [RFC] Python Finish Breakpoints

Phil Muldoon
2011-10-24T16:06:32Z

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

I have some comments regarding the Python bits.
>
> + ** A new class "gdb.FinishBreakpoint" is provided to catch the return
> + of a function. This class is based on the "finish" command
> + available in the CLI.
> +
> ** Type objects for struct and union types now allow access to
> the fields using standard Python dictionary (mapping) methods.
> For example, "some_type['myfield']" now works, as does
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index ba1b08f..ffd2ef6 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -5700,6 +5700,7 @@ init_raw_breakpoint_without_location (struct breakpoint *b,
> b->frame_id = null_frame_id;
> b->condition_not_parsed = 0;
> b->py_bp_object = NULL;
> + b->is_py_finish_bp = 0;

Is there any reason why this need to be in the breakpoint struct? I
think this should be encapsulated in breakpoint PyObject, and a accessor
method provided for it. As a finish breakpoint can only ever be
instantiated by Python, there will always be a py_bp_object attached to
make the call.

> +/* struct implementing the gdb.FinishBreakpoint object by extending
> + the gdb.Breakpoint class. */
> +struct finish_breakpoint_object
> +{
> + /* gdb.Breakpoint base class. */
> + struct breakpoint_object py_bp;
> + /* gdb.Type object of the function finished by this breakpoint. */
> + PyObject *function_type;
> + /* gdb.Type object of the value return by the breakpointed function. */
> + PyObject *return_type;
> + /* When stopped at this FinishBreakpoint, value returned by the function;
> + Py_None if the value is not computable;
> + NULL if GDB is not stopped at a FinishBreakpoint. */
> + PyObject *return_value;
> +};

I think these comments should wrap? They wrap for me in emacs.

Cheers

Phil