aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/python/py-symbol.c3
-rw-r--r--gdb/testsuite/gdb.python/py-symbol-3.c20
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.c1
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.exp13
4 files changed, 32 insertions, 5 deletions
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 8648a50..f1ba0ba 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -610,8 +610,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
/* Expand any symtabs that contain potentially matching symbols. */
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
expand_symtabs_matching (NULL, lookup_name, NULL, NULL,
- SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
- SEARCH_ALL_DOMAINS);
+ SEARCH_STATIC_BLOCK, flags);
for (objfile *objfile : current_program_space->objfiles ())
{
diff --git a/gdb/testsuite/gdb.python/py-symbol-3.c b/gdb/testsuite/gdb.python/py-symbol-3.c
new file mode 100644
index 0000000..6a95193
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-symbol-3.c
@@ -0,0 +1,20 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* A global 'rr' -- used for testing that lookup_static_symbols does
+ not find it. */
+int __attribute__ ((used)) rr = 107;
diff --git a/gdb/testsuite/gdb.python/py-symbol.c b/gdb/testsuite/gdb.python/py-symbol.c
index 57fce1e..b6b2cd6 100644
--- a/gdb/testsuite/gdb.python/py-symbol.c
+++ b/gdb/testsuite/gdb.python/py-symbol.c
@@ -44,6 +44,7 @@ extern void function_in_other_file (void);
int qq = 72; /* line of qq */
static int __attribute__ ((used)) rr = 42; /* line of rr */
+static int __attribute__ ((used)) qqrr = 42;
int func (int arg)
{
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index c174ba4..e6411b4 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -20,11 +20,11 @@ load_lib gdb-python.exp
require allow_python_tests
-standard_testfile py-symbol.c py-symbol-2.c
+standard_testfile py-symbol.c py-symbol-2.c py-symbol-3.c
set opts { debug additional_flags=-DUSE_TWO_FILES }
if {[prepare_for_testing "failed to prepare" $testfile \
- [list $srcfile $srcfile2] $opts]} {
+ [list $srcfile $srcfile2 $srcfile3] $opts]} {
return -1
}
@@ -36,6 +36,13 @@ set readnow_p [readnow]
gdb_test "python print (len (gdb.lookup_static_symbols ('rr')))" \
"2" "print (len (gdb.lookup_static_symbols ('rr')))"
+# This test does not make sense when readnow is in effect.
+if {!$readnow_p} {
+ # Make sure that the global symbol's symtab was not expanded.
+ gdb_test_no_output "pipe maint info symtab | grep \"name.*py-symbol-3.c\"" \
+ "global rr symtab was not expanded"
+}
+
# Restart so we don't have expanded symtabs after the previous test.
clean_restart ${binfile}
@@ -65,7 +72,7 @@ gdb_test "python print (gdb.lookup_global_symbol('qq').needs_frame)" \
# Similarly, test looking up a static symbol before we runto_main.
set rr_line [gdb_get_line_number "line of rr"]
set rr_line_alt [gdb_get_line_number "line of other rr" py-symbol-2.c]
-gdb_test "python print (gdb.lookup_global_symbol ('rr') is None)" "True" \
+gdb_test "python print (gdb.lookup_global_symbol ('qqrr') is None)" "True" \
"lookup_global_symbol for static var"
set cmd "python print (gdb.lookup_static_symbol ('rr').line)"