[PATCH 2/3] Fix latent bug in Python breakpoint creation

Simon Marchi simark@simark.ca
Thu Jan 12 17:44:47 GMT 2023


On 12/8/22 14:18, Tom Tromey via Gdb-patches wrote:
> While working on the previous patch, I noticed that Python breakpoint
> creation does:
> 
> -	  = (qualified != NULL && PyObject_IsTrue (qualified)
> 
> PyObject_IsTrue can fail, so this is missing an error check.  This
> patch adds the missing check.
> 
> Note that this could probably be improved by using the "p" format in
> the call to gdb_PyArg_ParseTupleAndKeywords, but that was added in
> Python 3.3, and I think gdb still supports 3.2.
> ---
>  gdb/python/py-breakpoint.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
> index 917fd367d06..39d9bd5dff6 100644
> --- a/gdb/python/py-breakpoint.c
> +++ b/gdb/python/py-breakpoint.c
> @@ -818,7 +818,7 @@ bppy_init_validate_args (const char *spec, char *source,
>  static void
>  bppy_create_breakpoint (enum bptype type, int access_type, int temporary_bp,
>  			int internal_bp, const char *spec,
> -			PyObject *qualified, const char *source,
> +			int qualified, const char *source,

You might as well make this parameter "bool".

Otherwise, LGTM.

Simon


More information about the Gdb-patches mailing list