This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3] Add more methods to gdb.Progspace
- From: Simon Marchi <simark at simark dot ca>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Sat, 15 Sep 2018 23:09:57 -0400
- Subject: Re: [PATCH v3] Add more methods to gdb.Progspace
- References: <20180913221627.13772-1-tom@tromey.com>
LGTM, I just noted some minor comments.
I wish there was more consistency in how the methods are documented (in the
progspace_object_methods array), but that should be another patch.
On 2018-09-13 6:16 p.m., Tom Tromey wrote:
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index aca6ec858cf..34f42c0effe 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -328,7 +328,9 @@ Return the @code{gdb.Symtab_and_line} object corresponding to the
> @var{pc} value. @xref{Symbol Tables In Python}. If an invalid
> value of @var{pc} is passed as an argument, then the @code{symtab} and
> @code{line} attributes of the returned @code{gdb.Symtab_and_line} object
> -will be @code{None} and 0 respectively.
> +will be @code{None} and 0 respectively. This is identical to
> +@code{current_progspace().find_pc_line(pc)} and is included for
Perhaps this should say gdb.current_progspace().find_pc_line(pc) ?
> +/* Implementation of solib_name (Long) -> String.
> + Returns the name of the shared library holding a given address, or None. */
> +
> +static PyObject *
> +pspy_solib_name (PyObject *o, PyObject *args)
> +{
> + char *soname;
> + PyObject *str_obj;
> + gdb_py_longest pc;
> + pspace_object *self = (pspace_object *) o;
> +
> + PSPY_REQUIRE_VALID (self);
> +
> + if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
> + return NULL;
> +
> + soname = solib_name_from_address (self->pspace, pc);
> + if (soname)
> + str_obj = host_string_to_python_string (soname);
> + else
> + {
> + str_obj = Py_None;
> + Py_INCREF (Py_None);
> + }
I know this is pre-existing code, but it could use Py_RETURN_NONE, then
we can get rid of the str_obj variable.
Simon