public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/gdb] gdb-17.2-rebase-f44: Back-port fix for RHBZ 2152431
@ 2026-06-28 0:00 Andrew Burgess
0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2026-06-28 0:00 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/gdb
Branch : gdb-17.2-rebase-f44
Commit : 69f0c792d65d961b609d38485da547467f47bae6
Author : Andrew Burgess <aburgess@redhat.com>
Date : 2022-12-19T17:01:56+00:00
Stats : +190/-0 in 5 file(s)
URL : https://src.fedoraproject.org/rpms/gdb/c/69f0c792d65d961b609d38485da547467f47bae6?branch=gdb-17.2-rebase-f44
Log:
Back-port fix for RHBZ 2152431
Fixes RHBZ 2152431, an issue where reading a label symbol's value
would cause GDB to crash. This pulls in two upstream commits
38665d717a3 and c3efaf0afd9 both of which should be in GDB 13 when it
is released.
---
diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include
index 792b270..3907c89 100644
--- a/_gdb.spec.Patch.include
+++ b/_gdb.spec.Patch.include
@@ -277,3 +277,6 @@ Patch065: gdb-sw22395-constify-target_desc.patch
# (Florian Weimer, RHBZ 2143992)
Patch066: gdb-rhbz2143992-libiberty-fix-c89isms-in-configure.patch
+
+Patch067: gdb-rhbz2152431-label-symbol-value.patch
+
diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include
index 8d1967c..9dbbe98 100644
--- a/_gdb.spec.patch.include
+++ b/_gdb.spec.patch.include
@@ -64,3 +64,4 @@
%patch064 -p1
%patch065 -p1
%patch066 -p1
+%patch067 -p1
diff --git a/_patch_order b/_patch_order
index bb36e5c..2cebc89 100644
--- a/_patch_order
+++ b/_patch_order
@@ -64,3 +64,4 @@ gdb-backport-readline_support.patch
gdb-backport-fix-break-main-file-remove-fail.patch
gdb-sw22395-constify-target_desc.patch
gdb-rhbz2143992-libiberty-fix-c89isms-in-configure.patch
+gdb-rhbz2152431-label-symbol-value.patch
diff --git a/gdb-rhbz2152431-label-symbol-value.patch b/gdb-rhbz2152431-label-symbol-value.patch
new file mode 100644
index 0000000..32d2942
--- /dev/null
+++ b/gdb-rhbz2152431-label-symbol-value.patch
@@ -0,0 +1,181 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Andrew Burgess <aburgess@redhat.com>
+Date: Mon, 19 Dec 2022 15:57:59 +0000
+Subject: gdb-rhbz2152431-label-symbol-value.patch
+
+Backport these two upstream commits to fix bug 2152431:
+
+ commit 38665d717a3e65c70e6432243d5eed9728a4888a
+ Date: Mon Dec 12 14:09:40 2022 +0000
+
+ gdb: use gdb_assert not internal_error
+
+And:
+
+ commit c3efaf0afd9d37004c42cdfd3ce0c1bfa979c45e
+ Date: Mon Dec 12 14:05:22 2022 +0000
+
+ gdb: fix crash when getting the value of a label symbol
+
+diff --git a/gdb/findvar.c b/gdb/findvar.c
+--- a/gdb/findvar.c
++++ b/gdb/findvar.c
+@@ -152,11 +152,7 @@ extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
+ CORE_ADDR
+ extract_typed_address (const gdb_byte *buf, struct type *type)
+ {
+- if (!type->is_pointer_or_reference ())
+- internal_error (__FILE__, __LINE__,
+- _("extract_typed_address: "
+- "type is not a pointer or reference"));
+-
++ gdb_assert (type->is_pointer_or_reference ());
+ return gdbarch_pointer_to_address (type->arch (), type, buf);
+ }
+
+@@ -205,11 +201,7 @@ template void store_integer (gdb_byte *addr, int len,
+ void
+ store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr)
+ {
+- if (!type->is_pointer_or_reference ())
+- internal_error (__FILE__, __LINE__,
+- _("store_typed_address: "
+- "type is not a pointer or reference"));
+-
++ gdb_assert (type->is_pointer_or_reference ());
+ gdbarch_address_to_pointer (type->arch (), type, buf, addr);
+ }
+
+@@ -634,19 +626,32 @@ language_defn::read_var_value (struct symbol *var,
+
+ case LOC_LABEL:
+ /* Put the constant back in target format. */
+- v = allocate_value (type);
+- if (overlay_debugging)
+- {
+- struct objfile *var_objfile = symbol_objfile (var);
+- addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
+- var->obj_section (var_objfile));
+- store_typed_address (value_contents_raw (v).data (), type, addr);
+- }
+- else
+- store_typed_address (value_contents_raw (v).data (), type,
+- SYMBOL_VALUE_ADDRESS (var));
+- VALUE_LVAL (v) = not_lval;
+- return v;
++ {
++ /* Put the constant back in target format. */
++ if (overlay_debugging)
++ {
++ struct objfile *var_objfile = symbol_objfile (var);
++ addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
++ var->obj_section (var_objfile));
++ }
++ else
++ addr = SYMBOL_VALUE_ADDRESS (var);
++
++ /* First convert the CORE_ADDR to a function pointer type, this
++ ensures the gdbarch knows what type of pointer we are
++ manipulating when value_from_pointer is called. */
++ type = builtin_type (symbol_arch (var))->builtin_func_ptr;
++ v = value_from_pointer (type, addr);
++
++ /* But we want to present the value as 'void *', so cast it to the
++ required type now, this will not change the values bit
++ representation. */
++ struct type *void_ptr_type
++ = builtin_type (symbol_arch (var))->builtin_data_ptr;
++ v = value_cast_pointers (void_ptr_type, v, 0);
++ VALUE_LVAL (v) = not_lval;
++ return v;
++ }
+
+ case LOC_CONST_BYTES:
+ if (is_dynamic_type (type))
+diff --git a/gdb/testsuite/gdb.python/py-label-symbol-value.c b/gdb/testsuite/gdb.python/py-label-symbol-value.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.python/py-label-symbol-value.c
+@@ -0,0 +1,38 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2022 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++volatile int global_var = 1;
++
++int
++get_value ()
++{
++ return global_var;
++}
++
++int
++main (void)
++{
++ int value = get_value ();
++ if (value > 0)
++ goto some_label;
++
++ return 1;
++
++ some_label:
++
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.python/py-label-symbol-value.exp b/gdb/testsuite/gdb.python/py-label-symbol-value.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.python/py-label-symbol-value.exp
+@@ -0,0 +1,39 @@
++# Copyright 2022 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++# Check that GDB handles the user asking for the value of a label
++# symbol (i.e. a symbol for a goto label).
++
++load_lib gdb-python.exp
++standard_testfile
++
++if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
++ return -1
++}
++
++# Skip all tests if Python scripting is not enabled.
++if { [skip_python_tests] } { continue }
++
++if ![runto_main] {
++ return -1
++}
++
++# Use Python to print the value of the 'some_label' symbol.
++gdb_test "python frame = gdb.selected_frame()"
++gdb_test "python frame_pc = frame.pc()"
++gdb_test "python block = gdb.current_progspace().block_for_pc(frame_pc)"
++gdb_test "python symbol,_ = gdb.lookup_symbol('some_label', block, gdb.SYMBOL_LABEL_DOMAIN)"
++gdb_test "python print(str(symbol.value()))" "$hex <main\\+$decimal>"
++gdb_test "python print(str(symbol.value().type))" "void \\*"
diff --git a/gdb.spec b/gdb.spec
index 68f5e8a..21456c8 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -1190,6 +1190,10 @@ fi
%endif
%changelog
+* Mon Dec 19 2022 Andrew Burgess <aburgess@redhat.com>
+- Backport upstream commits 38665d717a3 and c3efaf0afd9 to fix RHBZ
+ 2152431.
+
* Fri Dec 16 2022 Keith Seitz <keiths@redhat.com>
- Remove gdb-6.6-buildid-locate-rpm-scl.patch and
gdb-bz601887-dwarf4-rh-test.patch.
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-28 0:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-28 0:00 [rpms/gdb] gdb-17.2-rebase-f44: Back-port fix for RHBZ 2152431 Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox