From 92a549afd0750b9061a9744dc1ccb7f8d19a6717 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Wed, 15 Nov 2023 03:46:27 +0000 Subject: [PATCH] import UBI gdb-8.2-20.el8 --- SOURCES/_gdb.spec.Patch.include | 13 ++++ SOURCES/_gdb.spec.patch.include | 3 + ...arn-dw2_find_pc_sect_compunit_symtab.patch | 40 ++++++++++ ...rhbz2156888-copy_type-assertion-1of2.patch | 74 +++++++++++++++++++ ...rhbz2156888-copy_type-assertion-2of2.patch | 71 ++++++++++++++++++ SPECS/gdb.spec | 9 ++- 6 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 SOURCES/gdb-rhbz2150363-warn-dw2_find_pc_sect_compunit_symtab.patch create mode 100644 SOURCES/gdb-rhbz2156888-copy_type-assertion-1of2.patch create mode 100644 SOURCES/gdb-rhbz2156888-copy_type-assertion-2of2.patch diff --git a/SOURCES/_gdb.spec.Patch.include b/SOURCES/_gdb.spec.Patch.include index cdcadc2..669bb48 100644 --- a/SOURCES/_gdb.spec.Patch.include +++ b/SOURCES/_gdb.spec.Patch.include @@ -815,3 +815,16 @@ Patch199: gdb-rhbz2015131-restore-inferior-terminal-1of2.patch # (Simon Marchi, related to RHBZ 2015131) Patch200: gdb-rhbz2015131-avoid-sigttou-forks-2of2.patch +# Change assertion to warning in dw2_find_pc_sect_compunit_symtab +# Based on "Fix crash in new DWARF indexer" +# (Tom Tromey, RHBZ 2150363) +Patch201: gdb-rhbz2150363-warn-dw2_find_pc_sect_compunit_symtab.patch + +# Backport "Fix assertion failure in copy_type" +# (Tom Tromey, RHBZ 2156888) +Patch202: gdb-rhbz2156888-copy_type-assertion-1of2.patch + +# Backport of "Fix PR20630 regression test in gdb.base/printcmds.exp" +# (Tom deVries, RHBZ 2156888) +Patch203: gdb-rhbz2156888-copy_type-assertion-2of2.patch + diff --git a/SOURCES/_gdb.spec.patch.include b/SOURCES/_gdb.spec.patch.include index eba9d45..5939104 100644 --- a/SOURCES/_gdb.spec.patch.include +++ b/SOURCES/_gdb.spec.patch.include @@ -198,3 +198,6 @@ %patch198 -p1 %patch199 -p1 %patch200 -p1 +%patch201 -p1 +%patch202 -p1 +%patch203 -p1 diff --git a/SOURCES/gdb-rhbz2150363-warn-dw2_find_pc_sect_compunit_symtab.patch b/SOURCES/gdb-rhbz2150363-warn-dw2_find_pc_sect_compunit_symtab.patch new file mode 100644 index 0000000..2b4c7d6 --- /dev/null +++ b/SOURCES/gdb-rhbz2150363-warn-dw2_find_pc_sect_compunit_symtab.patch @@ -0,0 +1,40 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Mon, 27 Mar 2023 16:05:48 -0400 +Subject: gdb-rhbz2150363-warn-dw2_find_pc_sect_compunit_symtab.patch + +;; Change assertion to warning in dw2_find_pc_sect_compunit_symtab +;; Based on "Fix crash in new DWARF indexer" +;; (Tom Tromey, RHBZ 2150363) + +The assertion: + +../../gdb/dwarf2read.c:5272: internal-error: compunit_symtab* dw2_find_pc_sect_compunit_symtab(objfile*, bound_minimal_symbol, CORE_ADDR, obj_section*, int): Assertion `result != NULL' failed. + +was removed with the "Fix crash in new DWARF indexer" patch. Backport +this assertion removal from this patch. + +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -5261,15 +5261,15 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile, + if (!data) + return NULL; + +- if (warn_if_readin && data->v.quick->compunit_symtab) +- warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"), +- paddress (get_objfile_arch (objfile), pc)); +- + result + = recursively_find_pc_sect_compunit_symtab (dw2_instantiate_symtab (data, + false), + pc); +- gdb_assert (result != NULL); ++ ++ if (warn_if_readin && result == nullptr) ++ warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"), ++ paddress (get_objfile_arch (objfile), pc)); ++ + return result; + } + diff --git a/SOURCES/gdb-rhbz2156888-copy_type-assertion-1of2.patch b/SOURCES/gdb-rhbz2156888-copy_type-assertion-1of2.patch new file mode 100644 index 0000000..6976bd1 --- /dev/null +++ b/SOURCES/gdb-rhbz2156888-copy_type-assertion-1of2.patch @@ -0,0 +1,74 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Mon, 27 Mar 2023 16:12:19 -0400 +Subject: gdb-rhbz2156888-copy_type-assertion-1of2.patch + +;; Backport "Fix assertion failure in copy_type" +;; (Tom Tromey, RHBZ 2156888) + +PR exp/20630 points out a simple way to cause an assertion failure in +copy_type -- but this was found in the wild a few times as well. + +copy_type only works for objfile-owned types, but there isn't a deep +reason for this. This patch fixes the bug by updating copy_type to +work for any sort of type. + +Better would perhaps be to finally implement type GC, but I still +haven't attempted this. + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20630 + +diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c +--- a/gdb/gdbtypes.c ++++ b/gdb/gdbtypes.c +@@ -5027,27 +5027,25 @@ copy_type_recursive (struct objfile *objfile, + } + + /* Make a copy of the given TYPE, except that the pointer & reference +- types are not preserved. +- +- This function assumes that the given type has an associated objfile. +- This objfile is used to allocate the new type. */ ++ types are not preserved. */ + + struct type * + copy_type (const struct type *type) + { +- struct type *new_type; +- +- gdb_assert (TYPE_OBJFILE_OWNED (type)); +- +- new_type = alloc_type_copy (type); ++ struct type *new_type = alloc_type_copy (type); + TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); + TYPE_LENGTH (new_type) = TYPE_LENGTH (type); + memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type), + sizeof (struct main_type)); + if (TYPE_DYN_PROP_LIST (type) != NULL) +- TYPE_DYN_PROP_LIST (new_type) +- = copy_dynamic_prop_list (&TYPE_OBJFILE (type) -> objfile_obstack, +- TYPE_DYN_PROP_LIST (type)); ++ { ++ struct obstack *storage = (TYPE_OBJFILE_OWNED (type) ++ ? &TYPE_OBJFILE (type)->objfile_obstack ++ : gdbarch_obstack (TYPE_OWNER (type).gdbarch)); ++ ++ TYPE_DYN_PROP_LIST (new_type) ++ = copy_dynamic_prop_list (storage, TYPE_DYN_PROP_LIST (type)); ++ } + + return new_type; + } +diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp +--- a/gdb/testsuite/gdb.base/printcmds.exp ++++ b/gdb/testsuite/gdb.base/printcmds.exp +@@ -730,6 +730,9 @@ proc test_print_array_constants {} { + gdb_test_escape_braces "print {{0,1,2},{3,4,5}}" " = {{0, 1, 2}, {3, 4, 5}}" + gdb_test "print {4,5,6}\[2\]" " = 6" + gdb_test "print *&{4,5,6}\[1\]" "Attempt to take address of value not located in memory." ++ ++ # This used to cause a crash. ++ gdb_test "print {unsigned char[]}{65}" " = 65 'A'" + } + + proc test_print_enums {} { diff --git a/SOURCES/gdb-rhbz2156888-copy_type-assertion-2of2.patch b/SOURCES/gdb-rhbz2156888-copy_type-assertion-2of2.patch new file mode 100644 index 0000000..418099f --- /dev/null +++ b/SOURCES/gdb-rhbz2156888-copy_type-assertion-2of2.patch @@ -0,0 +1,71 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Keith Seitz +Date: Mon, 27 Mar 2023 16:23:54 -0400 +Subject: gdb-rhbz2156888-copy_type-assertion-2of2.patch + +;; Backport of "Fix PR20630 regression test in gdb.base/printcmds.exp" +;; (Tom deVries, RHBZ 2156888) + +On s390x-linux, I run into: +... +(gdb) print {unsigned char}{65}^M +$749 = 0 '\000'^M +(gdb) FAIL: gdb.base/printcmds.exp: print {unsigned char}{65} +... + +In contrast, on x86_64-linux, we have: +... +(gdb) print {unsigned char}{65}^M +$749 = 65 'A'^M +(gdb) PASS: gdb.base/printcmds.exp: print {unsigned char}{65} +... + +The first problem here is that the test is supposed to be a regression test +for PR20630, which can be reproduced (for an unfixed gdb) like this: +... +(gdb) p {unsigned char[]}{0x17} +gdbtypes.c:4641: internal-error: copy_type: \ + Assertion `TYPE_OBJFILE_OWNED (type)' failed. +... +but it's not due to insufficient quoting (note the dropped '[]'). + +That's easy to fix, but after that we have on s390 (big endian): +... +(gdb) print {unsigned char[]}{65}^M +$749 = ""^M +... +and on x86_64 (little endian): +... +(gdb) print {unsigned char[]}{65}^M +$749 = "A"^M +... + +Fix this by using 0xffffffff, such that in both cases we have: +... +(gdb) print {unsigned char[]}{0xffffffff}^M +$749 = "\377\377\377\377"^M +... + +Tested on x86_64-linux and s390x-linux. + +diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp +--- a/gdb/testsuite/gdb.base/printcmds.exp ++++ b/gdb/testsuite/gdb.base/printcmds.exp +@@ -714,6 +714,7 @@ proc test_print_string_constants {} { + } + + proc test_print_array_constants {} { ++ global hex + + if [target_info exists gdb,cannot_call_functions] { + unsupported "this target can not call functions" +@@ -732,7 +733,8 @@ proc test_print_array_constants {} { + gdb_test "print *&{4,5,6}\[1\]" "Attempt to take address of value not located in memory." + + # This used to cause a crash. +- gdb_test "print {unsigned char[]}{65}" " = 65 'A'" ++ set val [string_to_regexp {"\377\377\377\377"}] ++ gdb_test "print {unsigned char\[\]}{0xffffffff}" " = $val" + } + + proc test_print_enums {} { diff --git a/SPECS/gdb.spec b/SPECS/gdb.spec index 2806f06..895fc4b 100644 --- a/SPECS/gdb.spec +++ b/SPECS/gdb.spec @@ -26,7 +26,7 @@ Version: 8.2 # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. -Release: 19%{?dist} +Release: 20%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL Group: Development/Debuggers @@ -1062,6 +1062,13 @@ fi %endif %changelog +* Tue Mar 28 2023 Keith Seitz - 8.2-20.el8 +- Backport portion of "Fix crash in new DWARF indexer". + (Tom Tromey, RH BZ 2150363) +- Backport "Fix assertion failure in copy_type" and + "Fix PR20630 regression test in gdb.base/printcmds.exp". + (Tom Tromey and Tom de Vries, RH BZ 2156888) + * Tue May 24 2022 Keith Seitz - 8.2-19.el8 - Backport "Fix restoring of inferior terminal settings" - Backport "Avoid GDB SIGTTOU on catch exec + set follow-exec-mode