gdb/gdb-6.6-buildid-locate-solib-missing-ids.patch
Tom de Vries f103997c76 - Update to fedora rawhide @ a8e0b3d (gdb 15.1).
- Use gcc-9 for SLE-12 (default gcc 4.8.5 doesn't support C++17).
- Maintenance script qa-local.sh:
  * Update version to 15.1.
- Maintenance script qa.sh:
  * Add kfails due to gcc 4.8.5 DW_TAG_lexical_block oddity.
  * Extend PR24845 kfails.
  * Add PR31721 and PR32608 kfails.
- Patches added:
  * gdb-guile-use-scm_debug_typing_strictness-0.patch
  * gdb-doc-fix-gdb.unwinder-docs.patch
  * gdb-doc-fix-qisaddresstagged-anchor.patch
  * gdb-doc-fix-standard-replies-xref.patch
  * gdb-testsuite-fix-gdb_py_module_available-for-python.patch
  * gdb-testsuite-fix-another-regexp-in-gdb.threads-step.patch
  * gdb-testsuite-fix-timeouts-in-gdb.threads-step-over-.patch
- Patches updated:
  * gdb-6.3-gstack-20050411.patch
  * gdb-6.6-buildid-locate-solib-missing-ids.patch
  * gdb-6.6-buildid-locate.patch
  * gdb-add-rpm-suggestion-script.patch
  * gdb-gcore-bash.patch
  * gdb-python-avoid-depending-on-the-curses-library.patch
  * gdb-python-finishbreakpoint-update.patch
- Patches dropped:
  * gdb-add-missing-debug-ext-lang-hook.patch
  * gdb-add-missing-debug-info-python-hook.patch
  * gdb-do-not-import-py-curses-ascii-module.patch
  * gdb-ftbs-swapped-calloc-args.patch
  * gdb-handle-no-python-gdb-module.patch
  * gdb-merge-debug-symbol-lookup.patch
  * gdb-refactor-find-and-add-separate-symbol-file.patch
  * gdb-reformat-missing-debug-py-file.patch
  * gdb-remove-path-in-test-name.patch
  * gdb-rhbz-2232086-cpp-ify-mapped-symtab.patch
  * gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
  * gdb-rhbz-2232086-generate-gdb-index-consistently.patch
  * gdb-rhbz-2232086-reduce-size-of-gdb-index.patch
  * gdb-rhbz2232086-refactor-selftest-support.patch
  * gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
  * gdb-rhbz2250652-gdbpy_gil.patch
  * gdb-rhbz2261580-intrusive_list-assertion-fix.patch
  * gdb-rhbz2277160-apx-disasm.patch
  * gdb-rhel2295897-pre-read-DWZ-file-in-DWARF-reader.patch
  * gdb-sync-coffread-with-elfread.patch
  * gdb-remove-use-of-py-isascii
  * change-gdb.base-examine-backwards.exp-for-aix.patch
  * fix-regression-on-aarch64-linux-gdbserver.patch
  * fix-the-gdb.ada-inline-section-gc.exp-test.patch
  * fixup-powerpc-and-aarch64-fix-reverse-stepping-failu.patch
  * gdb-arm-fix-epilogue-frame-id.patch
  * gdb-arm-remove-thumb-bit-in-arm_adjust_breakpoint_ad.patch
  * gdb-arm-remove-tpidruro-register-from-non-freebsd-ta.patch
  * gdb-build-fix-gdbserver-linux-aarch64-low.cc-build.patch
  * gdb-exp-fix-cast-handling-for-indirection.patch
  * gdb-exp-fix-printing-of-out-of-bounds-struct-members.patch
  * gdb-exp-redo-cast-handling-for-indirection.patch
  * gdb-fix-heap-use-after-free-in-select_event_lwp.patch
  * gdb-fix-segfault-in-for_each_block-part-1.patch
  * gdb-fix-segfault-in-for_each_block-part-2.patch
  * gdb-python-fix-gdb.python-py-disasm.exp-on-arm-linux.patch
  * gdb-python-make-gdb.unwindinfo.add_saved_register-mo-fixup.patch
  * gdb-python-make-gdb.unwindinfo.add_saved_register-mo.patch
  * gdb-remote-fix-abort-on-remote_close_error.patch
  * gdb-s390-add-arch14-record-replay-support.patch
  * gdb-symtab-add-producer_is_gas.patch
  * gdb-symtab-don-t-defer-backward-refs-inter-cu-intra-.patch
  * gdb-symtab-factor-out-m_deferred_entries-usage.patch
  * gdb-symtab-factor-out-m_die_range_map-usage.patch
  * gdb-symtab-fix-dw_tag_inlined_subroutine-entries-in-.patch
  * gdb-symtab-handle-nullptr-parent-in-parent_map-set_p.patch
  * gdb-symtab-keep-track-of-all-parents-for-cooked-inde.patch
  * gdb-symtab-keep-track-of-processed-dies-in-shard.patch
  * gdb-symtab-refactor-condition-in-scan_attributes.patch
  * gdb-symtab-resolve-deferred-entries-inter-shard-case.patch
  * gdb-symtab-resolve-deferred-entries-intra-shard-case.patch
  * gdb-symtab-work-around-gas-pr28629.patch
  * gdb-symtab-work-around-pr-gas-29517-dwarf2-case.patch
  * gdb-symtab-work-around-pr-gas-29517.patch
  * gdb-symtab-workaround-pr-gas-31115.patch
  * gdb-tdep-fix-catching-syscall-execve-exit-for-arm.patch
  * gdb-tdep-fix-gdb.base-watch-bitfields.exp-on-aarch64.patch
  * gdb-tdep-fix-gdb.base-watchpoint-running-on-arm-ppc6.patch
  * gdb-tdep-fix-gdb.base-watchpoint-unaligned.exp-on-aa.patch
  * gdb-tdep-fix-nr-array-elements-in-ppc64_aggregate_ca.patch
  * gdb-tdep-fix-reverse-execution-of-ldr-immediate-t4.patch
  * gdb-testsuite-add-gdb.dwarf2-backward-spec-inter-cu..patch
  * gdb-testsuite-add-gdb.dwarf2-forward-spec-inter-cu.e.patch
  * gdb-testsuite-add-missing-include-in-gdb.base-ctf-pt.patch
  * gdb-testsuite-add-missing-include-in-gdb.base-rtld-s.patch
  * gdb-testsuite-add-missing-includes-in-gdb.trace-coll.patch
  * gdb-testsuite-add-missing-no-prompt-anchor-in-gdb.ba.patch
  * gdb-testsuite-add-pr-gdb-26967-kfail-in-two-more-tes.patch
  * gdb-testsuite-call-ldd-version-in-gdb.testsuite-dump.patch
  * gdb-testsuite-factor-out-proc-get_portnum.patch
  * gdb-testsuite-factor-out-proc-lock_dir.patch
  * gdb-testsuite-factor-out-proc-with_lock.patch
  * gdb-testsuite-fix-gdb.ada-verylong.exp-on-32-bit-tar.patch
  * gdb-testsuite-fix-gdb.base-eh_return.exp.patch
  * gdb-testsuite-fix-gdb.base-ending-run.exp-on-manjaro.patch
  * gdb-testsuite-fix-gdb.base-list-no-debug.exp-on-debi.patch
  * gdb-testsuite-fix-gdb.cp-namespace.exp-with-read1.patch
  * gdb-testsuite-fix-gdb.dwarf2-dw2-gas-workaround.exp.patch
  * gdb-testsuite-fix-gdb.mi-mi-dprintf.exp-with-read1.patch
  * gdb-testsuite-fix-gdbserver-pid-in-gdb.server-server.patch
  * gdb-testsuite-fix-gdb.server-server-connect.exp-for-.patch
  * gdb-testsuite-fix-license-text-in-gdb.reverse-map-to.patch
  * gdb-testsuite-fix-missing-return-type-in-gdb.linespe.patch
  * gdb-testsuite-fix-regexp-in-vgdb_start.patch
  * gdb-testsuite-fix-spurious-fails-with-examine-backwa.patch
  * gdb-testsuite-fix-test-case-gdb.threads-attach-stopp.patch
  * gdb-testsuite-fix-test-in-gdb.python-py-finish-break.patch
  * gdb-testsuite-fix-typo-in-gdb.base-catch-syscall.exp.patch
  * gdb-testsuite-fix-valgrind-tests-on-debian.patch
  * gdb-testsuite-further-handle-long-filenames-in-gdb.b.patch
  * gdb-testsuite-handle-core-without-build-id-in-gdb.ba.patch
  * gdb-testsuite-handle-pac-marker.patch
  * gdb-testsuite-make-gdb.base-solib-search.exp-more-ro.patch
  * gdb-testsuite-make-portnum-a-persistent-global.patch
  * gdb-testsuite-move-gpu-parallel.lock-to-cache-dir.patch
  * gdb-testsuite-remove-spurious-in-save_vars.patch
  * gdb-testsuite-reset-errcnt-and-warncnt-in-default_gd.patch
  * gdb-testsuite-simplify-gdb.server-server-kill-python.patch
  * gdb-testsuite-use-find_gnatmake-instead-of-gdb_find_.patch
  * gdb-testsuite-use-more-progbits-for-arm.patch
  * gdb-testsuite-use-unique-portnum-in-parallel-testing-check-slash-slash-case.patch
  * gdb-testsuite-use-unique-portnum-in-parallel-testing.patch
  * gdb-tui-allow-command-window-of-1-or-2-lines.patch
  * gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch
  * gdb-tui-fix-wmaybe-uninitialized-in-tui_find_disasse.patch
  * make-pascal_language-print_type-handle-varstring-nul.patch
  * powerpc-and-aarch64-fix-reverse-stepping-failure.patch
  * powerpc-fix-test-gdb.ada-finish-large.exp.patch
  * riscv-lrsc.patch
  * rs6000-unwind-on-each-instruction-fix.patch
  * s390-provide-ibm-z16-arch14-instruction-descriptions.patch

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=425
2025-01-29 07:03:03 +00:00

263 lines
9.2 KiB
Diff

From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.6-buildid-locate-solib-missing-ids.patch
;; Fix loading of core files without build-ids but with build-ids in executables.
;; Load strictly build-id-checked core files only if no executable is specified
;; (Jan Kratochvil, RH BZ 1339862).
;;=push+jan
gdb returns an incorrect back trace when applying a debuginfo
https://bugzilla.redhat.com/show_bug.cgi?id=1339862
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -347,11 +347,13 @@ lm_addr_check (const solib &so, bfd *abfd)
struct svr4_so
{
- svr4_so (const char *name, lm_info_svr4_up lm_info)
- : name (name), lm_info (std::move (lm_info))
+ svr4_so (const char *name, lm_info_svr4_up lm_info, const char *orig_name = nullptr)
+ : name (name), original_name (orig_name == nullptr ? name : orig_name),
+ lm_info (std::move (lm_info))
{}
std::string name;
+ std::string original_name;
lm_info_svr4_up lm_info;
};
@@ -1002,6 +1004,7 @@ so_list_from_svr4_sos (const std::vector<svr4_so> &sos)
newobj->so_name = so.name;
newobj->so_original_name = so.name;
+ newobj->so_original_name = so.original_name;
newobj->lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
dst.push_back (*newobj);
@@ -1263,11 +1266,28 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
continue;
}
+ /* Preserve original name since name may be changed below. */
+ gdb::unique_xmalloc_ptr<char> original_name = make_unique_xstrdup (name.get ());
{
- struct bfd_build_id *build_id;
+ struct bfd_build_id *build_id = nullptr;
- build_id = build_id_addr_get (li->l_ld);
- if (build_id != NULL)
+ /* In the case the main executable was found according to its build-id
+ (from a core file) prevent loading a different build of a library
+ with accidentally the same SO_NAME.
+
+ It suppresses bogus backtraces (and prints "??" there instead) if
+ the on-disk files no longer match the running program version.
+ If the main executable was not loaded according to its build-id do
+ not do any build-id checking of the libraries. There may be missing
+ build-ids dumped in the core file and we would map all the libraries
+ to the only existing file loaded that time - the executable. */
+ if (current_program_space->symfile_object_file != NULL
+ && (current_program_space->symfile_object_file->flags
+ & OBJF_BUILD_ID_CORE_LOADED) != 0)
+ build_id = build_id_addr_get (li->l_ld);
+
+
+ if (build_id != nullptr)
{
char *bid_name, *build_id_filename;
@@ -1280,23 +1300,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
xfree (bid_name);
}
else
- {
- debug_print_missing (name.get (), build_id_filename);
-
- /* In the case the main executable was found according to
- its build-id (from a core file) prevent loading
- a different build of a library with accidentally the
- same SO_NAME.
-
- It suppresses bogus backtraces (and prints "??" there
- instead) if the on-disk files no longer match the
- running program version. */
-
- if (current_program_space->symfile_object_file != NULL
- && (current_program_space->symfile_object_file->flags
- & OBJF_BUILD_ID_CORE_LOADED) != 0)
- name = make_unique_xstrdup ("");
- }
+ debug_print_missing (name.get (), build_id_filename);
xfree (build_id_filename);
xfree (build_id);
diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c
@@ -0,0 +1,21 @@
+/* Copyright 2010 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+void
+lib (void)
+{
+}
diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c
@@ -0,0 +1,25 @@
+/* Copyright 2010 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+extern void lib (void);
+
+int
+main (void)
+{
+ lib ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
@@ -0,0 +1,104 @@
+# Copyright 2016 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/>.
+
+require allow_shlib_tests
+
+set testfile "gcore-buildid-exec-but-not-solib"
+set srcmainfile ${testfile}-main.c
+set srclibfile ${testfile}-lib.c
+set libfile [standard_output_file ${testfile}-lib.so]
+set objfile [standard_output_file ${testfile}-main.o]
+set executable ${testfile}-main
+set binfile [standard_output_file ${executable}]
+set gcorefile [standard_output_file ${executable}.gcore]
+set outdir [file dirname $binfile]
+
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} "debug additional_flags=-Wl,--build-id"] != ""
+ || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } {
+ unsupported "-Wl,--build-id compilation failed"
+ return -1
+}
+set opts [list debug shlib=${libfile} "additional_flags=-Wl,--build-id"]
+if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } {
+ unsupported "-Wl,--build-id compilation failed"
+ return -1
+}
+
+clean_restart $executable
+gdb_load_shlib $libfile
+
+# Does this gdb support gcore?
+set test "help gcore"
+gdb_test_multiple $test $test {
+ -re "Undefined command: .gcore.*\r\n$gdb_prompt $" {
+ # gcore command not supported -- nothing to test here.
+ unsupported "gdb does not support gcore on this target"
+ return -1;
+ }
+ -re "Save a core file .*\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+
+if { ![runto lib] } then {
+ return -1
+}
+
+set escapedfilename [string_to_regexp ${gcorefile}]
+
+set test "save a corefile"
+gdb_test_multiple "gcore ${gcorefile}" $test {
+ -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Can't create a corefile\r\n$gdb_prompt $" {
+ unsupported $test
+ return -1
+ }
+}
+
+# Now restart gdb and load the corefile.
+
+clean_restart $executable
+gdb_load_shlib $libfile
+
+set buildid [build_id_debug_filename_get $libfile]
+
+regsub {\.debug$} $buildid {} buildid
+
+set debugdir [standard_output_file ${testfile}-debugdir]
+file delete -force -- $debugdir
+
+file mkdir $debugdir/[file dirname $libfile]
+file copy $libfile $debugdir/${libfile}
+
+file mkdir $debugdir/[file dirname $buildid]
+file copy $libfile $debugdir/${buildid}
+
+remote_exec build "ln -s /lib ${debugdir}/"
+remote_exec build "ln -s /lib64 ${debugdir}/"
+# /usr is not needed, all the libs are in /lib64: libm.so.6 libc.so.6 ld-linux-x86-64.so.2
+
+gdb_test_no_output "set solib-absolute-prefix $debugdir" \
+ "set solib-absolute-prefix"
+
+gdb_test_no_output "set debug-file-directory $debugdir" "set debug-file-directory"
+
+gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile"
+
+gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded"
+
+gdb_test "bt"
+gdb_test "info shared"