public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/gdb] gdb-17.2-rebase-f44: Backport commits 2fc56106422 and 2b646bb8767 from gdb-16-branch
Date: Sun, 28 Jun 2026 00:02:04 GMT [thread overview]
Message-ID: <178260492426.1.11957775584087169685.rpms-gdb-df0d4c229d55@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/gdb
Branch : gdb-17.2-rebase-f44
Commit : df0d4c229d55f5983564849bfbf82148313fbbe7
Author : Andrew Burgess <aburgess@redhat.com>
Date : 2025-02-10T17:08:00+00:00
Stats : +296/-1 in 6 file(s)
URL : https://src.fedoraproject.org/rpms/gdb/c/df0d4c229d55f5983564849bfbf82148313fbbe7?branch=gdb-17.2-rebase-f44
Log:
Backport commits 2fc56106422 and 2b646bb8767 from gdb-16-branch
Backport:
commit 2fc56106422935fb487b832dd7cbee9280041969
Date: Fri Feb 7 17:06:30 2025 +0100
[gdb/corefiles] Fix segfault in core_target_open
and:
commit 2b646bb87677b206af8f88f132a12a4181b6e356
Date: Wed Feb 5 20:12:03 2025 +0000
gdb/tui: use wrefresh if output is not surpressed
these two commits have been made to the gdb-16-branch after 16.2.
These commits are also present on the master branch. Both of these
commits fix regressions since GDB 15.
These commits will drop out when we rebase on to 16.3 or 17.1.
---
diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include
index 0f34581..f20f7a5 100644
--- a/_gdb.spec.Patch.include
+++ b/_gdb.spec.Patch.include
@@ -53,3 +53,13 @@ Patch010: gdb-add-index.patch
# RPMs to install when GDB finds an objfile with no debug info.
Patch011: gdb-add-rpm-suggestion-script.patch
+# Backport upstream commit 2fc56106422 which fixes a possible
+# segfault when opening a core file. This will drop out when we
+# rebase to 16.3 or 17.1
+Patch012: core-target-open-segfault.patch
+
+# Backport upstream commit 2b646bb8767, this fixes an issue where
+# TUI output was not flushed to the screen in some cases. This will
+# drop out when we rebase on 16.3 or 17.1.
+Patch013: tui-wrefresh-issue.patch
+
diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include
index a409d9f..cb13330 100644
--- a/_gdb.spec.patch.include
+++ b/_gdb.spec.patch.include
@@ -9,3 +9,5 @@
%patch -p1 -P009
%patch -p1 -P010
%patch -p1 -P011
+%patch -p1 -P012
+%patch -p1 -P013
diff --git a/_patch_order b/_patch_order
index fa1116c..1367ac0 100644
--- a/_patch_order
+++ b/_patch_order
@@ -9,3 +9,5 @@ gdb-rhbz1149205-catch-syscall-after-fork-test.patch
gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch
gdb-add-index.patch
gdb-add-rpm-suggestion-script.patch
+core-target-open-segfault.patch
+tui-wrefresh-issue.patch
diff --git a/core-target-open-segfault.patch b/core-target-open-segfault.patch
new file mode 100644
index 0000000..9320327
--- /dev/null
+++ b/core-target-open-segfault.patch
@@ -0,0 +1,56 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Tom de Vries <tdevries@suse.de>
+Date: Fri, 7 Feb 2025 17:06:30 +0100
+Subject: core-target-open-segfault.patch
+
+;; Backport upstream commit 2fc56106422 which fixes a possible
+;; segfault when opening a core file. This will drop out when we
+;; rebase to 16.3 or 17.1
+
+[gdb/corefiles] Fix segfault in core_target_open
+
+On x86_64-freebsd, with test-case gdb.arch/i386-biarch-core.exp I run into a
+segfault here in corelow.c:core_target_open:
+...
+ {
+ gdb::unique_xmalloc_ptr<char> failing_command = make_unique_xstrdup
+ (bfd_core_file_failing_command (current_program_space->core_bfd ()));
+ if (failing_command != nullptr)
+ gdb_printf (_("Core was generated by `%s'.\n"),
+ failing_command.get ());
+ }
+...
+where bfd_core_file_failing_command returns nullptr, so the segfault happens
+somewhere during "strdup (nullptr)".
+
+There doesn't seem to be a need to make a copy of the string, so fix this by
+dropping the make_unique_xstrdup.
+
+Tested on x86_64-linux.
+Tested the test-case on x86_64-freebsd.
+
+Approved-By: Tom Tromey <tom@tromey.com>
+
+PR corefiles/32634
+Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32634
+
+(cherry picked from commit 9dd3d66b79a2907726f407039234ad8677e9df16)
+
+diff --git a/gdb/corelow.c b/gdb/corelow.c
+--- a/gdb/corelow.c
++++ b/gdb/corelow.c
+@@ -1188,11 +1188,11 @@ core_target_open (const char *arg, int from_tty)
+ }
+ else
+ {
+- gdb::unique_xmalloc_ptr<char> failing_command = make_unique_xstrdup
+- (bfd_core_file_failing_command (current_program_space->core_bfd ()));
++ const char *failing_command
++ = bfd_core_file_failing_command (current_program_space->core_bfd ());
+ if (failing_command != nullptr)
+ gdb_printf (_("Core was generated by `%s'.\n"),
+- failing_command.get ());
++ failing_command);
+ }
+
+ /* Clearing any previous state of convenience variables. */
diff --git a/gdb.spec b/gdb.spec
index f1aaf60..c2bfd35 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -45,7 +45,7 @@ Version: 16.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: 1%{?dist}
+Release: 2%{?dist}
License: GPL-3.0-or-later AND BSD-3-Clause AND FSFAP AND LGPL-2.1-or-later AND GPL-2.0-or-later AND LGPL-2.0-or-later AND LicenseRef-Fedora-Public-Domain AND GFDL-1.3-or-later AND LGPL-2.0-or-later WITH GCC-exception-2.0 AND GPL-3.0-or-later WITH GCC-exception-3.1 AND GPL-2.0-or-later WITH GNU-compiler-exception
# Do not provide URL for snapshots as the file lasts there only for 2 days.
@@ -923,6 +923,11 @@ fi
# endif scl
%changelog
+* Mon Feb 10 2025 Andrew Burgess <aburgess@redhat.com>
+- Add core-target-open-segfault.patch and tui-wrefresh-issue.patch,
+ these backport upstream commits 2fc56106422 and 2b646bb8767
+ respectively, both fix regressiosn in GDB 16 vs GDB 15.
+
* Fri Feb 06 2025 Andrew Burgess <aburgess@redhat.com>
- Remove gdb-6.5-bz218379-ppc-solib-trampoline-test.patch. There must
be upstream tests that 'next' over a libc call. Additionally, it is
diff --git a/tui-wrefresh-issue.patch b/tui-wrefresh-issue.patch
new file mode 100644
index 0000000..93f5b6f
--- /dev/null
+++ b/tui-wrefresh-issue.patch
@@ -0,0 +1,220 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Andrew Burgess <aburgess@redhat.com>
+Date: Wed, 5 Feb 2025 20:12:03 +0000
+Subject: tui-wrefresh-issue.patch
+
+;; Backport upstream commit 2b646bb8767, this fixes an issue where
+;; TUI output was not flushed to the screen in some cases. This will
+;; drop out when we rebase on 16.3 or 17.1.
+
+gdb/tui: use wrefresh if output is not surpressed
+
+Recent work in the TUI has improved GDB's use of the curses
+wnoutrefresh and doupdate mechanism, which improves performance by
+batching together updates and then doing a single set of writes to the
+screen when doupdate is finally called.
+
+The tui_batch_rendering type is a RAII class which, in its destructor,
+calls doupdate to send the batched updates to the screen.
+
+However, if there is no tui_batch_rendering active on the call stack
+then any wnoutrefresh calls will remain batched but undisplayed until
+the next time doupdate happens to be called.
+
+This problem can be seen in PR gdb/32623. When an inferior is started
+the 'Starting program' message is not immediately displayed to the
+user.
+
+The 'Starting program' message originates from run_command_1 in
+infcmd.c, the message is sent to the current_uiout, which will be the
+TUI ui_out. After the message is sent, ui_out::flush() is called,
+here's the backtrace when that happens:
+
+ #0 tui_file::flush (this=0x36e4ab0) at ../../src/gdb/tui/tui-file.c:42
+ #1 0x0000000001004f4b in pager_file::flush (this=0x36d35f0) at ../../src/gdb/utils.c:1531
+ #2 0x0000000001004f71 in gdb_flush (stream=0x36d35f0) at ../../src/gdb/utils.c:1539
+ #3 0x00000000006975ab in cli_ui_out::do_flush (this=0x35a50b0) at ../../src/gdb/cli-out.c:250
+ #4 0x00000000009fd1f9 in ui_out::flush (this=0x35a50b0) at ../../src/gdb/ui-out.h:263
+ #5 0x00000000009f56ad in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at ../../src/gdb/infcmd.c:449
+ #6 0x00000000009f599a in run_command (args=0x0, from_tty=1) at ../../src/gdb/infcmd.c:511
+
+And if we check out tui_file::flush (tui-file.c) we can see that this
+just calls tui_win_info::refresh_window(), which in turn, just uses
+wnoutrefresh to batch any pending output.
+
+The problem is that, in the above backtrace, there is no
+tui_batch_rendering active, and so there will be no doupdate call to
+flush the output to the screen.
+
+We could add a tui_batch_rendering into tui_file::flush. And
+tui_file::write. And tui_file::puts .....
+
+... but that all seems a bit unnecessary. Instead, I propose that
+tui_win_info::refresh_window() should be changed. If suppress_output
+is true (i.e. a tui_batch_rendering is active) then we should continue
+to call wnoutrefresh(). But if suppress_output is false, meaning that
+no tui_batch_rendering is in place, then we should call wrefresh(),
+which immediately writes the output to the screen.
+
+Testing but PR gdb/32623 was a little involved. We need to 'run' the
+inferior and check for the 'Starting program' message. But DejaGNUU
+can only check for the message once it knows the message should have
+appeared. But, as the bug is that output is not displayed, we don't
+have any output hints that the inferior is started yet...
+
+In the end, I have the inferior create a file in the test's output
+directory. Now DejaGNU can send the 'run' command, and wait for the
+file to appear. Once that happens, we know that the 'Starting
+program' message should have appeared.
+
+Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32623
+
+Approved-By: Tom Tromey <tom@tromey.com>
+
+diff --git a/gdb/testsuite/gdb.tui/flush-after-run.c b/gdb/testsuite/gdb.tui/flush-after-run.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.tui/flush-after-run.c
+@@ -0,0 +1,54 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2025 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/>. */
++
++#include <unistd.h>
++#include <stdlib.h>
++#include <sys/stat.h>
++#include <errno.h>
++#include <stdio.h>
++
++int
++main (int argc, char *argv[])
++{
++ /* Don't let this test stay alive forever. */
++ alarm (300);
++
++ if (argc != 2)
++ abort ();
++
++ /* Check the file doesn't already exist. */
++ const char *filename = argv[1];
++ struct stat buf;
++ if (stat (filename, &buf) == 0 || errno != ENOENT)
++ abort ();
++
++ /* Create the file, and write something into it. */
++ FILE *out = fopen (filename, "w");
++ if (out == NULL)
++ abort ();
++
++ fprintf (out, "Hello World\n");
++
++ if (fclose (out) != 0)
++ abort ();
++
++ /* Spin until the marker file is deleted. */
++ while (stat (filename, &buf) == 0)
++ sleep (1);
++
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.tui/flush-after-run.exp b/gdb/testsuite/gdb.tui/flush-after-run.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.tui/flush-after-run.exp
+@@ -0,0 +1,66 @@
++# Copyright 2025 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 the 'Starting program' message is correctly flushed to
++# the TUI terminal as soon as it is available.
++
++require allow_tui_tests
++require target_can_use_run_cmd
++
++tuiterm_env
++
++standard_testfile
++
++if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
++ return -1
++}
++
++Term::clean_restart 24 80 $testfile
++
++if {![Term::enter_tui]} {
++ unsupported "TUI not supported"
++ return
++}
++
++# Pick a name for a marker file, and ensure it doesn't exist.
++set marker_file [standard_output_file "marker"]
++file delete $marker_file
++
++# Run the inferior, which will create MARKER_FILE.
++send_gdb "run \"$marker_file\"\n"
++
++# Spin until MARKER_FILE appears.
++while { ! [file exists $marker_file] } {
++ sleep 1
++}
++
++# We now know that the inferior has started, and that the 'Starting
++# program: ' string should have been printed to the terminal. Don't
++# use Term::wait_for here as there will be no prompt after the
++# 'Starting program' message.
++gdb_assert {[Term::wait_for_region_contents 0 16 80 7 "Starting program: "]} \
++ "starting program message has appeared"
++
++# Delete MARKER_FILE. This will cause the inferior to exit.
++file delete $marker_file
++
++# Now wait for the prompt, and check that the inferior exited message
++# appeared.
++gdb_assert {[Term::wait_for ""]} \
++ "wait for prompt after inferior exits"
++Term::check_region_contents \
++ "check for inferior exited message" \
++ 0 16 80 8 \
++ "\\\[Inferior $decimal \[^\r\n\]+ exited normally\\\]"
+diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
+--- a/gdb/tui/tui-wingeneral.c
++++ b/gdb/tui/tui-wingeneral.c
+@@ -56,7 +56,12 @@ void
+ tui_win_info::refresh_window ()
+ {
+ if (handle != NULL)
+- wnoutrefresh (handle.get ());
++ {
++ if (suppress_output)
++ wnoutrefresh (handle.get ());
++ else
++ wrefresh (handle.get ());
++ }
+ }
+
+ /* Draw a border around the window. */
reply other threads:[~2026-06-28 0:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178260492426.1.11957775584087169685.rpms-gdb-df0d4c229d55@fedoraproject.org \
--to=aburgess@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox