aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-11-13 14:03:58 -0700
committerTom Tromey <tromey@adacore.com>2023-11-17 08:43:04 -0700
commit17f2cab5f8d7550576a1ffaad8c16be9142028c3 (patch)
tree5a20384abd5a0af75ecd8f1c26c1c7c3bc489a75
parentfa2cc08fddd9faec495c0bef79c615c9d63716be (diff)
downloadbinutils-17f2cab5f8d7550576a1ffaad8c16be9142028c3.zip
binutils-17f2cab5f8d7550576a1ffaad8c16be9142028c3.tar.gz
binutils-17f2cab5f8d7550576a1ffaad8c16be9142028c3.tar.bz2
Ignore static members in NoOpStructPrinter
Hannes' patch to show local variables in the TUI pointed out that NoOpStructPrinter should ignore static members. This patch implements this. (cherry picked from commit 4a1b9a4badc8954221926b231b81392fa625653c)
-rw-r--r--gdb/python/lib/gdb/printing.py2
-rw-r--r--gdb/testsuite/gdb.dap/ptrref.cc12
-rw-r--r--gdb/testsuite/gdb.dap/ptrref.exp9
3 files changed, 21 insertions, 2 deletions
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py
index dec1351..14bd84b 100644
--- a/gdb/python/lib/gdb/printing.py
+++ b/gdb/python/lib/gdb/printing.py
@@ -350,7 +350,7 @@ class NoOpStructPrinter(gdb.ValuePrinter):
def children(self):
for field in self.__ty.fields():
- if field.name is not None:
+ if hasattr(field, "bitpos") and field.name is not None:
yield (field.name, self.__value[field])
diff --git a/gdb/testsuite/gdb.dap/ptrref.cc b/gdb/testsuite/gdb.dap/ptrref.cc
index bfb1afe..c9b83cd 100644
--- a/gdb/testsuite/gdb.dap/ptrref.cc
+++ b/gdb/testsuite/gdb.dap/ptrref.cc
@@ -15,9 +15,21 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+struct some_struct
+{
+ int x;
+ int y;
+
+ static int z;
+};
+
+int some_struct::z = 37;
+
void
func ()
{
+ some_struct aggregate { 91, 87 };
+
int value = 23;
int *ptr = &value;
diff --git a/gdb/testsuite/gdb.dap/ptrref.exp b/gdb/testsuite/gdb.dap/ptrref.exp
index e0cc745..456774a 100644
--- a/gdb/testsuite/gdb.dap/ptrref.exp
+++ b/gdb/testsuite/gdb.dap/ptrref.exp
@@ -55,7 +55,7 @@ gdb_assert {[llength $scopes] == 2} "two scopes"
lassign $scopes scope reg_scope
gdb_assert {[dict get $scope name] == "Locals"} "scope is locals"
-gdb_assert {[dict get $scope namedVariables] == 3} "three vars in scope"
+gdb_assert {[dict get $scope namedVariables] == 4} "three vars in scope"
set num [dict get $scope variablesReference]
set refs [lindex [dap_check_request_and_response "fetch variables" \
@@ -97,6 +97,13 @@ foreach var [dict get $refs body variables] {
"$name has exactly one child"
fetch_pointer $name $var
}
+ "aggregate" {
+ gdb_assert {[dict get $var variablesReference] != 0} \
+ "$name has children"
+ # This should omit the static field.
+ gdb_assert {[dict get $var namedVariables] == 2} \
+ "$name has exactly 2 children"
+ }
}
}