[RFC,v2,03/21] gdb/python: add domain property to gdb.Symbol
Checks
Commit Message
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
gdb/NEWS | 2 ++
gdb/doc/python.texi | 5 +++++
gdb/python/py-symbol.c | 11 +++++++++++
gdb/testsuite/gdb.python/py-symbol.exp | 1 +
4 files changed, 19 insertions(+)
Comments
> From: Jan Vrany <jan.vrany@labware.com>
> CC: Jan Vrany <jan.vrany@labware.com>,
> Eli Zaretskii <eliz@gnu.org>
> Date: Thu, 21 Nov 2024 12:46:56 +0000
>
> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
> ---
> gdb/NEWS | 2 ++
> gdb/doc/python.texi | 5 +++++
> gdb/python/py-symbol.c | 11 +++++++++++
> gdb/testsuite/gdb.python/py-symbol.exp | 1 +
> 4 files changed, 19 insertions(+)
OK for the documentation part, thanks.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Jan Vrany <jan.vrany@labware.com> writes:
> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
> ---
> gdb/NEWS | 2 ++
> gdb/doc/python.texi | 5 +++++
> gdb/python/py-symbol.c | 11 +++++++++++
> gdb/testsuite/gdb.python/py-symbol.exp | 1 +
> 4 files changed, 19 insertions(+)
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index c9e0439645f..1ea9fcc65b9 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -86,6 +86,8 @@
> ** Added gdb.Block.subblocks. Returns a list of blocks contained in that
> block.
>
> + ** Added gdb.Symbol.domain. Contains the domain of the symbol.
> +
> * Debugger Adapter Protocol changes
>
> ** The "scopes" request will now return a scope holding global
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index 290e9fea62f..09e374700a4 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -6203,6 +6203,11 @@ of a symbol. Each address class is a constant defined in the
> @code{gdb} module and described later in this chapter.
> @end defvar
>
> +@defvar Symbol.domain
> +The domain of the symbol. Each domain is a constant defined in the
> +@code{gdb} module and described later in this chapter.
> +@end defvar
> +
> @defvar Symbol.needs_frame
> This is @code{True} if evaluating this symbol's value requires a frame
> (@pxref{Frames In Python}) and @code{False} otherwise. Typically,
> diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
> index 24b53bbe38a..38eead9cb3a 100644
> --- a/gdb/python/py-symbol.c
> +++ b/gdb/python/py-symbol.c
> @@ -153,6 +153,16 @@ sympy_get_addr_class (PyObject *self, void *closure)
> return gdb_py_object_from_longest (symbol->aclass ()).release ();
> }
>
> +static PyObject *
> +sympy_get_domain (PyObject *self, void *closure)
Missing comment. Something like:
/* Implement gdb.Symbol.domain attribute. Return the domain as an
integer. */
With that:
Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Andrew
> +{
> + struct symbol *symbol = nullptr;
> +
> + SYMPY_REQUIRE_VALID (self, symbol);
> +
> + return gdb_py_object_from_longest (symbol->domain ()).release ();
> +}
> +
> static PyObject *
> sympy_is_argument (PyObject *self, void *closure)
> {
> @@ -707,6 +717,7 @@ static gdb_PyGetSetDef symbol_object_getset[] = {
> This is either name or linkage_name, depending on whether the user asked GDB\n\
> to display demangled or mangled names.", NULL },
> { "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." },
> + { "domain", sympy_get_domain, nullptr, "Domain of the symbol." },
> { "is_argument", sympy_is_argument, NULL,
> "True if the symbol is an argument of a function." },
> { "is_constant", sympy_is_constant, NULL,
> diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
> index c174ba4c70e..2a74c97a137 100644
> --- a/gdb/testsuite/gdb.python/py-symbol.exp
> +++ b/gdb/testsuite/gdb.python/py-symbol.exp
> @@ -135,6 +135,7 @@ gdb_test "python print (func.name)" "func" "test func.name"
> gdb_test "python print (func.print_name)" "func" "test func.print_name"
> gdb_test "python print (func.linkage_name)" "func" "test func.linkage_name"
> gdb_test "python print (func.addr_class == gdb.SYMBOL_LOC_BLOCK)" "True" "test func.addr_class"
> +gdb_test "python print (func.domain == gdb.SYMBOL_FUNCTION_DOMAIN)" "True" "test func.domain"
>
> # Stop in a second file and ensure we find its local static symbol.
> gdb_breakpoint "function_in_other_file"
> --
> 2.45.2
@@ -86,6 +86,8 @@
** Added gdb.Block.subblocks. Returns a list of blocks contained in that
block.
+ ** Added gdb.Symbol.domain. Contains the domain of the symbol.
+
* Debugger Adapter Protocol changes
** The "scopes" request will now return a scope holding global
@@ -6203,6 +6203,11 @@ of a symbol. Each address class is a constant defined in the
@code{gdb} module and described later in this chapter.
@end defvar
+@defvar Symbol.domain
+The domain of the symbol. Each domain is a constant defined in the
+@code{gdb} module and described later in this chapter.
+@end defvar
+
@defvar Symbol.needs_frame
This is @code{True} if evaluating this symbol's value requires a frame
(@pxref{Frames In Python}) and @code{False} otherwise. Typically,
@@ -153,6 +153,16 @@ sympy_get_addr_class (PyObject *self, void *closure)
return gdb_py_object_from_longest (symbol->aclass ()).release ();
}
+static PyObject *
+sympy_get_domain (PyObject *self, void *closure)
+{
+ struct symbol *symbol = nullptr;
+
+ SYMPY_REQUIRE_VALID (self, symbol);
+
+ return gdb_py_object_from_longest (symbol->domain ()).release ();
+}
+
static PyObject *
sympy_is_argument (PyObject *self, void *closure)
{
@@ -707,6 +717,7 @@ static gdb_PyGetSetDef symbol_object_getset[] = {
This is either name or linkage_name, depending on whether the user asked GDB\n\
to display demangled or mangled names.", NULL },
{ "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." },
+ { "domain", sympy_get_domain, nullptr, "Domain of the symbol." },
{ "is_argument", sympy_is_argument, NULL,
"True if the symbol is an argument of a function." },
{ "is_constant", sympy_is_constant, NULL,
@@ -135,6 +135,7 @@ gdb_test "python print (func.name)" "func" "test func.name"
gdb_test "python print (func.print_name)" "func" "test func.print_name"
gdb_test "python print (func.linkage_name)" "func" "test func.linkage_name"
gdb_test "python print (func.addr_class == gdb.SYMBOL_LOC_BLOCK)" "True" "test func.addr_class"
+gdb_test "python print (func.domain == gdb.SYMBOL_FUNCTION_DOMAIN)" "True" "test func.domain"
# Stop in a second file and ensure we find its local static symbol.
gdb_breakpoint "function_in_other_file"