This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Add an evaluation function hook to Python breakpoints.
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 14 Dec 2010 17:02:44 +0000
- Subject: Re: [patch] Add an evaluation function hook to Python breakpoints.
- References: <m38vztlr2r.fsf@redhat.com> <m3fwu0s463.fsf@fleche.redhat.com>
- Reply-to: pmuldoon at redhat dot com
Tom Tromey <tromey@redhat.com> writes:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> + PyObject *gdbpy_bp_eval = PyString_FromString ("evaluate");
>
> This is leaked. However...
>
> Phil> + if (PyObject_HasAttr (py_bp, gdbpy_bp_eval))
> Phil> + {
> Phil> + PyObject *result = PyObject_CallMethodObjArgs (py_bp,
> Phil> + gdbpy_bp_eval,
> Phil> + NULL);
>
> You can just use PyObject_HasAttrString and PyObject_CallMethod instead.
Ok, thanks.
> Phil> +gdb_py_test_silent_cmd "python eval_bp1 = bp_eval(\"$bp_location2\")" "Set breakpoint" 0
> Phil> +gdb_py_test_silent_cmd "python also_eval_bp1 = bp_also_eval(\"$bp_location2\")" "Set breakpoint" 0
>
> I think there should also be a test for the case where there is an
> ordinary user breakpoint at the same location as the Python breakpoints.
> In this case, the user breakpoint should stop, but all the Python
> methods should be invoked first.
All the breakpoints at a location will be evaluated, but does the order
matter? I can add the test to prove the point, but the Python breakpoints will
have the evaluation function called regardless if the user breakpoint
was first.
FWIW in bpstop_stop_status a bpstat chain is built from the location
where the inferior stopped. Then later, we iterate through that chain and
eventually call bpstat_check_breakpoint_conditions. Then finally in
that condition call we evaluate the Python function. This loop does not
exit until the all the bpstats in the chain have been iterated.
Cheers
Phil