aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Vrany <jan.vrany@labware.com>2025-02-04 13:56:49 +0000
committerJan Vrany <jan.vrany@labware.com>2025-02-04 13:56:49 +0000
commit30243af82d55050d4168090626dbc91a1c935159 (patch)
treea7fd97a9c5cbdbebaf64565db68b67f29e92d8d9
parent5166ed9c9c6f60859295d932b65c5c5a19984dfd (diff)
downloadbinutils-30243af82d55050d4168090626dbc91a1c935159.zip
binutils-30243af82d55050d4168090626dbc91a1c935159.tar.gz
binutils-30243af82d55050d4168090626dbc91a1c935159.tar.bz2
gdb/python: add domain property to gdb.Symbol
Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Andrew Burgess <aburgess@redhat.com>
-rw-r--r--gdb/NEWS2
-rw-r--r--gdb/doc/python.texi5
-rw-r--r--gdb/python/py-symbol.c16
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.exp3
4 files changed, 24 insertions, 2 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index 1d8f2c5..401479e 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -155,6 +155,8 @@ binary-upload in qSupported reply
** 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 d3c77d6..1e0fbdf 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -6209,6 +6209,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 f1ba0ba..3ce1049 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -1,6 +1,6 @@
/* Python interface to symbols.
- Copyright (C) 2008-2024 Free Software Foundation, Inc.
+ Copyright (C) 2008-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -153,6 +153,19 @@ sympy_get_addr_class (PyObject *self, void *closure)
return gdb_py_object_from_longest (symbol->aclass ()).release ();
}
+/* Implement gdb.Symbol.domain attribute. Return the domain as an
+ integer. */
+
+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)
{
@@ -719,6 +732,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_artificial", sympy_is_artificial, nullptr,
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index e6411b4..40f9038 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2024 Free Software Foundation, Inc.
+# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -142,6 +142,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"