diff --git a/gdb-initialize-the-data_head-variable-to-eliminate-c.patch b/gdb-initialize-the-data_head-variable-to-eliminate-c.patch new file mode 100644 index 0000000..1861a3f --- /dev/null +++ b/gdb-initialize-the-data_head-variable-to-eliminate-c.patch @@ -0,0 +1,45 @@ +From 44ca285b73b68f6a8fa3e89004b510d6b7d98e91 Mon Sep 17 00:00:00 2001 +From: Enze Li +Date: Sat, 11 Jun 2022 18:36:48 +0800 +Subject: [PATCH] gdb: initialize the data_head variable to eliminate + compilation warnings +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On a machine with gcc 12, I get this warning: + + CXX nat/linux-btrace.o +In function ‘btrace_error linux_read_bts(btrace_data_bts*, btrace_target_info*, btrace_read_type)’, + inlined from ‘btrace_error linux_read_btrace(btrace_data*, btrace_target_info*, btrace_read_type)’ at ../gdb/nat/linux-btrace.c:935:29: +../gdb/nat/linux-btrace.c:865:21: warning: ‘data_head’ may be used uninitialized [-Wmaybe-uninitialized] + 865 | pevent->last_head = data_head; + | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ +../gdb/nat/linux-btrace.c: In function ‘btrace_error linux_read_btrace(btrace_data*, btrace_target_info*, btrace_read_type)’: +../gdb/nat/linux-btrace.c:792:9: note: ‘data_head’ was declared here + 792 | __u64 data_head, data_tail; + | ^~~~~~~~~ + +Fix this by initializing the 'data_head' variable. + +Tested by rebuilding on x86_64 openSUSE Tumbleweed with gcc 12. +--- + gdb/nat/linux-btrace.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c +index b0d6dcd7cf1..c31fb5ffe43 100644 +--- a/gdb/nat/linux-btrace.c ++++ b/gdb/nat/linux-btrace.c +@@ -789,7 +789,7 @@ linux_read_bts (struct btrace_data_bts *btrace, + struct perf_event_buffer *pevent; + const uint8_t *begin, *end, *start; + size_t buffer_size, size; +- __u64 data_head, data_tail; ++ __u64 data_head = 0, data_tail; + unsigned int retries = 5; + + pevent = &tinfo->variant.bts.bts; +-- +2.33.0 + diff --git a/gdb.spec b/gdb.spec index 743822c..c48e428 100644 --- a/gdb.spec +++ b/gdb.spec @@ -1,6 +1,6 @@ Name: gdb Version: 12.1 -Release: 3 +Release: 4 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-1.3 Source: https://ftp.gnu.org/gnu/gdb/gdb-%{version}.tar.xz @@ -88,6 +88,7 @@ Patch76: gdb-sw22395-constify-target_desc.patch Patch77: 0001-set-entry-point-when-text-segment-is-missing.patch Patch78: 0002-Add-support-for-readline-8.2.patch +Patch79: gdb-initialize-the-data_head-variable-to-eliminate-c.patch %global gdb_src gdb-%{version} %global gdb_build build-%{_target_platform} @@ -363,6 +364,9 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/gdb/python/gdb/command/backtrace.py %{_infodir}/ctf-spec.info.gz %changelog +* Thu Jul 27 2023 Wenyu Liu - 12.1-4 +- initialize the data_head variable to eliminate compilation warnings + * Tue Feb 14 2023 Wenyu Liu - 12.1-3 - Rectify the spec file.