From b8c338f1c4e1d2b0bcc3878863d4b8d29fe468abd68ac5181fee5be6e0ba3224 Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Thu, 19 Oct 2023 13:23:08 +0000 Subject: [PATCH 01/10] - Add "Suggests: %{python}-Pygments". - Maintenance script qa.sh: * Note investigation of some ada test-cases. * Update PR30547 kfail. * Add PR28561 kfail. * Update PKRU-related kfail. * Use openSUSE_Factory_LegacyX86.i586 instead of openSUSE_Factory.i586. * Remove PR27813 kfail and corresponding todo. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=362 --- gdb.changes | 13 +++++++++++++ gdb.spec | 9 +++++++++ qa.sh | 47 ++++++++++++++++++----------------------------- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/gdb.changes b/gdb.changes index 2a2d9e2..3e8dd74 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Wed Sep 27 09:22:47 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Add "Suggests: %{python}-Pygments". +- Maintenance script qa.sh: + * Note investigation of some ada test-cases. + * Update PR30547 kfail. + * Add PR28561 kfail. + * Update PKRU-related kfail. + * Use openSUSE_Factory_LegacyX86.i586 instead of + openSUSE_Factory.i586. + * Remove PR27813 kfail and corresponding todo. + ------------------------------------------------------------------- Sun Aug 20 00:41:09 UTC 2023 - Luciano Santos <luc14n0@opensuse.org> diff --git a/gdb.spec b/gdb.spec index 0e83da7..d7dc296 100644 --- a/gdb.spec +++ b/gdb.spec @@ -583,6 +583,15 @@ Requires: libunwind %if %{build_main} +%if 0%{!?_without_python:1} +# For SLE-15 and later, we use source-highlight by default, and +# pygments as fallback. +# For SLE-12, source-highlight is not used, and we'd rather not start using +# pygments as default for an older release. +# So, suggests rather than recommends is what we want in both cases. +Suggests: %{python}-Pygments +%endif + %description GDB, the GNU debugger, allows you to debug programs written in C, C++, Java, and other languages, by executing them in a controlled fashion diff --git a/qa.sh b/qa.sh index 70dce54..112906f 100644 --- a/qa.sh +++ b/qa.sh @@ -1,25 +1,5 @@ #!/bin/bash -# Note: -# Occasionally we run into PR28561 - "[gdb/testsuite] Error due to not -# reading \r\n at end of mi prompt". -# https://sourceware.org/bugzilla/show_bug.cgi?id=28561 -# Not sure how to filter for that. - -# TODO: -# -# We run into FAILs like this: -# FAIL: gdb.base/options.exp: test-print: \ -# tab complete "thread apply all print " (clearing input line) (timeout) -# FAIL: gdb.base/options.exp: test-print: \ -# cmd complete "thread apply all print " -# in various test-cases. One instance is reported here ( -# https://sourceware.org/bugzilla/show_bug.cgi?id=27813 ). -# We could do a generic kfail for "(clearing input line) (timeout)", but that -# doesn't filter out the following FAIL. We need to update the testsuite to -# emit only one FAIL for this, or alternatively, add a possibility in this -# script to KFAIL one and all following FAILs in the same test-case. - usage () { echo "usage: $0 <1-5>" @@ -161,8 +141,6 @@ kfail=( "FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: .*: continue" # https://sourceware.org/bugzilla/show_bug.cgi?id=28065 "FAIL: gdb.threads/access-mem-running-thread-exit.exp:" - # https://sourceware.org/bugzilla/show_bug.cgi?id=27813 - "FAIL: gdb.cp/cpcompletion.exp:" # https://sourceware.org/bugzilla/show_bug.cgi?id=25503 "FAIL: gdb.threads/signal-while-stepping-over-bp-other-thread.exp: step \(pattern 3\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=26915 @@ -279,9 +257,15 @@ kfail=( "FAIL: gdb.base/info-os.exp: get shared-memory regions" "FAIL: gdb.base/info-os.exp: get threads" - #https://sourceware.org/bugzilla/show_bug.cgi?id=29790 + # Fails related to PKRU register. To be investigated. Might be fixed in + # gdb 14, but related patches look non-trivial to backport. + "FAIL: gdb.arch/i386-pkru.exp: pkru register" + "FAIL: gdb.arch/i386-pkru.exp: read pkru register" "FAIL: gdb.arch/i386-pkru.exp: read value after setting value" "FAIL: gdb.arch/i386-pkru.exp: variable after reading pkru" + "FAIL: gdb.base/gcore.exp: corefile restored all registers" + "FAIL: gdb.reverse/insn-reverse.exp: rdrand: compare registers on insn" + "FAIL: gdb.reverse/insn-reverse.exp: rdseed: compare registers on insn" # https://sourceware.org/bugzilla/show_bug.cgi?id=28478 "FAIL: gdb.gdb/selftest.exp: backtrace through signal handler" @@ -289,10 +273,6 @@ kfail=( # https://sourceware.org/bugzilla/show_bug.cgi?id=29781 "FAIL: gdb.mi/mi-multi-commands.exp: args=: look for second command output, command length .* \(timeout\)" - # https://sourceware.org/bugzilla/show_bug.cgi?id=27813 - "FAIL: .*.exp: .*tab complete .* \(clearing input line\) \(timeout\)" - "FAIL: .*.exp: .*cmd complete .*" - # https://sourceware.org/bugzilla/show_bug.cgi?id=27027 # https://sourceware.org/bugzilla/show_bug.cgi?id=28464 "FAIL: gdb.ada/mi_var_access.exp: Create varobj \(unexpected output\)" @@ -506,8 +486,10 @@ kfail_factory=( # https://sourceware.org/bugzilla/show_bug.cgi?id=29965 "FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=.*: continue \(the program exited\)" - # To be investigated. + # https://sourceware.org/pipermail/gdb-patches/2023-September/202757.html "FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 \(unexpected output\)" + + # https://sourceware.org/bugzilla/show_bug.cgi?id=30908 "FAIL: gdb.ada/str_binop_equal.exp: print my_str = \"ABCD\"" "FAIL: gdb.ada/widewide.exp: print my_wws = \" helo\"" "FAIL: gdb.ada/widewide.exp: print my_ws = \"wide\"" @@ -553,6 +535,12 @@ kfail_aarch64=( "FAIL: gdb.base/watchpoint-unaligned.exp: continue \(timeout\)" "FAIL: gdb.base/watchpoint-unaligned.exp: size8twice write" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28561 + # "[gdb/testsuite] Error due to not reading \r\n at end of mi prompt" + # We match pretty aggressively here. + "FAIL: gdb.mi/.*.exp:" + "FAIL: gdb.python/.*-mi.exp:" + ) # kfail_aarch64 kfail_powerpc64le=( @@ -770,6 +758,7 @@ case $n in "UNRESOLVED: gdb.base/gcore-excessive-memory.exp: verify we can get to main" # https://sourceware.org/bugzilla/show_bug.cgi?id=30547 + "UNRESOLVED: gdb.base/vfork-follow-parent.exp: resolution_method=schedule-multiple: print unblock_parent = 1" "UNRESOLVED: gdb.base/vfork-follow-parent.exp: resolution_method=schedule-multiple: continue to break_parent" ) @@ -936,7 +925,7 @@ case $n in ( # Known clean config: Factory i586 - config=openSUSE_Factory.i586/gdb-testresults + config=openSUSE_Factory_LegacyX86.i586/gdb-testresults sums=("$config/gdb-i586-suse-linux-m32.-fno-PIE.-no-pie.sum" "$config/gdb-i586-suse-linux-m32.sum") From 4d8ef504a25b1ea051ad8e160f7b2ea1536b04cb45bbad49ac302776dedd25dc Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Sat, 21 Oct 2023 08:04:00 +0000 Subject: [PATCH 02/10] - Maintenance script import-fedora.sh: * New script. Move skipped patches list from gdb.spec to script. - Update to fedora 38 @ 82cc8e0. - Patch renamed: * pass-const-frame_info_ptr-reference-for-skip_-langua.patch -> gdb-rhbz2192105-ftbs-dangling-pointer - Patches added: * gdb-bz2237392-dwarf-obstack-allocation.patch * gdb-bz2237515-debuginfod-double-free.patch * gdb-rhbz2160211-excessive-core-file-warnings.patch * gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch * gdb-rhbz2233961-CVE-2022-4806.patch * gdb-rhbz2233965-memory-leak.patch - Maintenance script qa-local.sh: * Add openSUSE_Leap_15.5 and openSUSE_Factory_LegacyX86. * Add "List configs" item. * Skip i586 for SLE-11. - Maintenance script qa.sh: * Make sure exit status is 0 OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=363 --- gdb-bz2237392-dwarf-obstack-allocation.patch | 68 +++++++ gdb-bz2237515-debuginfod-double-free.patch | 102 ++++++++++ ...2160211-excessive-core-file-warnings.patch | 108 ++++++++++ ...h => gdb-rhbz2192105-ftbs-dangling-pointer | 29 +-- ...6395-debuginfod-legacy-openssl-crash.patch | 188 ++++++++++++++++++ gdb-rhbz2233961-CVE-2022-4806.patch | 50 +++++ gdb-rhbz2233965-memory-leak.patch | 115 +++++++++++ gdb.changes | 23 +++ gdb.spec | 48 ++--- import-fedora.sh | 155 +++++++++++++++ qa-local.sh | 48 ++++- qa.sh | 2 + 12 files changed, 874 insertions(+), 62 deletions(-) create mode 100644 gdb-bz2237392-dwarf-obstack-allocation.patch create mode 100644 gdb-bz2237515-debuginfod-double-free.patch create mode 100644 gdb-rhbz2160211-excessive-core-file-warnings.patch rename pass-const-frame_info_ptr-reference-for-skip_-langua.patch => gdb-rhbz2192105-ftbs-dangling-pointer (87%) create mode 100644 gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch create mode 100644 gdb-rhbz2233961-CVE-2022-4806.patch create mode 100644 gdb-rhbz2233965-memory-leak.patch create mode 100644 import-fedora.sh diff --git a/gdb-bz2237392-dwarf-obstack-allocation.patch b/gdb-bz2237392-dwarf-obstack-allocation.patch new file mode 100644 index 0000000..8d706d3 --- /dev/null +++ b/gdb-bz2237392-dwarf-obstack-allocation.patch @@ -0,0 +1,68 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Andrew Burgess <aburgess@redhat.com> +Date: Thu, 14 Sep 2023 13:06:26 +0100 +Subject: gdb-bz2237392-dwarf-obstack-allocation.patch + +;; Backport upstream commit 54392c4df604f20 to fix an incorrect +;; obstack allocation that wold lead to memory corruption. + +gdb: fix buffer overflow in DWARF reader + +In this commit: + + commit 48ac197b0c209ccf1f2de9704eb6cdf7c5c73a8e + Date: Fri Nov 19 10:12:44 2021 -0700 + + Handle multiple addresses in call_site_target + +a buffer overflow bug was introduced when the following code was +added: + + CORE_ADDR *saved = XOBNEWVAR (&objfile->objfile_obstack, CORE_ADDR, + addresses.size ()); + std::copy (addresses.begin (), addresses.end (), saved); + +The definition of XOBNEWVAR is (from libiberty.h): + + #define XOBNEWVAR(O, T, S) ((T *) obstack_alloc ((O), (S))) + +So 'saved' is going to point to addresses.size () bytes of memory, +however, the std::copy will write addresses.size () number of +CORE_ADDR sized entries to the address pointed to by 'saved', this is +going to result in memory corruption. + +The mistake is that we should have used XOBNEWVEC, which allocates a +vector of entries, the definition of XOBNEWVEC is: + + #define XOBNEWVEC(O, T, N) \ + ((T *) obstack_alloc ((O), sizeof (T) * (N))) + +Which means we will have set aside enough space to create a copy of +the contents of the addresses vector. + +I'm not sure how to create a test for this problem, this issue cropped +up when debugging a particular i686 built binary, which just happened +to trigger a glibc assertion (likely due to random memory corruption), +debugging the same binary built for x86-64 appeared to work just fine. + +Using valgrind on the failing GDB binary pointed straight to the cause +of the problem, and with this patch in place there are no longer +valgrind errors in this area. + +If anyone has ideas for a test I'm happy to work on something. + +Co-Authored-By: Keith Seitz <keiths@redhat.com> +Approved-By: Tom Tromey <tom@tromey.com> + +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -12506,7 +12506,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) + std::vector<CORE_ADDR> addresses; + dwarf2_ranges_read_low_addrs (ranges_offset, target_cu, + target_die->tag, addresses); +- CORE_ADDR *saved = XOBNEWVAR (&objfile->objfile_obstack, CORE_ADDR, ++ CORE_ADDR *saved = XOBNEWVEC (&objfile->objfile_obstack, CORE_ADDR, + addresses.size ()); + std::copy (addresses.begin (), addresses.end (), saved); + call_site->target.set_loc_array (addresses.size (), saved); diff --git a/gdb-bz2237515-debuginfod-double-free.patch b/gdb-bz2237515-debuginfod-double-free.patch new file mode 100644 index 0000000..d6b509e --- /dev/null +++ b/gdb-bz2237515-debuginfod-double-free.patch @@ -0,0 +1,102 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Tom Tromey <tromey@adacore.com> +Date: Tue, 6 Dec 2022 12:07:12 -0700 +Subject: gdb-bz2237515-debuginfod-double-free.patch + +;; Backport upstream commit f96328accde1e63 to fix a potential double +;; free issue in the debuginfod code. + +Avoid double-free with debuginfod + +PR gdb/29257 points out a possible double free when debuginfod is in +use. Aside from some ugly warts in the symbol code (an ongoing +issue), the underlying issue in this particular case is that elfread.c +seems to assume that symfile_bfd_open will return NULL on error, +whereas in reality it throws an exception. As this code isn't +prepared for an exception, bad things result. + +This patch fixes the problem by introducing a non-throwing variant of +symfile_bfd_open and using it in the affected places. + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29257 + +diff --git a/gdb/elfread.c b/gdb/elfread.c +--- a/gdb/elfread.c ++++ b/gdb/elfread.c +@@ -1222,10 +1222,12 @@ elf_symfile_read_dwarf2 (struct objfile *objfile, + + if (!debugfile.empty ()) + { +- gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ())); ++ gdb_bfd_ref_ptr debug_bfd ++ (symfile_bfd_open_no_error (debugfile.c_str ())); + +- symbol_file_add_separate (debug_bfd, debugfile.c_str (), +- symfile_flags, objfile); ++ if (debug_bfd != nullptr) ++ symbol_file_add_separate (debug_bfd, debugfile.c_str (), ++ symfile_flags, objfile); + } + else + { +@@ -1245,13 +1247,12 @@ elf_symfile_read_dwarf2 (struct objfile *objfile, + if (fd.get () >= 0) + { + /* File successfully retrieved from server. */ +- gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (symfile_path.get ())); ++ gdb_bfd_ref_ptr debug_bfd ++ (symfile_bfd_open_no_error (symfile_path.get ())); + +- if (debug_bfd == nullptr) +- warning (_("File \"%s\" from debuginfod cannot be opened as bfd"), +- filename); +- else if (build_id_verify (debug_bfd.get (), build_id->size, +- build_id->data)) ++ if (debug_bfd != nullptr ++ && build_id_verify (debug_bfd.get (), build_id->size, ++ build_id->data)) + { + symbol_file_add_separate (debug_bfd, symfile_path.get (), + symfile_flags, objfile); +diff --git a/gdb/symfile.c b/gdb/symfile.c +--- a/gdb/symfile.c ++++ b/gdb/symfile.c +@@ -1744,6 +1744,23 @@ symfile_bfd_open (const char *name) + return sym_bfd; + } + ++/* See symfile.h. */ ++ ++gdb_bfd_ref_ptr ++symfile_bfd_open_no_error (const char *name) noexcept ++{ ++ try ++ { ++ return symfile_bfd_open (name); ++ } ++ catch (const gdb_exception_error &err) ++ { ++ warning ("%s", err.what ()); ++ } ++ ++ return nullptr; ++} ++ + /* Return the section index for SECTION_NAME on OBJFILE. Return -1 if + the section was not found. */ + +diff --git a/gdb/symfile.h b/gdb/symfile.h +--- a/gdb/symfile.h ++++ b/gdb/symfile.h +@@ -269,6 +269,11 @@ extern void set_initial_language (void); + + extern gdb_bfd_ref_ptr symfile_bfd_open (const char *); + ++/* Like symfile_bfd_open, but will not throw an exception on error. ++ Instead, it issues a warning and returns nullptr. */ ++ ++extern gdb_bfd_ref_ptr symfile_bfd_open_no_error (const char *) noexcept; ++ + extern int get_section_index (struct objfile *, const char *); + + extern int print_symbol_loading_p (int from_tty, int mainline, int full); diff --git a/gdb-rhbz2160211-excessive-core-file-warnings.patch b/gdb-rhbz2160211-excessive-core-file-warnings.patch new file mode 100644 index 0000000..2491123 --- /dev/null +++ b/gdb-rhbz2160211-excessive-core-file-warnings.patch @@ -0,0 +1,108 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Kevin Buettner <kevinb@redhat.com> +Date: Thu, 29 Jun 2023 18:20:30 -0700 +Subject: gdb-rhbz2160211-excessive-core-file-warnings.patch + +;; Backport two commits, 0ad504dd464 and ea70f941f9b, from Lancelot SIX +;; which prevent repeated warnings from being printed while loading a +;; core file. (RH BZ 2160211) + +gdb/corelow.c: avoid repeated warnings in build_file_mappings + +When GDB opens a coredump it tries to locate and then open all files +which were mapped in the process. + +If a file is found but cannot be opened with BFD (bfd_open / +bfd_check_format fails), then a warning is printed to the user. If the +same file was mapped multiple times in the process's address space, the +warning is printed once for each time the file was mapped. I find this +un-necessarily noisy. + +This patch makes it so the warning message is printed only once per +file. + +There was a comment in the code assuming that if the file was found on +the system, opening it (bfd_open + bfd_check_format) should always +succeed. A recent change in BFD (014a602b86f "Don't optimise bfd_seek +to same position") showed that this assumption is not valid. For +example, it is possible to have a core dump of a process which had +mmaped an IO page from a DRI render node (/dev/dri/runderD$NUM). In +such case the core dump does contain the information that portions of +this special file were mapped in the host process, but trying to seek to +position 0 will fail, making bfd_check_format fail. This patch removes +this comment. + +Reviewed-By: John Baldwin <jhb@FreeBSD.org> +Approved-By: Andrew Burgess <aburgess@redhat.com> + +gdb/corelow.c: do not try to reopen a file if open failed once + +In the current implementation, core_target::build_file_mappings will try +to locate and open files which were mapped in the process for which the +core dump was produced. If the file cannot be found or cannot be +opened, GDB will re-try to open it once for each time it was mapped in +the process's address space. + +This patch makes it so GDB recognizes that it has already failed to open +a given file once and does not re-try the process for each mapping. + +Reviewed-By: John Baldwin <jhb@FreeBSD.org> +Approved-By: Andrew Burgess <aburgess@redhat.com> + +diff --git a/gdb/corelow.c b/gdb/corelow.c +--- a/gdb/corelow.c ++++ b/gdb/corelow.c +@@ -237,6 +237,16 @@ core_target::build_file_mappings () + weed out non-file-backed mappings. */ + gdb_assert (filename != nullptr); + ++ if (unavailable_paths.find (filename) != unavailable_paths.end ()) ++ { ++ /* We have already seen some mapping for FILENAME but failed to ++ find/open the file. There is no point in trying the same ++ thing again so just record that the range [start, end) is ++ unavailable. */ ++ m_core_unavailable_mappings.emplace_back (start, end - start); ++ return; ++ } ++ + struct bfd *bfd = bfd_map[filename]; + if (bfd == nullptr) + { +@@ -254,11 +264,10 @@ core_target::build_file_mappings () + if (expanded_fname == nullptr) + { + m_core_unavailable_mappings.emplace_back (start, end - start); +- /* Print just one warning per path. */ +- if (unavailable_paths.insert (filename).second) +- warning (_("Can't open file %s during file-backed mapping " +- "note processing"), +- filename); ++ unavailable_paths.insert (filename); ++ warning (_("Can't open file %s during file-backed mapping " ++ "note processing"), ++ filename); + return; + } + +@@ -268,18 +277,11 @@ core_target::build_file_mappings () + if (bfd == nullptr || !bfd_check_format (bfd, bfd_object)) + { + m_core_unavailable_mappings.emplace_back (start, end - start); +- /* If we get here, there's a good chance that it's due to +- an internal error. We issue a warning instead of an +- internal error because of the possibility that the +- file was removed in between checking for its +- existence during the expansion in exec_file_find() +- and the calls to bfd_openr() / bfd_check_format(). +- Output both the path from the core file note along +- with its expansion to make debugging this problem +- easier. */ ++ unavailable_paths.insert (filename); + warning (_("Can't open file %s which was expanded to %s " + "during file-backed mapping note processing"), + filename, expanded_fname.get ()); ++ + if (bfd != nullptr) + bfd_close (bfd); + return; diff --git a/pass-const-frame_info_ptr-reference-for-skip_-langua.patch b/gdb-rhbz2192105-ftbs-dangling-pointer similarity index 87% rename from pass-const-frame_info_ptr-reference-for-skip_-langua.patch rename to gdb-rhbz2192105-ftbs-dangling-pointer index 4e3ec5d..fe5e73a 100644 --- a/pass-const-frame_info_ptr-reference-for-skip_-langua.patch +++ b/gdb-rhbz2192105-ftbs-dangling-pointer @@ -1,12 +1,16 @@ -From 406fd9f71067fce649343dfd609ca8e5e97b2164 Mon Sep 17 00:00:00 2001 -From: Mark Wielaard <mark@klomp.org> -Date: Tue, 2 May 2023 20:23:32 +0200 -Subject: [PATCH] Pass const frame_info_ptr reference for - skip_[language_]trampoline +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Kevin Buettner <kevinb@redhat.com> +Date: Wed, 3 May 2023 11:28:24 -0700 +Subject: gdb-rhbz2192105-ftbs-dangling-pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit +;; Backport upstream patch fixing a "dangling pointer" build problem +;; first seen when building with GCC 13.1.1 20230426 (Red Hat ;; 13.1.1-1). + +Pass const frame_info_ptr reference for skip_[language_]trampoline + g++ 13.1.1 produces a -Werror=dangling-pointer= In file included from ../../binutils-gdb/gdb/frame.h:75, @@ -43,15 +47,8 @@ Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30413 Tested-by: Kevin Buettner <kevinb@redhat.com> Reviewed-by: Kevin Buettner <kevinb@redhat.com> Reviewed-by: Tom Tromey <tom@tromey.com> ---- - gdb/c-lang.c | 2 +- - gdb/language.c | 2 +- - gdb/language.h | 4 ++-- - gdb/objc-lang.c | 2 +- - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gdb/c-lang.c b/gdb/c-lang.c -index 52010fa8cb1..a46343c837a 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -1003,7 +1003,7 @@ class cplus_language : public language_defn @@ -64,7 +61,6 @@ index 52010fa8cb1..a46343c837a 100644 { return cplus_skip_trampoline (fi, pc); diff --git a/gdb/language.c b/gdb/language.c -index 5037867b256..655d0794394 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -528,7 +528,7 @@ add_set_language_command () @@ -77,7 +73,6 @@ index 5037867b256..655d0794394 100644 for (const auto &lang : language_defn::languages) { diff --git a/gdb/language.h b/gdb/language.h -index cf94923ecc1..88c3bc90efe 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -471,7 +471,7 @@ struct language_defn @@ -99,7 +94,6 @@ index cf94923ecc1..88c3bc90efe 100644 /* Return demangled language symbol, or NULL. */ extern gdb::unique_xmalloc_ptr<char> language_demangle diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c -index e17a4c406c0..5bcf1e4f3f0 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -282,7 +282,7 @@ class objc_language : public language_defn @@ -111,8 +105,3 @@ index e17a4c406c0..5bcf1e4f3f0 100644 CORE_ADDR stop_pc) const override { struct gdbarch *gdbarch = get_frame_arch (frame); - -base-commit: 4b9342bc7f1d79b1453afd6c15e1a5cdefa92d9e --- -2.35.3 - diff --git a/gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch b/gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch new file mode 100644 index 0000000..a820aa0 --- /dev/null +++ b/gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch @@ -0,0 +1,188 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Andrew Burgess <aburgess@redhat.com> +Date: Tue, 20 Jun 2023 09:46:35 +0100 +Subject: gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch + +;; Backport upstream commit f3eee5861743d635 to fix a crash triggered +;; when debuginfod makes use of particular openssl settings. + +gdb/debuginfod: cleanup debuginfod earlier + +A GDB crash was discovered on Fedora GDB that was tracked back to an +issue with the way that debuginfod is cleaned up. + +The bug was reported on Fedora 37, 38, and 39. Here are the steps to +reproduce: + +1. The file /etc/ssl/openssl.cnf contains the following lines: + + [provider_sect] + default = default_sect + ##legacy = legacy_sect + ## + [default_sect] + activate = 1 + + ##[legacy_sect] + ##activate = 1 + + The bug will occur when the '##' characters are removed so that the + lines in question look like this: + + [provider_sect] + default = default_sect + legacy = legacy_sect + + [default_sect] + activate = 1 + + [legacy_sect] + activate = 1 + +2. Clean up any existing debuginfod cache data: + + > rm -rf $HOME/.cache/debuginfod_client + +3. Run GDB: + + > gdb -nx -q -iex 'set trace-commands on' \ + -iex 'set debuginfod enabled on' \ + -iex 'set confirm off' \ + -ex 'start' -ex 'quit' /bin/ls + +set debuginfod enabled on + +set confirm off + Reading symbols from /bin/ls... + Downloading separate debug info for /usr/bin/ls + ... snip ... + Temporary breakpoint 1, main (argc=1, argv=0x7fffffffde38) at ../src/ls.c:1646 + 1646 { + +quit + + Fatal signal: Segmentation fault + ----- Backtrace ----- + ... snip ... + +So GDB ends up crashing during exit. + +What's happening is that when debuginfod is initialised +debuginfod_begin is called (this is in the debuginfod library), this +in turn sets up libcurl, which makes use of openssl. Somewhere during +this setup process an at_exit function is registered to cleanup some +state. + +Back in GDB the debuginfod_client object is managed using this code: + + /* Deleter for a debuginfod_client. */ + + struct debuginfod_client_deleter + { + void operator() (debuginfod_client *c) + { + debuginfod_end (c); + } + }; + + using debuginfod_client_up + = std::unique_ptr<debuginfod_client, debuginfod_client_deleter>; + +And then a global debuginfod_client_up is created to hold a pointer to +the debuginfod_client object. As a global this will be cleaned up +using the standard C++ global object destructor mechanism, which is +run after the at_exit handlers. + +However, it is expected that when debuginfod_end is called the +debuginfod_client object will still be in a usable state, that is, we +don't expect the at_exit handlers to have run and started cleaning up +the library state. + +To fix this issue we need to ensure that debuginfod_end is called +before the at_exit handlers have a chance to run. + +This commit removes the debuginfod_client_up type, and instead has GDB +hold a raw pointer to the debuginfod_client object. We then make use +of GDB's make_final_cleanup to register a function that will call +debuginfod_end. + +As GDB's final cleanups are called before exit is called, this means +that debuginfod_end will be called before the at_exit handlers are +called, and the crash identified above is resolved. + +It's not obvious how this issue can easily be tested for. The bug does +not appear to manifest when using a local debuginfod server, so we'd +need to setup something more involved. For now I'm proposing this +patch without any associated tests. + +diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c +--- a/gdb/debuginfod-support.c ++++ b/gdb/debuginfod-support.c +@@ -96,20 +96,6 @@ struct user_data + ui_out::progress_update progress; + }; + +-/* Deleter for a debuginfod_client. */ +- +-struct debuginfod_client_deleter +-{ +- void operator() (debuginfod_client *c) +- { +- debuginfod_end (c); +- } +-}; +- +-using debuginfod_client_up +- = std::unique_ptr<debuginfod_client, debuginfod_client_deleter>; +- +- + /* Convert SIZE into a unit suitable for use with progress updates. + SIZE should in given in bytes and will be converted into KB, MB, GB + or remain unchanged. UNIT will be set to "B", "KB", "MB" or "GB" +@@ -180,20 +166,45 @@ progressfn (debuginfod_client *c, long cur, long total) + return 0; + } + ++/* Cleanup ARG, which is a debuginfod_client pointer. */ ++ ++static void ++cleanup_debuginfod_client (void *arg) ++{ ++ debuginfod_client *client = static_cast<debuginfod_client *> (arg); ++ debuginfod_end (client); ++} ++ ++/* Return a pointer to the single global debuginfod_client, initialising it ++ first if needed. */ ++ + static debuginfod_client * + get_debuginfod_client () + { +- static debuginfod_client_up global_client; ++ static debuginfod_client *global_client = nullptr; + + if (global_client == nullptr) + { +- global_client.reset (debuginfod_begin ()); ++ global_client = debuginfod_begin (); + + if (global_client != nullptr) +- debuginfod_set_progressfn (global_client.get (), progressfn); ++ { ++ /* It is important that we cleanup the debuginfod_client object ++ before calling exit. Some of the libraries used by debuginfod ++ make use of at_exit handlers to perform cleanup. ++ ++ If we wrapped the debuginfod_client in a unique_ptr and relied ++ on its destructor to cleanup then this would be run as part of ++ the global C++ object destructors, which is after the at_exit ++ handlers, which is too late. ++ ++ So instead, we make use of GDB's final cleanup mechanism. */ ++ make_final_cleanup (cleanup_debuginfod_client, global_client); ++ debuginfod_set_progressfn (global_client, progressfn); ++ } + } + +- return global_client.get (); ++ return global_client; + } + + /* Check if debuginfod is enabled. If configured to do so, ask the user diff --git a/gdb-rhbz2233961-CVE-2022-4806.patch b/gdb-rhbz2233961-CVE-2022-4806.patch new file mode 100644 index 0000000..567ea40 --- /dev/null +++ b/gdb-rhbz2233961-CVE-2022-4806.patch @@ -0,0 +1,50 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com> +Date: Thu, 21 Sep 2023 18:52:49 +0200 +Subject: gdb-rhbz2233961-CVE-2022-4806.patch + +;; Backport PR29922, SHT_NOBITS section +;; avoids section size sanity check. + +PR29922, SHT_NOBITS section avoids section size sanity check + +PR 29922 +* dwarf2.c (find_debug_info): Ignore sections without +SEC_HAS_CONTENTS. + +diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c +--- a/bfd/dwarf2.c ++++ b/bfd/dwarf2.c +@@ -4831,16 +4831,19 @@ find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections, + { + look = debug_sections[debug_info].uncompressed_name; + msec = bfd_get_section_by_name (abfd, look); +- if (msec != NULL) ++ /* Testing SEC_HAS_CONTENTS is an anti-fuzzer measure. Of ++ course debug sections always have contents. */ ++ if (msec != NULL && (msec->flags & SEC_HAS_CONTENTS) != 0) + return msec; + + look = debug_sections[debug_info].compressed_name; + msec = bfd_get_section_by_name (abfd, look); +- if (msec != NULL) ++ if (msec != NULL && (msec->flags & SEC_HAS_CONTENTS) != 0) + return msec; + + for (msec = abfd->sections; msec != NULL; msec = msec->next) +- if (startswith (msec->name, GNU_LINKONCE_INFO)) ++ if ((msec->flags & SEC_HAS_CONTENTS) != 0 ++ && startswith (msec->name, GNU_LINKONCE_INFO)) + return msec; + + return NULL; +@@ -4848,6 +4851,9 @@ find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections, + + for (msec = after_sec->next; msec != NULL; msec = msec->next) + { ++ if ((msec->flags & SEC_HAS_CONTENTS) == 0) ++ continue; ++ + look = debug_sections[debug_info].uncompressed_name; + if (strcmp (msec->name, look) == 0) + return msec; diff --git a/gdb-rhbz2233965-memory-leak.patch b/gdb-rhbz2233965-memory-leak.patch new file mode 100644 index 0000000..dce7f7f --- /dev/null +++ b/gdb-rhbz2233965-memory-leak.patch @@ -0,0 +1,115 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com> +Date: Sat, 14 Oct 2023 12:37:50 +0200 +Subject: gdb-rhbz2233965-memory-leak.patch + +;; Backport PR29925, Memory leak in find_abstract_instance + +PR29925, Memory leak in find_abstract_instance + +The testcase in the PR had a variable with both DW_AT_decl_file and +DW_AT_specification, where the DW_AT_specification also specified +DW_AT_decl_file. This leads to a memory leak as the file name is +malloced and duplicates are not expected. + +I've also changed find_abstract_instance to not use a temp for "name", +because that can result in a change in behaviour from the usual last +of duplicate attributes wins. + + PR 29925 + * dwarf2.c (find_abstract_instance): Delete "name" variable. + Free *filename_ptr before assigning new file name. + (scan_unit_for_symbols): Similarly free func->file and + var->file before assigning. + +diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c +--- a/bfd/dwarf2.c ++++ b/bfd/dwarf2.c +@@ -3441,7 +3441,6 @@ find_abstract_instance (struct comp_unit *unit, + struct abbrev_info *abbrev; + uint64_t die_ref = attr_ptr->u.val; + struct attribute attr; +- const char *name = NULL; + + if (recur_count == 100) + { +@@ -3602,9 +3601,9 @@ find_abstract_instance (struct comp_unit *unit, + case DW_AT_name: + /* Prefer DW_AT_MIPS_linkage_name or DW_AT_linkage_name + over DW_AT_name. */ +- if (name == NULL && is_str_form (&attr)) ++ if (*pname == NULL && is_str_form (&attr)) + { +- name = attr.u.str; ++ *pname = attr.u.str; + if (mangle_style (unit->lang) == 0) + *is_linkage = true; + } +@@ -3612,7 +3611,7 @@ find_abstract_instance (struct comp_unit *unit, + case DW_AT_specification: + if (is_int_form (&attr) + && !find_abstract_instance (unit, &attr, recur_count + 1, +- &name, is_linkage, ++ pname, is_linkage, + filename_ptr, linenumber_ptr)) + return false; + break; +@@ -3622,7 +3621,7 @@ find_abstract_instance (struct comp_unit *unit, + non-string forms into these attributes. */ + if (is_str_form (&attr)) + { +- name = attr.u.str; ++ *pname = attr.u.str; + *is_linkage = true; + } + break; +@@ -3630,8 +3629,11 @@ find_abstract_instance (struct comp_unit *unit, + if (!comp_unit_maybe_decode_line_info (unit)) + return false; + if (is_int_form (&attr)) +- *filename_ptr = concat_filename (unit->line_table, +- attr.u.val); ++ { ++ free (*filename_ptr); ++ *filename_ptr = concat_filename (unit->line_table, ++ attr.u.val); ++ } + break; + case DW_AT_decl_line: + if (is_int_form (&attr)) +@@ -3643,7 +3645,6 @@ find_abstract_instance (struct comp_unit *unit, + } + } + } +- *pname = name; + return true; + } + +@@ -4139,8 +4140,11 @@ scan_unit_for_symbols (struct comp_unit *unit) + + case DW_AT_decl_file: + if (is_int_form (&attr)) +- func->file = concat_filename (unit->line_table, +- attr.u.val); ++ { ++ free (func->file); ++ func->file = concat_filename (unit->line_table, ++ attr.u.val); ++ } + break; + + case DW_AT_decl_line: +@@ -4182,8 +4186,11 @@ scan_unit_for_symbols (struct comp_unit *unit) + + case DW_AT_decl_file: + if (is_int_form (&attr)) +- var->file = concat_filename (unit->line_table, +- attr.u.val); ++ { ++ free (var->file); ++ var->file = concat_filename (unit->line_table, ++ attr.u.val); ++ } + break; + + case DW_AT_decl_line: diff --git a/gdb.changes b/gdb.changes index 3e8dd74..7945443 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,26 @@ +------------------------------------------------------------------- +Fri Oct 20 10:43:32 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Maintenance script import-fedora.sh: + * New script. Move skipped patches list from gdb.spec to script. +- Update to fedora 38 @ 82cc8e0. +- Patch renamed: + * pass-const-frame_info_ptr-reference-for-skip_-langua.patch -> + gdb-rhbz2192105-ftbs-dangling-pointer +- Patches added: + * gdb-bz2237392-dwarf-obstack-allocation.patch + * gdb-bz2237515-debuginfod-double-free.patch + * gdb-rhbz2160211-excessive-core-file-warnings.patch + * gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch + * gdb-rhbz2233961-CVE-2022-4806.patch + * gdb-rhbz2233965-memory-leak.patch +- Maintenance script qa-local.sh: + * Add openSUSE_Leap_15.5 and openSUSE_Factory_LegacyX86. + * Add "List configs" item. + * Skip i586 for SLE-11. +- Maintenance script qa.sh: + * Make sure exit status is 0 + ------------------------------------------------------------------- Wed Sep 27 09:22:47 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/gdb.spec b/gdb.spec index d7dc296..7367dfe 100644 --- a/gdb.spec +++ b/gdb.spec @@ -165,7 +165,7 @@ NoSource: 18 NoSource: 19 %endif -# Fedora import from branch f38, commit fc4e284. +# Fedora import from branch f38, commit 82cc8e0. #Fedora Packages begin Patch2: gdb-6.3-gstack-20050411.patch @@ -214,37 +214,16 @@ Patch54: gdb-opcodes-clflushopt-test.patch Patch55: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch Patch57: gdb-linux_perf-bundle.patch Patch59: gdb-rhbz1553104-s390x-arch12-test.patch -Patch62: gdb-binutils29988-read_indexed_address.patch +Patch60: gdb-binutils29988-read_indexed_address.patch +Patch61: gdb-rhbz2192105-ftbs-dangling-pointer +Patch62: gdb-rhbz2160211-excessive-core-file-warnings.patch +Patch63: gdb-rhbz2196395-debuginfod-legacy-openssl-crash.patch +Patch64: gdb-bz2237515-debuginfod-double-free.patch +Patch65: gdb-bz2237392-dwarf-obstack-allocation.patch +Patch66: gdb-rhbz2233961-CVE-2022-4806.patch +Patch67: gdb-rhbz2233965-memory-leak.patch #Fedora Packages end -# Fedora Packages not copied: -# -# Not applicable for openSUSE: -# - gdb-libexec-add-index.patch -# - gdb-6.3-rh-testversion-20041202.patch -# - gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch -# - gdb-6.8-bz466901-backtrace-full-prelinked.patch -# - gdb-container-rh-pkg.patch -# -# Broken: -# - gdb-6.5-BEA-testsuite.patch -# over-specific test-case in a shell script -# - gdb-6.5-readline-long-line-crash-test.patch -# Hangs for horizontal-scroll-mode on, times out after 10 minutes. -# - gdb-rhbz1156192-recursive-dlopen-test.patch -# Fragile test-case, requires glibc to fail in a certain way. -# -# Obsolete: -# - gdb-6.7-charsign-test.patch (dropped by fedora) -# - gdb-6.7-ppc-clobbered-registers-O2-test.patch -# - gdb-test-ivy-bridge.patch (dropped by fedora) -# - gdb-ppc-power7-test.patch (dropped by fedora) -# - gdb-6.3-bz140532-ppc-unwinding-test.patch (dropped by fedora) -# -# Dropped: -# - gdb-rhbz2177655-aarch64-pauth-valid-regcache.patch (included in 13.2) -# - gdb-rhbz2183595-rustc-inside_main.patch (included in 13.2) - # Fedora patches fixup # These need a number with at least four digits, otherwise patchlist.pl removes # them when upgrading. @@ -335,7 +314,6 @@ Patch2093: powerpc-fix-for-gdb.reverse-finish-precsave.exp-and-.patch Patch2094: powerpc-regression-fix-for-reverse-finish-command.patch Patch2095: gdb-testsuite-don-t-use-string-cat-in-gdb.dwarf2-dw2.patch Patch2096: move-step_until-procedure.patch -Patch2097: pass-const-frame_info_ptr-reference-for-skip_-langua.patch # Backports from master, not yet available in next release. @@ -696,7 +674,14 @@ find -name "*.info*"|xargs rm -f %patch55 -p1 %patch57 -p1 %patch59 -p1 +%patch60 -p1 +%patch61 -p1 %patch62 -p1 +%patch63 -p1 +%patch64 -p1 +%patch65 -p1 +%patch66 -p1 +%patch67 -p1 #Fedora patching end %patch1000 -p1 @@ -754,7 +739,6 @@ find -name "*.info*"|xargs rm -f %patch2094 -p1 %patch2095 -p1 %patch2096 -p1 -%patch2097 -p1 %patch2100 -p1 %patch2101 -p1 diff --git a/import-fedora.sh b/import-fedora.sh new file mode 100644 index 0000000..1f37ebf --- /dev/null +++ b/import-fedora.sh @@ -0,0 +1,155 @@ +#!/bin/bash + +# Fedora Packages not copied: +# +skip_patches=( + # Not applicable for openSUSE. + gdb-add-index.patch + gdb-6.3-rh-testversion-20041202.patch + gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch + gdb-6.8-bz466901-backtrace-full-prelinked.patch + gdb-container-rh-pkg.patch + + # Broken. + # Over-specific test-case in a shell script. + gdb-6.5-BEA-testsuite.patch + # Hangs for horizontal-scroll-mode on, times out after 10 minutes. + gdb-6.5-readline-long-line-crash-test.patch + + # Fragile test-case, requires glibc to fail in a certain way. + gdb-rhbz1156192-recursive-dlopen-test.patch + + # Obsolete (dropped by fedora). + gdb-6.7-charsign-test.patch + gdb-test-ivy-bridge.patch + gdb-ppc-power7-test.patch + gdb-6.3-bz140532-ppc-unwinding-test.patch + + # Obsolete. + gdb-6.7-charsign-test.patch + gdb-6.7-ppc-clobbered-registers-O2-test.patch +) + +usage () +{ + echo "usage: $(basename "$0") <fedora package dir> " +} + +dir="$1" + +if [ ! -f "$dir"/_patch_order ]; then + usage + exit 1 +fi + +mark1="^#Fedora Packages begin" +mark2="^#Fedora Packages end" +mark3="^#Fedora patching start" +mark4="^#Fedora patching end" + +remove_current_patches () +{ + # shellcheck disable=SC2207 + current_patches=($(awk "/$mark1/,/$mark2/{ print }" gdb.spec \ + | grep Patch \ + | awk '{print $2}')) + + for current_patch in "${current_patches[@]}"; do + rm -f "$current_patch" + done +} + +skip () +{ + local p + p="$1" + + for skip_patch in "${skip_patches[@]}"; do + if [ "$p" = "$skip_patch" ]; then + return 0 + fi + done + + return 1 +} + +import_patches () +{ + # Get the parts of gdb.spec that we want to keep unchanged. + awk "NR==1,/$mark1/" gdb.spec \ + > gdb.spec.1 + awk "/$mark2/,/$mark3/" gdb.spec \ + > gdb.spec.3 + awk "/$mark4/,0" gdb.spec \ + > gdb.spec.5 + + # Start generating the parts of gdb.spec that we want to change. + f1=gdb.spec.2 + f2=gdb.spec.4 + rm -f $f1 $f2 + + # Handle each fedora patch. + skipped_patches=() + n=1 + # shellcheck disable=SC2013 + for p in $(cat "$dir"/_patch_order); do + if skip "$p"; then + echo "Skipped: $p" + skipped_patches=("${skipped_patches[@]}" "$p") + + # Keep numbers the same as in fedora package. + n=$((n + 1)) + continue + fi + + cp "$dir"/"$p" . + + printf \ + "%-16s%s\n" "Patch$n:" "$p" \ + >> $f1 + + echo \ + "%patch$n -p1" \ + >> $f2 + + n=$((n + 1)) + done + + # Report which patches did not get skipped. + for skip_patch in "${skip_patches[@]}"; do + found=false + for skipped_patch in "${skipped_patches[@]}"; do + if [ "$skip_patch" = "$skipped_patch" ]; then + found=true + break + fi + done + if ! $found; then + echo "Not skipped: $skip_patch" + fi + done + + # Assemble new gdb.spec. + rm -f gdb.spec.new + for n in $(seq 1 5); do + cat gdb.spec."$n" \ + >> gdb.spec.new + done + + # Cleanup. + for n in $(seq 1 5); do + rm -f gdb.spec."$n" + done + + # Update gdb.spec. + mv gdb.spec.new gdb.spec +} + +main () +{ + remove_current_patches + + import_patches +} + +main "$@" diff --git a/qa-local.sh b/qa-local.sh index 2723b07..010bd56 100644 --- a/qa-local.sh +++ b/qa-local.sh @@ -9,23 +9,28 @@ logs=$root/logs pkgs=$root/pkgs configs=" +openSUSE_Leap_15.5 openSUSE_Leap_15.4 openSUSE_Leap_15.3 openSUSE_Factory +openSUSE_Factory_LegacyX86 SLE-15 SLE-12 SLE-11 " +archs="x86_64 i586" + version=13.2 usage () { echo "usage: $0 <1-4>" echo "1: Cleanup" - echo "2: Do local builds without testsuite" - echo "3: Do local builds with testsuite" - echo "4: Verify local testsuite results" + echo "2: List configs" + echo "3: Do local builds without testsuite" + echo "4: Do local builds with testsuite" + echo "5: Verify local testsuite results" } if [ $# -eq 0 ]; then @@ -71,16 +76,28 @@ acquire_sudo_rights () done & } -archs="x86_64 i586" - have_combo () { arch="$1" c="$2" if [ "$arch" = "i586" ]; then - case $c in - SLE-12|SLE-15) + case " $c " in + " openSUSE_Factory ") + # Doesn't have i586. + return 1 + ;; + " SLE-11 "|" SLE-12 "|" SLE-15 ") + # SLE-12 and SLE-15 don't have i586. SLE-11 does, but + # we ignore that for now. + return 1 + ;; + esac + fi + if [ "$arch" = "x86_64" ]; then + case " $c " in + " openSUSE_Factory_LegacyX86 ") + # Doesn't have x86_64. return 1 ;; esac @@ -94,6 +111,17 @@ case "$n" in ;; 2) + for arch in $archs; do + for c in $configs; do + if ! have_combo $arch $c; then + continue + fi + echo "$c $arch" + done + done + ;; + + 3) acquire_sudo_rights rm -Rf $logs/$n @@ -127,7 +155,7 @@ case "$n" in done ;; - 3) + 4) acquire_sudo_rights rm -Rf $logs/$n @@ -186,7 +214,7 @@ case "$n" in done ;; - 4) + 5) for arch in $archs; do for c in $configs; do if ! have_combo $arch $c; then @@ -194,7 +222,7 @@ case "$n" in fi echo "CONFIG: $c $arch" case $c in - openSUSE_Factory) + openSUSE_Factory|openSUSE_Factory_LegacyX86) bash qa.sh -local -$arch -factory $pkgs/gdb-testresults.$c.$arch ;; SLE-12) diff --git a/qa.sh b/qa.sh index 112906f..0296fc4 100644 --- a/qa.sh +++ b/qa.sh @@ -1040,3 +1040,5 @@ case $n in exit 1 ;; esac + +true From 66a858c773d2561d0ab2391980bfc7bf9886705732d9b52aea840ef501d7113a Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Tue, 24 Oct 2023 12:50:18 +0000 Subject: [PATCH 03/10] - Mention import-fedora.sh to fix warning. - Maintenance script qa.sh: * Update kfail for PR28561. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=364 --- gdb.changes | 7 +++++++ gdb.spec | 2 ++ qa.sh | 1 + 3 files changed, 10 insertions(+) diff --git a/gdb.changes b/gdb.changes index 7945443..b46ec52 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Sat Oct 21 08:05:18 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Mention import-fedora.sh to fix warning. +- Maintenance script qa.sh: + * Update kfail for PR28561. + ------------------------------------------------------------------- Fri Oct 20 10:43:32 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/gdb.spec b/gdb.spec index 7367dfe..b22f2bd 100644 --- a/gdb.spec +++ b/gdb.spec @@ -145,6 +145,7 @@ Source16: qa.sh Source17: qa-local.sh Source18: qa-remote.sh Source19: README.qa +Source20: import-fedora.sh %if %{build_testsuite} NoSource: 0 @@ -163,6 +164,7 @@ NoSource: 16 NoSource: 17 NoSource: 18 NoSource: 19 +NoSource: 20 %endif # Fedora import from branch f38, commit 82cc8e0. diff --git a/qa.sh b/qa.sh index 0296fc4..68c9d85 100644 --- a/qa.sh +++ b/qa.sh @@ -540,6 +540,7 @@ kfail_aarch64=( # We match pretty aggressively here. "FAIL: gdb.mi/.*.exp:" "FAIL: gdb.python/.*-mi.exp:" + "FAIL: gdb.python/py-mi-.*.exp:" ) # kfail_aarch64 From 7cb3ecbb8b270c866f31d927cc3289c7ec9b4a285c61ac142f179b1e67d9c2df Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Thu, 26 Oct 2023 08:58:08 +0000 Subject: [PATCH 04/10] - Patches added (manual import from fedora rawhide @ 52a4dab): * 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 --- ...rhbz1773651-gdb-index-internal-error.patch | 105 ++++++++ gdb-support-rseq-auxvs.patch | 45 ++++ ...main-language-without-symtab-expansi.patch | 202 ++++++++++++++ ...ine-number-of-static-const-class-mem.patch | 84 ++++++ ...oo-many-symbols-in-gdbpy_lookup_stat.patch | 66 +++++ ...ndle-pu-in-iterate_over_some_symtabs.patch | 59 ++++ gdb-symtab-work-around-pr-gas-29517.patch | 255 ++++++++++++++++++ ...testsuite-add-kfail-for-pr-ada-30908.patch | 108 ++++++++ ...d-wait-for-index-cache-in-gdb.dwarf2.patch | 53 ++++ ...d-xfail-for-gdb-29965-in-gdb.threads.patch | 65 +++++ ...x-gdb.ada-mi_task_arg.exp-with-newer.patch | 64 +++++ ...x-gdb.arch-i386-signal.exp-on-x86_64.patch | 91 +++++++ ...x-gdb.cp-m-static.exp-regression-on-.patch | 76 ++++++ ...x-gdb.dwarf2-nullptr_t.exp-with-cc-w.patch | 38 +++ ...x-regexps-in-gdb.base-step-over-sysc.patch | 85 ++++++ gdb.changes | 30 +++ gdb.spec | 154 ++++++----- qa.sh | 51 ++-- 18 files changed, 1534 insertions(+), 97 deletions(-) create mode 100644 gdb-rhbz1773651-gdb-index-internal-error.patch create mode 100644 gdb-support-rseq-auxvs.patch create mode 100644 gdb-symtab-find-main-language-without-symtab-expansi.patch create mode 100644 gdb-symtab-fix-line-number-of-static-const-class-mem.patch create mode 100644 gdb-symtab-fix-too-many-symbols-in-gdbpy_lookup_stat.patch create mode 100644 gdb-symtab-handle-pu-in-iterate_over_some_symtabs.patch create mode 100644 gdb-symtab-work-around-pr-gas-29517.patch create mode 100644 gdb-testsuite-add-kfail-for-pr-ada-30908.patch create mode 100644 gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch create mode 100644 gdb-testsuite-add-xfail-for-gdb-29965-in-gdb.threads.patch create mode 100644 gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-with-newer.patch create mode 100644 gdb-testsuite-fix-gdb.arch-i386-signal.exp-on-x86_64.patch create mode 100644 gdb-testsuite-fix-gdb.cp-m-static.exp-regression-on-.patch create mode 100644 gdb-testsuite-fix-gdb.dwarf2-nullptr_t.exp-with-cc-w.patch create mode 100644 gdb-testsuite-fix-regexps-in-gdb.base-step-over-sysc.patch diff --git a/gdb-rhbz1773651-gdb-index-internal-error.patch b/gdb-rhbz1773651-gdb-index-internal-error.patch new file mode 100644 index 0000000..aae8f08 --- /dev/null +++ b/gdb-rhbz1773651-gdb-index-internal-error.patch @@ -0,0 +1,105 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Kevin Buettner <kevinb@redhat.com> +Date: Mon, 2 Oct 2023 15:05:23 -0700 +Subject: gdb-rhbz1773651-gdb-index-internal-error.patch + +;; Backport upstream patch which prevents internal error when +;; generating a gdb-index file (RH BZ 1773651). + +Throw error when creating an overly large gdb-index file + +The header in a .gdb_index section uses 32-bit unsigned offsets to +refer to other areas of the section. Thus, there is a size limit of +2^32-1 which is currently unaccounted for by GDB's code for outputting +these sections. + +At the moment, when GDB creates an overly large section, it will exit +abnormally due to an internal error, which is caused by a failed +assert in assert_file_size, which in turn is called from +write_gdbindex_1, both of which are in gdb/dwarf2/index-write.c. + +This is what happens when that assert fails: + +$ gdb -q -nx -iex 'set auto-load no' -iex 'set debuginfod enabled off' -ex file ./libgraph_tool_inference.so -ex "save gdb-index `pwd`/" +Reading symbols from ./libgraph_tool_inference.so... +No executable file now. +Discard symbol table from `libgraph_tool_inference.so'? (y or n) n +Not confirmed. +../../gdb/dwarf2/index-write.c:1069: internal-error: assert_file_size: Assertion `file_size == expected_size' failed. +A problem internal to GDB has been detected, +further debugging may prove unreliable. +----- Backtrace ----- +0x55fddb4d78b0 gdb_internal_backtrace_1 + ../../gdb/bt-utils.c:122 +0x55fddb4d78b0 _Z22gdb_internal_backtracev + ../../gdb/bt-utils.c:168 +0x55fddb98b5d4 internal_vproblem + ../../gdb/utils.c:396 +0x55fddb98b8de _Z15internal_verrorPKciS0_P13__va_list_tag + ../../gdb/utils.c:476 +0x55fddbb71654 _Z18internal_error_locPKciS0_z + ../../gdbsupport/errors.cc:58 +0x55fddb5a0f23 assert_file_size + ../../gdb/dwarf2/index-write.c:1069 +0x55fddb5a1ee0 assert_file_size + /usr/include/c++/13/bits/stl_iterator.h:1158 +0x55fddb5a1ee0 write_gdbindex_1 + ../../gdb/dwarf2/index-write.c:1119 +0x55fddb5a51be write_gdbindex + ../../gdb/dwarf2/index-write.c:1273 +[...] +--------------------- +../../gdb/dwarf2/index-write.c:1069: internal-error: assert_file_size: Assertion `file_size == expected_size' failed. + +This problem was encountered while building the python-graph-tool +package on Fedora. The Fedora bugzilla bug can be found here: + +https://bugzilla.redhat.com/show_bug.cgi?id=1773651 + +This commit prevents the internal error from occurring by calling error() +when the file size exceeds 2^32-1. + +Using a gdb built with this commit, I now see this behavior instead: + +$ gdb -q -nx -iex 'set auto-load no' -iex 'set debuginfod enabled off' -ex file ./libgraph_tool_inference.so -ex "save gdb-index `pwd`/" +Reading symbols from ./libgraph_tool_inference.so... +No executable file now. +Discard symbol table from `/mesquite2/fedora-bugs/1773651/libgraph_tool_inference.so'? (y or n) n +Not confirmed. +Error while writing index for `/mesquite2/fedora-bugs/1773651/libgraph_tool_inference.so': gdb-index maximum file size of 4294967295 exceeded +(gdb) + +I wish I could provide a test case, but due to the sizes of both the +input and output files, I think that testing resources would be +strained or exceeded in many environments. + +My testing on Fedora 38 shows no regressions. + +Approved-by: Tom Tromey <tom@tromey.com> + +diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c +--- a/gdb/dwarf2/index-write.c ++++ b/gdb/dwarf2/index-write.c +@@ -1082,7 +1082,7 @@ write_gdbindex_1 (FILE *out_file, + { + data_buf contents; + const offset_type size_of_header = 6 * sizeof (offset_type); +- offset_type total_len = size_of_header; ++ size_t total_len = size_of_header; + + /* The version number. */ + contents.append_offset (8); +@@ -1109,6 +1109,13 @@ write_gdbindex_1 (FILE *out_file, + + gdb_assert (contents.size () == size_of_header); + ++ /* The maximum size of an index file is limited by the maximum value ++ capable of being represented by 'offset_type'. Throw an error if ++ that length has been exceeded. */ ++ size_t max_size = ~(offset_type) 0; ++ if (total_len > max_size) ++ error (_("gdb-index maximum file size of %zu exceeded"), max_size); ++ + contents.file_write (out_file); + cu_list.file_write (out_file); + types_cu_list.file_write (out_file); diff --git a/gdb-support-rseq-auxvs.patch b/gdb-support-rseq-auxvs.patch new file mode 100644 index 0000000..759bb20 --- /dev/null +++ b/gdb-support-rseq-auxvs.patch @@ -0,0 +1,45 @@ +From 1bbcd2144710c4b1daa9c404df0ebc80c3461747 Mon Sep 17 00:00:00 2001 +From: Ilya Leoshkevich <iii@linux.ibm.com> +Date: Thu, 22 Jun 2023 01:03:04 +0200 +Subject: [PATCH 11/12] gdb: support rseq auxvs + +Linux kernel commit commit 317c8194e6ae ("rseq: Introduce feature size +and alignment ELF auxiliary vector entries") introduced two new auxvs: +AT_RSEQ_FEATURE_SIZE and AT_RSEQ_ALIGN. Support them in GDB. This +fixes auxv.exp on kernels >= v6.3. +--- + gdb/auxv.c | 4 ++++ + include/elf/common.h | 2 ++ + 2 files changed, 6 insertions(+) + +diff --git a/gdb/auxv.c b/gdb/auxv.c +index 812b2807554..3ce5ccd3342 100644 +--- a/gdb/auxv.c ++++ b/gdb/auxv.c +@@ -493,6 +493,10 @@ default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, + AUXV_FORMAT_STR); + TAG (AT_RANDOM, _("Address of 16 random bytes"), AUXV_FORMAT_HEX); + TAG (AT_HWCAP2, _("Extension of AT_HWCAP"), AUXV_FORMAT_HEX); ++ TAG (AT_RSEQ_FEATURE_SIZE, _("rseq supported feature size"), ++ AUXV_FORMAT_HEX); ++ TAG (AT_RSEQ_ALIGN, _("rseq allocation alignment"), ++ AUXV_FORMAT_HEX); + TAG (AT_EXECFN, _("File name of executable"), AUXV_FORMAT_STR); + TAG (AT_SECURE, _("Boolean, was exec setuid-like?"), AUXV_FORMAT_DEC); + TAG (AT_SYSINFO, _("Special system info/entry points"), AUXV_FORMAT_HEX); +diff --git a/include/elf/common.h b/include/elf/common.h +index 16587f6fb06..a37b1f9a264 100644 +--- a/include/elf/common.h ++++ b/include/elf/common.h +@@ -1353,6 +1353,8 @@ + may differ from AT_PLATFORM. */ + #define AT_RANDOM 25 /* Address of 16 random bytes. */ + #define AT_HWCAP2 26 /* Extension of AT_HWCAP. */ ++#define AT_RSEQ_FEATURE_SIZE 27 /* rseq supported feature size */ ++#define AT_RSEQ_ALIGN 28 /* rseq allocation alignment */ + #define AT_EXECFN 31 /* Filename of executable. */ + /* Pointer to the global system page used for system calls and other + nice things. */ +-- +2.35.3 + diff --git a/gdb-symtab-find-main-language-without-symtab-expansi.patch b/gdb-symtab-find-main-language-without-symtab-expansi.patch new file mode 100644 index 0000000..6717706 --- /dev/null +++ b/gdb-symtab-find-main-language-without-symtab-expansi.patch @@ -0,0 +1,202 @@ +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 + diff --git a/gdb-symtab-fix-line-number-of-static-const-class-mem.patch b/gdb-symtab-fix-line-number-of-static-const-class-mem.patch new file mode 100644 index 0000000..8e935b3 --- /dev/null +++ b/gdb-symtab-fix-line-number-of-static-const-class-mem.patch @@ -0,0 +1,84 @@ +From e5972def532f3ed248dfbd2f220f28dc367f4ca1 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Fri, 24 Mar 2023 15:45:56 +0100 +Subject: [PATCH 07/12] [gdb/symtab] Fix line number of static const class + member + +Since commit 6d263fe46e0 ("Avoid bad breakpoints with --gc-sections"), there +was a silent regression on openSUSE Leap 15.4 for test-case +gdb.cp/m-static.exp, from: +... +(gdb) info variable everywhere^M +All variables matching regular expression "everywhere":^M +^M +File /home/vries/tmp.local-remote-host-native/m-static.h:^M +8: const int gnu_obj_4::everywhere;^M +(gdb) +... +to: +... +(gdb) info variable everywhere^M +All variables matching regular expression "everywhere":^M +^M +File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static.h:^M +8: const int gnu_obj_4::everywhere;^M +^M +File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static1.cc:^M +8: const int gnu_obj_4::everywhere;^M +(gdb) +... + +Another regression was found due to that commit, and it was fixed in commit +99d679e7b30 ("[gdb/symtab] Fix "file index out of range" complaint") by +limiting the scope of the fix in the original commit. + +Fix this regression by yet further limiting the scope of that fix, making sure +that this bit in dwarf_decode_lines is executed again for m-static1.cc: +... + /* Make sure a symtab is created for every file, even files + which contain only variables (i.e. no code with associated + line numbers). */ +... + +Tested on x86_64-linux. + +PR symtab/30265 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30265 +--- + gdb/dwarf2/read.c | 3 +-- + gdb/testsuite/gdb.cp/m-static.exp | 4 +++- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +index f39eba7a008..04bc0e1cbbd 100644 +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -9633,8 +9633,7 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, + then there won't be any interesting code in the CU, but a check later on + (in lnp_state_machine::check_line_address) will fail to properly exclude + an entry that was removed via --gc-sections. */ +- if (have_code) +- dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping); ++ dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping && have_code); + } + + /* Process DW_TAG_compile_unit or DW_TAG_partial_unit. */ +diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp +index a67b4cd3736..049e88299da 100644 +--- a/gdb/testsuite/gdb.cp/m-static.exp ++++ b/gdb/testsuite/gdb.cp/m-static.exp +@@ -183,8 +183,10 @@ gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const flo + if { $non_dwarf } { setup_xfail *-*-* } + gdb_test "info variable everywhere" \ + [multi_line \ ++ {All variables matching regular expression "everywhere":} \ ++ "" \ + "File (.*/)?m-static\[.\]h:" \ +- "$decimal:\tconst int gnu_obj_4::everywhere;.*"] ++ "$decimal:\tconst int gnu_obj_4::everywhere;"] + + # Perhaps at some point test4 should also include a test for a static + # const int that was initialized in the header file. But I'm not sure +-- +2.35.3 + diff --git a/gdb-symtab-fix-too-many-symbols-in-gdbpy_lookup_stat.patch b/gdb-symtab-fix-too-many-symbols-in-gdbpy_lookup_stat.patch new file mode 100644 index 0000000..c7c2bcb --- /dev/null +++ b/gdb-symtab-fix-too-many-symbols-in-gdbpy_lookup_stat.patch @@ -0,0 +1,66 @@ +From 1362bc937bd54dbd22dd7b3c7ae9d8ab6ca7bbfc Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Wed, 6 Sep 2023 11:00:01 +0200 +Subject: [PATCH 10/12] [gdb/symtab] Fix too many symbols in + gdbpy_lookup_static_symbols + +When running test-case gdb.python/py-symbol.exp with target board +cc-with-dwz-m, we run into: +... +(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M +4^M +(gdb) FAIL: gdb.python/py-symbol.exp: \ + print (len (gdb.lookup_static_symbols ('rr'))) +... +while with target board unix we have instead: +... +(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M +2^M +(gdb) PASS: gdb.python/py-symbol.exp: \ + print (len (gdb.lookup_static_symbols ('rr'))) +... + +The problem is that the loop in gdbpy_lookup_static_symbols loops over compunits +representing both CUs and PUs: +... + for (compunit_symtab *cust : objfile->compunits ()) +... + +When doing a lookup on a PU, the user link is followed until we end up at a CU, +and the lookup is done in that CU. + +In other words, when doing a lookup in the loop for a PU we duplicate the +lookup for a CU that is already handled by the loop. + +Fix this by skipping PUs in the loop in gdb.lookup_static_symbols. + +Tested on x86_64-linux. + +PR symtab/25261 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25261 +--- + gdb/python/py-symbol.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c +index b8777966c47..ed4250bc2c7 100644 +--- a/gdb/python/py-symbol.c ++++ b/gdb/python/py-symbol.c +@@ -582,9 +582,12 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) + { + for (compunit_symtab *cust : objfile->compunits ()) + { +- const struct blockvector *bv; ++ /* Skip included compunits to prevent including compunits from ++ being searched twice. */ ++ if (cust->user != nullptr) ++ continue; + +- bv = cust->blockvector (); ++ const struct blockvector *bv = cust->blockvector (); + const struct block *block = bv->static_block (); + + if (block != nullptr) +-- +2.35.3 + diff --git a/gdb-symtab-handle-pu-in-iterate_over_some_symtabs.patch b/gdb-symtab-handle-pu-in-iterate_over_some_symtabs.patch new file mode 100644 index 0000000..11fbb5e --- /dev/null +++ b/gdb-symtab-handle-pu-in-iterate_over_some_symtabs.patch @@ -0,0 +1,59 @@ +From c67e982325c5b2249b0e29d07a9dc1985614e898 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Wed, 6 Sep 2023 10:14:50 +0200 +Subject: [PATCH 08/12] [gdb/symtab] Handle PU in iterate_over_some_symtabs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When running test-case gdb.base/setshow.exp with target board cc-with-dwz I +run into: +... +(gdb) info line 1^M +Line 1 of "setshow.c" is at address 0x400527 <main> but contains no code.^M +Line 1 of "setshow.c" is at address 0x400527 <main> but contains no code.^M +(gdb) FAIL: gdb.base/setshow.exp: test_setshow_annotate: annotation_level 1 +... +while the expected output is: +... +Line 1 of "setshow.c" is at address 0x400527 <main> but contains no code. +��setshow.c:1:0:beg:0x400527 +... + +The second line of the expected output is missing due to the first line of the +expected output being repeated, so the problem is that the "Line 1" line is +printed twice. + +This happens because the PU imported by the CU reuses the filetab of the CU, +and both the CU and PU are visited by iterate_over_some_symtabs. + +Fix this by skipping PUs in iterate_over_some_symtabs. + +Tested on x86_64-linux, target boards unix, cc-with-dwz and cc-with-dwz-m. + +Approved-By: Tom Tromey <tom@tromey.com> + +PR symtab/30797 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30797 +--- + gdb/symtab.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/gdb/symtab.c b/gdb/symtab.c +index a662d7d1869..fe7cc679b6b 100644 +--- a/gdb/symtab.c ++++ b/gdb/symtab.c +@@ -550,6 +550,10 @@ iterate_over_some_symtabs (const char *name, + + for (cust = first; cust != NULL && cust != after_last; cust = cust->next) + { ++ /* Skip included compunits. */ ++ if (cust->user != nullptr) ++ continue; ++ + for (symtab *s : cust->filetabs ()) + { + if (compare_filenames_for_search (s->filename, name)) +-- +2.35.3 + diff --git a/gdb-symtab-work-around-pr-gas-29517.patch b/gdb-symtab-work-around-pr-gas-29517.patch new file mode 100644 index 0000000..0b850a0 --- /dev/null +++ b/gdb-symtab-work-around-pr-gas-29517.patch @@ -0,0 +1,255 @@ +From 92a5f5ae1b71d152d943ee896bf6cd073d50daa7 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Thu, 28 Sep 2023 13:55:07 +0200 +Subject: [PATCH 02/12] [gdb/symtab] Work around PR gas/29517 + +When using glibc debuginfo generated with gas 2.39, we run into PR gas/29517: +... +$ gdb -q -batch a.out -ex start -ex "p (char *)strstr (\"haha\", \"ah\")" +Temporary breakpoint 1 at 0x40051b: file hello.c, line 6. + +Temporary breakpoint 1, main () at hello.c:6 +6 printf ("hello\n"); +Invalid cast. +... +while without glibc debuginfo installed we get the expected result: +... +$n = 0x7ffff7daa1b1 "aha" +... +and likewise with glibc debuginfo generated with gas 2.40. + +The strstr ifunc resolves to __strstr_sse2_unaligned. The problem is that gas +generates dwarf that states that the return type is void: +... +<1><3e1e58>: Abbrev Number: 2 (DW_TAG_subprogram) + <3e1e59> DW_AT_name : __strstr_sse2_unaligned + <3e1e5d> DW_AT_external : 1 + <3e1e5e> DW_AT_low_pc : 0xbbd2e + <3e1e66> DW_AT_high_pc : 0xbc1c3 +... +while the return type should be a DW_TAG_unspecified_type, as is the case +with gas 2.40. + +We can still use the workaround of casting to another function type for both +__strstr_sse2_unaligned: +... +(gdb) p ((char * (*) (const char *, const char *))__strstr_sse2_unaligned) \ + ("haha", "ah") +$n = 0x7ffff7daa211 "aha" +... +and strstr (which requires using *strstr to dereference the ifunc before we +cast): +... +gdb) p ((char * (*) (const char *, const char *))*strstr) ("haha", "ah") +$n = 0x7ffff7daa251 "aha" +... +but that's a bit cumbersome to use. + +Work around this in the dwarf reader, such that we have instead: +... +(gdb) p (char *)strstr ("haha", "ah") +$n = 0x7ffff7daa1b1 "aha" +... + +This also requires fixing producer_is_gcc to stop returning true for +producer "GNU AS 2.39.0". + +Tested on x86_64-linux. + +PR symtab/30911 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30911 +--- + gdb/dwarf2/cu.c | 1 + + gdb/dwarf2/cu.h | 1 + + gdb/dwarf2/read.c | 22 ++++++++++++ + gdb/producer.c | 8 ++++- + .../gdb.dwarf2/dw2-unspecified-type.c | 9 ++++- + .../gdb.dwarf2/dw2-unspecified-type.exp | 36 +++++++++++++++---- + 6 files changed, 68 insertions(+), 9 deletions(-) + +diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c +index 9c1691c90e9..42fd4f4441b 100644 +--- a/gdb/dwarf2/cu.c ++++ b/gdb/dwarf2/cu.c +@@ -40,6 +40,7 @@ dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu, + producer_is_icc_lt_14 (false), + producer_is_codewarrior (false), + producer_is_clang (false), ++ producer_is_gas_2_39 (false), + processing_has_namespace_info (false), + load_all_dies (false) + { +diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h +index e8dbde9c019..710aeb5b237 100644 +--- a/gdb/dwarf2/cu.h ++++ b/gdb/dwarf2/cu.h +@@ -265,6 +265,7 @@ struct dwarf2_cu + bool producer_is_icc_lt_14 : 1; + bool producer_is_codewarrior : 1; + bool producer_is_clang : 1; ++ bool producer_is_gas_2_39 : 1; + + /* When true, the file that we're processing is known to have + debugging info for C++ namespaces. GCC 3.3.x did not produce +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +index b9e7e18f2a6..f39eba7a008 100644 +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -13370,6 +13370,8 @@ check_producer (struct dwarf2_cu *cu) + cu->producer_is_codewarrior = true; + else if (producer_is_clang (cu->producer, &major, &minor)) + cu->producer_is_clang = true; ++ else if (startswith (cu->producer, "GNU AS 2.39.0")) ++ cu->producer_is_gas_2_39 = true; + else + { + /* For other non-GCC compilers, expect their behavior is DWARF version +@@ -13405,6 +13407,15 @@ producer_is_codewarrior (struct dwarf2_cu *cu) + return cu->producer_is_codewarrior; + } + ++static bool ++producer_is_gas_2_39 (struct dwarf2_cu *cu) ++{ ++ if (!cu->checked_producer) ++ check_producer (cu); ++ ++ return cu->producer_is_gas_2_39; ++} ++ + /* Return the accessibility of DIE, as given by DW_AT_accessibility. + If that attribute is not available, return the appropriate + default. */ +@@ -16581,6 +16592,17 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) + + type = die_type (die, cu); + ++ if (type->code () == TYPE_CODE_VOID ++ && !type->is_stub () ++ && die->child == nullptr ++ && producer_is_gas_2_39 (cu)) ++ { ++ /* Work around PR gas/29517, pretend we have an DW_TAG_unspecified_type ++ return type. */ ++ type = init_type (cu->per_objfile->objfile, TYPE_CODE_VOID, 0, NULL); ++ type->set_is_stub (true); ++ } ++ + /* The die_type call above may have already set the type for this DIE. */ + ftype = get_die_type (die, cu); + if (ftype) +diff --git a/gdb/producer.c b/gdb/producer.c +index 655eb971283..9fcf749e3d4 100644 +--- a/gdb/producer.c ++++ b/gdb/producer.c +@@ -54,13 +54,19 @@ producer_is_gcc (const char *producer, int *major, int *minor) + if (minor == NULL) + minor = &min; + ++ /* Skip GNU. */ ++ cs = &producer[strlen ("GNU ")]; ++ ++ /* Bail out for GNU AS. */ ++ if (startswith (cs, "AS ")) ++ return 0; ++ + /* Skip any identifier after "GNU " - such as "C11" "C++" or "Java". + A full producer string might look like: + "GNU C 4.7.2" + "GNU Fortran 4.8.2 20140120 (Red Hat 4.8.2-16) -mtune=generic ..." + "GNU C++14 5.0.0 20150123 (experimental)" + */ +- cs = &producer[strlen ("GNU ")]; + while (*cs && !isspace (*cs)) + cs++; + if (*cs && isspace (*cs)) +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c +index 1df09214d4a..e07d9517ff2 100644 +--- a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c ++++ b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c +@@ -17,9 +17,16 @@ + + extern int foo (void); + ++int ++bar (void) ++{ ++ asm ("bar_label: .globl bar_label"); ++ return 0; ++} ++ + int + main (void) + { +- int res = foo (); ++ int res = foo () + bar (); + return res; + } +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp +index a353395592e..bd707204fba 100644 +--- a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp ++++ b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp +@@ -29,10 +29,18 @@ lassign $foo_res \ + foo_start foo_len + set foo_end "$foo_start + $foo_len" + ++set bar_res \ ++ [function_range bar \ ++ [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]] ++lassign $bar_res \ ++ bar_start bar_len ++set bar_end "$bar_start + $bar_len" ++ + # Create the DWARF. + set asm_file [standard_output_file $srcfile3] + Dwarf::assemble $asm_file { + global foo_start foo_end ++ global bar_start bar_end + declare_labels unspecified_type_label + + cu {} { +@@ -47,7 +55,19 @@ Dwarf::assemble $asm_file { + {high_pc $foo_end addr} + {type :$unspecified_type_label} + } ++ } ++ } + ++ cu {} { ++ compile_unit { ++ {language @DW_LANG_Mips_Assembler} ++ {producer "GNU AS 2.39.0"} ++ } { ++ DW_TAG_subprogram { ++ {name bar} ++ {low_pc $bar_start addr} ++ {high_pc $bar_end addr} ++ } + } + } + } +@@ -61,12 +81,14 @@ if ![runto_main] { + return -1 + } + +-# Print the function type. Return type should be stub type, which is printed +-# as void. +-gdb_test "ptype foo" "type = void \\(void\\)" ++foreach f {foo bar} { ++ # Print the function type. Return type should be stub type, which is printed ++ # as void. ++ gdb_test "ptype $f" "type = void \\(void\\)" + +-# Call the function, casting the function to the correct function type. +-gdb_test "p ((int (*) ()) foo) ()" " = 0" ++ # Call the function, casting the function to the correct function type. ++ gdb_test "p ((int (*) ()) $f) ()" " = 0" + +-# Call the function, casting the function result to the correct type. +-gdb_test "p (int) foo ()" " = 0" ++ # Call the function, casting the function result to the correct type. ++ gdb_test "p (int) $f ()" " = 0" ++} +-- +2.35.3 + diff --git a/gdb-testsuite-add-kfail-for-pr-ada-30908.patch b/gdb-testsuite-add-kfail-for-pr-ada-30908.patch new file mode 100644 index 0000000..ab213c3 --- /dev/null +++ b/gdb-testsuite-add-kfail-for-pr-ada-30908.patch @@ -0,0 +1,108 @@ +From 0b29bc75761b11387f89912ce827311b8eac18a6 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Sun, 1 Oct 2023 15:10:32 +0200 +Subject: [PATCH 04/12] [gdb/testsuite] Add KFAIL for PR ada/30908 + +With gcc 13.2.1, I run into a cluster of fails: +... +FAIL: gdb.ada/str_binop_equal.exp: print my_str = "ABCD" +FAIL: gdb.ada/widewide.exp: print my_wws = " helo" +FAIL: gdb.ada/widewide.exp: print my_ws = "wide" +... + +The problem is that the debug info contains information about function +ada.strings.maps."=", and gdb uses it to implement the comparison. +The function is supposed to compare two char sets, not strings, so gdb +shouldn't use it. This is PR ada/30908. + +I don't see the same problem with gcc 7.5.0, because the exec doesn't contain +the debug info for the function, because the corresponding object is not +linked in. Adter adding "with Ada.Strings.Maps; use Ada.Strings.Maps;" to +gdb.ada/widewide/foo.adb I run into the same problem with gcc 7.5.0. + +Add KFAILs for the PR. + +Tested on x86_64-linux: +- openSUSE Leap 15.4 (using gcc 7.5.0), and +- openSUSE Tumbleweed (using gcc 13.2.1). + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30908 +--- + gdb/testsuite/gdb.ada/str_binop_equal.exp | 20 ++++++++++++++-- + gdb/testsuite/gdb.ada/widewide.exp | 28 +++++++++++++++++++++-- + 2 files changed, 44 insertions(+), 4 deletions(-) + +diff --git a/gdb/testsuite/gdb.ada/str_binop_equal.exp b/gdb/testsuite/gdb.ada/str_binop_equal.exp +index 5eb531c1453..2c1b8414c5c 100644 +--- a/gdb/testsuite/gdb.ada/str_binop_equal.exp ++++ b/gdb/testsuite/gdb.ada/str_binop_equal.exp +@@ -31,8 +31,24 @@ runto "foo_p211_061.adb:$bp_location" + gdb_test "print my_str = my_str" \ + " = true" + +-gdb_test "print my_str = \"ABCD\"" \ +- " = true" ++set kfail_re \ ++ [multi_line \ ++ [string_to_regexp {Symbol: ada.strings.maps."="}] \ ++ ".*" \ ++ "\\$$decimal = false"] ++ ++gdb_test_no_output "set debug expr 1" ++ ++gdb_test_multiple {print my_str = "ABCD"} "" { ++ -re -wrap " = true" { ++ pass $gdb_test_name ++ } ++ -re -wrap $kfail_re { ++ kfail ada/30908 $gdb_test_name ++ } ++} ++ ++gdb_test "set debug expr 0" + + gdb_test "print my_str = \"EFGH\"" \ + " = false" +diff --git a/gdb/testsuite/gdb.ada/widewide.exp b/gdb/testsuite/gdb.ada/widewide.exp +index 5de5d52b8cb..b91b6bc746b 100644 +--- a/gdb/testsuite/gdb.ada/widewide.exp ++++ b/gdb/testsuite/gdb.ada/widewide.exp +@@ -42,9 +42,33 @@ gdb_test "print my_wws(1)" "= 32 ' '" + + gdb_test "print my_wws(2)" "= 104 'h'" + +-gdb_test "print my_wws = \" helo\"" " = true" ++set kfail_re \ ++ [multi_line \ ++ [string_to_regexp {Symbol: ada.strings.maps."="}] \ ++ ".*" \ ++ "\\$$decimal = false"] ++ ++gdb_test_no_output "set debug expr 1" ++ ++gdb_test_multiple {print my_wws = " helo"} "" { ++ -re -wrap " = true" { ++ pass $gdb_test_name ++ } ++ -re -wrap $kfail_re { ++ kfail ada/30908 $gdb_test_name ++ } ++} ++gdb_test_multiple {print my_ws = "wide"} "" { ++ -re -wrap " = true" { ++ pass $gdb_test_name ++ } ++ -re -wrap $kfail_re { ++ kfail ada/30908 $gdb_test_name ++ } ++} ++ ++gdb_test "set debug expr 0" + +-gdb_test "print my_ws = \"wide\"" " = true" + gdb_test "print my_ws = \"nope\"" " = false" + + gdb_test "print \"x\" & my_ws & \"y\"" " = \"xwidey\"" +-- +2.35.3 + diff --git a/gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch b/gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch new file mode 100644 index 0000000..1050225 --- /dev/null +++ b/gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch @@ -0,0 +1,53 @@ +From 2521ac7ed0c495b9e804c4356939b9be7166853c Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Thu, 26 Oct 2023 10:34:24 +0200 +Subject: [PATCH] [gdb/testsuite] Add wait-for-index-cache in + gdb.dwarf2/per-bfd-sharing.exp + +If we make writing an index-cache entry very slow by doing this in +index_cache::store: +... + try + { ++ sleep (15); + index_cache_debug ("writing index cache for objfile %s", + bfd_get_filename (per_bfd->obfd)); +... +we run into: +... +FAIL: gdb.dwarf2/per-bfd-sharing.exp: \ + couldn't remove files in temporary cache dir +... + +The FAIL happens because there is no index-cache entry in the cache dir. + +The problem is that gdb is killed (by gdb_exit) before the index-cache entry +is written. + +Fix this by using "maint wait-for-index-cache". + +Tested on x86_64-linux. + +PR testsuite/30528 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30528 +--- + gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp +index 46284c2b775..7bdf59fbcd1 100644 +--- a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp ++++ b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp +@@ -47,6 +47,7 @@ with_test_prefix "populate index cache" { + "set index-cache directory" + gdb_test_no_output "set index-cache enabled on" + gdb_test "file $binfile" "Reading symbols from .*" "file" ++ gdb_test_no_output "maint wait-for-index-cache" + } + + proc load_binary { method } { + +base-commit: b7f9471d211d35eba33b86e073268b4a89b78a92 +-- +2.35.3 + diff --git a/gdb-testsuite-add-xfail-for-gdb-29965-in-gdb.threads.patch b/gdb-testsuite-add-xfail-for-gdb-29965-in-gdb.threads.patch new file mode 100644 index 0000000..2272a17 --- /dev/null +++ b/gdb-testsuite-add-xfail-for-gdb-29965-in-gdb.threads.patch @@ -0,0 +1,65 @@ +From ebceffa1196651683a7a6d31abb4b3b5adc6c168 Mon Sep 17 00:00:00 2001 +From: Simon Marchi <simon.marchi@efficios.com> +Date: Thu, 7 Sep 2023 21:53:55 -0400 +Subject: [PATCH 12/12] gdb/testsuite: add xfail for gdb/29965 in + gdb.threads/process-exit-status-is-leader-exit-status.exp + +Bug 29965 shows on a Linux kernel >= 6.1, that test fails consistently +with: + + FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=0: continue (the program exited) + ... + FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=9: continue (the program exited) + +This is due to a change in Linux kernel behavior [1] that affects +exactly what this test tests. That is, if multiple threads (including +the leader) call SYS_exit, the exit status of the process should be the +exit status of the leader. After that change in the kernel, it is no +longer the case. + +Add an xfail in the test, based on the Linux kernel version. The goal +is that if a regression is introduced in GDB regarding this feature, it +should be caught if running on an older kernel where the behavior was +consistent. + +[1] https://bugzilla.suse.com/show_bug.cgi?id=1206926 + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29965 +Change-Id: If6ab7171c92bfc1a3b961c7179e26611773969eb +Approved-By: Tom de Vries <tdevries@suse.de> +--- + ...cess-exit-status-is-leader-exit-status.exp | 19 ++++++++++++++++++- + 1 file changed, 18 insertions(+), 1 deletion(-) + +diff --git a/gdb/testsuite/gdb.threads/process-exit-status-is-leader-exit-status.exp b/gdb/testsuite/gdb.threads/process-exit-status-is-leader-exit-status.exp +index f64d6a73dea..e470fe29110 100644 +--- a/gdb/testsuite/gdb.threads/process-exit-status-is-leader-exit-status.exp ++++ b/gdb/testsuite/gdb.threads/process-exit-status-is-leader-exit-status.exp +@@ -41,6 +41,23 @@ for {set iteration 0} {$iteration < 10} {incr iteration} { + return + } + +- gdb_test "continue" "\\\[Inferior 1 \\(.*\\) exited with code 01\\\]" ++ gdb_test_multiple "continue" "" { ++ -re -wrap "\\\[Inferior 1 \\(.*\\) exited with code 01\\\]" { ++ pass $gdb_test_name ++ } ++ ++ -re -wrap "\\\[Inferior 1 \\(.*\\) exited with code $::decimal\\\]" { ++ set lkv [linux_kernel_version] ++ ++ if { [llength $lkv] != 0 } { ++ if { [version_compare {6 1 0} <= $lkv] } { ++ xfail "$gdb_test_name (PR 29965)" ++ return ++ } ++ } ++ ++ fail $gdb_test_name ++ } ++ } + } + } +-- +2.35.3 + diff --git a/gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-with-newer.patch b/gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-with-newer.patch new file mode 100644 index 0000000..584e0cb --- /dev/null +++ b/gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-with-newer.patch @@ -0,0 +1,64 @@ +From ad1be044276c4727434f84ac6c554da4f2829aaf Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Tue, 26 Sep 2023 18:57:49 +0200 +Subject: [PATCH 05/12] [gdb/testsuite] Fix gdb.ada/mi_task_arg.exp with newer + gcc + +When running test-case gdb.ada/mi_task_arg.exp on openSUSE Tumbleweed using +gcc 13.2.1, I run into (layout adapted for readability): +... +-stack-list-arguments 1^M +^done,stack-args=[ + frame={level="0",args=[]}, + frame={level="1",args=[{name="<_task>",value="0x464820"}, + {name="<_taskL>",value="129"}]}, + frame={level="2",args=[{name="self_id",value="0x464840"}]}, + frame={level="3",args=[]}, + frame={level="4",args=[]} +]^M +(gdb) ^M +FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output) +... + +On openSUSE Leap 15.4 with gcc 7.5.0 I get instead: +... +-stack-list-arguments 1^M +^done,stack-args=[ + frame={level="0",args=[]}, + frame={level="1",args=[{name="<_task>",value="0x444830"}]}, + frame={level="2",args=[{name="self_id",value="0x444850"}]}, + frame={level="3",args=[]}, + frame={level="4",args=[]}]^M +(gdb) ^M +PASS: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 +... + +The difference in gdb output is due to difference in the dwarf generated by +the compiler, so I don't see a problem with gdb here. + +Fix this by updating the test-case to accept this output. + +Tested on x86_64-linux. + +Approved-By: Tom Tromey <tom@tromey.com> +--- + gdb/testsuite/gdb.ada/mi_task_arg.exp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gdb/testsuite/gdb.ada/mi_task_arg.exp b/gdb/testsuite/gdb.ada/mi_task_arg.exp +index ffee40ad044..2820f2d3722 100644 +--- a/gdb/testsuite/gdb.ada/mi_task_arg.exp ++++ b/gdb/testsuite/gdb.ada/mi_task_arg.exp +@@ -49,7 +49,8 @@ if {![mi_runto "task_switch.break_me"]} { + set frame0 "frame=\{level=\"0\",args=\\\[\\\]\}" + # Frame for task_switch.caller + set frame1_args "\{name=\"<_task>\",value=\"$hex\"\}" +-set frame1 "frame=\{level=\"1\",args=\\\[$frame1_args\\\]\}" ++set frame1_opt_args "\{name=\"<_taskL>\",value=\"$decimal\"\}" ++set frame1 "frame=\{level=\"1\",args=\\\[${frame1_args}(,$frame1_opt_args)?\\\]\}" + # Frame for system.tasking.stages.task_wrapper + set frame2_args "(\{name=\"self_id\",value=\"($hex|<optimized out>)\"\})?" + set frame2 "frame=\{level=\"2\",args=\\\[$frame2_args\\\]\}" +-- +2.35.3 + diff --git a/gdb-testsuite-fix-gdb.arch-i386-signal.exp-on-x86_64.patch b/gdb-testsuite-fix-gdb.arch-i386-signal.exp-on-x86_64.patch new file mode 100644 index 0000000..40aa2ad --- /dev/null +++ b/gdb-testsuite-fix-gdb.arch-i386-signal.exp-on-x86_64.patch @@ -0,0 +1,91 @@ +From ef58dedc82b17919360bf51f7efcbf6d74c11329 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Sun, 1 Oct 2023 13:00:23 +0200 +Subject: [PATCH 01/12] [gdb/testsuite] Fix gdb.arch/i386-signal.exp on x86_64 + +On x86_64-linux, with test-case gdb.arch/i386-signal.exp I run into: +... +builtin_spawn -ignore SIGHUP gcc -fno-stack-protector i386-signal.c \ + -fdiagnostics-color=never -fno-pie -g -no-pie -lm -o i386-signal^M +/tmp/cc2xydTG.s: Assembler messages:^M +/tmp/cc2xydTG.s:50: Error: operand size mismatch for `push'^M +compiler exited with status 1 +output is: +/tmp/cc2xydTG.s: Assembler messages:^M +/tmp/cc2xydTG.s:50: Error: operand size mismatch for `push'^M + +gdb compile failed, /tmp/cc2xydTG.s: Assembler messages: +/tmp/cc2xydTG.s:50: Error: operand size mismatch for `push' +UNTESTED: gdb.arch/i386-signal.exp: failed to compile +... + +This is with gas 2.41, it compiles without problems with gas 2.40. Some more +strict checking was added in commit 5cc007751cd ("x86: further adjust +extend-to-32bit-address conditions"). + +The offending bit is: +... + " push $sigframe\n" +... +which refers to a function: +... + " .globl sigframe\n" + "sigframe:\n" +... + +The test-case passes with target board unix/-m32. + +Make the test-case work by using pushq instead of push for the +is_amd64_regs_target case. + +Tested on x86_64-linux, with target boards: +- unix/-m64 (is_amd64_regs_target == 1), and +- unix/-m32 (is_amd64_regs_target == 0), + +PR testsuite/30928 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30928 +--- + gdb/testsuite/gdb.arch/i386-signal.c | 4 ++++ + gdb/testsuite/gdb.arch/i386-signal.exp | 7 ++++++- + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/gdb/testsuite/gdb.arch/i386-signal.c b/gdb/testsuite/gdb.arch/i386-signal.c +index 19bb1bbaaf8..4bf97e5f159 100644 +--- a/gdb/testsuite/gdb.arch/i386-signal.c ++++ b/gdb/testsuite/gdb.arch/i386-signal.c +@@ -45,7 +45,11 @@ asm(".text\n" + " .align 8\n" + " .globl setup\n" + "setup:\n" ++#if IS_AMD64_REGS_TARGET ++ " pushq $sigframe\n" ++#else + " push $sigframe\n" ++#endif + " jmp func\n" + "\n" + " .cfi_startproc\n" +diff --git a/gdb/testsuite/gdb.arch/i386-signal.exp b/gdb/testsuite/gdb.arch/i386-signal.exp +index 9806970b245..0a413f73a5b 100644 +--- a/gdb/testsuite/gdb.arch/i386-signal.exp ++++ b/gdb/testsuite/gdb.arch/i386-signal.exp +@@ -22,8 +22,13 @@ if {![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]} { + + standard_testfile + ++set opts {} ++lappend opts debug ++lappend opts nopie ++lappend opts additional_flags=-DIS_AMD64_REGS_TARGET=[is_amd64_regs_target] ++ + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ +- executable { debug nopie }] != "" } { ++ executable $opts] != "" } { + untested "failed to compile" + return -1 + } + +base-commit: b671ae32ae890a373abcfe4b19a3b662fd5e86f2 +-- +2.35.3 + diff --git a/gdb-testsuite-fix-gdb.cp-m-static.exp-regression-on-.patch b/gdb-testsuite-fix-gdb.cp-m-static.exp-regression-on-.patch new file mode 100644 index 0000000..7ba1b12 --- /dev/null +++ b/gdb-testsuite-fix-gdb.cp-m-static.exp-regression-on-.patch @@ -0,0 +1,76 @@ +From 424c96685651cc949597d700811a5fbb15256d1d Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Fri, 24 Mar 2023 09:18:07 +0100 +Subject: [PATCH 06/12] [gdb/testsuite] Fix gdb.cp/m-static.exp regression on + Ubuntu 20.04 + +In commit 722c4596034 ("[gdb/testsuite] Fix gdb.cp/*.exp for remote host"), I +needed to change ".*/" into "(.*/)?" in: +... +gdb_test "info variable everywhere" \ + "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;" +... + +However, due to the fact that I got this output: +... +(gdb) info variable everywhere^M +All variables matching regular expression "everywhere":^M +^M +File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static.h:^M +8: const int gnu_obj_4::everywhere;^M +^M +File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static1.cc:^M +8: const int gnu_obj_4::everywhere;^M +... +I decided to make the matching somewhat stricter, to make sure that the two +matched lines were subsequent. + +The commit turned out to be more strict than intended, and caused a regression +on Ubuntu 20.04, where the output was instead: +... +(gdb) info variable everywhere^M +All variables matching regular expression "everywhere":^M +^M +File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static.h:^M +8: const int gnu_obj_4::everywhere;^M +... + +At that point I realized I'm looking at a bug (filed as PR symtab/30265), +which manifests on openSUSE Leap 15.4 for native and readnow, and on Ubuntu +20.04 for readnow, but not for native. + +Before my commit, the test-case passed whether the bug manifested or not. + +After my commit, the test-case only passed when the bug manifested. + +Fix the test-case regression by reverting to the situation before the commit: +pass whether the bug manifests or not. We could add an xfail for the PR, but +I'm expecting a fix soon, so that doesn't look worth the effort. + +Tested on x86_64-linux, both on openSUSE Leap 15.4 and Ubuntu 20.04, both with +native and readnow. + +Reported-By: Simon Marchi <simon.marchi@efficios.com> +--- + gdb/testsuite/gdb.cp/m-static.exp | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp +index 97a5645b53a..a67b4cd3736 100644 +--- a/gdb/testsuite/gdb.cp/m-static.exp ++++ b/gdb/testsuite/gdb.cp/m-static.exp +@@ -181,7 +181,10 @@ gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const flo + + # Also make sure static const members can be found via "info var". + if { $non_dwarf } { setup_xfail *-*-* } +-gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;" ++gdb_test "info variable everywhere" \ ++ [multi_line \ ++ "File (.*/)?m-static\[.\]h:" \ ++ "$decimal:\tconst int gnu_obj_4::everywhere;.*"] + + # Perhaps at some point test4 should also include a test for a static + # const int that was initialized in the header file. But I'm not sure +-- +2.35.3 + diff --git a/gdb-testsuite-fix-gdb.dwarf2-nullptr_t.exp-with-cc-w.patch b/gdb-testsuite-fix-gdb.dwarf2-nullptr_t.exp-with-cc-w.patch new file mode 100644 index 0000000..906bc56 --- /dev/null +++ b/gdb-testsuite-fix-gdb.dwarf2-nullptr_t.exp-with-cc-w.patch @@ -0,0 +1,38 @@ +From 335a151d834199610b515e67f1924d6e0a211db2 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Wed, 30 Aug 2023 23:33:31 +0200 +Subject: [PATCH 09/12] [gdb/testsuite] Fix gdb.dwarf2/nullptr_t.exp with + cc-with-dwz-m + +When running test-case gdb.dwarf2/nullptr_t.exp with target board +cc-with-dwz-m, I run into: +... +FAIL: gdb.dwarf2/nullptr_t.exp: decltype(nullptr) symbol +... + +The problem is that were looking for "typedef void decltype\\(nullptr\\)" +using "maint print symbols -source $srcfile", but dwz has moved the typedef to +a PU, so it's shown by "maint print symbols -source <unknown>" instead. + +Fix this by dropping the "-source $srcfile" bit. + +Tested on x86_64-linux, with make-check-all.sh. +--- + gdb/testsuite/gdb.dwarf2/nullptr_t.exp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdb/testsuite/gdb.dwarf2/nullptr_t.exp b/gdb/testsuite/gdb.dwarf2/nullptr_t.exp +index a02ebbf109e..e78d90fdb25 100644 +--- a/gdb/testsuite/gdb.dwarf2/nullptr_t.exp ++++ b/gdb/testsuite/gdb.dwarf2/nullptr_t.exp +@@ -34,6 +34,6 @@ with_complaints 5 { + gdb_test $cmd $re "$cmd without complaints" + } + +-gdb_test "maint print symbols -source $srcfile" \ ++gdb_test "maint print symbols" \ + "typedef void decltype\\(nullptr\\); \r\n.*" \ + "decltype(nullptr) symbol" +-- +2.35.3 + diff --git a/gdb-testsuite-fix-regexps-in-gdb.base-step-over-sysc.patch b/gdb-testsuite-fix-regexps-in-gdb.base-step-over-sysc.patch new file mode 100644 index 0000000..2399574 --- /dev/null +++ b/gdb-testsuite-fix-regexps-in-gdb.base-step-over-sysc.patch @@ -0,0 +1,85 @@ +From e492116f04d3b4d704c4f6f3259143d7fb16a03e Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Wed, 26 Jul 2023 11:53:31 +0200 +Subject: [PATCH 03/12] [gdb/testsuite] Fix regexps in + gdb.base/step-over-syscall.exp + +When running test-case gdb.base/step-over-syscall.exp without glibc debuginfo +installed, I get: +... +(gdb) continue^M +Continuing.^M +^M +Breakpoint 2, 0x00007ffff7d4405e in vfork () from /lib64/libc.so.6^M +(gdb) PASS: gdb.base/step-over-syscall.exp: vfork: displaced=off: \ + continue to vfork (1st time) +... +but with glibc debuginfo installed I get instead: +... +(gdb) continue^M +Continuing.^M +^M +Breakpoint 2, 0x00007ffff7d4405e in __libc_vfork () at \ + ../sysdeps/unix/sysv/linux/x86_64/vfork.S:44^M +44 ENTRY (__vfork)^M +(gdb) FAIL: gdb.base/step-over-syscall.exp: vfork: displaced=off: \ + continue to vfork (1st time) +... + +The FAIL is due to a mismatch with regexp: +... + "Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" +... +because it cannot match both ".* in " and the __libc_ prefix. + +Fix this by using instead the regexp: +... + "Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*" +... + +Tested on x86_64-linux. +--- + gdb/testsuite/gdb.base/step-over-syscall.exp | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp +index 424eee142fd..87ff2606d30 100644 +--- a/gdb/testsuite/gdb.base/step-over-syscall.exp ++++ b/gdb/testsuite/gdb.base/step-over-syscall.exp +@@ -127,13 +127,13 @@ proc setup { syscall } { + + gdb_test "break \*$syscall" "Breakpoint \[0-9\]* at .*" + +- gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ ++ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*" \ + "continue to $syscall (1st time)" + # Hit the breakpoint on $syscall for the first time. In this time, + # we will let PLT resolution done, and the number single steps we will + # do later will be reduced. + +- gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ ++ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*" \ + "continue to $syscall (2nd time)" + # Hit the breakpoint on $syscall for the second time. In this time, + # the address of syscall insn and next insn of syscall are recorded. +@@ -265,7 +265,7 @@ proc step_over_syscall { syscall } { + return -1 + } + +- gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ ++ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*" \ + "continue to $syscall (3rd time)" + + # Hit the breakpoint on $syscall for the third time. In this time, we'll set +@@ -333,7 +333,7 @@ proc break_cond_on_syscall { syscall follow_fork detach_on_fork } { + return -1 + } + +- gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ ++ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*" \ + "continue to $syscall" + # Delete breakpoint syscall insns to avoid interference with other syscalls. + delete_breakpoints +-- +2.35.3 + diff --git a/gdb.changes b/gdb.changes index b46ec52..06588cb 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,33 @@ +------------------------------------------------------------------- +Tue Oct 24 13:39:35 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Patches added (manual import from fedora rawhide @ 52a4dab): + * 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. + ------------------------------------------------------------------- Sat Oct 21 08:05:18 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/gdb.spec b/gdb.spec index b22f2bd..f7402f5 100644 --- a/gdb.spec +++ b/gdb.spec @@ -224,6 +224,7 @@ Patch64: gdb-bz2237515-debuginfod-double-free.patch Patch65: gdb-bz2237392-dwarf-obstack-allocation.patch Patch66: gdb-rhbz2233961-CVE-2022-4806.patch Patch67: gdb-rhbz2233965-memory-leak.patch +Patch68: gdb-rhbz1773651-gdb-index-internal-error.patch #Fedora Packages end # Fedora patches fixup @@ -289,37 +290,51 @@ Patch1505: gdb-testsuite-fix-gdb.base-step-over-syscall.exp-with-m32-amd-ca # Backports from master, available in next release. -Patch2040: remove-some-unnecessary-includes-from-exp.y.patch -Patch2041: gdb-testsuite-fix-gdb.gdb-python-helper.exp-with-o2-.patch -Patch2042: gdb-testsuite-simplify-gdb.base-unwind-on-each-insn..patch -Patch2043: gdb-testsuite-handle-output-after-prompt-in-gdb.thre.patch - -Patch2075: gdb-testsuite-add-xfail-in-gdb.arch-i386-pkru.exp.patch -Patch2076: gdb-testsuite-factor-out-proc-linux_kernel_version.patch -Patch2077: gdb-testsuite-add-xfail-in-gdb.python-py-record-btra.patch -Patch2078: gdb-testsuite-fix-gdb.threads-schedlock.exp-on-fast-.patch -Patch2079: gdb-testsuite-simplify-gdb.arch-amd64-disp-step-avx..patch -Patch2080: gdb-testsuite-fix-gdb.threads-schedlock.exp-for-gcc-.patch -Patch2081: gdb-testsuite-add-xfail-case-in-gdb.python-py-record.patch -Patch2082: aarch64-avoid-initializers-for-vlas.patch -Patch2083: gdb-tdep-aarch64-fix-frame-address-of-last-insn.patch -Patch2084: fix-pr30369-regression-on-aarch64-arm-pr30506.patch -Patch2085: gdb-testsuite-fix-breakpoint-regexp-in-gdb.ada-out_o.patch -Patch2086: gdb-testsuite-relax-breakpoint-count-check-in-gdb.py.patch -Patch2087: gdb-testsuite-fix-buffer-overflow-in-gdb.base-signed.patch -Patch2088: gdb-testsuite-require-syscall-time-in-gdb.reverse-ti.patch -Patch2089: gdb-testsuite-handle-missing-gdc-in-gdb.dlang-dlang-.patch -Patch2090: gdb-testsuite-add-basic-lmap-for-tcl-8.6.patch -Patch2091: gdb-testsuite-fix-gdb.rust-watch.exp-on-ppc64le.patch -Patch2092: gdb-testsuite-fix-gdb.python-py-breakpoint.exp-timeo.patch -Patch2093: powerpc-fix-for-gdb.reverse-finish-precsave.exp-and-.patch -Patch2094: powerpc-regression-fix-for-reverse-finish-command.patch -Patch2095: gdb-testsuite-don-t-use-string-cat-in-gdb.dwarf2-dw2.patch -Patch2096: move-step_until-procedure.patch +Patch2000: remove-some-unnecessary-includes-from-exp.y.patch +Patch2001: gdb-testsuite-fix-gdb.gdb-python-helper.exp-with-o2-.patch +Patch2002: gdb-testsuite-simplify-gdb.base-unwind-on-each-insn..patch +Patch2003: gdb-testsuite-handle-output-after-prompt-in-gdb.thre.patch +Patch2004: gdb-testsuite-add-xfail-in-gdb.arch-i386-pkru.exp.patch +Patch2005: gdb-testsuite-factor-out-proc-linux_kernel_version.patch +Patch2006: gdb-testsuite-add-xfail-in-gdb.python-py-record-btra.patch +Patch2007: gdb-testsuite-fix-gdb.threads-schedlock.exp-on-fast-.patch +Patch2008: gdb-testsuite-simplify-gdb.arch-amd64-disp-step-avx..patch +Patch2009: gdb-testsuite-fix-gdb.threads-schedlock.exp-for-gcc-.patch +Patch2010: gdb-testsuite-add-xfail-case-in-gdb.python-py-record.patch +Patch2011: aarch64-avoid-initializers-for-vlas.patch +Patch2012: gdb-tdep-aarch64-fix-frame-address-of-last-insn.patch +Patch2013: fix-pr30369-regression-on-aarch64-arm-pr30506.patch +Patch2014: gdb-testsuite-fix-breakpoint-regexp-in-gdb.ada-out_o.patch +Patch2015: gdb-testsuite-relax-breakpoint-count-check-in-gdb.py.patch +Patch2016: gdb-testsuite-fix-buffer-overflow-in-gdb.base-signed.patch +Patch2017: gdb-testsuite-require-syscall-time-in-gdb.reverse-ti.patch +Patch2018: gdb-testsuite-handle-missing-gdc-in-gdb.dlang-dlang-.patch +Patch2019: gdb-testsuite-add-basic-lmap-for-tcl-8.6.patch +Patch2020: gdb-testsuite-fix-gdb.rust-watch.exp-on-ppc64le.patch +Patch2021: gdb-testsuite-fix-gdb.python-py-breakpoint.exp-timeo.patch +Patch2022: powerpc-fix-for-gdb.reverse-finish-precsave.exp-and-.patch +Patch2023: powerpc-regression-fix-for-reverse-finish-command.patch +Patch2024: gdb-testsuite-don-t-use-string-cat-in-gdb.dwarf2-dw2.patch +Patch2025: move-step_until-procedure.patch +Patch2026: gdb-testsuite-fix-gdb.arch-i386-signal.exp-on-x86_64.patch +Patch2027: gdb-testsuite-fix-regexps-in-gdb.base-step-over-sysc.patch +Patch2028: gdb-testsuite-add-kfail-for-pr-ada-30908.patch +Patch2029: gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-with-newer.patch +Patch2030: gdb-testsuite-fix-gdb.cp-m-static.exp-regression-on-.patch +Patch2031: gdb-symtab-fix-line-number-of-static-const-class-mem.patch +Patch2032: gdb-symtab-handle-pu-in-iterate_over_some_symtabs.patch +Patch2033: gdb-testsuite-fix-gdb.dwarf2-nullptr_t.exp-with-cc-w.patch +Patch2034: gdb-symtab-fix-too-many-symbols-in-gdbpy_lookup_stat.patch +Patch2035: gdb-support-rseq-auxvs.patch +Patch2036: gdb-testsuite-add-xfail-for-gdb-29965-in-gdb.threads.patch +Patch2037: gdb-cli-handle-pending-c-after-rl_callback_read_char.patch +Patch2038: gdb-testsuite-add-have_host_locale.patch +Patch2039: gdb-symtab-find-main-language-without-symtab-expansi.patch # Backports from master, not yet available in next release. -# +Patch2070: gdb-symtab-work-around-pr-gas-29517.patch +Patch2071: gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch # Backport from gdb-patches @@ -331,10 +346,6 @@ Patch2101: gdb-testsuite-prevent-compilation-fails-with-unix-fpie-pie.patch Patch2104: gdb-testsuite-work-around-skip_prologue-problems-in-gdb.threads-process-dies-while-detaching.exp.patch # https://sourceware.org/pipermail/gdb-patches/2021-May/178990.html Patch2105: gdb-cli-add-ignore-errors-command.patch -# https://sourceware.org/pipermail/gdb-patches/2023-May/199802.html -Patch2106: gdb-cli-handle-pending-c-after-rl_callback_read_char.patch -# https://sourceware.org/pipermail/gdb-patches/2023-June/200242.html -Patch2107: gdb-testsuite-add-have_host_locale.patch # Debug patches. @@ -564,13 +575,13 @@ Requires: libunwind %if %{build_main} %if 0%{!?_without_python:1} +%if 0%{?suse_version} >= 1500 # For SLE-15 and later, we use source-highlight by default, and -# pygments as fallback. -# For SLE-12, source-highlight is not used, and we'd rather not start using -# pygments as default for an older release. -# So, suggests rather than recommends is what we want in both cases. +# pygments as fallback. So, suggests rather than recommends is what we want. +# Don't bother older releases with this. Suggests: %{python}-Pygments %endif +%endif %description GDB, the GNU debugger, allows you to debug programs written in C, C++, @@ -684,6 +695,7 @@ find -name "*.info*"|xargs rm -f %patch65 -p1 %patch66 -p1 %patch67 -p1 +%patch68 -p1 #Fedora patching end %patch1000 -p1 @@ -714,40 +726,54 @@ find -name "*.info*"|xargs rm -f %patch1504 -p1 %patch1505 -p1 -%patch2040 -p1 -%patch2041 -p1 -%patch2042 -p1 -%patch2043 -p1 +%patch2000 -p1 +%patch2001 -p1 +%patch2002 -p1 +%patch2003 -p1 +%patch2004 -p1 +%patch2005 -p1 +%patch2006 -p1 +%patch2007 -p1 +%patch2008 -p1 +%patch2009 -p1 +%patch2010 -p1 +%patch2011 -p1 +%patch2012 -p1 +%patch2013 -p1 +%patch2014 -p1 +%patch2015 -p1 +%patch2016 -p1 +%patch2017 -p1 +%patch2018 -p1 +%patch2019 -p1 +%patch2020 -p1 +%patch2021 -p1 +%patch2022 -p1 +%patch2023 -p1 +%patch2024 -p1 +%patch2025 -p1 +%patch2026 -p1 +%patch2027 -p1 +%patch2028 -p1 +%patch2029 -p1 +%patch2030 -p1 +%patch2031 -p1 +%patch2032 -p1 +%patch2033 -p1 +%patch2034 -p1 +%patch2035 -p1 +%patch2036 -p1 +%patch2037 -p1 +%patch2038 -p1 +%patch2039 -p1 -%patch2075 -p1 -%patch2076 -p1 -%patch2077 -p1 -%patch2078 -p1 -%patch2079 -p1 -%patch2080 -p1 -%patch2081 -p1 -%patch2082 -p1 -%patch2083 -p1 -%patch2084 -p1 -%patch2085 -p1 -%patch2086 -p1 -%patch2087 -p1 -%patch2088 -p1 -%patch2089 -p1 -%patch2090 -p1 -%patch2091 -p1 -%patch2092 -p1 -%patch2093 -p1 -%patch2094 -p1 -%patch2095 -p1 -%patch2096 -p1 +%patch2070 -p1 +%patch2071 -p1 %patch2100 -p1 %patch2101 -p1 %patch2104 -p1 %patch2105 -p1 -%patch2106 -p1 -%patch2107 -p1 #unpack libipt %if 0%{have_libipt} diff --git a/qa.sh b/qa.sh index 68c9d85..5297213 100644 --- a/qa.sh +++ b/qa.sh @@ -132,31 +132,41 @@ kfail=( # https://sourceware.org/bugzilla/show_bug.cgi?id=26971 "FAIL: gdb.arch/amd64-init-x87-values.exp: check_x87_regs_around_init: check post FLD1 value of .fop" "FAIL: gdb.arch/amd64-init-x87-values.exp: check_x87_regs_around_init: check post FLD1 value of .fioff" + # https://sourceware.org/bugzilla/show_bug.cgi?id=24845 "FAIL: gdb.base/step-over-syscall.exp: clone: displaced=off: single step over clone" "FAIL: gdb.base/step-over-syscall.exp: clone: displaced=off: continue to marker \(clone\)" + # https://sourceware.org/bugzilla/show_bug.cgi?id=19436#c1 "FAIL: gdb.cp/no-dmgl-verbose.exp: setting breakpoint at 'f\(std::string\)'" + # https://sourceware.org/bugzilla/show_bug.cgi?id=25504 "FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: .*: continue" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28065 "FAIL: gdb.threads/access-mem-running-thread-exit.exp:" + # https://sourceware.org/bugzilla/show_bug.cgi?id=25503 "FAIL: gdb.threads/signal-while-stepping-over-bp-other-thread.exp: step \(pattern 3\)" + # https://sourceware.org/bugzilla/show_bug.cgi?id=26915 "FAIL: gdb.threads/schedlock.exp: schedlock=off: .*: other threads ran - unlocked" "FAIL: gdb.threads/watchthreads-threaded.exp: watchpoint on args\[[1-3]\] hit in thread" "FAIL: gdb.threads/watchthreads-threaded.exp: watch args\[[1-3]\]" "FAIL: gdb.threads/watchthreads-threaded.exp: threaded watch loop" "FAIL: gdb.threads/watchthreads-threaded.exp: combination of threaded watchpoints = 30 \+ initial values" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28479 "FAIL: gdb.mi/mi-nonstop.exp: wait for thread exit \(timeout\)" + # https://sourceware.org/bugzilla/show_bug.cgi?id=26273 "FAIL: gdb.threads/gcore-stale-thread.exp: save a corefile" "FAIL: gdb.threads/gcore-stale-thread.exp: exited thread is current due to non-stop" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28467 # -pie, x86_64 -m32 or i586. "FAIL: gdb.base/nodebug.exp: p/c \(int\) array_index\(\"abcdef\",2\)" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28617 "FAIL: gdb.base/info-os.exp: get process groups \(timeout\)" "FAIL: gdb.base/info-os.exp: get threads \(timeout\)" @@ -174,6 +184,7 @@ kfail=( # https://sourceware.org/bugzilla/show_bug.cgi?id=26363 "FAIL: gdb.xml/tdesc-reload.exp: .*internal error" + # https://sourceware.org/bugzilla/show_bug.cgi?id=26761 "FAIL: gdb.base/gdb-sigterm.exp: .*internal error" @@ -432,28 +443,28 @@ kfail_sle11=( kfail_factory=( - # https://sourceware.org/bugzilla/show_bug.cgi?id=28463 - "FAIL: gdb.ada/set_pckd_arr_elt.exp: scenario=minimal: print va.t\(1\) := 15" - "FAIL: gdb.ada/set_pckd_arr_elt.exp: scenario=minimal: continue to update_small for va.t" - # https://sourceware.org/bugzilla/show_bug.cgi?id=28108 - "FAIL: gdb.base/langs.exp: up to foo in langs.exp" - "FAIL: gdb.base/langs.exp: up to cppsub_ in langs.exp" - "FAIL: gdb.base/langs.exp: up to fsub in langs.exp" # https://sourceware.org/pipermail/gdb-patches/2021-October/182449.html "FAIL: gdb.threads/current-lwp-dead.exp: continue to breakpoint: fn_return" + # Similar error message to the one above, see if fixing that one fixes this. "FAIL: gdb.threads/clone-new-thread-event.exp: catch SIGUSR1" + # https://sourceware.org/bugzilla/show_bug.cgi?id=27238 "FAIL: gdb.go/package.exp: gdb_breakpoint: set breakpoint at package2.Foo" "FAIL: gdb.go/package.exp: going to first breakpoint \(the program exited\)" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28551 "FAIL: gdb.go/package.exp: going to first breakpoint \\(GDB internal error\\)" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28468 "FAIL: gdb.threads/signal-command-handle-nopass.exp: step-over (yes|no): signal SIGUSR1" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28477 "FAIL: gdb.base/step-over-syscall.exp: clone: displaced=off: continue to marker \(clone\)" + # https://sourceware.org/bugzilla/show_bug.cgi?id=26867 "FAIL: gdb.threads/signal-sigtrap.exp: sigtrap thread 1: signal SIGTRAP reaches handler" + # https://sourceware.org/bugzilla/show_bug.cgi?id=28510 "FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: br main" "FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: l" @@ -461,21 +472,10 @@ kfail_factory=( # https://sourceware.org/bugzilla/show_bug.cgi?id=28667 "FAIL: gdb.reverse/watch-precsave.exp: watchpoint hit, fourth time \\(GDB internal error\\)" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29160 - "FAIL: gdb.ctf/.*.exp" - "FAIL: gdb.base/ctf-.*.exp" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29196 "FAIL: gdb.base/gdb11531.exp: watchpoint variable triggers at next" "FAIL: gdb.base/gdb11531.exp: watchpoint variable triggers at continue" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29247 - "FAIL: gdb.base/varargs.exp: print find_max_long_double_real\(4, ldc1, ldc2, ldc3, ldc4\)" - - # We get "value has been optimized out", which is possible for an optimized gdb, due - # to optimization of function c_print_type. - "FAIL: gdb.gdb/python-helper.exp: print \*type->main_type" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29253 "FAIL: gdb.server/stop-reply-no-thread.exp: to_disable=threads: continue to main \(timeout\)" "FAIL: gdb.server/stop-reply-no-thread.exp: to_disable=threads: continue until exit \(timeout\)" @@ -483,17 +483,6 @@ kfail_factory=( # https://sourceware.org/bugzilla/show_bug.cgi?id=29706 "FAIL: gdb.base/eof-exit.exp: with non-dump terminal: with bracketed-paste-mode on: close GDB with eof \(missed the prompt\)" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29965 - "FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=.*: continue \(the program exited\)" - - # https://sourceware.org/pipermail/gdb-patches/2023-September/202757.html - "FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 \(unexpected output\)" - - # https://sourceware.org/bugzilla/show_bug.cgi?id=30908 - "FAIL: gdb.ada/str_binop_equal.exp: print my_str = \"ABCD\"" - "FAIL: gdb.ada/widewide.exp: print my_wws = \" helo\"" - "FAIL: gdb.ada/widewide.exp: print my_ws = \"wide\"" - # Looks like a problem with modern debug info, where stepping out of a # function takes more one step. "FAIL: gdb.base/rtld-step.exp: finish out of foo 1" @@ -506,10 +495,6 @@ kfail_factory=( # Sets breakpoints in gdb build with lto. This is known to be slow, and # likely to cause timeouts. gdb.gdb/python-helper.exp - - # https://sourceware.org/bugzilla/show_bug.cgi?id=30540 - FAIL: gdb.base/auxv.exp: info auxv on live process - FAIL: gdb.base/auxv.exp: info auxv on gcore-created dump ) # kfail_factory From ee9e61fe99f6e87a99e5d29b967c6aa2e56f4d14152318456bd592d327ba52fb Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Thu, 26 Oct 2023 10:49:31 +0000 Subject: [PATCH 05/10] - Patches added (backport from master): * gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch - Patches dropped (requires unsupported command): * gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch - Maintenance script qa.sh: * Added PR30528 kfail. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=366 --- ...t-deduplicate-variables-in-gdb-index.patch | 81 +++++++++++++++++++ ...d-wait-for-index-cache-in-gdb.dwarf2.patch | 53 ------------ gdb.changes | 10 +++ gdb.spec | 4 +- qa.sh | 3 + 5 files changed, 96 insertions(+), 55 deletions(-) create mode 100644 gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch delete mode 100644 gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch diff --git a/gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch b/gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch new file mode 100644 index 0000000..4abe95f --- /dev/null +++ b/gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch @@ -0,0 +1,81 @@ +From 04d0d6ebdc6d08f5a7ec0d4c89eb1835deef54dc Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Sun, 13 Aug 2023 14:08:06 +0200 +Subject: [PATCH] [gdb/symtab] Don't deduplicate variables in gdb-index + +When running test-case gdb.python/py-symbol.exp with target board +cc-with-gdb-index, we run into: +... +(gdb) python print (len (gdb.lookup_static_symbols ('rr')))^M +1^M +(gdb) FAIL: gdb.python/py-symbol.exp: print (len (gdb.lookup_static_symbols ('rr'))) +... + +[ Note that the test-case contains rr in both py-symtab.c: +... +static int __attribute__ ((used)) rr = 42; /* line of rr */ +... +and py-symtab-2.c: +... +static int __attribute__ ((used)) rr = 99; /* line of other rr */ +... ] + +This passes with gdb-12-branch, and fails with gdb-13-branch. + +AFAIU the current code in symtab_index_entry::minimize makes the assumption +that it's fine to store only one copy of rr in the gdb-index, because +"print rr" will only ever print one, and always the same. + +But that fails to recognize that gdb supports gdb.lookup_static_symbols, which +returns a list of variables rather than the first one. + +In other words, the current approach breaks feature parity between cooked +index and gdb-index. + +Note btw that also debug-names has both instances: +... +[ 5] #00597969 rr: + <4> DW_TAG_variable DW_IDX_compile_unit=3 DW_IDX_GNU_internal=1 + <4> DW_TAG_variable DW_IDX_compile_unit=4 DW_IDX_GNU_internal=1 +... + +Fix this in symtab_index_entry::minimize, by not deduplicating variables. + +Tested on x86_64-linux, with target boards unix and cc-with-gdb-index. + +Reviewed-by: Kevin Buettner <kevinb@redhat.com> + +PR symtab/30720 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30720 +--- + gdb/dwarf2/index-write.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c +index d10583568c0..ea67f73ac3c 100644 +--- a/gdb/dwarf2/index-write.c ++++ b/gdb/dwarf2/index-write.c +@@ -294,7 +294,7 @@ symtab_index_entry::minimize () + auto from = std::unique (cu_indices.begin (), cu_indices.end ()); + cu_indices.erase (from, cu_indices.end ()); + +- /* We don't want to enter a variable or type more than once, so ++ /* We don't want to enter a type more than once, so + remove any such duplicates from the list as well. When doing + this, we want to keep the entry from the first CU -- but this is + implicit due to the sort. This choice is done because it's +@@ -304,8 +304,7 @@ symtab_index_entry::minimize () + [&] (offset_type val) + { + gdb_index_symbol_kind kind = GDB_INDEX_SYMBOL_KIND_VALUE (val); +- if (kind != GDB_INDEX_SYMBOL_KIND_TYPE +- && kind != GDB_INDEX_SYMBOL_KIND_VARIABLE) ++ if (kind != GDB_INDEX_SYMBOL_KIND_TYPE) + return false; + + val &= ~GDB_INDEX_CU_MASK; + +base-commit: 2521ac7ed0c495b9e804c4356939b9be7166853c +-- +2.35.3 + diff --git a/gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch b/gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch deleted file mode 100644 index 1050225..0000000 --- a/gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 2521ac7ed0c495b9e804c4356939b9be7166853c Mon Sep 17 00:00:00 2001 -From: Tom de Vries <tdevries@suse.de> -Date: Thu, 26 Oct 2023 10:34:24 +0200 -Subject: [PATCH] [gdb/testsuite] Add wait-for-index-cache in - gdb.dwarf2/per-bfd-sharing.exp - -If we make writing an index-cache entry very slow by doing this in -index_cache::store: -... - try - { -+ sleep (15); - index_cache_debug ("writing index cache for objfile %s", - bfd_get_filename (per_bfd->obfd)); -... -we run into: -... -FAIL: gdb.dwarf2/per-bfd-sharing.exp: \ - couldn't remove files in temporary cache dir -... - -The FAIL happens because there is no index-cache entry in the cache dir. - -The problem is that gdb is killed (by gdb_exit) before the index-cache entry -is written. - -Fix this by using "maint wait-for-index-cache". - -Tested on x86_64-linux. - -PR testsuite/30528 -Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30528 ---- - gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp -index 46284c2b775..7bdf59fbcd1 100644 ---- a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp -+++ b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp -@@ -47,6 +47,7 @@ with_test_prefix "populate index cache" { - "set index-cache directory" - gdb_test_no_output "set index-cache enabled on" - gdb_test "file $binfile" "Reading symbols from .*" "file" -+ gdb_test_no_output "maint wait-for-index-cache" - } - - proc load_binary { method } { - -base-commit: b7f9471d211d35eba33b86e073268b4a89b78a92 --- -2.35.3 - diff --git a/gdb.changes b/gdb.changes index 06588cb..571fc7b 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Thu Oct 26 09:24:04 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Patches added (backport from master): + * gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch +- Patches dropped (requires unsupported command): + * gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch +- Maintenance script qa.sh: + * Added PR30528 kfail. + ------------------------------------------------------------------- Tue Oct 24 13:39:35 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/gdb.spec b/gdb.spec index f7402f5..0a78447 100644 --- a/gdb.spec +++ b/gdb.spec @@ -330,11 +330,11 @@ Patch2036: gdb-testsuite-add-xfail-for-gdb-29965-in-gdb.threads.patch Patch2037: gdb-cli-handle-pending-c-after-rl_callback_read_char.patch Patch2038: gdb-testsuite-add-have_host_locale.patch Patch2039: gdb-symtab-find-main-language-without-symtab-expansi.patch +Patch2040: gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch # Backports from master, not yet available in next release. Patch2070: gdb-symtab-work-around-pr-gas-29517.patch -Patch2071: gdb-testsuite-add-wait-for-index-cache-in-gdb.dwarf2.patch # Backport from gdb-patches @@ -766,9 +766,9 @@ find -name "*.info*"|xargs rm -f %patch2037 -p1 %patch2038 -p1 %patch2039 -p1 +%patch2040 -p1 %patch2070 -p1 -%patch2071 -p1 %patch2100 -p1 %patch2101 -p1 diff --git a/qa.sh b/qa.sh index 5297213..6d7bdec 100644 --- a/qa.sh +++ b/qa.sh @@ -303,6 +303,9 @@ kfail=( # https://sourceware.org/bugzilla/show_bug.cgi?id=30521 "FAIL: gdb.base/printcmds.exp: print {unsigned char\[\]}{0xffffffff}" + # https://sourceware.org/bugzilla/show_bug.cgi?id=30528 + "FAIL: gdb.dwarf2/per-bfd-sharing.exp: couldn't remove files in temporary cache dir" + ) # kfail kfail_sle12=( From 6827fe201627357b12176385d26c8fb4ab35d83358555cf3bc7379e4596d391b Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Sun, 29 Oct 2023 08:12:22 +0000 Subject: [PATCH 06/10] - Maintenance script qa.sh: * Add comment to kfail for PR30528. * Add UNRESOLVED kfail for gdb.base/gcore-excessive-memory.exp. * Add UNRESOLVED kfail for PR31001. * Remove PR27238 kfail. * Add powerpc64le hw watchpoint kfails. * Add PR31004 kfail. * Add PR30531 kfail. - Patches added (backport from master): * xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch * avoid-manual-memory-management-in-go-lang.c.patch * gdb-go-handle-v3-go_0-mangled-prefix.patch OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=367 --- ...anual-memory-management-in-go-lang.c.patch | 202 ++++++++++++++++++ gdb-go-handle-v3-go_0-mangled-prefix.patch | 138 ++++++++++++ gdb.changes | 16 ++ gdb.spec | 6 + qa.sh | 58 ++++- ...werror-dangling-pointer-issue-with-m.patch | 139 ++++++++++++ 6 files changed, 554 insertions(+), 5 deletions(-) create mode 100644 avoid-manual-memory-management-in-go-lang.c.patch create mode 100644 gdb-go-handle-v3-go_0-mangled-prefix.patch create mode 100644 xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch diff --git a/avoid-manual-memory-management-in-go-lang.c.patch b/avoid-manual-memory-management-in-go-lang.c.patch new file mode 100644 index 0000000..093f577 --- /dev/null +++ b/avoid-manual-memory-management-in-go-lang.c.patch @@ -0,0 +1,202 @@ +From 4e0e7ff14ba271576232160bf337639662a2ea23 Mon Sep 17 00:00:00 2001 +From: Tom Tromey <tom@tromey.com> +Date: Thu, 16 Feb 2023 17:36:29 -0700 +Subject: [PATCH 2/3] Avoid manual memory management in go-lang.c + +I noticed a couple of spots in go-lang.c that could be improved by +using unique_ptr. + +Reviewed-By: Andrew Burgess <aburgess@redhat.com> +--- + gdb/dwarf2/read.c | 2 +- + gdb/go-exp.c | 287 +++++++++++++++++++++++----------------------- + gdb/go-exp.y | 8 +- + gdb/go-lang.c | 40 +++---- + gdb/go-lang.h | 11 +- + 5 files changed, 173 insertions(+), 175 deletions(-) + +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +index 8aa7f8c31e5..61f4bd75013 100644 +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -7890,7 +7890,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) + && sym->aclass () == LOC_BLOCK) + { + gdb::unique_xmalloc_ptr<char> this_package_name +- (go_symbol_package_name (sym)); ++ = go_symbol_package_name (sym); + + if (this_package_name == NULL) + continue; +diff --git a/gdb/go-exp.y b/gdb/go-exp.y +index cbaa79ee18c..542a06d06d6 100644 +--- a/gdb/go-exp.y ++++ b/gdb/go-exp.y +@@ -1393,16 +1393,16 @@ classify_name (struct parser_state *par_state, const struct block *block) + current package. */ + + { +- char *current_package_name = go_block_package_name (block); ++ gdb::unique_xmalloc_ptr<char> current_package_name ++ = go_block_package_name (block); + + if (current_package_name != NULL) + { + struct stoken sval = +- build_packaged_name (current_package_name, +- strlen (current_package_name), ++ build_packaged_name (current_package_name.get (), ++ strlen (current_package_name.get ()), + copy.c_str (), copy.size ()); + +- xfree (current_package_name); + sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN, + &is_a_field_of_this); + if (sym.symbol) +diff --git a/gdb/go-lang.c b/gdb/go-lang.c +index 7549f14dc63..f9176ace71d 100644 +--- a/gdb/go-lang.c ++++ b/gdb/go-lang.c +@@ -163,11 +163,8 @@ unpack_package_and_object (char *buf, + + Space for the resulting strings is malloc'd in one buffer. + PACKAGEP,OBJECTP,METHOD_TYPE* will (typically) point into this buffer. +- [There are a few exceptions, but the caller is still responsible for +- freeing the resulting pointer.] + A pointer to this buffer is returned, or NULL if symbol isn't a + mangled Go symbol. +- The caller is responsible for freeing the result. + + *METHOD_TYPE_IS_POINTERP is set to a boolean indicating if + the method type is a pointer. +@@ -180,7 +177,7 @@ unpack_package_and_object (char *buf, + If we ever need to unpack the method type, this routine should work + for that too. */ + +-static char * ++static gdb::unique_xmalloc_ptr<char> + unpack_mangled_go_symbol (const char *mangled_name, + const char **packagep, + const char **objectp, +@@ -209,9 +206,10 @@ unpack_mangled_go_symbol (const char *mangled_name, + /* main.init is mangled specially. */ + if (strcmp (mangled_name, "__go_init_main") == 0) + { +- char *package = xstrdup ("main"); ++ gdb::unique_xmalloc_ptr<char> package ++ = make_unique_xstrdup ("main"); + +- *packagep = package; ++ *packagep = package.get (); + *objectp = "init"; + return package; + } +@@ -219,9 +217,10 @@ unpack_mangled_go_symbol (const char *mangled_name, + /* main.main is mangled specially (missing prefix). */ + if (strcmp (mangled_name, "main.main") == 0) + { +- char *package = xstrdup ("main"); ++ gdb::unique_xmalloc_ptr<char> package ++ = make_unique_xstrdup ("main"); + +- *packagep = package; ++ *packagep = package.get (); + *objectp = "main"; + return package; + } +@@ -261,7 +260,8 @@ unpack_mangled_go_symbol (const char *mangled_name, + + /* At this point we've decided we have a mangled Go symbol. */ + +- buf = xstrdup (mangled_name); ++ gdb::unique_xmalloc_ptr<char> result = make_unique_xstrdup (mangled_name); ++ buf = result.get (); + + /* Search backwards looking for "N<digit(s)>". */ + p = buf + len; +@@ -317,7 +317,7 @@ unpack_mangled_go_symbol (const char *mangled_name, + } + + unpack_package_and_object (buf, packagep, objectp); +- return buf; ++ return result; + } + + /* Implements the la_demangle language_defn routine for language Go. +@@ -381,10 +381,9 @@ go_language::demangle_symbol (const char *mangled_name, int options) const + return make_unique_xstrdup ((const char *) obstack_finish (&tempbuf)); + } + +-/* Given a Go symbol, return its package or NULL if unknown. +- Space for the result is malloc'd, caller must free. */ ++/* See go-lang.h. */ + +-char * ++gdb::unique_xmalloc_ptr<char> + go_symbol_package_name (const struct symbol *sym) + { + const char *mangled_name = sym->linkage_name (); +@@ -393,8 +392,7 @@ go_symbol_package_name (const struct symbol *sym) + const char *method_type_package_name; + const char *method_type_object_name; + int method_type_is_pointer; +- char *name_buf; +- char *result; ++ gdb::unique_xmalloc_ptr<char> name_buf; + + gdb_assert (sym->language () == language_go); + name_buf = unpack_mangled_go_symbol (mangled_name, +@@ -405,15 +403,12 @@ go_symbol_package_name (const struct symbol *sym) + /* Some Go symbols don't have mangled form we interpret (yet). */ + if (name_buf == NULL) + return NULL; +- result = xstrdup (package_name); +- xfree (name_buf); +- return result; ++ return make_unique_xstrdup (package_name); + } + +-/* Return the package that BLOCK is in, or NULL if there isn't one. +- Space for the result is malloc'd, caller must free. */ ++/* See go-lang.h. */ + +-char * ++gdb::unique_xmalloc_ptr<char> + go_block_package_name (const struct block *block) + { + while (block != NULL) +@@ -422,7 +417,8 @@ go_block_package_name (const struct block *block) + + if (function != NULL) + { +- char *package_name = go_symbol_package_name (function); ++ gdb::unique_xmalloc_ptr<char> package_name ++ = go_symbol_package_name (function); + + if (package_name != NULL) + return package_name; +diff --git a/gdb/go-lang.h b/gdb/go-lang.h +index f0929cc3ac5..8edfe6ed53a 100644 +--- a/gdb/go-lang.h ++++ b/gdb/go-lang.h +@@ -62,9 +62,14 @@ extern const char *go_main_name (void); + + extern enum go_type go_classify_struct_type (struct type *type); + +-extern char *go_symbol_package_name (const struct symbol *sym); +- +-extern char *go_block_package_name (const struct block *block); ++/* Given a Go symbol, return its package or nullptr if unknown. */ ++extern gdb::unique_xmalloc_ptr<char> go_symbol_package_name ++ (const struct symbol *sym); ++ ++/* Return the package that BLOCK is in, or nullptr if there isn't ++ one. */ ++extern gdb::unique_xmalloc_ptr<char> go_block_package_name ++ (const struct block *block); + + extern const struct builtin_go_type *builtin_go_type (struct gdbarch *); + +-- +2.35.3 + diff --git a/gdb-go-handle-v3-go_0-mangled-prefix.patch b/gdb-go-handle-v3-go_0-mangled-prefix.patch new file mode 100644 index 0000000..58676f1 --- /dev/null +++ b/gdb-go-handle-v3-go_0-mangled-prefix.patch @@ -0,0 +1,138 @@ +From 6c9e159dbd1a35aafa134fcd52982174236a8dd9 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Thu, 5 Oct 2023 23:22:11 +0200 +Subject: [PATCH 3/3] [gdb/go] Handle v3 go_0 mangled prefix + +With gcc-10 we have: +... +(gdb) break package2.Foo^M +Breakpoint 2 at 0x402563: file package2.go, line 5.^M +(gdb) PASS: gdb.go/package.exp: setting breakpoint 1 +... +but with gcc-11: +... +gdb) break package2.Foo^M +Function "package2.Foo" not defined.^M +Make breakpoint pending on future shared library load? (y or [n]) n^M +(gdb) FAIL: gdb.go/package.exp: gdb_breakpoint: set breakpoint at package2.Foo +... + +In the gcc-10 case, though the exec contains dwarf, it's not used to set the +breakpoint (which is an independent problem, filed as PR go/30941), instead +the minimal symbol information is used. + +The minimal symbol information changed between gcc-10 and gcc-11: +... +$ nm a.out.10 | grep Foo +000000000040370d T go.package2.Foo +0000000000404e50 R go.package2.Foo..f +$ nm a.out.11 | grep Foo +0000000000403857 T go_0package2.Foo +0000000000405030 R go_0package2.Foo..f +... + +A new v3 mangling scheme was used. The mangling schemes define a separator +character and mangling character: +- for v2, dot is used both as separator character and mangling character, and +- for v3, dot is used as separator character and underscore as mangling + character. + +For more details, see [1] and [2]. + +In v3, "_0" demangles to ".". [ See gcc commit a01dda3c23b ("compiler, libgo: +change mangling scheme"), function Special_char_code::Special_char_code. ] + +Handle the new go_0 prefix in unpack_mangled_go_symbol, which fixes the +test-case. + +Note that this doesn't fix this regression: +... +$ gccgo-10 package2.go -c -g0 +$ gccgo-10 package1.go package2.o -g0 +$ gdb -q -batch a.out -ex "break go.package2.Foo" +Breakpoint 1 at 0x40370d +$ gccgo-11 package2.go -c -g0 +$ gccgo-11 package1.go package2.o -g0 +$ gdb -q -batch a.out -ex "break go.package2.Foo" +Function "go.package2.Foo" not defined. +... + +With gcc-10, we set a breakpoint on the mangled minimal symbol. That +one has simply changed for gcc-11, so it's equivalent to using: +... +$ gdb -q -batch a.out -ex "break go_0package2.Foo" +Breakpoint 1 at 0x403857 +... +which does work. + +Tested on x86_64-linux: +- openSUSE Leap 15.4, using gccgo-7, +- openSUSE Tumbleweed, using gccgo-13. + +PR go/27238 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27238 + +[1] https://go-review.googlesource.com/c/gofrontend/+/271726 +[2] https://github.com/golang/go/issues/41862#issuecomment-707244103 +--- + gdb/go-lang.c | 30 +++++++++++++++++++++++++++--- + 1 file changed, 27 insertions(+), 3 deletions(-) + +diff --git a/gdb/go-lang.c b/gdb/go-lang.c +index f9176ace71d..8a5568f56e0 100644 +--- a/gdb/go-lang.c ++++ b/gdb/go-lang.c +@@ -233,16 +233,28 @@ unpack_mangled_go_symbol (const char *mangled_name, + libgo_.*: used by gccgo's runtime + + Thus we don't support -fgo-prefix (except as used by the runtime). */ +- if (!startswith (mangled_name, "go.") +- && !startswith (mangled_name, "libgo_")) ++ bool v3; ++ if (startswith (mangled_name, "go_0")) ++ /* V3 mangling detected, see ++ https://go-review.googlesource.com/c/gofrontend/+/271726 . */ ++ v3 = true; ++ else if (startswith (mangled_name, "go.") ++ || startswith (mangled_name, "libgo_")) ++ v3 = false; ++ else + return NULL; + + /* Quick check for whether a search may be fruitful. */ + /* Ignore anything with @plt, etc. in it. */ + if (strchr (mangled_name, '@') != NULL) + return NULL; ++ + /* It must have at least two dots. */ +- first_dot = strchr (mangled_name, '.'); ++ if (v3) ++ first_dot = strchr (mangled_name, '0'); ++ else ++ first_dot = strchr (mangled_name, '.'); ++ + if (first_dot == NULL) + return NULL; + /* Treat "foo.bar" as unmangled. It can collide with lots of other +@@ -263,6 +275,18 @@ unpack_mangled_go_symbol (const char *mangled_name, + gdb::unique_xmalloc_ptr<char> result = make_unique_xstrdup (mangled_name); + buf = result.get (); + ++ if (v3) ++ { ++ /* Replace "go_0" with "\0go.". */ ++ buf[0] = '\0'; ++ buf[1] = 'g'; ++ buf[2] = 'o'; ++ buf[3] = '.'; ++ ++ /* Skip the '\0'. */ ++ buf++; ++ } ++ + /* Search backwards looking for "N<digit(s)>". */ + p = buf + len; + saw_digit = method_type = NULL; +-- +2.35.3 + diff --git a/gdb.changes b/gdb.changes index 571fc7b..49476c9 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Thu Oct 26 12:51:55 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Maintenance script qa.sh: + * Add comment to kfail for PR30528. + * Add UNRESOLVED kfail for gdb.base/gcore-excessive-memory.exp. + * Add UNRESOLVED kfail for PR31001. + * Remove PR27238 kfail. + * Add powerpc64le hw watchpoint kfails. + * Add PR31004 kfail. + * Add PR30531 kfail. +- Patches added (backport from master): + * xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch + * avoid-manual-memory-management-in-go-lang.c.patch + * gdb-go-handle-v3-go_0-mangled-prefix.patch + ------------------------------------------------------------------- Thu Oct 26 09:24:04 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/gdb.spec b/gdb.spec index 0a78447..b14993f 100644 --- a/gdb.spec +++ b/gdb.spec @@ -331,6 +331,9 @@ Patch2037: gdb-cli-handle-pending-c-after-rl_callback_read_char.patch Patch2038: gdb-testsuite-add-have_host_locale.patch Patch2039: gdb-symtab-find-main-language-without-symtab-expansi.patch Patch2040: gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch +Patch2041: xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch +Patch2042: avoid-manual-memory-management-in-go-lang.c.patch +Patch2043: gdb-go-handle-v3-go_0-mangled-prefix.patch # Backports from master, not yet available in next release. @@ -767,6 +770,9 @@ find -name "*.info*"|xargs rm -f %patch2038 -p1 %patch2039 -p1 %patch2040 -p1 +%patch2041 -p1 +%patch2042 -p1 +%patch2043 -p1 %patch2070 -p1 diff --git a/qa.sh b/qa.sh index 6d7bdec..6fe694e 100644 --- a/qa.sh +++ b/qa.sh @@ -304,6 +304,7 @@ kfail=( "FAIL: gdb.base/printcmds.exp: print {unsigned char\[\]}{0xffffffff}" # https://sourceware.org/bugzilla/show_bug.cgi?id=30528 + # Fixed in 15. Backportable to 14. "FAIL: gdb.dwarf2/per-bfd-sharing.exp: couldn't remove files in temporary cache dir" ) # kfail @@ -394,6 +395,10 @@ kfail_sle12=( "FAIL: gdb.fortran/module.exp: print var_d" "FAIL: gdb.fortran/module.exp: print var_x value 31" + # https://sourceware.org/bugzilla/show_bug.cgi?id=30531 + "FAIL: gdb.threads/clone-thread_db.exp: continue to clone_fn \(the program exited\)" + "FAIL: gdb.threads/clone-thread_db.exp: continue to end \(the program is no longer running\)" + ) # kfail_sle12 kfail_sle11=( @@ -452,10 +457,6 @@ kfail_factory=( # Similar error message to the one above, see if fixing that one fixes this. "FAIL: gdb.threads/clone-new-thread-event.exp: catch SIGUSR1" - # https://sourceware.org/bugzilla/show_bug.cgi?id=27238 - "FAIL: gdb.go/package.exp: gdb_breakpoint: set breakpoint at package2.Foo" - "FAIL: gdb.go/package.exp: going to first breakpoint \(the program exited\)" - # https://sourceware.org/bugzilla/show_bug.cgi?id=28551 "FAIL: gdb.go/package.exp: going to first breakpoint \\(GDB internal error\\)" @@ -613,9 +614,51 @@ kfail_powerpc64le=( # https://sourceware.org/bugzilla/show_bug.cgi?id=30542 "FAIL: gdb.base/watch-before-fork.exp: test: continue to catch fork" - # https://sourceware.org/bugzilla/show_bug.cgi?id=30543 "FAIL: gdb.python/py-send-packet.exp: call python run_auxv_send_packet_test function" + + # Cluster of fails related to hw watchpoint support. + "FAIL: gdb.ada/scoped_watch.exp:" + "FAIL: gdb.ada/task_watch.exp:" + "FAIL: gdb.ada/watch_minus_l.exp:" + "FAIL: gdb.base/watch-before-fork.exp:" + "FAIL: gdb.base/watch-bitfields.exp:" + "FAIL: gdb.base/watch-cond.exp:" + "FAIL: gdb.base/watch-cond-infcall.exp:" + "FAIL: gdb.base/watchpoint-during-step.exp:" + "FAIL: gdb.base/watchpoint.exp:" + "FAIL: gdb.base/watchpoint-hw-attach.exp:" + "FAIL: gdb.base/watchpoint-hw-hit-once.exp:" + "FAIL: gdb.base/watchpoints.exp:" + "FAIL: gdb.base/watchpoint-solib.exp:" + "FAIL: gdb.base/watchpoint-stops-at-right-insn.exp:" + "FAIL: gdb.base/watchpoint-unaligned.exp:" + "FAIL: gdb.base/watch-read.exp:" + "FAIL: gdb.base/watch_thread_num.exp:" + "FAIL: gdb.base/watch-vfork.exp:" + "FAIL: gdb.cp/watch-cp.exp:" + "FAIL: gdb.mi/mi-watch.exp:" + "FAIL: gdb.threads/step-over-trips-on-watchpoint.exp:" + "FAIL: gdb.threads/watchpoint-fork.exp:" + "FAIL: gdb.threads/watchthreads2.exp:" + "FAIL: gdb.threads/wp-replication.exp:" + "FAIL: gdb.base/display.exp:" + "FAIL: gdb.base/recurse.exp:" + "FAIL: gdb.base/gdb11531.exp:" + "FAIL: gdb.base/pr11022.exp:" + "FAIL: gdb.base/value-double-free.exp: continue \(the program exited\)" + "FAIL: gdb.base/value-double-free.exp: print empty\(\)" + "FAIL: gdb.cp/annota2.exp: watch triggered on a.x \(timeout\)" + "FAIL: gdb.cp/annota2.exp: annotate-quit" + "FAIL: gdb.cp/annota3.exp: watch triggered on a.x \(timeout\)" + "FAIL: gdb.cp/annota3.exp: annotate-quit \(pattern 1\)" + "FAIL: gdb.mi/pr11022.exp:" + "FAIL: gdb.python/py-breakpoint.exp: test_watchpoints: Test watchpoint write \(the program exited\)" + "FAIL: gdb.python/py-breakpoint.exp: test_bkpt_internal: Test watchpoint write \(the program exited\)" + "FAIL: gdb.python/py-breakpoint.exp: test_bkpt_eval_funcs: Test watchpoint write \(the program exited\)" + + # https://sourceware.org/bugzilla/show_bug.cgi?id=31004 + "FAIL: gdb.base/run-control-while-bg-execution.exp: action1=kill: action2=run: run" ) kfail_powerpc64le_sle12=( @@ -744,11 +787,16 @@ case $n in # https://sourceware.org/bugzilla/show_bug.cgi?id=28323 "SLE-12.x86_64.*gdb.ada/mi_dyn_arr.exp" + # Gdb runs out of virtual memory, we can expect an internal error. + "UNRESOLVED: gdb.base/gcore-excessive-memory.exp: attach" "UNRESOLVED: gdb.base/gcore-excessive-memory.exp: verify we can get to main" # https://sourceware.org/bugzilla/show_bug.cgi?id=30547 "UNRESOLVED: gdb.base/vfork-follow-parent.exp: resolution_method=schedule-multiple: print unblock_parent = 1" "UNRESOLVED: gdb.base/vfork-follow-parent.exp: resolution_method=schedule-multiple: continue to break_parent" + + # https://sourceware.org/bugzilla/show_bug.cgi?id=31001 + "UNRESOLVED: gdb.threads/async.exp: thread 1: current thread is 1" ) kfail_re=$(join "|" "${kfail[@]}") diff --git a/xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch b/xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch new file mode 100644 index 0000000..db00512 --- /dev/null +++ b/xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch @@ -0,0 +1,139 @@ +From c835eac78b389ce1e29aade9d0468c13854c1cb9 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard <mark@klomp.org> +Date: Sat, 29 Apr 2023 22:46:11 +0200 +Subject: [PATCH 1/3] xcoffread.c: Fix -Werror=dangling-pointer= issue with + main_subfile. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +GCC 13 points out that main_subfile has local function scope, but a +pointer to it is assigned to the global inclTable array subfile +element field: + +In function ‘void process_linenos(CORE_ADDR, CORE_ADDR)’, + inlined from ‘void aix_process_linenos(objfile*)’ at xcoffread.c:727:19, + inlined from ‘void aix_process_linenos(objfile*)’ at xcoffread.c:720:1: +xcoffread.c:629:37: error: storing the address of local variable ‘main_subfile’ in ‘*inclTable.19_45 + _28._inclTable::subfile’ [-Werror=dangling-pointer=] + 629 | inclTable[ii].subfile = &main_subfile; + | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ +xcoffread.c: In function ‘void aix_process_linenos(objfile*)’: +xcoffread.c:579:18: note: ‘main_subfile’ declared here + 579 | struct subfile main_subfile; + | ^~~~~~~~~~~~ +xcoffread.c:496:19: note: ‘inclTable’ declared here + 496 | static InclTable *inclTable; /* global include table */ + | ^~~~~~~~~ + +Fix this by making main_subfile file static. And allocate and +deallocated together with inclTable in allocate_include_entry and +xcoff_symfile_finish. Adjust the use of main_subfile in +process_linenos to take a pointer to the subfile. +--- + gdb/xcoffread.c | 24 +++++++++++++----------- + 1 file changed, 13 insertions(+), 11 deletions(-) + +diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c +index 52ae3aecb97..53779259b57 100644 +--- a/gdb/xcoffread.c ++++ b/gdb/xcoffread.c +@@ -501,6 +501,9 @@ static int inclIndx; /* last entry to table */ + static int inclLength; /* table length */ + static int inclDepth; /* nested include depth */ + ++/* subfile structure for the main compilation unit. */ ++static subfile *main_subfile; ++ + static void allocate_include_entry (void); + + static void +@@ -551,6 +554,7 @@ allocate_include_entry (void) + inclTable = XCNEWVEC (InclTable, INITIAL_INCLUDE_TABLE_LENGTH); + inclLength = INITIAL_INCLUDE_TABLE_LENGTH; + inclIndx = 0; ++ main_subfile = new subfile; + } + else if (inclIndx >= inclLength) + { +@@ -578,9 +582,6 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + file_ptr max_offset + = XCOFF_DATA (this_symtab_objfile)->max_lineno_offset; + +- /* subfile structure for the main compilation unit. */ +- struct subfile main_subfile; +- + /* In the main source file, any time we see a function entry, we + reset this variable to function's absolute starting line number. + All the following line numbers in the function are relative to +@@ -599,7 +600,7 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + /* All source lines were in the main source file. None in include + files. */ + +- enter_line_range (&main_subfile, offset, 0, start, end, ++ enter_line_range (main_subfile, offset, 0, start, end, + &main_source_baseline); + + else +@@ -616,7 +617,7 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + if (offset < inclTable[ii].begin) + { + enter_line_range +- (&main_subfile, offset, inclTable[ii].begin - linesz, ++ (main_subfile, offset, inclTable[ii].begin - linesz, + start, 0, &main_source_baseline); + } + +@@ -627,9 +628,9 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + + main_source_baseline = inclTable[ii].funStartLine; + enter_line_range +- (&main_subfile, inclTable[ii].begin, inclTable[ii].end, ++ (main_subfile, inclTable[ii].begin, inclTable[ii].end, + start, 0, &main_source_baseline); +- inclTable[ii].subfile = &main_subfile; ++ inclTable[ii].subfile = main_subfile; + } + else + { +@@ -651,24 +652,24 @@ process_linenos (CORE_ADDR start, CORE_ADDR end) + enter remaining lines of the main file, if any left. */ + if (offset < max_offset + 1 - linesz) + { +- enter_line_range (&main_subfile, offset, 0, start, end, ++ enter_line_range (main_subfile, offset, 0, start, end, + &main_source_baseline); + } + } + + /* Process main file's line numbers. */ +- if (!main_subfile.line_vector_entries.empty ()) ++ if (!main_subfile->line_vector_entries.empty ()) + { + /* Line numbers are not necessarily ordered. xlc compilation will + put static function to the end. */ +- arrange_linetable (main_subfile.line_vector_entries); ++ arrange_linetable (main_subfile->line_vector_entries); + } + + /* Now, process included files' line numbers. */ + + for (int ii = 0; ii < inclIndx; ++ii) + { +- if (inclTable[ii].subfile != ((struct subfile *) &main_subfile) ++ if (inclTable[ii].subfile != main_subfile + && !inclTable[ii].subfile->line_vector_entries.empty ()) + { + /* Line numbers are not necessarily ordered. xlc compilation will +@@ -1811,6 +1812,7 @@ xcoff_symfile_finish (struct objfile *objfile) + { + xfree (inclTable); + inclTable = NULL; ++ delete main_subfile; + } + inclIndx = inclLength = inclDepth = 0; + } + +base-commit: 38a5283b23caca5317eaeb7927a5a11eccc6eb69 +-- +2.35.3 + From 8961c2b3e423500428cc542634fc445724bfd271f04c069ed24aac735bea2305 Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Tue, 31 Oct 2023 08:26:56 +0000 Subject: [PATCH 07/10] - Maintenance script qa.sh: * Update PR28561 kfail. * Update PR29781 kfail. - Maintenance script qa-local.sh: * Add "Verify quilt setup" step. - Patches added (backport from master): * gdb-symtab-handle-self-reference-die.patch * gdb-symtab-handle-self-reference-in-inherit_abstract.patch * gdb-symtab-add-optimized-out-static-var-to-cooked-in.patch OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=368 --- ...ptimized-out-static-var-to-cooked-in.patch | 299 ++++++++++++++++++ gdb-symtab-handle-self-reference-die.patch | 159 ++++++++++ ...e-self-reference-in-inherit_abstract.patch | 92 ++++++ gdb.changes | 13 + gdb.spec | 6 + qa-local.sh | 18 +- qa.sh | 4 +- 7 files changed, 584 insertions(+), 7 deletions(-) create mode 100644 gdb-symtab-add-optimized-out-static-var-to-cooked-in.patch create mode 100644 gdb-symtab-handle-self-reference-die.patch create mode 100644 gdb-symtab-handle-self-reference-in-inherit_abstract.patch diff --git a/gdb-symtab-add-optimized-out-static-var-to-cooked-in.patch b/gdb-symtab-add-optimized-out-static-var-to-cooked-in.patch new file mode 100644 index 0000000..cb8838f --- /dev/null +++ b/gdb-symtab-add-optimized-out-static-var-to-cooked-in.patch @@ -0,0 +1,299 @@ +From 7f4601b0a51f400bd1b1bc0f7895254d467e3bb4 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Fri, 21 Jul 2023 08:25:25 +0200 +Subject: [PATCH] [gdb/symtab] Add optimized out static var to cooked index + +Consider the test-case: +... +$ cat main.c +int main (void) { return 0; } +$ cat static-optimized-out.c +static int aaa; +... +compiled like this: +... +$ gcc-12 static-optimized-out.c main.c -g -O2 -flto +... + +There's a difference in behaviour depending on symtab expansion state: +... +$ gdb -q -batch a.out -ex "print aaa" +No symbol "aaa" in current context. +$ gdb -q -batch a.out -ex "maint expand-symtab" -ex "print aaa" +$1 = <optimized out> +... + +The reason for the difference is that the optimized out variable aaa: +... + <1><104>: Abbrev Number: 2 (DW_TAG_variable) + <105> DW_AT_name : aaa + <109> DW_AT_decl_file : 1 + <10a> DW_AT_decl_line : 18 + <10b> DW_AT_decl_column : 12 + <10c> DW_AT_type : <0x110> +... +is not added to the cooked index because of this clause in abbrev_table::read: +... + else if (!has_location && !has_specification_or_origin && !has_external + && cur_abbrev->tag == DW_TAG_variable) + cur_abbrev->interesting = false; +... + +Fix this inconsistency by making sure that the optimized out variable is added +to the cooked index. + +Regression tested on x86_64-linux. + +Add two test-cases, a C test-case gdb.opt/static-optimized-out.exp and a dwarf +assembly test-case gdb.dwarf2/static-optimized-out.exp. + +Tested gdb.opt/static-optimized-out.exp with gcc-8 to gcc-12, for which we now +consistently get: +... +(gdb) print aaa^M +$1 = <optimized out>^M +... +and with gcc 7.5.0 and clang 13.0.1, for which we still consistently get: +... +(gdb) print aaa^M +No symbol "aaa" in current context.^M +... +due to missing debug info for the variable. + +PR symtab/30656 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30656 + +Approved-By: Tom Tromey <tom@tromey.com> +--- + gdb/dwarf2/abbrev.c | 9 --- + .../gdb.dwarf2/static-optimized-out.exp | 69 +++++++++++++++++++ + gdb/testsuite/gdb.opt/main.c | 22 ++++++ + gdb/testsuite/gdb.opt/static-optimized-out.c | 18 +++++ + .../gdb.opt/static-optimized-out.exp | 49 +++++++++++++ + 5 files changed, 158 insertions(+), 9 deletions(-) + create mode 100644 gdb/testsuite/gdb.dwarf2/static-optimized-out.exp + create mode 100644 gdb/testsuite/gdb.opt/main.c + create mode 100644 gdb/testsuite/gdb.opt/static-optimized-out.c + create mode 100644 gdb/testsuite/gdb.opt/static-optimized-out.exp + +diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c +index 1ebf8f6eed5..3a429fd41b1 100644 +--- a/gdb/dwarf2/abbrev.c ++++ b/gdb/dwarf2/abbrev.c +@@ -162,7 +162,6 @@ abbrev_table::read (struct dwarf2_section_info *section, + bool has_specification_or_origin = false; + bool has_name = false; + bool has_linkage_name = false; +- bool has_location = false; + bool has_external = false; + + /* Now read in declarations. */ +@@ -217,11 +216,6 @@ abbrev_table::read (struct dwarf2_section_info *section, + has_linkage_name = true; + break; + +- case DW_AT_const_value: +- case DW_AT_location: +- has_location = true; +- break; +- + case DW_AT_sibling: + if (is_csize && cur_attr.form == DW_FORM_ref4) + sibling_offset = size; +@@ -296,9 +290,6 @@ abbrev_table::read (struct dwarf2_section_info *section, + cur_abbrev->interesting = false; + else if (!tag_interesting_for_index (cur_abbrev->tag)) + cur_abbrev->interesting = false; +- else if (!has_location && !has_specification_or_origin && !has_external +- && cur_abbrev->tag == DW_TAG_variable) +- cur_abbrev->interesting = false; + else + cur_abbrev->interesting = true; + +diff --git a/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp +new file mode 100644 +index 00000000000..1547a8acbc0 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp +@@ -0,0 +1,69 @@ ++# 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 an optimized out static variable is printed the same independent ++# of state of symtab expansion. See also gdb.opt/static-optimized-out.exp. ++ ++load_lib dwarf.exp ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++if { ![dwarf2_support] } { ++ return 0 ++} ++ ++standard_testfile main.c -dw.S ++ ++# Make DWARF for the test. ++set asm_file [standard_output_file $srcfile2] ++Dwarf::assemble $asm_file { ++ cu {} { ++ compile_unit { ++ { ++ language @DW_LANG_C ++ } ++ } { ++ declare_labels integer_label ++ ++ integer_label: DW_TAG_base_type { ++ {DW_AT_byte_size 4 DW_FORM_sdata} ++ {DW_AT_encoding @DW_ATE_signed} ++ {DW_AT_name integer} ++ } ++ ++ DW_TAG_variable { ++ {name var} ++ {type :$integer_label} ++ } ++ } ++ } ++} ++ ++if { [prepare_for_testing "failed to prepare" ${testfile} \ ++ [list $srcfile $asm_file] {nodebug}] } { ++ return -1 ++} ++ ++gdb_test "print var" " = <optimized out>" ++ ++# Expand all symbol tables. ++gdb_test_no_output "maint expand-symtabs" ++ ++# Make sure we do an actual lookup rather than just returning the same as ++# before. ++gdb_test_no_output "maint flush symbol-cache" ++ ++with_test_prefix "after expand-symtabs" { ++ gdb_test "print var" " = <optimized out>" ++} +diff --git a/gdb/testsuite/gdb.opt/main.c b/gdb/testsuite/gdb.opt/main.c +new file mode 100644 +index 00000000000..c6beff77dbe +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/main.c +@@ -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; ++} +diff --git a/gdb/testsuite/gdb.opt/static-optimized-out.c b/gdb/testsuite/gdb.opt/static-optimized-out.c +new file mode 100644 +index 00000000000..44287fbd6d2 +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/static-optimized-out.c +@@ -0,0 +1,18 @@ ++/* 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/>. */ ++ ++static int aaa; +diff --git a/gdb/testsuite/gdb.opt/static-optimized-out.exp b/gdb/testsuite/gdb.opt/static-optimized-out.exp +new file mode 100644 +index 00000000000..bd673b6503e +--- /dev/null ++++ b/gdb/testsuite/gdb.opt/static-optimized-out.exp +@@ -0,0 +1,49 @@ ++# 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 an optimized out static variable is printed the same independent ++# of state of symtab expansion. See also gdb.dwarf2/static-optimized-out.exp. ++ ++standard_testfile .c main.c ++ ++set opts {} ++lappend opts debug ++lappend opts "optimize=-O2 -flto" ++ ++if { [prepare_for_testing "failed to prepare" $testfile \ ++ [list $srcfile $srcfile2] $opts] } { ++ return -1 ++} ++ ++set val "" ++gdb_test_multiple "print aaa" "" { ++ -re -wrap "\r\n(?:\\$$decimal = )?(\[^\r\n\]*)" { ++ set val $expect_out(1,string) ++ } ++} ++ ++if { $val == "" } { ++ return ++} ++ ++# Expand all symbol tables. ++gdb_test_no_output "maint expand-symtab" ++ ++# Make sure we do an actual lookup rather than just returning the same as ++# before. ++gdb_test_no_output "maint flush symbol-cache" ++ ++# Now check that we get the same result in both cases. ++gdb_test "print aaa" [string_to_regexp $val] "consistency" + +base-commit: 800c393f89a94f49b01dff99f693cb13c5e28116 +-- +2.35.3 + diff --git a/gdb-symtab-handle-self-reference-die.patch b/gdb-symtab-handle-self-reference-die.patch new file mode 100644 index 0000000..a8ebf43 --- /dev/null +++ b/gdb-symtab-handle-self-reference-die.patch @@ -0,0 +1,159 @@ +From 8f53ac47d3f9c3800c8429d9187961ba81707d8b Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Wed, 16 Aug 2023 23:43:25 +0200 +Subject: [PATCH 1/2] [gdb/symtab] Handle self-reference DIE + +While working on a dwarf assembly test-case I accidentally created the +following pathological dwarf: +... + <1><be>: Abbrev Number: 3 (DW_TAG_class_type) + <bf> DW_AT_name : c1 + <c2> DW_AT_specification: <0xbe> +... +and noticed gdb segfaulting during cooked index creating due to running out of +stack. This is a regression from gdb-12, where gdb just hung. + +Fix this by inhibiting the scan_attributes self-recursion for self-references. + +The same test-case with -readnow makes gdb hang, so also fix this in +dwarf2_attr and follow_die_ref. + +Note that this doesn't fix the same problems for the more complicated case of: +... + <1><be>: Abbrev Number: 3 (DW_TAG_class_type) + <bf> DW_AT_name : c1 + <c2> DW_AT_specification: <0xc6> + <1><c6>: Abbrev Number: 4 (DW_TAG_class_type) + <c7> DW_AT_name : c2 + <ca> DW_AT_specification: <0xbe> +... +but the approach for deciding whether to fix pathological dwarf cases is as +per PR27981 comment 3: +... +yes if it is cheap/obvious, and no if it is something complicated or expensive. +... +and at this point I'm not sure whether fixing this will fall in the first +category. + +Tested on x86_64-linux. + +Approved-By: Tom Tromey <tom@tromey.com> +--- + gdb/dwarf2/read.c | 22 +++++++++-- + gdb/testsuite/gdb.dwarf2/self-spec.exp | 54 ++++++++++++++++++++++++++ + 2 files changed, 73 insertions(+), 3 deletions(-) + create mode 100644 gdb/testsuite/gdb.dwarf2/self-spec.exp + +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +index 61f4bd75013..1be5f381432 100644 +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -18289,9 +18289,15 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, + new_info_ptr, + &bytes_read); + new_info_ptr += bytes_read; +- scan_attributes (scanning_per_cu, new_reader, new_info_ptr, new_info_ptr, +- new_abbrev, name, linkage_name, flags, nullptr, +- parent_entry, maybe_defer, true); ++ ++ if (new_reader->cu == reader->cu && new_info_ptr == watermark_ptr) ++ { ++ /* Self-reference, we're done. */ ++ } ++ else ++ scan_attributes (scanning_per_cu, new_reader, new_info_ptr, ++ new_info_ptr, new_abbrev, name, linkage_name, ++ flags, nullptr, parent_entry, maybe_defer, true); + } + } + +@@ -19783,7 +19789,11 @@ dwarf2_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu) + if (!spec) + break; + ++ struct die_info *prev_die = die; + die = follow_die_ref (die, spec, &cu); ++ if (die == prev_die) ++ /* Self-reference, we're done. */ ++ break; + } + + return NULL; +@@ -22521,6 +22531,12 @@ follow_die_ref (struct die_info *src_die, const struct attribute *attr, + struct dwarf2_cu *cu = *ref_cu; + struct die_info *die; + ++ if (attr->form != DW_FORM_GNU_ref_alt && src_die->sect_off == sect_off) ++ { ++ /* Self-reference, we're done. */ ++ return src_die; ++ } ++ + die = follow_die_offset (sect_off, + (attr->form == DW_FORM_GNU_ref_alt + || cu->per_cu->is_dwz), +diff --git a/gdb/testsuite/gdb.dwarf2/self-spec.exp b/gdb/testsuite/gdb.dwarf2/self-spec.exp +new file mode 100644 +index 00000000000..77e92549fd1 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/self-spec.exp +@@ -0,0 +1,54 @@ ++# 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 gdb doesn't hang or segfault on reading a DIE with a ++# specification reference to itself. ++ ++load_lib dwarf.exp ++ ++if {![dwarf2_support]} { ++ return 0 ++} ++ ++standard_testfile main.c .S ++ ++# Create the DWARF. ++set asm_file [standard_output_file $srcfile2] ++Dwarf::assemble $asm_file { ++ cu {} { ++ compile_unit {{language @DW_LANG_C_plus_plus}} { ++ declare_labels c1 ++ c1: class_type { ++ {name c1} ++ {specification :$c1} ++ } ++ } ++ } ++} ++ ++if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" {}] { ++ return -1 ++} ++ ++set index [have_index $binfile] ++if { ![string eq $index ""] } { ++ return 0 ++} ++ ++if { [readnow] } { ++ return 0 ++} ++ ++gdb_test "maint expand-symtabs" + +base-commit: 6c9e159dbd1a35aafa134fcd52982174236a8dd9 +-- +2.35.3 + diff --git a/gdb-symtab-handle-self-reference-in-inherit_abstract.patch b/gdb-symtab-handle-self-reference-in-inherit_abstract.patch new file mode 100644 index 0000000..01219c7 --- /dev/null +++ b/gdb-symtab-handle-self-reference-in-inherit_abstract.patch @@ -0,0 +1,92 @@ +From 800c393f89a94f49b01dff99f693cb13c5e28116 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Mon, 28 Aug 2023 16:27:58 +0200 +Subject: [PATCH 2/2] [gdb/symtab] Handle self-reference in + inherit_abstract_dies + +Building gdb with gcc 7.5.0 and -flto -O2 -flto-partition=one generates a +self-referencing DIE: +... + <2><91dace>: Abbrev Number: 405 (DW_TAG_label) + <91dad0> DW_AT_abstract_origin: <0x91dace> +... + +When encountering the self-reference DIE in inherit_abstract_dies we loop +following the abstract origin, effectively hanging gdb. + +Fix this by handling self-referencing DIEs in the loop in +inherit_abstract_dies. + +Tested on x86_64-linux. + +Approved-By: Tom Tromey <tom@tromey.com> + +PR symtab/30799 +https://sourceware.org/bugzilla/show_bug.cgi?id=30799 +--- + gdb/dwarf2/read.c | 7 +++++++ + gdb/testsuite/gdb.dwarf2/self-spec.exp | 16 +++++++++++++++- + 2 files changed, 22 insertions(+), 1 deletion(-) + +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +index 1be5f381432..970dd54c7a5 100644 +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -11938,8 +11938,15 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) + if (attr == nullptr) + break; + ++ die_info *prev_child_origin_die = child_origin_die; + child_origin_die = follow_die_ref (child_origin_die, attr, + &child_origin_cu); ++ ++ if (prev_child_origin_die == child_origin_die) ++ { ++ /* Handle DIE with self-reference. */ ++ break; ++ } + } + + /* If missing DW_AT_abstract_origin, try the corresponding child +diff --git a/gdb/testsuite/gdb.dwarf2/self-spec.exp b/gdb/testsuite/gdb.dwarf2/self-spec.exp +index 77e92549fd1..f04ff6da42e 100644 +--- a/gdb/testsuite/gdb.dwarf2/self-spec.exp ++++ b/gdb/testsuite/gdb.dwarf2/self-spec.exp +@@ -14,7 +14,7 @@ + # along with this program. If not, see <http://www.gnu.org/licenses/>. + + # Check that gdb doesn't hang or segfault on reading a DIE with a +-# specification reference to itself. ++# specification/abstract_origin reference to itself. + + load_lib dwarf.exp + +@@ -29,11 +29,25 @@ set asm_file [standard_output_file $srcfile2] + Dwarf::assemble $asm_file { + cu {} { + compile_unit {{language @DW_LANG_C_plus_plus}} { ++ # Check handling of self-referencing DIE. + declare_labels c1 + c1: class_type { + {name c1} + {specification :$c1} + } ++ ++ # Check handling of self-referencing child DIE. Regression test ++ # for PR30799. ++ declare_labels f1 abstract_f1 f1_l ++ abstract_f1: subprogram {} ++ f1: subprogram { ++ {MACRO_AT_func {main}} ++ {abstract_origin :$abstract_f1} ++ } { ++ f1_l: label { ++ {abstract_origin :$f1_l} ++ } ++ } + } + } + } +-- +2.35.3 + diff --git a/gdb.changes b/gdb.changes index 49476c9..493b354 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Sun Oct 29 18:57:21 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Maintenance script qa.sh: + * Update PR28561 kfail. + * Update PR29781 kfail. +- Maintenance script qa-local.sh: + * Add "Verify quilt setup" step. +- Patches added (backport from master): + * gdb-symtab-handle-self-reference-die.patch + * gdb-symtab-handle-self-reference-in-inherit_abstract.patch + * gdb-symtab-add-optimized-out-static-var-to-cooked-in.patch + ------------------------------------------------------------------- Thu Oct 26 12:51:55 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/gdb.spec b/gdb.spec index b14993f..6757498 100644 --- a/gdb.spec +++ b/gdb.spec @@ -334,6 +334,9 @@ Patch2040: gdb-symtab-don-t-deduplicate-variables-in-gdb-index.patch Patch2041: xcoffread.c-fix-werror-dangling-pointer-issue-with-m.patch Patch2042: avoid-manual-memory-management-in-go-lang.c.patch Patch2043: gdb-go-handle-v3-go_0-mangled-prefix.patch +Patch2044: gdb-symtab-handle-self-reference-die.patch +Patch2045: gdb-symtab-handle-self-reference-in-inherit_abstract.patch +Patch2046: gdb-symtab-add-optimized-out-static-var-to-cooked-in.patch # Backports from master, not yet available in next release. @@ -773,6 +776,9 @@ find -name "*.info*"|xargs rm -f %patch2041 -p1 %patch2042 -p1 %patch2043 -p1 +%patch2044 -p1 +%patch2045 -p1 +%patch2046 -p1 %patch2070 -p1 diff --git a/qa-local.sh b/qa-local.sh index 010bd56..c7fa981 100644 --- a/qa-local.sh +++ b/qa-local.sh @@ -28,9 +28,10 @@ usage () echo "usage: $0 <1-4>" echo "1: Cleanup" echo "2: List configs" - echo "3: Do local builds without testsuite" - echo "4: Do local builds with testsuite" - echo "5: Verify local testsuite results" + echo "3: Verify quilt setup" + echo "4: Do local builds without testsuite" + echo "5: Do local builds with testsuite" + echo "6: Verify local testsuite results" } if [ $# -eq 0 ]; then @@ -120,8 +121,13 @@ case "$n" in done done ;; - + 3) + quilt setup -d $root -v gdb.spec + rm -Rf $root/gdb-* + ;; + + 4) acquire_sudo_rights rm -Rf $logs/$n @@ -155,7 +161,7 @@ case "$n" in done ;; - 4) + 5) acquire_sudo_rights rm -Rf $logs/$n @@ -214,7 +220,7 @@ case "$n" in done ;; - 5) + 6) for arch in $archs; do for c in $configs; do if ! have_combo $arch $c; then diff --git a/qa.sh b/qa.sh index 6fe694e..8c54d34 100644 --- a/qa.sh +++ b/qa.sh @@ -282,7 +282,7 @@ kfail=( "FAIL: gdb.gdb/selftest.exp: backtrace through signal handler" # https://sourceware.org/bugzilla/show_bug.cgi?id=29781 - "FAIL: gdb.mi/mi-multi-commands.exp: args=: look for second command output, command length .* \(timeout\)" + "FAIL: gdb.mi/mi-multi-commands.exp: args=.*: look for second command output, command length .* \(timeout\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=27027 # https://sourceware.org/bugzilla/show_bug.cgi?id=28464 @@ -530,6 +530,8 @@ kfail_aarch64=( "FAIL: gdb.mi/.*.exp:" "FAIL: gdb.python/.*-mi.exp:" "FAIL: gdb.python/py-mi-.*.exp:" + "FAIL: gdb.ada/mi.*.exp:" + "FAIL: gdb.base/annota.*.exp:" ) # kfail_aarch64 From e87e79cf5fa315c5785b7a65ea2239a80604bf9583c3691de0ca822d0403b4d4 Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Tue, 31 Oct 2023 10:02:24 +0000 Subject: [PATCH 08/10] - Maintenance script qa.sh: * Remove PR28467, PR29418, PR29420, PR29814 and PR29408 kfail. * Remove gdb.tui/tui-layout-asm-short-prog.exp kfail. * Remove commit f68eca29d3b, 29004660c94, 301fe55e9c4, 4d88ae0c7b5, e7d69e72bfd, 8b272d7671f, 85819864f7c, 167f3beb655 and a0eda3df5b7 kfails. * Add PR31015 kfail. * Remove PR29793 kfail. * Remove gdb.arch/powerpc-bcl-prologue.exp kfail. * Remove PR29813 and PR29816 kfail. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=369 --- gdb.changes | 14 +++++++++ qa.sh | 85 ++--------------------------------------------------- 2 files changed, 16 insertions(+), 83 deletions(-) diff --git a/gdb.changes b/gdb.changes index 493b354..6843048 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Tue Oct 31 09:02:42 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Maintenance script qa.sh: + * Remove PR28467, PR29418, PR29420, PR29814 and PR29408 kfail. + * Remove gdb.tui/tui-layout-asm-short-prog.exp kfail. + * Remove commit f68eca29d3b, 29004660c94, 301fe55e9c4, + 4d88ae0c7b5, e7d69e72bfd, 8b272d7671f, 85819864f7c, 167f3beb655 + and a0eda3df5b7 kfails. + * Add PR31015 kfail. + * Remove PR29793 kfail. + * Remove gdb.arch/powerpc-bcl-prologue.exp kfail. + * Remove PR29813 and PR29816 kfail. + ------------------------------------------------------------------- Sun Oct 29 18:57:21 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/qa.sh b/qa.sh index 8c54d34..59a17d2 100644 --- a/qa.sh +++ b/qa.sh @@ -163,10 +163,6 @@ kfail=( "FAIL: gdb.threads/gcore-stale-thread.exp: save a corefile" "FAIL: gdb.threads/gcore-stale-thread.exp: exited thread is current due to non-stop" - # https://sourceware.org/bugzilla/show_bug.cgi?id=28467 - # -pie, x86_64 -m32 or i586. - "FAIL: gdb.base/nodebug.exp: p/c \(int\) array_index\(\"abcdef\",2\)" - # https://sourceware.org/bugzilla/show_bug.cgi?id=28617 "FAIL: gdb.base/info-os.exp: get process groups \(timeout\)" "FAIL: gdb.base/info-os.exp: get threads \(timeout\)" @@ -186,6 +182,7 @@ kfail=( "FAIL: gdb.xml/tdesc-reload.exp: .*internal error" # https://sourceware.org/bugzilla/show_bug.cgi?id=26761 + # Should be fixed in gdb-14. "FAIL: gdb.base/gdb-sigterm.exp: .*internal error" # If a test-case fails to compile, it's not a GDB FAIL, ignore. @@ -368,11 +365,6 @@ kfail_sle12=( "FAIL: gdb.base/premature-dummy-frame-removal.exp: set debug frame on" "FAIL: gdb.base/longjmp-until-in-main.exp: until \\\$line, in main" - # Commit 2d77a94ff17 ("[gdb/testsuite] Require debug info for - # gdb.tui/tui-layout-asm-short-prog.exp") - "FAIL: gdb.tui/tui-layout-asm-short-prog.exp: check asm box contents" - "FAIL: gdb.tui/tui-layout-asm-short-prog.exp: check asm box contents again" - # Test-cases that use -static but may turn out to be PIE when using # unix/-fPIE/-fpie. # https://sourceware.org/bugzilla/show_bug.cgi?id=29244 @@ -504,22 +496,10 @@ kfail_factory=( kfail_aarch64=( - # https://sourceware.org/bugzilla/show_bug.cgi?id=29408 - "FAIL: gdb.base/large-frame.exp: optimize=-O0: backtrace" - "FAIL: gdb.base/large-frame.exp: optimize=-O1: backtrace" - "FAIL: gdb.base/large-frame.exp: optimize=-O2: backtrace" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29405 "FAIL: gdb.base/step-over-syscall.exp: (fork|vfork): displaced=(on|off): pc after stepi matches insn addr after syscall" "FAIL: gdb.base/step-over-syscall.exp: (fork|vfork): displaced=(on|off): check_pc_after_cross_syscall: single step over fork final pc" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29418 - "FAIL: gdb.ada/O2_float_param.exp: scenario=all: frame" - "FAIL: gdb.ada/O2_float_param.exp: scenario=minimal: frame" - - # https://sourceware.org/bugzilla/show_bug.cgi?id=29420 - "FAIL: gdb.ada/convvar_comp.exp: print \\\$item.started" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29423 "FAIL: gdb.base/watchpoint-unaligned.exp: continue \(timeout\)" "FAIL: gdb.base/watchpoint-unaligned.exp: size8twice write" @@ -537,56 +517,15 @@ kfail_aarch64=( kfail_powerpc64le=( - # https://sourceware.org/bugzilla/show_bug.cgi?id=29420 - "FAIL: gdb.ada/convvar_comp.exp: print \\\$item.started" - - # https://sourceware.org/bugzilla/show_bug.cgi?id=29814 - "FAIL: gdb.base/msym-bp-shl.exp: debug=0: before run: info breakpoint" - "FAIL: gdb.base/msym-bp-shl.exp: debug=1: before run: info breakpoint" - - # Commit a0eda3df5b7 ("PowerPC, fix support for printing the function - # return value for non-trivial values"). - "FAIL: gdb.cp/non-trivial-retval.exp: finish from" + # https://sourceware.org/bugzilla/show_bug.cgi?id=31015 "FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Small_Float_Vector" - "FAIL: gdb.base/gnu_vector.exp: call add_structvecs" - - # Commit f68eca29d3b ("PowerPC, fix gdb.base/retval-large-struct.exp"). - "FAIL: gdb.base/retval-large-struct.exp: finish from return_large_struct" # https://sourceware.org/bugzilla/show_bug.cgi?id=29792 "FAIL: gdb.opt/solib-intra-step.exp: second-hit" - # Carl Love mentioned he's working on these. - # https://sourceware.org/bugzilla/show_bug.cgi?id=29793#c2 - "FAIL: gdb.reverse/finish-precsave.exp" - "FAIL: gdb.reverse/finish-reverse.exp" - - # Commit 29004660c94 ("PowerPC fix for gdb.server/sysroot.exp"). - "FAIL: gdb.server/sysroot.exp: sysroot=local: continue to printf" - "FAIL: gdb.server/sysroot.exp: sysroot=remote: continue to printf" - # Known to run into timeouts. "FAIL: gdb.gdb/python-helper.exp" - # Fedora test. Fails because it doesn't handle ppc64le. - "FAIL: gdb.arch/powerpc-bcl-prologue.exp: powerpc arch test" - - # Commit 301fe55e9c4 ("PowerPC: bp-permanent.exp, kill-after-signal fix"). - "FAIL: gdb.base/kill-after-signal.exp: stepi" - "FAIL: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: stepi signal with handler: mainline pc points at permanent breakpoint" - "FAIL: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=1: stepi signal with handler: mainline pc points at permanent breakpoint" - "FAIL: gdb.base/bp-permanent.exp: always_inserted=on, sw_watchpoint=0: stepi signal with handler: mainline pc points at permanent breakpoint" - "FAIL: gdb.base/bp-permanent.exp: always_inserted=on, sw_watchpoint=1: stepi signal with handler: mainline pc points at permanent breakpoint" - - # https://sourceware.org/bugzilla/show_bug.cgi?id=29813 - "FAIL: gdb.base/vla-optimized-out.exp: o1: printed size of optimized out vla" - - # Commit 4d88ae0c7b5 ("[gdb/testsuite] Fix gdb.base/maint.exp on powerpc64le"). - "FAIL: gdb.base/maint.exp: maint print objfiles: symtabs" - - # Commit e7d69e72bfd ("gdb: always add the default register groups"). - "FAIL: gdb.xml/tdesc-regs.exp: maintenance print reggroups" - # https://sourceware.org/bugzilla/show_bug.cgi?id=30548 "FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level [0-9]*: backtrace when the unwind is broken at frame [0-9]*" @@ -596,15 +535,6 @@ kfail_powerpc64le=( "FAIL: gdb.reverse/next-reverse-bkpt-over-sr.exp: reverse-next over call trips user breakpoint at function entry" "FAIL: gdb.reverse/next-reverse-bkpt-over-sr.exp: stopped at the right callee call" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29816 - "FAIL: gdb.ada/float-bits.exp: print 16llf#4000921fb54442d18469898cc51701b8#" - "FAIL: gdb.ada/float-bits.exp: print \\\$foo:=16llf#4000921fb54442d18469898cc51701b8#" - "FAIL: gdb.ada/float-bits.exp: print internal long double variable after assignment" - - # Commit 8b272d7671f ("[gdb/testsuite] Fix gdb.guile/scm-symtab.exp for - # ppc64le"). - "FAIL: gdb.guile/scm-symtab.exp: test find-pc-line with resume address" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29897 "FAIL: gdb.base/run-control-while-bg-execution.exp: action1=.*: action2=start: start \(GDB internal error\)" "FAIL: gdb.base/run-control-while-bg-execution.exp: action1=.*: action2=run: run \(GDB internal error\)" @@ -665,21 +595,10 @@ kfail_powerpc64le=( kfail_powerpc64le_sle12=( - # Commit 85819864f7c ("[gdb/testsuite] Fix gdb.arch/altivec-regs.exp with - # gcc 4.8.5"). - "FAIL: gdb.arch/altivec-regs.exp: down to vector_fun" - "FAIL: gdb.arch/altivec-regs.exp: finish returned correct value" - "FAIL: gdb.arch/altivec-regs.exp: print vector parameter a" - "FAIL: gdb.arch/altivec-regs.exp: print vector parameter b" - ) kfail_s390x_s390=( - # Commit 167f3beb655 ("[gdb/testsuite] Fix gdb.base/write_mem.exp for big - # endian") - "FAIL: gdb.base/write_mem.exp: x /xh main" - ) # Plain s390 or s390x/-m31. From 169ee8027b4025312267dad028956871d437947a913dee5efed1126e2073dbc7 Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Mon, 13 Nov 2023 12:53:28 +0000 Subject: [PATCH 09/10] - Maintenance script qa.sh: * Update PR28561 kfail. * Remove PR31015 kfail. * Remove PR30547 kfail. - Patches added (backport from master): * gdb-symtab-add-producer_is_gas.patch * gdb-symtab-work-around-gas-pr28629.patch * gdb-tdep-fix-nr-array-elements-in-ppc64_aggregate_ca.patch * gdb-testsuite-fix-gdb.python-py-breakpoint.exp-with-.patch * gdb-tui-fix-segfault-in-tui_find_disassembly_address.patch * gdb-tui-fix-wmaybe-uninitialized-in-tui_find_disasse.patch * gdb-testsuite-add-wait_for_msg-arg-to-term-resize-fi.patch - Patches added (backport from gdb-patches): * gdb-fix-segfault-in-for_each_block-part-2.patch * gdb-tui-allow-command-window-of-1-or-2-lines.patch * gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=370 --- ...ix-segfault-in-for_each_block-part-2.patch | 168 +++++++++++ gdb-symtab-add-producer_is_gas.patch | 125 ++++++++ gdb-symtab-work-around-gas-pr28629.patch | 278 ++++++++++++++++++ ...array-elements-in-ppc64_aggregate_ca.patch | 86 ++++++ ...d-wait_for_msg-arg-to-term-resize-fi.patch | 49 +++ ...x-gdb.python-py-breakpoint.exp-with-.patch | 65 ++++ ...allow-command-window-of-1-or-2-lines.patch | 80 +++++ ...resizing-of-terminal-to-1-or-2-lines.patch | 147 +++++++++ ...ault-in-tui_find_disassembly_address.patch | 148 ++++++++++ ...be-uninitialized-in-tui_find_disasse.patch | 57 ++++ gdb.changes | 20 ++ gdb.spec | 24 ++ qa.sh | 10 +- 13 files changed, 1249 insertions(+), 8 deletions(-) create mode 100644 gdb-fix-segfault-in-for_each_block-part-2.patch create mode 100644 gdb-symtab-add-producer_is_gas.patch create mode 100644 gdb-symtab-work-around-gas-pr28629.patch create mode 100644 gdb-tdep-fix-nr-array-elements-in-ppc64_aggregate_ca.patch create mode 100644 gdb-testsuite-add-wait_for_msg-arg-to-term-resize-fi.patch create mode 100644 gdb-testsuite-fix-gdb.python-py-breakpoint.exp-with-.patch create mode 100644 gdb-tui-allow-command-window-of-1-or-2-lines.patch create mode 100644 gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch create mode 100644 gdb-tui-fix-segfault-in-tui_find_disassembly_address.patch create mode 100644 gdb-tui-fix-wmaybe-uninitialized-in-tui_find_disasse.patch diff --git a/gdb-fix-segfault-in-for_each_block-part-2.patch b/gdb-fix-segfault-in-for_each_block-part-2.patch new file mode 100644 index 0000000..1fa7db4 --- /dev/null +++ b/gdb-fix-segfault-in-for_each_block-part-2.patch @@ -0,0 +1,168 @@ +From 1cd845ab3d405412aabf9b959aa527dd60143826 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Thu, 2 Nov 2023 14:51:02 +0100 +Subject: [PATCH] [gdb] Fix segfault in for_each_block, part 2 + +The previous commit describes PR gdb/30547, a segfault when running test-case +gdb.base/vfork-follow-parent.exp on powerpc64 (likewise on s390x). + +The root cause for the segmentation fault is that linux_is_uclinux gives an +incorrect result: it returns true instead of false. + +So, why does linux_is_uclinux: +... +int +linux_is_uclinux (void) +{ + CORE_ADDR dummy; + + return (target_auxv_search (AT_NULL, &dummy) > 0 + && target_auxv_search (AT_PAGESZ, &dummy) == 0); +... +return true? + +This is because ppc_linux_target_wordsize returns 4 instead of 8, causing +ppc_linux_nat_target::auxv_parse to misinterpret the auxv vector. + +So, why does ppc_linux_target_wordsize: +... +int +ppc_linux_target_wordsize (int tid) +{ + int wordsize = 4; + + /* Check for 64-bit inferior process. This is the case when the host is + 64-bit, and in addition the top bit of the MSR register is set. */ + long msr; + + errno = 0; + msr = (long) ptrace (PTRACE_PEEKUSER, tid, PT_MSR * 8, 0); + if (errno == 0 && ppc64_64bit_inferior_p (msr)) + wordsize = 8; + + return wordsize; +} +... +return 4? + +Specifically, we get this result because because tid == 0, so we get +errno == ESRCH. + +The tid == 0 is caused by the switch_to_no_thread in +handle_vfork_child_exec_or_exit: +... + /* Switch to no-thread while running clone_program_space, so + that clone_program_space doesn't want to read the + selected frame of a dead process. */ + scoped_restore_current_thread restore_thread; + switch_to_no_thread (); + + inf->pspace = new program_space (maybe_new_address_space ()); +... +but moving the maybe_new_address_space call to before that gives us the +same result. The tid is no longer 0, but we still get ESRCH because the +thread has exited. + +Fix this in handle_vfork_child_exec_or_exit by doing the +maybe_new_address_space call in the context of the vfork parent. + +Tested on top of trunk on x86_64-linux and ppc64le-linux. +Tested on top of gdb-14-branch on ppc64-linux. + +Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca> + +PR gdb/30547 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30547 +--- + gdb/infrun.c | 16 +++++++++++----- + gdb/nat/ppc-linux.c | 2 ++ + gdb/ppc-linux-nat.c | 2 ++ + gdb/s390-linux-nat.c | 5 ++++- + 4 files changed, 19 insertions(+), 6 deletions(-) + +diff --git a/gdb/infrun.c b/gdb/infrun.c +index 9c1b1f04e4d..c078098a6f8 100644 +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -1014,13 +1014,19 @@ handle_vfork_child_exec_or_exit (int exec) + go ahead and create a new one for this exiting + inferior. */ + +- /* Switch to no-thread while running clone_program_space, so +- that clone_program_space doesn't want to read the +- selected frame of a dead process. */ + scoped_restore_current_thread restore_thread; +- switch_to_no_thread (); + +- inf->pspace = new program_space (maybe_new_address_space ()); ++ /* Temporarily switch to the vfork parent, to facilitate ptrace ++ calls done during maybe_new_address_space. */ ++ switch_to_thread (any_live_thread_of_inferior (vfork_parent)); ++ address_space *aspace = maybe_new_address_space (); ++ ++ /* Switch back to the vfork child inferior. Switch to no-thread ++ while running clone_program_space, so that clone_program_space ++ doesn't want to read the selected frame of a dead process. */ ++ switch_to_inferior_no_thread (inf); ++ ++ inf->pspace = new program_space (aspace); + inf->aspace = inf->pspace->aspace; + set_current_program_space (inf->pspace); + inf->removable = true; +diff --git a/gdb/nat/ppc-linux.c b/gdb/nat/ppc-linux.c +index 0957d1b58a7..74549754806 100644 +--- a/gdb/nat/ppc-linux.c ++++ b/gdb/nat/ppc-linux.c +@@ -78,6 +78,8 @@ ppc64_64bit_inferior_p (long msr) + int + ppc_linux_target_wordsize (int tid) + { ++ gdb_assert (tid != 0); ++ + int wordsize = 4; + + /* Check for 64-bit inferior process. This is the case when the host is +diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c +index d8a8fbdf706..500fb566bc1 100644 +--- a/gdb/ppc-linux-nat.c ++++ b/gdb/ppc-linux-nat.c +@@ -1918,6 +1918,8 @@ ppc_linux_nat_target::auxv_parse (const gdb_byte **readptr, + const gdb_byte *endptr, CORE_ADDR *typep, + CORE_ADDR *valp) + { ++ gdb_assert (inferior_ptid != null_ptid); ++ + int tid = inferior_ptid.lwp (); + if (tid == 0) + tid = inferior_ptid.pid (); +diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c +index fc3917d30be..403f37d690d 100644 +--- a/gdb/s390-linux-nat.c ++++ b/gdb/s390-linux-nat.c +@@ -949,10 +949,12 @@ s390_target_wordsize (void) + /* Check for 64-bit inferior process. This is the case when the host is + 64-bit, and in addition bit 32 of the PSW mask is set. */ + #ifdef __s390x__ ++ int tid = s390_inferior_tid (); ++ gdb_assert (tid != 0); + long pswm; + + errno = 0; +- pswm = (long) ptrace (PTRACE_PEEKUSER, s390_inferior_tid (), PT_PSWMASK, 0); ++ pswm = (long) ptrace (PTRACE_PEEKUSER, tid, PT_PSWMASK, 0); + if (errno == 0 && (pswm & 0x100000000ul) != 0) + wordsize = 8; + #endif +@@ -965,6 +967,7 @@ s390_linux_nat_target::auxv_parse (const gdb_byte **readptr, + const gdb_byte *endptr, CORE_ADDR *typep, + CORE_ADDR *valp) + { ++ gdb_assert (inferior_ptid != null_ptid); + int sizeof_auxv_field = s390_target_wordsize (); + enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + const gdb_byte *ptr = *readptr; + +base-commit: 59053f06bd94be51efacfa80f9a1f738e3e1ee9c +-- +2.35.3 + diff --git a/gdb-symtab-add-producer_is_gas.patch b/gdb-symtab-add-producer_is_gas.patch new file mode 100644 index 0000000..3ede8a8 --- /dev/null +++ b/gdb-symtab-add-producer_is_gas.patch @@ -0,0 +1,125 @@ +From aa8ba17b9a3fdfeeb65df4c3e0731a0e9e96cbf7 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Wed, 1 Nov 2023 00:33:12 +0100 +Subject: [PATCH 1/2] [gdb/symtab] Add producer_is_gas + +Add producer_is_gas, a generic way to get the gas version from the +producer string. + +Tested on x86_64-linux. +--- + gdb/dwarf2/read.c | 4 ++-- + gdb/producer.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ + gdb/producer.h | 5 +++++ + 3 files changed, 63 insertions(+), 2 deletions(-) + +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +index 970dd54c7a5..472684a5817 100644 +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -13376,8 +13376,8 @@ check_producer (struct dwarf2_cu *cu) + cu->producer_is_codewarrior = true; + else if (producer_is_clang (cu->producer, &major, &minor)) + cu->producer_is_clang = true; +- else if (startswith (cu->producer, "GNU AS 2.39.0")) +- cu->producer_is_gas_2_39 = true; ++ else if (producer_is_gas (cu->producer, &major, &minor)) ++ cu->producer_is_gas_2_39 = major == 2 && minor == 39; + else + { + /* For other non-GCC compilers, expect their behavior is DWARF version +diff --git a/gdb/producer.c b/gdb/producer.c +index 9fcf749e3d4..cd83dfce128 100644 +--- a/gdb/producer.c ++++ b/gdb/producer.c +@@ -81,6 +81,45 @@ producer_is_gcc (const char *producer, int *major, int *minor) + + /* See producer.h. */ + ++bool ++producer_is_gas (const char *producer, int *major, int *minor) ++{ ++ if (producer == nullptr) ++ { ++ /* No producer, don't know. */ ++ return false; ++ } ++ ++ /* Detect prefix. */ ++ const char prefix[] = "GNU AS "; ++ if (!startswith (producer, prefix)) ++ { ++ /* Producer is not gas. */ ++ return false; ++ } ++ ++ /* Skip prefix. */ ++ const char *cs = &producer[strlen (prefix)]; ++ ++ /* Ensure that major/minor are not nullptrs. */ ++ int maj, min; ++ if (major == nullptr) ++ major = &maj; ++ if (minor == nullptr) ++ minor = &min; ++ ++ int scanned = sscanf (cs, "%d.%d", major, minor); ++ if (scanned != 2) ++ { ++ /* Unable to scan major/minor version. */ ++ return false; ++ } ++ ++ return true; ++} ++ ++ /* See producer.h. */ ++ + bool + producer_is_icc_ge_19 (const char *producer) + { +@@ -251,6 +290,23 @@ Version 18.0 Beta"; + SELF_CHECK (!producer_is_gcc (flang_llvm_exp, &major, &minor)); + SELF_CHECK (producer_is_llvm (flang_llvm_exp)); + } ++ ++ { ++ static const char gas_exp[] = "GNU AS 2.39.0"; ++ int major = 0, minor = 0; ++ SELF_CHECK (!producer_is_gcc (gas_exp, &major, &minor)); ++ SELF_CHECK (producer_is_gas (gas_exp, &major, &minor)); ++ SELF_CHECK (major == 2 && minor == 39); ++ ++ static const char gas_incomplete_exp[] = "GNU AS "; ++ SELF_CHECK (!producer_is_gas (gas_incomplete_exp, &major, &minor)); ++ SELF_CHECK (!producer_is_gcc (gas_incomplete_exp, &major, &minor)); ++ ++ static const char gas_incomplete_exp_2[] = "GNU AS 2"; ++ SELF_CHECK (!producer_is_gas (gas_incomplete_exp_2, &major, &minor)); ++ SELF_CHECK (!producer_is_gcc (gas_incomplete_exp_2, &major, &minor)); ++ } ++ + } + } + } +diff --git a/gdb/producer.h b/gdb/producer.h +index c915979b122..00718511775 100644 +--- a/gdb/producer.h ++++ b/gdb/producer.h +@@ -30,6 +30,11 @@ extern int producer_is_gcc_ge_4 (const char *producer); + is NULL or it isn't GCC. */ + extern int producer_is_gcc (const char *producer, int *major, int *minor); + ++/* Returns nonzero if the given PRODUCER string is GAS and sets the MAJOR ++ and MINOR versions when not NULL. Returns zero if the given PRODUCER ++ is NULL or it isn't GAS. */ ++bool producer_is_gas (const char *producer, int *major, int *minor); ++ + /* Check for Intel compilers >= 19.0. */ + extern bool producer_is_icc_ge_19 (const char *producer); + + +base-commit: 39553c1e285c426946188ec2a890c1c1cb933060 +-- +2.35.3 + diff --git a/gdb-symtab-work-around-gas-pr28629.patch b/gdb-symtab-work-around-gas-pr28629.patch new file mode 100644 index 0000000..4811877 --- /dev/null +++ b/gdb-symtab-work-around-gas-pr28629.patch @@ -0,0 +1,278 @@ +From b1136560e772dd4c74f1fbb41f6ba840b92fb9d6 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Wed, 1 Nov 2023 00:33:12 +0100 +Subject: [PATCH 2/2] [gdb/symtab] Work around gas PR28629 + +When running test-case gdb.tui/tui-layout-asm-short-prog.exp on AlmaLinux 9.2 +ppc64le, I run into: +... +FAIL: gdb.tui/tui-layout-asm-short-prog.exp: check asm box contents +... + +The problem is that we get: +... + 7 [ No Assembly Available ] +... +because tui_get_begin_asm_address doesn't succeed. + +In more detail, tui_get_begin_asm_address calls: +... + find_line_pc (sal.symtab, sal.line, &addr); +... +with: +... +(gdb) p *sal.symtab +$5 = {next = 0x130393c0, m_compunit = 0x130392f0, m_linetable = 0x0, + filename = "tui-layout-asm-short-prog.S", + filename_for_id = "$gdb/build/gdb/testsuite/tui-layout-asm-short-prog.S", + m_language = language_asm, fullname = 0x0} +(gdb) p sal.line +$6 = 1 +... + +The problem is the filename_for_id which is the source file prefixed with the +compilation dir rather than the source dir. + +This is due to faulty debug info generated by gas, PR28629: +... + <1a> DW_AT_name : tui-layout-asm-short-prog.S + <1e> DW_AT_comp_dir : $gdb/build/gdb/testsuite + <22> DW_AT_producer : GNU AS 2.35.2 +... + +The DW_AT_name is relative, and it's relative to the DW_AT_comp_dir entry, +making the effective name $gdb/build/gdb/testsuite/tui-layout-asm-short-prog.S. + +The bug is fixed starting version 2.38, where we get instead: +... + <1a> DW_AT_name : + $gdb/src/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.S + <1e> DW_AT_comp_dir : $gdb/build/gdb/testsuite + <22> DW_AT_producer : GNU AS 2.38 +... + +Work around the faulty debug info by constructing the filename_for_id using +the second directory from the directory table in the .debug_line header: +... + The Directory Table (offset 0x22, lines 2, columns 1): + Entry Name + 0 $gdb/build/gdb/testsuite + 1 $gdb/src/gdb/testsuite/gdb.tui +... + +Note that the used gas contains a backport of commit 3417bfca676 ("GAS: +DWARF-5: Ensure that the 0'th entry in the directory table contains the +current working directory."), because directory 0 is correct. With the +unpatched 2.35.2 release the directory 0 entry is incorrect: it's a copy of +entry 1. + +Add a dwarf assembly test-case that reflects the debug info as generated by +unpatched gas 2.35.2. + +Tested on x86_64-linux. + +Approved-By: Tom Tromey <tom@tromey.com> +--- + gdb/dwarf2/cu.c | 1 + + gdb/dwarf2/cu.h | 1 + + gdb/dwarf2/read.c | 37 +++++++- + .../gdb.dwarf2/dw2-gas-workaround.exp | 94 +++++++++++++++++++ + 4 files changed, 132 insertions(+), 1 deletion(-) + create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp + +diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c +index 42fd4f4441b..6b5d956649f 100644 +--- a/gdb/dwarf2/cu.c ++++ b/gdb/dwarf2/cu.c +@@ -40,6 +40,7 @@ dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu, + producer_is_icc_lt_14 (false), + producer_is_codewarrior (false), + producer_is_clang (false), ++ producer_is_gas_lt_2_38 (false), + producer_is_gas_2_39 (false), + processing_has_namespace_info (false), + load_all_dies (false) +diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h +index 710aeb5b237..9b1e8775ff4 100644 +--- a/gdb/dwarf2/cu.h ++++ b/gdb/dwarf2/cu.h +@@ -265,6 +265,7 @@ struct dwarf2_cu + bool producer_is_icc_lt_14 : 1; + bool producer_is_codewarrior : 1; + bool producer_is_clang : 1; ++ bool producer_is_gas_lt_2_38 : 1; + bool producer_is_gas_2_39 : 1; + + /* When true, the file that we're processing is known to have +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +index 472684a5817..2339cceb829 100644 +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -146,6 +146,8 @@ static int dwarf2_loclist_index; + static int dwarf2_locexpr_block_index; + static int dwarf2_loclist_block_index; + ++static bool producer_is_gas_lt_2_38 (struct dwarf2_cu *cu); ++ + /* Size of .debug_loclists section header for 32-bit DWARF format. */ + #define LOCLIST_HEADER_SIZE32 12 + +@@ -9663,6 +9665,27 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) + + file_and_directory &fnd = find_file_and_directory (die, cu); + ++ /* GAS supports generating dwarf-5 info starting version 2.35. Versions ++ 2.35-2.37 generate an incorrect CU name attribute: it's relative, ++ implicitly prefixing it with the compilation dir. Work around this by ++ prefixing it with the source dir instead. */ ++ if (cu->header.version == 5 && !IS_ABSOLUTE_PATH (fnd.get_name ()) ++ && producer_is_gas_lt_2_38 (cu)) ++ { ++ attr = dwarf2_attr (die, DW_AT_stmt_list, cu); ++ if (attr != nullptr && attr->form_is_unsigned ()) ++ { ++ sect_offset line_offset = (sect_offset) attr->as_unsigned (); ++ line_header_up lh = dwarf_decode_line_header (line_offset, cu, ++ fnd.get_comp_dir ()); ++ if (lh->version == 5 && lh->is_valid_file_index (1)) ++ { ++ std::string dir = lh->include_dir_at (1); ++ fnd.set_comp_dir (std::move (dir)); ++ } ++ } ++ } ++ + cu->start_compunit_symtab (fnd.get_name (), fnd.intern_comp_dir (objfile), + lowpc); + +@@ -13377,7 +13400,10 @@ check_producer (struct dwarf2_cu *cu) + else if (producer_is_clang (cu->producer, &major, &minor)) + cu->producer_is_clang = true; + else if (producer_is_gas (cu->producer, &major, &minor)) +- cu->producer_is_gas_2_39 = major == 2 && minor == 39; ++ { ++ cu->producer_is_gas_lt_2_38 = major < 2 || (major == 2 && minor < 38); ++ cu->producer_is_gas_2_39 = major == 2 && minor == 39; ++ } + else + { + /* For other non-GCC compilers, expect their behavior is DWARF version +@@ -13413,6 +13439,15 @@ producer_is_codewarrior (struct dwarf2_cu *cu) + return cu->producer_is_codewarrior; + } + ++static bool ++producer_is_gas_lt_2_38 (struct dwarf2_cu *cu) ++{ ++ if (!cu->checked_producer) ++ check_producer (cu); ++ ++ return cu->producer_is_gas_lt_2_38; ++} ++ + static bool + producer_is_gas_2_39 (struct dwarf2_cu *cu) + { +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp +new file mode 100644 +index 00000000000..416778f51b7 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp +@@ -0,0 +1,94 @@ ++# 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/>. ++ ++# Test line number information in various configurations. ++ ++load_lib dwarf.exp ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++if { ![dwarf2_support] } { ++ return -1 ++} ++ ++standard_testfile dw2-lines.c -dw2.S ++ ++with_shared_gdb { ++ set func_info_vars [get_func_info bar] ++} ++ ++# Helper function. ++proc line_for { l } { ++ global srcfile ++ set line [gdb_get_line_number "$l:" $srcfile] ++ return [expr $line + 1] ++} ++ ++set asm_file [standard_output_file $srcfile2] ++Dwarf::assemble $asm_file { ++ declare_labels Llines ++ global srcdir subdir srcfile objdir ++ global func_info_vars ++ foreach var $func_info_vars { ++ global $var ++ } ++ ++ cu { version 5 } { ++ compile_unit { ++ {language @DW_LANG_Mips_Assembler} ++ {name $srcfile} ++ {comp_dir $objdir} ++ {stmt_list $Llines DW_FORM_sec_offset} ++ {producer "GNU AS 2.35.2"} ++ } { ++ subprogram { ++ {external 1 flag} ++ {name bar} ++ {low_pc $bar_start addr} ++ {high_pc "$bar_start + $bar_len" addr} ++ } ++ } ++ } ++ ++ lines [list version 5] Llines { ++ set diridx1 [include_dir "${srcdir}/${subdir}"] ++ set diridx2 [include_dir "${srcdir}/${subdir}"] ++ file_name "$srcfile" $diridx1 ++ file_name "$srcfile" $diridx2 ++ ++ program { ++ DW_LNE_set_address bar_label ++ line [line_for bar_label] ++ DW_LNS_copy ++ ++ DW_LNE_set_address bar_label_2 ++ DW_LNE_end_sequence ++ } ++ } ++} ++ ++if { [prepare_for_testing "failed to prepare" ${testfile} \ ++ [list $srcfile $asm_file] {nodebug}] } { ++ return -1 ++} ++ ++gdb_test_no_output "set debug symtab-create 1" ++gdb_test_multiple "ptype bar" "" { ++ -re -wrap "$objdir.*" { ++ fail $gdb_test_name ++ } ++ -re -wrap "" { ++ pass $gdb_test_name ++ } ++} +-- +2.35.3 + diff --git a/gdb-tdep-fix-nr-array-elements-in-ppc64_aggregate_ca.patch b/gdb-tdep-fix-nr-array-elements-in-ppc64_aggregate_ca.patch new file mode 100644 index 0000000..0b91eaf --- /dev/null +++ b/gdb-tdep-fix-nr-array-elements-in-ppc64_aggregate_ca.patch @@ -0,0 +1,86 @@ +From 3f0c512dc37dbede372a018732d315726a56d10e Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Wed, 1 Nov 2023 08:07:15 +0100 +Subject: [PATCH] [gdb/tdep] Fix nr array elements in ppc64_aggregate_candidate + +On AlmaLinux 9.2 powerpc64le I run into: +... +(gdb) PASS: gdb.ada/array_return.exp: continuing to Create_Small_Float_Vector +finish^M +Run till exit from #0 pck.create_small_float_vector () at pck.adb:30^M +0x00000000100022d4 in p () at p.adb:25^M +25 Vector := Create_Small_Float_Vector;^M +Value returned is $3 = (2.80259693e-45, 2.80259693e-45)^M +(gdb) FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Small_Float_Vector +... +while this is expected: +... +Value returned is $3 = (4.25, 4.25)^M +... + +The problem is here in ppc64_aggregate_candidate: +... + if (!get_array_bounds (type, &low_bound, &high_bound)) + return -1; + count *= high_bound - low_bound +... + +The array type (containing 2 elements) is: +... + type Small_Float_Vector is array (1 .. 2) of Float; +... +so we have: +... +(gdb) p low_bound +$1 = 1 +(gdb) p high_bound +$2 = 2 +... +but we calculate the number of elements in the array using +"high_bound - low_bound", which is 1. + +Consequently, gdb fails to correctly classify the type as a ELFv2 homogeneous +aggregate. + +Fix this by calculating the number of elements in the array by using +"high_bound - low_bound + 1" instead. + +Furthermore, high_bound can (in general, though perhaps not here) be also be +smaller than low_bound, so to be safe take that into account as well: +... + LONGEST nr_array_elements = (low_bound > high_bound + ? 0 + : (high_bound - low_bound + 1)); + count *= nr_array_elements; +... + +Tested on powerpc64le-linux. + +PR tdep/31015 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31015 +--- + gdb/ppc-sysv-tdep.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c +index 9cea63307e6..dc89201eed2 100644 +--- a/gdb/ppc-sysv-tdep.c ++++ b/gdb/ppc-sysv-tdep.c +@@ -1126,7 +1126,11 @@ ppc64_aggregate_candidate (struct type *type, + + if (!get_array_bounds (type, &low_bound, &high_bound)) + return -1; +- count *= high_bound - low_bound; ++ ++ LONGEST nr_array_elements = (low_bound > high_bound ++ ? 0 ++ : (high_bound - low_bound + 1)); ++ count *= nr_array_elements; + + /* There must be no padding. */ + if (count == 0) + +base-commit: b1136560e772dd4c74f1fbb41f6ba840b92fb9d6 +-- +2.35.3 + diff --git a/gdb-testsuite-add-wait_for_msg-arg-to-term-resize-fi.patch b/gdb-testsuite-add-wait_for_msg-arg-to-term-resize-fi.patch new file mode 100644 index 0000000..2cda741 --- /dev/null +++ b/gdb-testsuite-add-wait_for_msg-arg-to-term-resize-fi.patch @@ -0,0 +1,49 @@ +From 028d19e262b4086bc266b2657edd566bb4757927 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Mon, 13 Nov 2023 11:33:23 +0100 +Subject: [PATCH 5/6] [gdb/testsuite] Add wait_for_msg arg to Term::resize fix + +From commit deb1ba4e38b ("[gdb/tui] Fix TUI resizing for TERM=ansi"). + +Required for "[gdb/tui] Fix resizing of terminal to 1 or 2 lines". +--- + gdb/testsuite/lib/tuiterm.exp | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp +index 591c4ca9c4c..eaac09581e9 100644 +--- a/gdb/testsuite/lib/tuiterm.exp ++++ b/gdb/testsuite/lib/tuiterm.exp +@@ -1066,7 +1066,7 @@ namespace eval Term { + } + } + +- proc resize {rows cols} { ++ proc resize {rows cols {wait_for_msg 1}} { + variable _rows + variable _cols + variable _resize_count +@@ -1080,14 +1080,18 @@ namespace eval Term { + # Due to the strange column resizing behavior, and because we + # don't care about this intermediate resize, we don't check + # the size here. +- wait_for "@@ resize done $_resize_count" ++ if { $wait_for_msg } { ++ wait_for "@@ resize done $_resize_count" ++ } + incr _resize_count + # Somehow the number of columns transmitted to gdb is one less + # than what we request from expect. We hide this weird + # details from the caller. + _do_resize $_rows $cols + stty columns [expr {$_cols + 1}] < $::gdb_tty_name +- wait_for "@@ resize done $_resize_count, size = ${_cols}x${rows}" ++ if { $wait_for_msg } { ++ wait_for "@@ resize done $_resize_count, size = ${_cols}x${rows}" ++ } + incr _resize_count + } + } +-- +2.35.3 + diff --git a/gdb-testsuite-fix-gdb.python-py-breakpoint.exp-with-.patch b/gdb-testsuite-fix-gdb.python-py-breakpoint.exp-with-.patch new file mode 100644 index 0000000..6824e92 --- /dev/null +++ b/gdb-testsuite-fix-gdb.python-py-breakpoint.exp-with-.patch @@ -0,0 +1,65 @@ +From 0cb123a4157d215c80f3deb339a3ba10a188ba19 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Mon, 2 Jan 2023 11:59:17 +0100 +Subject: [PATCH 1/6] [gdb/testsuite] Fix gdb.python/py-breakpoint.exp with + libstdc++ debug info + +On x86_64-linux, I run into: +... +(gdb) python hbp1 = gdb.Breakpoint("add", type=gdb.BP_HARDWARE_BREAKPOINT)^M +Hardware assisted breakpoint 2 at 0x40072e: add. (7 locations)^M +(gdb) FAIL: gdb.python/py-breakpoint.exp: test_hardware_breakpoints: \ + Set hardware breakpoint +... +due to libstdc++ debug info: +... +$ gdb -q -batch outputs/gdb.python/py-breakpoint/py-breakpoint \ + -ex start \ + -ex "b add" \ + -ex "info break" +Temporary breakpoint 1 at 0x40076a: file py-breakpoint.c, line 50. + +Temporary breakpoint 1, main (argc=1, argv=$hex) at py-breakpoint.c:50 +50 int foo = 5; +Breakpoint 2 at 0x40072e: add. (7 locations) +Num Type Disp Enb Address What +2 breakpoint keep y <MULTIPLE> +2.1 y 0x000000000040072e in add(int) at \ + py-breakpoint.c:39 +2.2 y 0x00007ffff7b131de in \ + (anonymous namespace)::fast_float::bigint::add at \ + ../../../../../libstdc++-v3/src/c++17/fast_float/fast_float.h:1815 + ... +2.7 y 0x00007ffff7b137e4 in \ + (anonymous namespace)::fast_float::bigint::add at \ + ../../../../../libstdc++-v3/src/c++17/fast_float/fast_float.h:1815 +... + +Fix this by using qualified=True. + +Tested on x86_64-linux. +PR testsuite/29910 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29910 +--- + gdb/testsuite/gdb.python/py-breakpoint.exp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp +index 9ba6b837a41..23c6637cd3a 100644 +--- a/gdb/testsuite/gdb.python/py-breakpoint.exp ++++ b/gdb/testsuite/gdb.python/py-breakpoint.exp +@@ -273,7 +273,8 @@ proc_with_prefix test_hardware_breakpoints { } { + + delete_breakpoints + +- gdb_test "python hbp1 = gdb.Breakpoint(\"add\", type=gdb.BP_HARDWARE_BREAKPOINT)" \ ++ set bp_args {"add", type=gdb.BP_HARDWARE_BREAKPOINT, qualified=True} ++ gdb_test "python hbp1 = gdb.Breakpoint($bp_args)" \ + ".*Hardware assisted breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\." \ + "Set hardware breakpoint" + gdb_test "python print (gdb.breakpoints()\[0\].type == gdb.BP_HARDWARE_BREAKPOINT)" \ + +base-commit: 1cd845ab3d405412aabf9b959aa527dd60143826 +-- +2.35.3 + diff --git a/gdb-tui-allow-command-window-of-1-or-2-lines.patch b/gdb-tui-allow-command-window-of-1-or-2-lines.patch new file mode 100644 index 0000000..c67b949 --- /dev/null +++ b/gdb-tui-allow-command-window-of-1-or-2-lines.patch @@ -0,0 +1,80 @@ +From 02616ce7c5571e5b2680cad52f8c58b27f77b2a5 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Thu, 9 Nov 2023 09:04:39 +0100 +Subject: [PATCH 4/6] [gdb/tui] Allow command window of 1 or 2 lines + +When starting TUI in a terminal with 2 lines (likewise with 1 line): +... +$ echo $LINES +2 +$ gdb -q -tui +... +we run into this assert in tui_apply_current_layout: +... + /* This should always be made visible by a layout. */ + gdb_assert (TUI_CMD_WIN != nullptr); +... + +The problem is that for the command window: +- the minimum height is 3 (the default), but +- the maximum height is only 2 because there are only 2 lines. + +This discrepancy eventually leads to a call to newwin in make_window with: +... +(gdb) p height +$1 = 3 +(gdb) p width +$2 = 66 +(gdb) p y +$3 = -1 +(gdb) p x +$4 = 0 +(gdb) +... +which results in a nullptr, which eventually triggers the assert. + +The easiest way to fix this is to change the minimum height of the command +window to 1. However, that would also change behaviour for the case that the +screen size is 3 lines or more. For instance, in gdb.tui/winheight.exp the +number of lines in the terminal is 24, and the test-case checks that the user +cannot increase the source window height to the point that the command window +height would be less than 3. + +Fix this by calculating the minimum height of the command window as follows: +- the default (3) if max_height () allows it, and +- max_height () otherwise. + +Tested on x86_64-linux. + +PR tui/31044 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31044 +--- + gdb/tui/tui-command.h | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h +index f6842880bb2..e8c96ecee30 100644 +--- a/gdb/tui/tui-command.h ++++ b/gdb/tui/tui-command.h +@@ -57,6 +57,18 @@ struct tui_cmd_window : public tui_win_info + /* The command window can't be made invisible. */ + } + ++ /* Compute the minimum height of this window. */ ++ virtual int min_height () const override ++ { ++ int preferred_min = tui_win_info::min_height (); ++ int max = max_height (); ++ /* If there is enough space to accommodate the preferred minimum height, ++ use it. Otherwise, use as much as possible. */ ++ return (preferred_min <= max ++ ? preferred_min ++ : max); ++ } ++ + int start_line = 0; + + protected: +-- +2.35.3 + diff --git a/gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch b/gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch new file mode 100644 index 0000000..d5a084b --- /dev/null +++ b/gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch @@ -0,0 +1,147 @@ +From c55a452eaf9390d5659d3205f762aa2cb84511e1 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Thu, 9 Nov 2023 09:05:01 +0100 +Subject: [PATCH 6/6] [gdb/tui] Fix resizing of terminal to 1 or 2 lines + +When starting TUI in a terminal with 3 lines: +... +$ echo $LINES +3 +$ gdb -q -tui +... +and resizing the terminal to 2 lines we run into a segfault. + +The problem is that for the source window: +- the minimum height is 3 (the default), but +- the maximum height is only 2 because there are only 2 lines. + +This discrepancy eventually leads to a call to newwin in make_window with: +... +(gdb) p height +$1 = 3 +(gdb) p width +$2 = 56 +(gdb) p y +$3 = -1 +(gdb) p x +$4 = 0 +... +which results in a nullptr. + +This violates the assumption here in tui_apply_current_layout: +.... + /* Get the new list of currently visible windows. */ + std::vector<tui_win_info *> new_tui_windows; + applied_layout->get_windows (&new_tui_windows); +... +that get_windows only returns visible windows, which leads to tui_windows +holding a dangling pointer, which results in the segfault. + +Fix this by: +- making sure get_windows only returns visible windows, and +- detecting the situation and dropping windows from the layout if + there's no room for them. + +Tested on x86_64-linux. + +PR tui/31044 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31044 +--- + gdb/testsuite/gdb.tui/resize.exp | 9 +++++++++ + gdb/tui/tui-layout.c | 22 ++++++++++++++++++++-- + gdb/tui/tui-layout.h | 6 +++++- + 3 files changed, 34 insertions(+), 3 deletions(-) + +diff --git a/gdb/testsuite/gdb.tui/resize.exp b/gdb/testsuite/gdb.tui/resize.exp +index 60d5116886b..e15f8a2f507 100644 +--- a/gdb/testsuite/gdb.tui/resize.exp ++++ b/gdb/testsuite/gdb.tui/resize.exp +@@ -39,3 +39,12 @@ Term::check_contents "source at startup" "\\|.*21 *return 0" + + Term::resize 40 90 + Term::check_box "source box after resize" 0 0 90 26 ++ ++# Check that resizing to less than 3 lines doesn't cause problems. ++foreach lines { 2 1 } { ++ with_test_prefix lines=$lines { ++ Term::resize $lines 90 0 ++ Term::wait_for "" ++ Term::check_region_contents "has prompt" 0 0 90 $lines "$gdb_prompt" ++ } ++} +diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c +index 27abee02087..362c1447910 100644 +--- a/gdb/tui/tui-layout.c ++++ b/gdb/tui/tui-layout.c +@@ -442,6 +442,13 @@ tui_layout_window::apply (int x_, int y_, int width_, int height_, + width = width_; + height = height_; + gdb_assert (m_window != nullptr); ++ if (width == 0 || height == 0) ++ { ++ /* The window was dropped, so it's going to be deleted, reset the ++ soon to be dangling pointer. */ ++ m_window = nullptr; ++ return; ++ } + m_window->resize (height, width, x, y); + } + +@@ -823,6 +830,7 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_, + int available_size = m_vertical ? height : width; + int last_index = -1; + int total_weight = 0; ++ int prev = -1; + for (int i = 0; i < m_splits.size (); ++i) + { + bool cmd_win_already_exists = TUI_CMD_WIN != nullptr; +@@ -854,6 +862,14 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_, + info[i].max_size = info[i].min_size; + } + ++ if (info[i].min_size > info[i].max_size) ++ { ++ /* There is not enough room for this window, drop it. */ ++ info[i].min_size = 0; ++ info[i].max_size = 0; ++ continue; ++ } ++ + if (info[i].min_size == info[i].max_size) + available_size -= info[i].min_size; + else +@@ -864,10 +880,12 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_, + + /* Two adjacent boxed windows will share a border, making a bit + more size available. */ +- if (i > 0 +- && m_splits[i - 1].layout->last_edge_has_border_p () ++ if (prev != -1 ++ && m_splits[prev].layout->last_edge_has_border_p () + && m_splits[i].layout->first_edge_has_border_p ()) + info[i].share_box = true; ++ ++ prev = i; + } + + /* If last_index is set then we have a window that is not of a fixed +diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h +index 206f1117445..ec013a3f051 100644 +--- a/gdb/tui/tui-layout.h ++++ b/gdb/tui/tui-layout.h +@@ -185,7 +185,11 @@ class tui_layout_window : public tui_layout_base + /* See tui_layout_base::get_windows. */ + void get_windows (std::vector<tui_win_info *> *windows) override + { +- windows->push_back (m_window); ++ if (m_window != nullptr && m_window->is_visible ()) ++ { ++ /* Only get visible windows. */ ++ windows->push_back (m_window); ++ } + } + + protected: +-- +2.35.3 + diff --git a/gdb-tui-fix-segfault-in-tui_find_disassembly_address.patch b/gdb-tui-fix-segfault-in-tui_find_disassembly_address.patch new file mode 100644 index 0000000..36534ee --- /dev/null +++ b/gdb-tui-fix-segfault-in-tui_find_disassembly_address.patch @@ -0,0 +1,148 @@ +From 0f8f51e98c7f643b8ce32bc6f6d621ce902d7a66 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Thu, 28 Sep 2023 20:17:33 +0200 +Subject: [PATCH 2/6] [gdb/tui] Fix segfault in tui_find_disassembly_address + +PR29040 describes a FAIL for test-case gdb.threads/next-fork-other-thread.exp +and target board unix/-m32. + +The FAIL happens due to the test executable running into an assert, which is +caused by a forked child segfaulting, like so: +... + Program terminated with signal SIGSEGV, Segmentation fault. + #0 0x00000000 in ?? () +... + +I tried to reproduce the segfault with exec next-fork-other-thread-fork, using +TUI layout asm. + +I set a breakpoint at fork and ran to the breakpoint, and somewhere during the +following session I ran into a gdb segfault here in +tui_find_disassembly_address: +... + /* Disassemble forward. */ + next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines); + last_addr = asm_lines.back ().addr; +... +due to asm_lines being empty after the call to tui_disassemble, while +asm_lines.back () assumes that it's not empty. + +I have not been able to reproduce that segfault in that original setting, I'm +not sure of the exact scenario (though looking back it probably involved +"set detach-on-fork off"). + +What likely happened is that I managed to reproduce PR29040, and TUI (attempted +to) display the disassembly for address 0, which led to the gdb segfault. + +When gdb_print_insn encounters an insn it cannot print because it can't read +the memory, it throws a MEMORY_ERROR that is caught by tui_disassemble. + +The specific bit that causes the gdb segfault is that if gdb_print_insn throws +a MEMORY_ERROR for the first insn in tui_disassemble, it returns an empty +asm_lines. + +FWIW, I did manage to reproduce the gdb segfault as follows: +... +$ gdb -q \ + -iex "set pagination off" \ + /usr/bin/rustc \ + -ex "set breakpoint pending on" \ + -ex "b dl_main" \ + -ex run \ + -ex "up 4" \ + -ex "layout asm" \ + -ex "print \$pc" + ... +<TUI> + ... +$1 = (void (*)()) 0x1 +(gdb) +... +Now press <up>, and the segfault triggers. + +Fix the segfault by handling asm_lines.empty () results of tui_disassemble in +tui_find_disassembly_address. + +I've written a unit test that exercises this scenario. + +Tested on x86_64-linux. + +Reviewed-by: Kevin Buettner <kevinb@redhat.com> + +PR tui/30823 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30823 +--- + gdb/tui/tui-disasm.c | 39 +++++++++++++++++++++++++++++++++++++++ + 1 file changed, 39 insertions(+) + +diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c +index f0b55769d71..03c78aa1291 100644 +--- a/gdb/tui/tui-disasm.c ++++ b/gdb/tui/tui-disasm.c +@@ -41,6 +41,8 @@ + #include "objfiles.h" + #include "cli/cli-style.h" + #include "tui/tui-location.h" ++#include "gdbsupport/selftest.h" ++#include "inferior.h" + + #include "gdb_curses.h" + +@@ -203,6 +205,8 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) + instruction fails to disassemble we will take the address of the + previous instruction that did disassemble as the result. */ + tui_disassemble (gdbarch, asm_lines, pc, max_lines + 1); ++ if (asm_lines.empty ()) ++ return pc; + new_low = asm_lines.back ().addr; + } + else +@@ -244,6 +248,8 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) + + /* Disassemble forward. */ + next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines); ++ if (asm_lines.empty ()) ++ break; + last_addr = asm_lines.back ().addr; + + /* If disassembling from the current value of NEW_LOW reached PC +@@ -522,3 +528,36 @@ tui_disasm_window::display_start_addr (struct gdbarch **gdbarch_p, + *gdbarch_p = m_gdbarch; + *addr_p = m_start_line_or_addr.u.addr; + } ++ ++#if GDB_SELF_TEST ++namespace selftests { ++namespace tui { ++namespace disasm { ++ ++static void ++run_tests () ++{ ++ if (current_inferior () != nullptr) ++ { ++ struct gdbarch *gdbarch = current_inferior ()->gdbarch; ++ ++ /* Check that tui_find_disassembly_address robustly handles the case of ++ being passed a PC for which gdb_print_insn throws a MEMORY_ERROR. */ ++ SELF_CHECK (tui_find_disassembly_address (gdbarch, 0, 1) == 0); ++ SELF_CHECK (tui_find_disassembly_address (gdbarch, 0, -1) == 0); ++ } ++} ++ ++} /* namespace disasm */ ++} /* namespace tui */ ++} /* namespace selftests */ ++#endif /* GDB_SELF_TEST */ ++ ++void _initialize_tui_disasm (); ++void ++_initialize_tui_disasm () ++{ ++#if GDB_SELF_TEST ++ selftests::register_test ("tui-disasm", selftests::tui::disasm::run_tests); ++#endif ++} +-- +2.35.3 + diff --git a/gdb-tui-fix-wmaybe-uninitialized-in-tui_find_disasse.patch b/gdb-tui-fix-wmaybe-uninitialized-in-tui_find_disasse.patch new file mode 100644 index 0000000..01738b0 --- /dev/null +++ b/gdb-tui-fix-wmaybe-uninitialized-in-tui_find_disasse.patch @@ -0,0 +1,57 @@ +From 0f2bdd8648e47e10334f8cc8e47b277d4064d0a2 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Mon, 13 Nov 2023 09:31:20 +0100 +Subject: [PATCH 3/6] [gdb/tui] Fix Wmaybe-uninitialized in + tui_find_disassembly_address +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When building gdb with -O2, we run into: +... +gdb/tui/tui-disasm.c: In function ‘CORE_ADDR tui_find_disassembly_address \ + (gdbarch*, CORE_ADDR, int)’: +gdb/tui/tui-disasm.c:293:7: warning: ‘last_addr’ may be used uninitialized \ + in this function [-Wmaybe-uninitialized] + if (last_addr < pc) + ^~ +... + +The warning triggers since commit 72535eb14bd ("[gdb/tui] Fix segfault in +tui_find_disassembly_address"). + +Fix the warning by ensuring that last_addr is initialized at the point of +use: +... ++ last_addr = asm_lines.back ().addr; + if (last_addr < pc) +... + +Tested on x86_64-linux. +--- + gdb/tui/tui-disasm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c +index 03c78aa1291..bbbc92c8183 100644 +--- a/gdb/tui/tui-disasm.c ++++ b/gdb/tui/tui-disasm.c +@@ -281,7 +281,6 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) + /* Take the best possible match we have. */ + new_low = *possible_new_low; + next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines); +- last_addr = asm_lines.back ().addr; + gdb_assert (asm_lines.size () >= max_lines); + } + +@@ -290,6 +289,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) + We keep the disassembled instructions in the 'lines' window + and shift it downward (increasing its addresses). */ + int pos = max_lines - 1; ++ last_addr = asm_lines.back ().addr; + if (last_addr < pc) + do + { +-- +2.35.3 + diff --git a/gdb.changes b/gdb.changes index 6843048..d685db0 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,23 @@ +------------------------------------------------------------------- +Tue Oct 31 11:59:43 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Maintenance script qa.sh: + * Update PR28561 kfail. + * Remove PR31015 kfail. + * Remove PR30547 kfail. +- Patches added (backport from master): + * gdb-symtab-add-producer_is_gas.patch + * gdb-symtab-work-around-gas-pr28629.patch + * gdb-tdep-fix-nr-array-elements-in-ppc64_aggregate_ca.patch + * gdb-testsuite-fix-gdb.python-py-breakpoint.exp-with-.patch + * gdb-tui-fix-segfault-in-tui_find_disassembly_address.patch + * gdb-tui-fix-wmaybe-uninitialized-in-tui_find_disasse.patch + * gdb-testsuite-add-wait_for_msg-arg-to-term-resize-fi.patch +- Patches added (backport from gdb-patches): + * gdb-fix-segfault-in-for_each_block-part-2.patch + * gdb-tui-allow-command-window-of-1-or-2-lines.patch + * gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch + ------------------------------------------------------------------- Tue Oct 31 09:02:42 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/gdb.spec b/gdb.spec index 6757498..91aff14 100644 --- a/gdb.spec +++ b/gdb.spec @@ -337,10 +337,18 @@ Patch2043: gdb-go-handle-v3-go_0-mangled-prefix.patch Patch2044: gdb-symtab-handle-self-reference-die.patch Patch2045: gdb-symtab-handle-self-reference-in-inherit_abstract.patch Patch2046: gdb-symtab-add-optimized-out-static-var-to-cooked-in.patch +Patch2047: gdb-testsuite-fix-gdb.python-py-breakpoint.exp-with-.patch +Patch2048: gdb-tui-fix-segfault-in-tui_find_disassembly_address.patch +# Part of upstream commit deb1ba4e38b ("[gdb/tui] Fix TUI resizing for TERM=ansi"). +Patch2049: gdb-testsuite-add-wait_for_msg-arg-to-term-resize-fi.patch # Backports from master, not yet available in next release. Patch2070: gdb-symtab-work-around-pr-gas-29517.patch +Patch2071: gdb-symtab-add-producer_is_gas.patch +Patch2072: gdb-symtab-work-around-gas-pr28629.patch +Patch2073: gdb-tdep-fix-nr-array-elements-in-ppc64_aggregate_ca.patch +Patch2074: gdb-tui-fix-wmaybe-uninitialized-in-tui_find_disasse.patch # Backport from gdb-patches @@ -352,6 +360,12 @@ Patch2101: gdb-testsuite-prevent-compilation-fails-with-unix-fpie-pie.patch Patch2104: gdb-testsuite-work-around-skip_prologue-problems-in-gdb.threads-process-dies-while-detaching.exp.patch # https://sourceware.org/pipermail/gdb-patches/2021-May/178990.html Patch2105: gdb-cli-add-ignore-errors-command.patch +# https://sourceware.org/pipermail/gdb-patches/2023-November/203942.html +Patch2106: gdb-fix-segfault-in-for_each_block-part-2.patch +# https://sourceware.org/pipermail/gdb-patches/2023-November/203928.html +Patch2107: gdb-tui-allow-command-window-of-1-or-2-lines.patch +# https://sourceware.org/pipermail/gdb-patches/2023-November/203929.html +Patch2108: gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch # Debug patches. @@ -779,13 +793,23 @@ find -name "*.info*"|xargs rm -f %patch2044 -p1 %patch2045 -p1 %patch2046 -p1 +%patch2047 -p1 +%patch2048 -p1 +%patch2049 -p1 %patch2070 -p1 +%patch2071 -p1 +%patch2072 -p1 +%patch2073 -p1 +%patch2074 -p1 %patch2100 -p1 %patch2101 -p1 %patch2104 -p1 %patch2105 -p1 +%patch2106 -p1 +%patch2107 -p1 +%patch2108 -p1 #unpack libipt %if 0%{have_libipt} diff --git a/qa.sh b/qa.sh index 59a17d2..2fa6a7a 100644 --- a/qa.sh +++ b/qa.sh @@ -512,14 +512,12 @@ kfail_aarch64=( "FAIL: gdb.python/py-mi-.*.exp:" "FAIL: gdb.ada/mi.*.exp:" "FAIL: gdb.base/annota.*.exp:" - + "FAIL: gdb.dwarf2/dw2-opt-structptr.exp: mi" + ) # kfail_aarch64 kfail_powerpc64le=( - # https://sourceware.org/bugzilla/show_bug.cgi?id=31015 - "FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Small_Float_Vector" - # https://sourceware.org/bugzilla/show_bug.cgi?id=29792 "FAIL: gdb.opt/solib-intra-step.exp: second-hit" @@ -712,10 +710,6 @@ case $n in "UNRESOLVED: gdb.base/gcore-excessive-memory.exp: attach" "UNRESOLVED: gdb.base/gcore-excessive-memory.exp: verify we can get to main" - # https://sourceware.org/bugzilla/show_bug.cgi?id=30547 - "UNRESOLVED: gdb.base/vfork-follow-parent.exp: resolution_method=schedule-multiple: print unblock_parent = 1" - "UNRESOLVED: gdb.base/vfork-follow-parent.exp: resolution_method=schedule-multiple: continue to break_parent" - # https://sourceware.org/bugzilla/show_bug.cgi?id=31001 "UNRESOLVED: gdb.threads/async.exp: thread 1: current thread is 1" ) From da80731f87b7492c48464f2c0cb8cb120c786cf894d40cffe15355685bdf117e Mon Sep 17 00:00:00 2001 From: Tom de Vries <tdevries@suse.com> Date: Tue, 14 Nov 2023 18:24:58 +0000 Subject: [PATCH 10/10] - Maintenance script qa.sh: * Update PR31004 kfail. - Patches added (backport from gdb-patches): * gdb-fix-segfault-in-for_each_block-part-1.patch OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=371 --- ...ix-segfault-in-for_each_block-part-1.patch | 645 ++++++++++++++++++ gdb.changes | 8 + gdb.spec | 3 + qa.sh | 2 +- 4 files changed, 657 insertions(+), 1 deletion(-) create mode 100644 gdb-fix-segfault-in-for_each_block-part-1.patch diff --git a/gdb-fix-segfault-in-for_each_block-part-1.patch b/gdb-fix-segfault-in-for_each_block-part-1.patch new file mode 100644 index 0000000..2a84bcf --- /dev/null +++ b/gdb-fix-segfault-in-for_each_block-part-1.patch @@ -0,0 +1,645 @@ +From 75617e6d28b93814ac46ad85ad4fc2b133f61114 Mon Sep 17 00:00:00 2001 +From: Tom de Vries <tdevries@suse.de> +Date: Fri, 3 Nov 2023 16:25:33 +0100 +Subject: [PATCH] [gdb] Fix segfault in for_each_block, part 1 + +When running test-case gdb.base/vfork-follow-parent.exp on powerpc64 (likewise +on s390x), I run into: +... +(gdb) PASS: gdb.base/vfork-follow-parent.exp: \ + exec_file=vfork-follow-parent-exit: target-non-stop=on: non-stop=off: \ + resolution_method=schedule-multiple: print unblock_parent = 1 +continue^M +Continuing.^M +Reading symbols from vfork-follow-parent-exit...^M +^M +^M +Fatal signal: Segmentation fault^M +----- Backtrace -----^M +0x1027d3e7 gdb_internal_backtrace_1^M + src/gdb/bt-utils.c:122^M +0x1027d54f _Z22gdb_internal_backtracev^M + src/gdb/bt-utils.c:168^M +0x1057643f handle_fatal_signal^M + src/gdb/event-top.c:889^M +0x10576677 handle_sigsegv^M + src/gdb/event-top.c:962^M +0x3fffa7610477 ???^M +0x103f2144 for_each_block^M + src/gdb/dcache.c:199^M +0x103f235b _Z17dcache_invalidateP13dcache_struct^M + src/gdb/dcache.c:251^M +0x10bde8c7 _Z24target_dcache_invalidatev^M + src/gdb/target-dcache.c:50^M +... +or similar. + +The root cause for the segmentation fault is that linux_is_uclinux gives an +incorrect result: it should always return false, given that we're running on a +regular linux system, but instead it returns first true, then false. + +In more detail, the segmentation fault happens as follows: +- a program space with an address space is created +- a second program space is about to be created. maybe_new_address_space + is called, and because linux_is_uclinux returns true, maybe_new_address_space + returns false, and no new address space is created +- a second program space with the same address space is created +- a program space is deleted. Because linux_is_uclinux now returns false, + gdbarch_has_shared_address_space (current_inferior ()->arch ()) returns + false, and the address space is deleted +- when gdb uses the address space of the remaining program space, we run into + the segfault, because the address space is deleted. + +Hardcoding linux_is_uclinux to false makes the test-case pass. + +We leave addressing the root cause for the following commit in this series. + +For now, prevent the segmentation fault by making the address space a refcounted +object. + +This was already suggested here [1]: +... +A better solution might be to have the address spaces be reference counted +... + +Tested on top of trunk on x86_64-linux and ppc64le-linux. +Tested on top of gdb-14-branch on ppc64-linux. + +Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca> + +PR gdb/30547 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30547 + +[1] https://sourceware.org/pipermail/gdb-patches/2023-October/202928.html +--- + gdb/breakpoint.c | 29 ++++++++------- + gdb/inferior.c | 8 ++--- + gdb/inferior.h | 2 +- + gdb/infrun.c | 20 +++++------ + gdb/linux-nat.c | 2 +- + gdb/process-stratum-target.c | 2 +- + gdb/progspace.c | 22 +++++------- + gdb/progspace.h | 64 +++++++++++++++++++++------------- + gdb/record-btrace.c | 2 +- + gdb/regcache.c | 2 +- + gdb/scoped-mock-context.h | 2 +- + gdb/target-dcache.c | 11 +++--- + gdbsupport/refcounted-object.h | 17 +++++++++ + 13 files changed, 103 insertions(+), 80 deletions(-) + +diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c +index f8d19356828..f4acb4ea8c4 100644 +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -1605,7 +1605,7 @@ one_breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf, + int bptoffset = 0; + + if (!breakpoint_address_match (target_info->placed_address_space, 0, +- current_program_space->aspace, 0)) ++ current_program_space->aspace.get (), 0)) + { + /* The breakpoint is inserted in a different address space. */ + return; +@@ -2278,7 +2278,7 @@ should_be_inserted (struct bp_location *bl) + a breakpoint. */ + if ((bl->loc_type == bp_loc_software_breakpoint + || bl->loc_type == bp_loc_hardware_breakpoint) +- && stepping_past_instruction_at (bl->pspace->aspace, ++ && stepping_past_instruction_at (bl->pspace->aspace.get (), + bl->address) + /* The single-step breakpoint may be inserted at the location + we're trying to step if the instruction branches to itself. +@@ -2713,7 +2713,7 @@ insert_bp_location (struct bp_location *bl, + read the breakpoint instead of returning the data saved in + the breakpoint location's shadow contents. */ + bl->target_info.reqstd_address = bl->address; +- bl->target_info.placed_address_space = bl->pspace->aspace; ++ bl->target_info.placed_address_space = bl->pspace->aspace.get (); + bl->target_info.length = bl->length; + + /* When working with target-side conditions, we must pass all the conditions +@@ -4276,7 +4276,7 @@ bp_location_inserted_here_p (const struct bp_location *bl, + const address_space *aspace, CORE_ADDR pc) + { + if (bl->inserted +- && breakpoint_address_match (bl->pspace->aspace, bl->address, ++ && breakpoint_address_match (bl->pspace->aspace.get (), bl->address, + aspace, pc)) + { + /* An unmapped overlay can't be a match. */ +@@ -4355,7 +4355,7 @@ hardware_watchpoint_inserted_in_range (const address_space *aspace, + continue; + + for (bp_location *loc : bpt->locations ()) +- if (loc->pspace->aspace == aspace && loc->inserted) ++ if (loc->pspace->aspace.get () == aspace && loc->inserted) + { + CORE_ADDR l, h; + +@@ -7153,10 +7153,10 @@ breakpoint_location_address_match (struct bp_location *bl, + const address_space *aspace, + CORE_ADDR addr) + { +- return (breakpoint_address_match (bl->pspace->aspace, bl->address, ++ return (breakpoint_address_match (bl->pspace->aspace.get (), bl->address, + aspace, addr) + || (bl->length +- && breakpoint_address_match_range (bl->pspace->aspace, ++ && breakpoint_address_match_range (bl->pspace->aspace.get (), + bl->address, bl->length, + aspace, addr))); + } +@@ -7173,7 +7173,7 @@ breakpoint_location_address_range_overlap (struct bp_location *bl, + CORE_ADDR addr, int len) + { + if (gdbarch_has_global_breakpoints (target_gdbarch ()) +- || bl->pspace->aspace == aspace) ++ || bl->pspace->aspace.get () == aspace) + { + int bl_len = bl->length != 0 ? bl->length : 1; + +@@ -7230,8 +7230,10 @@ breakpoint_locations_match (const struct bp_location *loc1, + /* We compare bp_location.length in order to cover ranged + breakpoints. Keep this in sync with + bp_location_is_less_than. */ +- return (breakpoint_address_match (loc1->pspace->aspace, loc1->address, +- loc2->pspace->aspace, loc2->address) ++ return (breakpoint_address_match (loc1->pspace->aspace.get (), ++ loc1->address, ++ loc2->pspace->aspace.get (), ++ loc2->address) + && (loc1->loc_type == loc2->loc_type || sw_hw_bps_match) + && loc1->length == loc2->length); + } +@@ -9297,8 +9299,9 @@ ranged_breakpoint::breakpoint_hit (const struct bp_location *bl, + || ws.sig () != GDB_SIGNAL_TRAP) + return 0; + +- return breakpoint_address_match_range (bl->pspace->aspace, bl->address, +- bl->length, aspace, bp_addr); ++ return breakpoint_address_match_range (bl->pspace->aspace.get (), ++ bl->address, bl->length, aspace, ++ bp_addr); + } + + /* Implement the "resources_needed" method for ranged breakpoints. */ +@@ -11696,7 +11699,7 @@ code_breakpoint::breakpoint_hit (const struct bp_location *bl, + || ws.sig () != GDB_SIGNAL_TRAP) + return 0; + +- if (!breakpoint_address_match (bl->pspace->aspace, bl->address, ++ if (!breakpoint_address_match (bl->pspace->aspace.get (), bl->address, + aspace, bp_addr)) + return 0; + +diff --git a/gdb/inferior.c b/gdb/inferior.c +index b0ecca8b63a..87c61eeafd7 100644 +--- a/gdb/inferior.c ++++ b/gdb/inferior.c +@@ -775,15 +775,13 @@ remove_inferior_command (const char *args, int from_tty) + struct inferior * + add_inferior_with_spaces (void) + { +- struct address_space *aspace; + struct program_space *pspace; + struct inferior *inf; + + /* If all inferiors share an address space on this system, this + doesn't really return a new address space; otherwise, it + really does. */ +- aspace = maybe_new_address_space (); +- pspace = new program_space (aspace); ++ pspace = new program_space (maybe_new_address_space ()); + inf = add_inferior (0); + inf->pspace = pspace; + inf->aspace = pspace->aspace; +@@ -946,15 +944,13 @@ clone_inferior_command (const char *args, int from_tty) + + for (i = 0; i < copies; ++i) + { +- struct address_space *aspace; + struct program_space *pspace; + struct inferior *inf; + + /* If all inferiors share an address space on this system, this + doesn't really return a new address space; otherwise, it + really does. */ +- aspace = maybe_new_address_space (); +- pspace = new program_space (aspace); ++ pspace = new program_space (maybe_new_address_space ()); + inf = add_inferior (0); + inf->pspace = pspace; + inf->aspace = pspace->aspace; +diff --git a/gdb/inferior.h b/gdb/inferior.h +index 4d001b0ad50..fa5c3c92eeb 100644 +--- a/gdb/inferior.h ++++ b/gdb/inferior.h +@@ -541,7 +541,7 @@ class inferior : public refcounted_object, + bool removable = false; + + /* The address space bound to this inferior. */ +- struct address_space *aspace = NULL; ++ address_space_ref_ptr aspace; + + /* The program space bound to this inferior. */ + struct program_space *pspace = NULL; +diff --git a/gdb/infrun.c b/gdb/infrun.c +index c078098a6f8..4073150d80c 100644 +--- a/gdb/infrun.c ++++ b/gdb/infrun.c +@@ -501,8 +501,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \ + } + else + { +- child_inf->aspace = new address_space (); +- child_inf->pspace = new program_space (child_inf->aspace); ++ child_inf->pspace = new program_space (new_address_space ()); ++ child_inf->aspace = child_inf->pspace->aspace; + child_inf->removable = true; + clone_program_space (child_inf->pspace, parent_inf->pspace); + } +@@ -573,8 +573,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \ + + child_inf->aspace = parent_inf->aspace; + child_inf->pspace = parent_inf->pspace; +- parent_inf->aspace = new address_space (); +- parent_inf->pspace = new program_space (parent_inf->aspace); ++ parent_inf->pspace = new program_space (new_address_space ()); ++ parent_inf->aspace = parent_inf->pspace->aspace; + clone_program_space (parent_inf->pspace, child_inf->pspace); + + /* The parent inferior is still the current one, so keep things +@@ -583,8 +583,8 @@ holding the child stopped. Try \"set detach-on-fork\" or \ + } + else + { +- child_inf->aspace = new address_space (); +- child_inf->pspace = new program_space (child_inf->aspace); ++ child_inf->pspace = new program_space (new_address_space ()); ++ child_inf->aspace = child_inf->pspace->aspace; + child_inf->removable = true; + child_inf->symfile_flags = SYMFILE_NO_READ; + clone_program_space (child_inf->pspace, parent_inf->pspace); +@@ -938,7 +938,6 @@ handle_vfork_child_exec_or_exit (int exec) + if (vfork_parent->pending_detach) + { + struct program_space *pspace; +- struct address_space *aspace; + + /* follow-fork child, detach-on-fork on. */ + +@@ -963,9 +962,8 @@ handle_vfork_child_exec_or_exit (int exec) + of" a hack. */ + + pspace = inf->pspace; +- aspace = inf->aspace; +- inf->aspace = nullptr; + inf->pspace = nullptr; ++ address_space_ref_ptr aspace = std::move (inf->aspace); + + if (print_inferior_events) + { +@@ -1019,7 +1017,7 @@ handle_vfork_child_exec_or_exit (int exec) + /* Temporarily switch to the vfork parent, to facilitate ptrace + calls done during maybe_new_address_space. */ + switch_to_thread (any_live_thread_of_inferior (vfork_parent)); +- address_space *aspace = maybe_new_address_space (); ++ address_space_ref_ptr aspace = maybe_new_address_space (); + + /* Switch back to the vfork child inferior. Switch to no-thread + while running clone_program_space, so that clone_program_space +@@ -5639,7 +5637,7 @@ handle_inferior_event (struct execution_control_state *ecs) + = get_thread_arch_aspace_regcache (parent_inf->process_target (), + ecs->ws.child_ptid (), + gdbarch, +- parent_inf->aspace); ++ parent_inf->aspace.get ()); + /* Read PC value of parent process. */ + parent_pc = regcache_read_pc (regcache); + +diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c +index 2b206a4ec1e..474d3c7f945 100644 +--- a/gdb/linux-nat.c ++++ b/gdb/linux-nat.c +@@ -4316,7 +4316,7 @@ linux_nat_target::thread_address_space (ptid_t ptid) + + inf = find_inferior_pid (this, pid); + gdb_assert (inf != NULL); +- return inf->aspace; ++ return inf->aspace.get (); + } + + /* Return the cached value of the processor core for thread PTID. */ +diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c +index 4722c5a0f28..e67012a8591 100644 +--- a/gdb/process-stratum-target.c ++++ b/gdb/process-stratum-target.c +@@ -37,7 +37,7 @@ process_stratum_target::thread_address_space (ptid_t ptid) + "address space of thread %s\n"), + target_pid_to_str (ptid).c_str ()); + +- return inf->aspace; ++ return inf->aspace.get (); + } + + struct gdbarch * +diff --git a/gdb/progspace.c b/gdb/progspace.c +index 32bdfebcf7c..55df3b65dfe 100644 +--- a/gdb/progspace.c ++++ b/gdb/progspace.c +@@ -54,8 +54,8 @@ address_space::address_space () + return a pointer to an existing address space, in case inferiors + share an address space on this target system. */ + +-struct address_space * +-maybe_new_address_space (void) ++address_space_ref_ptr ++maybe_new_address_space () + { + int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ()); + +@@ -65,7 +65,7 @@ maybe_new_address_space (void) + return program_spaces[0]->aspace; + } + +- return new address_space (); ++ return new_address_space (); + } + + /* Start counting over from scratch. */ +@@ -93,9 +93,9 @@ remove_program_space (program_space *pspace) + + /* See progspace.h. */ + +-program_space::program_space (address_space *aspace_) ++program_space::program_space (address_space_ref_ptr aspace_) + : num (++last_program_space_num), +- aspace (aspace_) ++ aspace (std::move (aspace_)) + { + program_spaces.push_back (this); + } +@@ -118,8 +118,6 @@ program_space::~program_space () + /* Defer breakpoint re-set because we don't want to create new + locations for this pspace which we're tearing down. */ + clear_symtab_users (SYMFILE_DEFER_BP_RESET); +- if (!gdbarch_has_shared_address_space (target_gdbarch ())) +- delete this->aspace; + } + + /* See progspace.h. */ +@@ -389,18 +387,14 @@ update_address_spaces (void) + + if (shared_aspace) + { +- struct address_space *aspace = new address_space (); ++ address_space_ref_ptr aspace = new_address_space (); + +- delete current_program_space->aspace; + for (struct program_space *pspace : program_spaces) + pspace->aspace = aspace; + } + else + for (struct program_space *pspace : program_spaces) +- { +- delete pspace->aspace; +- pspace->aspace = new address_space (); +- } ++ pspace->aspace = new_address_space (); + + for (inferior *inf : all_inferiors ()) + if (gdbarch_has_global_solist (target_gdbarch ())) +@@ -437,5 +431,5 @@ initialize_progspace (void) + modules have done that. Do this before + initialize_current_architecture, because that accesses the ebfd + of current_program_space. */ +- current_program_space = new program_space (new address_space ()); ++ current_program_space = new program_space (new_address_space ()); + } +diff --git a/gdb/progspace.h b/gdb/progspace.h +index 85215f0e2f1..07cca8c675c 100644 +--- a/gdb/progspace.h ++++ b/gdb/progspace.h +@@ -28,6 +28,8 @@ + #include "solist.h" + #include "gdbsupport/next-iterator.h" + #include "gdbsupport/safe-iterator.h" ++#include "gdbsupport/refcounted-object.h" ++#include "gdbsupport/gdb_ref_ptr.h" + #include <list> + #include <vector> + +@@ -42,6 +44,40 @@ struct so_list; + + typedef std::list<std::unique_ptr<objfile>> objfile_list; + ++/* An address space. It is used for comparing if ++ pspaces/inferior/threads see the same address space and for ++ associating caches to each address space. */ ++struct address_space : public refcounted_object ++{ ++ /* Create a new address space object, and add it to the list. */ ++ address_space (); ++ DISABLE_COPY_AND_ASSIGN (address_space); ++ ++ /* Returns the integer address space id of this address space. */ ++ int num () const ++ { ++ return m_num; ++ } ++ ++ /* Per aspace data-pointers required by other GDB modules. */ ++ registry<address_space> registry_fields; ++ ++private: ++ int m_num; ++}; ++ ++using address_space_ref_ptr ++ = gdb::ref_ptr<address_space, ++ refcounted_object_delete_ref_policy<address_space>>; ++ ++/* Create a new address space. */ ++ ++static inline address_space_ref_ptr ++new_address_space () ++{ ++ return address_space_ref_ptr::new_reference (new address_space); ++} ++ + /* An iterator that wraps an iterator over std::unique_ptr<objfile>, + and dereferences the returned object. This is useful for iterating + over a list of shared pointers and returning raw pointers -- which +@@ -191,7 +227,7 @@ struct program_space + { + /* Constructs a new empty program space, binds it to ASPACE, and + adds it to the program space list. */ +- explicit program_space (address_space *aspace); ++ explicit program_space (address_space_ref_ptr aspace); + + /* Releases a program space, and all its contents (shared libraries, + objfiles, and any other references to the program space in other +@@ -332,7 +368,7 @@ struct program_space + are global, then this field is ignored (we don't currently + support inferiors sharing a program space if the target doesn't + make breakpoints global). */ +- struct address_space *aspace = NULL; ++ address_space_ref_ptr aspace; + + /* True if this program space's section offsets don't yet represent + the final offsets of the "live" address space (that is, the +@@ -379,28 +415,6 @@ struct program_space + target_section_table m_target_sections; + }; + +-/* An address space. It is used for comparing if +- pspaces/inferior/threads see the same address space and for +- associating caches to each address space. */ +-struct address_space +-{ +- /* Create a new address space object, and add it to the list. */ +- address_space (); +- DISABLE_COPY_AND_ASSIGN (address_space); +- +- /* Returns the integer address space id of this address space. */ +- int num () const +- { +- return m_num; +- } +- +- /* Per aspace data-pointers required by other GDB modules. */ +- registry<address_space> registry_fields; +- +-private: +- int m_num; +-}; +- + /* The list of all program spaces. There's always at least one. */ + extern std::vector<struct program_space *>program_spaces; + +@@ -443,7 +457,7 @@ class scoped_restore_current_program_space + /* Maybe create a new address space object, and add it to the list, or + return a pointer to an existing address space, in case inferiors + share an address space. */ +-extern struct address_space *maybe_new_address_space (void); ++extern address_space_ref_ptr maybe_new_address_space (); + + /* Update all program spaces matching to address spaces. The user may + have created several program spaces, and loaded executables into +diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c +index 0daba893813..276cdcc03b8 100644 +--- a/gdb/record-btrace.c ++++ b/gdb/record-btrace.c +@@ -2314,7 +2314,7 @@ record_btrace_replay_at_breakpoint (struct thread_info *tp) + if (insn == NULL) + return 0; + +- return record_check_stopped_by_breakpoint (tp->inf->aspace, insn->pc, ++ return record_check_stopped_by_breakpoint (tp->inf->aspace.get (), insn->pc, + &btinfo->stop_reason); + } + +diff --git a/gdb/regcache.c b/gdb/regcache.c +index 56b6d047874..8a0b57e67b8 100644 +--- a/gdb/regcache.c ++++ b/gdb/regcache.c +@@ -1617,7 +1617,7 @@ get_thread_arch_aspace_regcache_and_check (process_stratum_target *target, + the current inferior's gdbarch. Also use the current inferior's address + space. */ + gdbarch *arch = current_inferior ()->gdbarch; +- address_space *aspace = current_inferior ()->aspace; ++ address_space *aspace = current_inferior ()->aspace.get (); + regcache *regcache + = get_thread_arch_aspace_regcache (target, ptid, arch, aspace); + +diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h +index 9ad7ebf5f0c..5f25dc7ed6b 100644 +--- a/gdb/scoped-mock-context.h ++++ b/gdb/scoped-mock-context.h +@@ -38,7 +38,7 @@ struct scoped_mock_context + + Target mock_target; + ptid_t mock_ptid {1, 1}; +- program_space mock_pspace {new address_space ()}; ++ program_space mock_pspace {new_address_space ()}; + inferior mock_inferior {mock_ptid.pid ()}; + thread_info mock_thread {&mock_inferior, mock_ptid}; + +diff --git a/gdb/target-dcache.c b/gdb/target-dcache.c +index 13c2888e7ea..b1b772ab76e 100644 +--- a/gdb/target-dcache.c ++++ b/gdb/target-dcache.c +@@ -33,7 +33,7 @@ int + target_dcache_init_p (void) + { + DCACHE *dcache +- = target_dcache_aspace_key.get (current_program_space->aspace); ++ = target_dcache_aspace_key.get (current_program_space->aspace.get ()); + + return (dcache != NULL); + } +@@ -44,7 +44,7 @@ void + target_dcache_invalidate (void) + { + DCACHE *dcache +- = target_dcache_aspace_key.get (current_program_space->aspace); ++ = target_dcache_aspace_key.get (current_program_space->aspace.get ()); + + if (dcache != NULL) + dcache_invalidate (dcache); +@@ -56,7 +56,7 @@ target_dcache_invalidate (void) + DCACHE * + target_dcache_get (void) + { +- return target_dcache_aspace_key.get (current_program_space->aspace); ++ return target_dcache_aspace_key.get (current_program_space->aspace.get ()); + } + + /* Return the target dcache. If it is not initialized yet, initialize +@@ -66,12 +66,13 @@ DCACHE * + target_dcache_get_or_init (void) + { + DCACHE *dcache +- = target_dcache_aspace_key.get (current_program_space->aspace); ++ = target_dcache_aspace_key.get (current_program_space->aspace.get ()); + + if (dcache == NULL) + { + dcache = dcache_init (); +- target_dcache_aspace_key.set (current_program_space->aspace, dcache); ++ target_dcache_aspace_key.set (current_program_space->aspace.get (), ++ dcache); + } + + return dcache; +diff --git a/gdbsupport/refcounted-object.h b/gdbsupport/refcounted-object.h +index d8fdb950043..294fd873df1 100644 +--- a/gdbsupport/refcounted-object.h ++++ b/gdbsupport/refcounted-object.h +@@ -67,4 +67,21 @@ struct refcounted_object_ref_policy + } + }; + ++/* A policy class to interface gdb::ref_ptr with a refcounted_object, that ++ deletes the object once the refcount reaches 0.. */ ++ ++template<typename T> ++struct refcounted_object_delete_ref_policy ++{ ++ static void incref (T *obj) ++ { obj->incref (); } ++ ++ static void decref (T *obj) ++ { ++ obj->decref (); ++ if (obj->refcount () == 0) ++ delete obj; ++ } ++}; ++ + #endif /* COMMON_REFCOUNTED_OBJECT_H */ + +base-commit: c55a452eaf9390d5659d3205f762aa2cb84511e1 +-- +2.35.3 + diff --git a/gdb.changes b/gdb.changes index d685db0..b40f848 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Nov 13 14:08:08 UTC 2023 - Tom de Vries <tdevries@suse.com> + +- Maintenance script qa.sh: + * Update PR31004 kfail. +- Patches added (backport from gdb-patches): + * gdb-fix-segfault-in-for_each_block-part-1.patch + ------------------------------------------------------------------- Tue Oct 31 11:59:43 UTC 2023 - Tom de Vries <tdevries@suse.com> diff --git a/gdb.spec b/gdb.spec index 91aff14..1424d9f 100644 --- a/gdb.spec +++ b/gdb.spec @@ -366,6 +366,8 @@ Patch2106: gdb-fix-segfault-in-for_each_block-part-2.patch Patch2107: gdb-tui-allow-command-window-of-1-or-2-lines.patch # https://sourceware.org/pipermail/gdb-patches/2023-November/203929.html Patch2108: gdb-tui-fix-resizing-of-terminal-to-1-or-2-lines.patch +# https://sourceware.org/pipermail/gdb-patches/2023-November/203943.html +Patch2109: gdb-fix-segfault-in-for_each_block-part-1.patch # Debug patches. @@ -810,6 +812,7 @@ find -name "*.info*"|xargs rm -f %patch2106 -p1 %patch2107 -p1 %patch2108 -p1 +%patch2109 -p1 #unpack libipt %if 0%{have_libipt} diff --git a/qa.sh b/qa.sh index 2fa6a7a..0b68caa 100644 --- a/qa.sh +++ b/qa.sh @@ -588,7 +588,7 @@ kfail_powerpc64le=( "FAIL: gdb.python/py-breakpoint.exp: test_bkpt_eval_funcs: Test watchpoint write \(the program exited\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=31004 - "FAIL: gdb.base/run-control-while-bg-execution.exp: action1=kill: action2=run: run" + "FAIL: gdb.base/run-control-while-bg-execution.exp: action1=.*: action2=run: run" ) kfail_powerpc64le_sle12=(