objfile_debug_name (this));
bool result = false;
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
{
if (iter->has_unexpanded_symtabs (this))
{
gdb_printf (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
objfile_debug_name (this));
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
{
retval = iter->find_last_source_symtab (this);
if (retval != nullptr)
gdb_printf (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
objfile_debug_name (this));
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
iter->forget_cached_source_info (this);
}
return result;
};
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
{
if (!iter->expand_symtabs_matching (this,
match_one_filename,
return true;
};
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
{
if (!iter->expand_symtabs_matching (this,
nullptr,
gdb_printf (gdb_stdlog, "qf->print_stats (%s, %d)\n",
objfile_debug_name (this), print_bcache);
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
iter->print_stats (this, print_bcache);
}
lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
lookup_name_info lookup_name = base_lookup.make_ignore_params ();
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
iter->expand_symtabs_matching (this,
nullptr,
&lookup_name,
gdb_printf (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
objfile_debug_name (this));
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
iter->expand_all_symtabs (this);
}
return filename_cmp (basenames ? basename : fullname, filename) == 0;
};
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
iter->expand_symtabs_matching (this,
file_matcher,
nullptr,
domain_name (domain), global,
host_address_to_string (ordered_compare));
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
iter->expand_matching_symbols (this, name, domain, global,
ordered_compare);
}
host_address_to_string (&expansion_notify),
search_domain_name (kind));
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,
symbol_matcher, expansion_notify,
search_flags, domain, kind))
host_address_to_string (section),
warn_if_readin);
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
{
retval = iter->find_pc_sect_compunit_symtab (this, msymbol, pc, section,
warn_if_readin);
objfile_debug_name (this),
need_fullname);
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
iter->map_symbol_filenames (this, fun, need_fullname);
}
hex_string (address));
struct compunit_symtab *result = NULL;
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
{
result = iter->find_compunit_symtab_by_address (this, address);
if (result != nullptr)
enum language result = language_unknown;
*symbol_found_p = false;
- for (const auto &iter : qf)
+ for (const auto &iter : qf_require_partial_symbols ())
{
result = iter->lookup_global_symbol_language (this, name, domain,
symbol_found_p);
--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2022 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/>. */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+int
+main (void)
+{
+ pid_t pid = fork ();
+ if (pid == 0)
+ {
+ void *shlib = dlopen (SHLIB_PATH, RTLD_NOW);
+ int (*add) (int, int) = dlsym (shlib, "add");
+
+ return add (-2, 2);
+ }
+
+ int wstatus;
+ if (waitpid (pid, &wstatus, 0) == -1)
+ assert (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) == 0);
+
+ return 0;
+}
--- /dev/null
+# Copyright 2022 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/>.
+
+# This test is a regression test for when GDB debugs a program with:
+# - set follow-fork-mode child
+# - set detach-on-fork off
+#
+# If the program forks, and the child loads a shared library (via
+# dlopen for example), GDB should still load the symtab for this objfile.
+# When a breakpoint is hit in this file, GDB should display the location
+# in the source of the shlib, and "list" should display the source where
+# the program stopped.
+
+if { [skip_shlib_tests] } {
+ return 0
+}
+
+standard_testfile .c -shlib.c
+set shlib_path [standard_output_file ${testfile}-lib.so]
+
+if { [gdb_compile_shlib $srcdir/$subdir/$srcfile2 $shlib_path {debug}] != "" } {
+ return
+}
+
+set opts [list shlib_load additional_flags=-DSHLIB_PATH="${shlib_path}"]
+if { [build_executable "failed to prepare" ${testfile} ${srcfile} $opts] } {
+ return
+}
+
+proc do_test {} {
+ clean_restart $::binfile
+ gdb_load_shlib $::shlib_path
+ gdb_test_no_output "set follow-fork-mode child"
+ gdb_test_no_output "set detach-on-fork off"
+
+ runto "add" allow-pending
+
+ # Since we have debug info in the shlib, we should have the file name available.
+ gdb_test "frame" "add \(.*\) at .*$::srcfile2:\[0-9\]+.*"
+
+ # We must also be able to display the source for the current function.
+ gdb_test "list" "return a \\+ b;.*"
+}
+
+do_test