* gdb-rhbz1773651-gdb-index-internal-error.patch - Patches added (backport from master): * gdb-support-rseq-auxvs.patch * gdb-symtab-fix-line-number-of-static-const-class-mem.patch * gdb-symtab-fix-too-many-symbols-in-gdbpy_lookup_stat.patch * gdb-symtab-handle-pu-in-iterate_over_some_symtabs.patch * gdb-symtab-work-around-pr-gas-29517.patch * gdb-testsuite-add-kfail-for-pr-ada-30908.patch * gdb-testsuite-add-xfail-for-gdb-29965-in-gdb.threads.patch * gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-with-newer.patch * gdb-testsuite-fix-gdb.arch-i386-signal.exp-on-x86_64.patch * gdb-testsuite-fix-gdb.cp-m-static.exp-regression-on-.patch * gdb-testsuite-fix-gdb.dwarf2-nullptr_t.exp-with-cc-w.patch * gdb-testsuite-fix-regexps-in-gdb.base-step-over-sysc.patch * gdb-symtab-find-main-language-without-symtab-expansi.patch * gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch - Patches moved (from "Backport from gdb-patches" to "Backports from master, available in next release"): * gdb-cli-handle-pending-c-after-rl_callback_read_char.patch * gdb-testsuite-add-have_host_locale.patch - Maintenance script qa.sh: * Remove PR28463, PR28108, PR29247 and PR29160 kfails. * Remove PR30540, PR30908, PR29965 kfails. * Remove gdb.ada/mi_task_arg.exp kfail. - Limit "Suggests: %{python}-Pygments" to SLE-15 and later. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=365
203 lines
6.8 KiB
Diff
203 lines
6.8 KiB
Diff
From e2f41776aa9ca2f625bbc50e9bb498e2a95dba25 Mon Sep 17 00:00:00 2001
|
|
From: Tom de Vries <tdevries@suse.de>
|
|
Date: Sat, 5 Aug 2023 17:57:13 +0200
|
|
Subject: [PATCH] [gdb/symtab] Find main language without symtab expansion
|
|
|
|
When loading an executable using "file a.out", the language is set according
|
|
to a.out, which can involve looking up the language of symbol "main", which
|
|
will cause the symtab expansion for the containing CU.
|
|
|
|
Expansion of lto debug info can be slow, so in commit d3214198119 ("[gdb] Use
|
|
partial symbol table to find language for main") a feature was added to avoid
|
|
the symtab expansion.
|
|
|
|
This feature stopped working after commit 7f4307436fd ("Fix "start" for D,
|
|
Rust, etc").
|
|
|
|
[ The commit addresses problems related to command start, which requires finding
|
|
the main function:
|
|
- for language D, "main" was found instead of "D main", and
|
|
- for Rust, the correct function was found, but attributed the wrong name
|
|
(not fully qualified). ]
|
|
|
|
Reimplement the feature by adding
|
|
cooked_index_functions::lookup_global_symbol_language.
|
|
|
|
Tested on x86_64-linux.
|
|
|
|
PR symtab/30661
|
|
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30661
|
|
---
|
|
gdb/dwarf2/read.c | 41 +++++++++++++++++++++++++++++++
|
|
gdb/testsuite/gdb.base/main-c.exp | 33 +++++++++++++++++++++++++
|
|
gdb/testsuite/gdb.cp/main-cp.exp | 33 +++++++++++++++++++++++++
|
|
gdb/testsuite/gdb.cp/main.cc | 22 +++++++++++++++++
|
|
4 files changed, 129 insertions(+)
|
|
create mode 100644 gdb/testsuite/gdb.base/main-c.exp
|
|
create mode 100644 gdb/testsuite/gdb.cp/main-cp.exp
|
|
create mode 100644 gdb/testsuite/gdb.cp/main.cc
|
|
|
|
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
|
index 04bc0e1cbbd..8aa7f8c31e5 100644
|
|
--- a/gdb/dwarf2/read.c
|
|
+++ b/gdb/dwarf2/read.c
|
|
@@ -18621,6 +18621,47 @@ struct cooked_index_functions : public dwarf2_base_index_functions
|
|
if (dwarf2_has_info (objfile, nullptr))
|
|
dwarf2_build_psymtabs (objfile);
|
|
}
|
|
+
|
|
+ enum language lookup_global_symbol_language (struct objfile *objfile,
|
|
+ const char *name,
|
|
+ domain_enum domain,
|
|
+ bool *symbol_found_p) override
|
|
+ {
|
|
+ *symbol_found_p = false;
|
|
+
|
|
+ if (!(domain == VAR_DOMAIN && streq (name, "main")))
|
|
+ return language_unknown;
|
|
+
|
|
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
|
|
+ struct dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
|
|
+ if (per_bfd->index_table == nullptr)
|
|
+ return language_unknown;
|
|
+
|
|
+ /* Expansion of large CUs can be slow. By returning the language of main
|
|
+ here for C and C++, we avoid CU expansion during set_initial_language.
|
|
+ But by doing a symbol lookup in the cooked index, we are forced to wait
|
|
+ for finalization to complete. See PR symtab/30174 for ideas how to
|
|
+ bypass that as well. */
|
|
+ cooked_index_vector *table
|
|
+ = (gdb::checked_static_cast<cooked_index_vector *>
|
|
+ (per_objfile->per_bfd->index_table.get ()));
|
|
+ table->wait ();
|
|
+
|
|
+ for (const cooked_index_entry *entry : table->find (name, false))
|
|
+ {
|
|
+ if (entry->tag != DW_TAG_subprogram)
|
|
+ continue;
|
|
+
|
|
+ enum language lang = entry->per_cu->lang ();
|
|
+ if (!(lang == language_c || lang == language_cplus))
|
|
+ continue;
|
|
+
|
|
+ *symbol_found_p = true;
|
|
+ return lang;
|
|
+ }
|
|
+
|
|
+ return language_unknown;
|
|
+ }
|
|
};
|
|
|
|
dwarf2_per_cu_data *
|
|
diff --git a/gdb/testsuite/gdb.base/main-c.exp b/gdb/testsuite/gdb.base/main-c.exp
|
|
new file mode 100644
|
|
index 00000000000..bcbd0fca7e4
|
|
--- /dev/null
|
|
+++ b/gdb/testsuite/gdb.base/main-c.exp
|
|
@@ -0,0 +1,33 @@
|
|
+# Copyright 2023 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/>.
|
|
+
|
|
+# Check that finding main to set the current language doesn't cause any symtab
|
|
+# to be expanded.
|
|
+
|
|
+standard_testfile main.c
|
|
+
|
|
+if { [readnow] } {
|
|
+ return -1
|
|
+}
|
|
+
|
|
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
|
|
+ return -1
|
|
+}
|
|
+
|
|
+if { ![string eq [have_index $binfile] ""] } {
|
|
+ return -1
|
|
+}
|
|
+
|
|
+gdb_test_no_output "maint info symtabs"
|
|
diff --git a/gdb/testsuite/gdb.cp/main-cp.exp b/gdb/testsuite/gdb.cp/main-cp.exp
|
|
new file mode 100644
|
|
index 00000000000..86d626bdbaf
|
|
--- /dev/null
|
|
+++ b/gdb/testsuite/gdb.cp/main-cp.exp
|
|
@@ -0,0 +1,33 @@
|
|
+# Copyright 2023 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/>.
|
|
+
|
|
+# Check that finding main to set the current language doesn't cause any symtab
|
|
+# to be expanded.
|
|
+
|
|
+standard_testfile main.cc
|
|
+
|
|
+if { [readnow] } {
|
|
+ return -1
|
|
+}
|
|
+
|
|
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
|
|
+ return -1
|
|
+}
|
|
+
|
|
+if { ![string eq [have_index $binfile] ""] } {
|
|
+ return -1
|
|
+}
|
|
+
|
|
+gdb_test_no_output "maint info symtabs"
|
|
diff --git a/gdb/testsuite/gdb.cp/main.cc b/gdb/testsuite/gdb.cp/main.cc
|
|
new file mode 100644
|
|
index 00000000000..c6beff77dbe
|
|
--- /dev/null
|
|
+++ b/gdb/testsuite/gdb.cp/main.cc
|
|
@@ -0,0 +1,22 @@
|
|
+/* This testcase is part of GDB, the GNU debugger.
|
|
+
|
|
+ Copyright 2023 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/>. */
|
|
+
|
|
+int
|
|
+main (void)
|
|
+{
|
|
+ return 0;
|
|
+}
|
|
|
|
base-commit: ebceffa1196651683a7a6d31abb4b3b5adc6c168
|
|
--
|
|
2.35.3
|
|
|