- Patches added: * avoid-crash-with-length.patch * correct-bounds-check-when-working-around-gas-dwarf-5.patch * fix-crash-in-f-typeprint.c.patch - Patches added (swo#33560, bsc#1251213): * bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch * gdb-corefiles-fix-segfault-in-add_thread_silent.patch - Patches added (swo#32542, swo#33354): * change-return-value-of-_bfd_mmap_temporary.patch - Patches added (swo#33068, swo#33069): * gdb-fix-handling-of-aborted-inferior-call.patch - Patches added (swo#33620): * gdb-rust-fix-handling-of-unsigned-discriminant.patch - Patches added (swo#33444): * have-gdb.threadexitedevent-inherit-from-gdb.threadev.patch - Patches added (swo#33617): * mark-pascal-as-case-insensitive.patch - Patches added (testsuite): * check-gnatmake-version-in-gnat_version_compare.patch * gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch * gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch * gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch * gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch * gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch * gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch * gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch * gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch * gdb-testsuite-force-dwarf-in-gdb.pascal.patch * gdb-testsuite-rust-fix-for-empty-array.patch * gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch * gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch * gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch * powerpc-mark-rtti-typeid-tests-as-expected-fail-befo.patch - Maintenance script import-patches.sh: * Use git instead of osc. - Maintenance script qa.sh: * Add PR32893 kfail.
153 lines
5.0 KiB
Diff
153 lines
5.0 KiB
Diff
From a8669ab2846396a2eb310e969250b39bd8116920 Mon Sep 17 00:00:00 2001
|
|
From: Tom de Vries <tdevries@suse.de>
|
|
Date: Mon, 1 Sep 2025 09:07:11 +0200
|
|
Subject: [PATCH 21/25] [gdb] Fix handling of aborted inferior call
|
|
|
|
PR gdb/33069 reports the following behavior:
|
|
...
|
|
$ gdb -q ls -ex starti -ex "b *1"
|
|
Reading symbols from ls...
|
|
(No debugging symbols found in ls)
|
|
Starting program: /usr/bin/ls
|
|
|
|
Program stopped.
|
|
0x00007ffff7fe4f00 in _start () from /lib64/ld-linux-x86-64.so.2
|
|
Breakpoint 1 at 0x1
|
|
(gdb) p (int)strlen("abc")
|
|
Warning:
|
|
Cannot insert breakpoint 1.
|
|
Cannot access memory at address 0x1
|
|
|
|
Command aborted.
|
|
An error occurred while in a function called from GDB.
|
|
Evaluation of the expression containing the function
|
|
(malloc@plt) will be abandoned.
|
|
When the function is done executing, GDB will silently stop.
|
|
|
|
[1]+ Stopped gdb -q ls -ex starti -ex "b *1"
|
|
$ fg
|
|
gdb -q ls -ex starti -ex "b *1"
|
|
(gdb)
|
|
...
|
|
with gdb being unresponsive to further input.
|
|
|
|
PR gdb/33068 reports a similar problem, but using gdbserver, and in that case
|
|
gdb doesn't go into the background, but is likewise unresponsive.
|
|
|
|
This is a regression since commit b1c0ab20809 ("gdb: avoid double stop after
|
|
failed breakpoint condition check"), and consequently since release gdb 14.1.
|
|
|
|
The commit changed this in run_inferior_call:
|
|
...
|
|
if (current_ui->prompt_state == PROMPT_BLOCKED)
|
|
- current_ui->unregister_file_handler ();
|
|
- else
|
|
- current_ui->register_file_handler ();
|
|
+ {
|
|
+ if (call_thread->thread_fsm ()->finished_p ())
|
|
+ async_disable_stdin ();
|
|
+ else
|
|
+ async_enable_stdin ();
|
|
+ }
|
|
...
|
|
which means current_ui->register_file_handler is no longer called in the
|
|
current_ui->prompt_state == PROMPT_NEEDED case.
|
|
|
|
Fix this by:
|
|
- restoring this behavior, fixing the unresponsiveness, and
|
|
- adding target_terminal::ours alongside it, fixing the problem that gdb goes
|
|
into the background.
|
|
|
|
Add a new test-case gdb.base/infcall-failure-2.exp, a regression test for the
|
|
unresponsiveness issue. The problem of gdb going into the background did not
|
|
reproduce in the test-case.
|
|
|
|
Tested on x86_64-linux.
|
|
|
|
Reviewed-By: Keith Seitz <keiths@redhat.com>
|
|
|
|
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33068
|
|
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33069
|
|
---
|
|
gdb/infcall.c | 12 +++++--
|
|
gdb/testsuite/gdb.base/infcall-failure-2.exp | 37 ++++++++++++++++++++
|
|
2 files changed, 46 insertions(+), 3 deletions(-)
|
|
create mode 100644 gdb/testsuite/gdb.base/infcall-failure-2.exp
|
|
|
|
diff --git a/gdb/infcall.c b/gdb/infcall.c
|
|
index 6399278c6ae..d0c6517e84a 100644
|
|
--- a/gdb/infcall.c
|
|
+++ b/gdb/infcall.c
|
|
@@ -887,9 +887,9 @@ run_inferior_call (std::unique_ptr<call_thread_fsm> sm,
|
|
call async_enable_stdin. This changes the prompt state to
|
|
PROMPT_NEEDED.
|
|
|
|
- If the previous prompt state was PROMPT_NEEDED, then as
|
|
- async_enable_stdin has already been called, nothing additional
|
|
- needs to be done here. */
|
|
+ If the previous prompt state was PROMPT_NEEDED, then async_enable_stdin
|
|
+ may or may not have been called, so do the same changes as in
|
|
+ async_enable_stdin. */
|
|
if (current_ui->prompt_state == PROMPT_BLOCKED)
|
|
{
|
|
if (call_thread->thread_fsm ()->finished_p ())
|
|
@@ -897,6 +897,12 @@ run_inferior_call (std::unique_ptr<call_thread_fsm> sm,
|
|
else
|
|
async_enable_stdin ();
|
|
}
|
|
+ else if (current_ui->prompt_state == PROMPT_NEEDED)
|
|
+ {
|
|
+ /* Copied from async_enable_stdin. */
|
|
+ target_terminal::ours ();
|
|
+ current_ui->register_file_handler ();
|
|
+ }
|
|
|
|
/* If the infcall does NOT succeed, normal_stop will have already
|
|
finished the thread states. However, on success, normal_stop
|
|
diff --git a/gdb/testsuite/gdb.base/infcall-failure-2.exp b/gdb/testsuite/gdb.base/infcall-failure-2.exp
|
|
new file mode 100644
|
|
index 00000000000..2a7d7844acf
|
|
--- /dev/null
|
|
+++ b/gdb/testsuite/gdb.base/infcall-failure-2.exp
|
|
@@ -0,0 +1,37 @@
|
|
+# 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/>.
|
|
+
|
|
+standard_testfile infcall-failure.c
|
|
+
|
|
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] == -1 } {
|
|
+ return
|
|
+}
|
|
+
|
|
+if { ![runto_main] } {
|
|
+ return
|
|
+}
|
|
+
|
|
+if { ![gdb_breakpoint "*0x1" message] } {
|
|
+ return
|
|
+}
|
|
+
|
|
+gdb_test "p foo ()" \
|
|
+ [multi_line \
|
|
+ [string_to_regexp "Command aborted."] \
|
|
+ ".*" ]
|
|
+
|
|
+# Check that gdb is still responsive. Regression test for PR gdb/33068.
|
|
+gdb_test "p 1 + 1" \
|
|
+ " = 2"
|
|
--
|
|
2.51.0
|
|
|