Patched dropped: * gdb-6.6-buildid-locate-tests.patch Patches modified: * gdb-add-rpm-suggestion-script.patch - Update to fedora rawhide @ 12e32a6. Patches modified: * gdb-add-rpm-suggestion-script.patch * gdb-backport-buildid-related-changes.patch * gdb-remove-qnx-neutrino-support.patch - Update to fedora rawhide @ 264209d. Maintenance script import-fedora.sh: * Drop gdb-rhbz1156192-recursive-dlopen-test.patch from skip_patches. - Update to fedora rawhide @ 020018c. Maintenance script import-fedora.sh: * Drop gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch from skip_patches. - Update to fedora rawhide @ 1e3eb79. Maintenance script import-fedora.sh: * Drop gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch from skip_patches. - Update to fedora rawhide @ 1a098a7. Patches dropped: * gdb-6.3-gstack-20050411.patch * gdb-testsuite-require-can_spawn_for_attach-in-gdb.ba.patch - Update to fedora rawhide @ 5fc2d96. Patches dropped: * gdb-backport-buildid-related-changes.patch * gdb-catchpoint-re-set.patch * gdb-remove-qnx-neutrino-support.patch - Update to fedora rawhide @ 6b0ca99 (gdb 16.2). Patches updated (fedora): * gdb-add-rpm-suggestion-script.patch Maintenance script qa-local.sh: * Update version to 16.2. Patches updated: * gdb-testsuite-ada-pie.patch * gdb-tui-enable-work-around-libncurses-segfault.patch * gdb-guile-use-scm_debug_typing_strictness-0.patch * add-gdbarch_dwarf2_reg_piece_offset-hook.patch * gdb-testsuite-fix-gdb.ada-big_packed_array.exp-on-s3.patch * gdb-cli-add-ignore-errors-command.patch * fixup-gdb-add-rpm-suggestion-script.patch Patches dropped: * gdb-testsuite-fix-another-regexp-in-gdb.threads-step.patch * gdb-testsuite-fix-error-in-gdb.server-server-kill-py.patch * gdb-testsuite-fix-timeout-in-gdb.tui-resize-2.exp.patch * fix-gdb.dap-step-out.exp-on-s390x.patch * fix-gdb.dwarf2-shortpiece.exp-on-s390x.patch * gdb-build-fix-unused-var-in-corelow.c.patch * gdb-exp-fix-gdb.fortran-intrinsics.exp-fail-on-arm.patch * gdb-prune-inferior-after-switching-inferior.patch * gdb-record-fix-out-of-bounds-write-in-aarch64_record.patch * gdb-symtab-fix-target-type-of-complex-long-double-on.patch * gdb-symtab-return-correct-reader-for-top-level-cu-in.patch * gdb-tdep-fix-arm-thumb2-hw-breakpoint.patch * gdb-tdep-fix-recording-of-t1-push.patch * gdb-tdep-handle-sycall-statx-for-arm-linux.patch * gdb-tdep-handle-syscall-clock_gettime64-for-arm-linu.patch * gdb-tdep-s390-add-arch15-record-replay-support.patch * gdb-testsuite-avoid-intermittent-failures-on-a-debug.patch * gdb-testsuite-don-t-use-set-auto-solib-add-off.patch * gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-on-arm-lin.patch * gdb-testsuite-fix-gdb.arch-arm-pseudo-unwind.exp-wit.patch * gdb-testsuite-fix-gdb.arch-arm-single-step-kernel-he.patch * gdb-testsuite-fix-gdb.arch-riscv-tdesc-regs.exp.patch * gdb-testsuite-fix-gdb.base-empty-host-env-vars.exp.patch * gdb-testsuite-fix-gdb.base-list-dot-nodebug-and-make.patch * gdb-testsuite-fix-gdb.cp-m-static.exp-on-arm.patch * gdb-testsuite-fix-gdb.dwarf2-dw2-fixed-point.exp-on-.patch * gdb-testsuite-fix-gdb.dwarf2-dw2-lines.exp-on-arm-li.patch * gdb-testsuite-fix-gdb.fortran-array-bounds.exp-on-ar.patch * gdb-testsuite-fix-gdb.python-py-format-address.exp-o.patch * gdb-testsuite-fix-gdb.python-py-format-string.exp-wi.patch * gdb-testsuite-fix-gdb.python-py-mi-cmd.exp-with-pyth.patch * gdb-testsuite-fix-gdb.threads-leader-exit-attach.exp.patch * gdb-testsuite-fix-regexp-in-gdb.ada-mi_var_access.ex.patch * gdb-testsuite-fix-regexp-in-gdb.arch-i386-disp-step-.patch * gdb-testsuite-fix-regexp-in-gdb.threads-stepi-over-c.patch * gdb-testsuite-fix-timeout-in-gdb.mi-mi-multi-command.patch * handle-address-class-annotation-for-s390x-in-some-te.patch * opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch * s390-add-arch15-concurrent-functions-facility-insns.patch * s390-add-arch15-instruction-names.patch * s390-add-arch15-instructions.patch * s390-align-opcodes-to-lower-case.patch * s390-fix-disassembly-of-optional-addressing-operands.patch * s390-relax-risbg-n-z-risb-h-l-gz-rns-ros-rxs-bgt-ope.patch * s390-simplify-dis-assembly-of-insn-operands-with-con.patch * s390-treat-addressing-operand-sequence-as-one-in-dis.patch * use-setvariable-in-gdb.dap-scopes.exp.patch Patches added: * gdb-testsuite-fix-gdb.dwarf2-implptr.exp-regression.patch * gdb-testsuite-work-around-pr32850.patch * gdb-symtab-fix-gdb.base-fission-macro.exp-with-unix-.patch * gdb-testsuite-fix-another-timeout-in-gdb.base-bg-exe.patch - Add "BuildRequires: glibc-locale" for gdb:testsuite to fix SLFO testsuite failures. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=454
202 lines
6.3 KiB
Diff
202 lines
6.3 KiB
Diff
From 6634dd948f02d1f7bd5c0a952899620276b1c260 Mon Sep 17 00:00:00 2001
|
|
From: Tom de Vries <tdevries@suse.de>
|
|
Date: Mon, 7 Apr 2025 16:19:48 +0200
|
|
Subject: [PATCH] [gdb/cli] Add ignore-errors command
|
|
|
|
While trying to reproduce a failing test-case from the testsuite on the
|
|
command line using a gdb command script, I ran into the problem that a command
|
|
failed which stopped script execution.
|
|
|
|
I could work around this by splitting the script at each error, but I realized
|
|
it would be nice if I could tell gdb to ignore the error.
|
|
|
|
A python workaround ignore-errors exists, mentioned here (
|
|
https://sourceware.org/legacy-ml/gdb/2010-06/msg00100.html ), which is
|
|
already supplied by distros like Fedora and openSUSE.
|
|
|
|
FTR, a more elaborate try-catch solution was posted here (
|
|
https://sourceware.org/bugzilla/show_bug.cgi?id=8487 ).
|
|
|
|
This patch adds native ignore-errors support (so no python needed).
|
|
|
|
So with this script:
|
|
...
|
|
$ cat script.gdb
|
|
ignore-errors run
|
|
echo here
|
|
...
|
|
we have:
|
|
...
|
|
$ gdb -q -batch -x script.gdb
|
|
No executable file specified.
|
|
Use the "file" or "exec-file" command.
|
|
here$
|
|
...
|
|
|
|
Note that quit is not caught:
|
|
...
|
|
$ gdb -q
|
|
(gdb) ignore-errors quit
|
|
$
|
|
...
|
|
which is the same behaviour as with the python implementation.
|
|
|
|
Tested on x86_64-linux.
|
|
|
|
gdb/ChangeLog:
|
|
|
|
2021-05-18 Tom de Vries <tdevries@suse.de>
|
|
|
|
* cli/cli-cmds.c (ignore_errors_command_completer)
|
|
(ignore_errors_command): New function.
|
|
(_initialize_cli_cmds): Add "ignore-errors" cmd.
|
|
|
|
gdb/doc/ChangeLog:
|
|
|
|
2021-05-18 Tom de Vries <tdevries@suse.de>
|
|
|
|
* gdb.texinfo (Command Files): Document command ignore-errors.
|
|
|
|
gdb/testsuite/ChangeLog:
|
|
|
|
2021-05-18 Tom de Vries <tdevries@suse.de>
|
|
|
|
* gdb.base/ignore-errors.exp: New test.
|
|
* gdb.base/ignore-errors.gdb: New command file.
|
|
---
|
|
gdb/cli/cli-cmds.c | 35 ++++++++++++++++++++++++
|
|
gdb/doc/gdb.texinfo | 8 +++++-
|
|
gdb/testsuite/gdb.base/ignore-errors.exp | 24 ++++++++++++++++
|
|
gdb/testsuite/gdb.base/ignore-errors.gdb | 2 ++
|
|
4 files changed, 68 insertions(+), 1 deletion(-)
|
|
create mode 100644 gdb/testsuite/gdb.base/ignore-errors.exp
|
|
create mode 100644 gdb/testsuite/gdb.base/ignore-errors.gdb
|
|
|
|
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
|
|
index 0140c717ca2..c244eebbdf7 100644
|
|
--- a/gdb/cli/cli-cmds.c
|
|
+++ b/gdb/cli/cli-cmds.c
|
|
@@ -39,6 +39,7 @@
|
|
#include "location.h"
|
|
#include "block.h"
|
|
#include "valprint.h"
|
|
+#include "event-top.h"
|
|
|
|
#include "ui-out.h"
|
|
#include "interps.h"
|
|
@@ -2572,6 +2573,34 @@ shell_internal_fn (struct gdbarch *gdbarch,
|
|
return value::allocate_optimized_out (int_type);
|
|
}
|
|
|
|
+/* Completer for "ignore-errors". */
|
|
+
|
|
+static void
|
|
+ignore_errors_command_completer (cmd_list_element *ignore,
|
|
+ completion_tracker &tracker,
|
|
+ const char *text, const char * /*word*/)
|
|
+{
|
|
+ complete_nested_command_line (tracker, text);
|
|
+}
|
|
+
|
|
+/* Implementation of the ignore-errors command. */
|
|
+
|
|
+static void
|
|
+ignore_errors_command (const char *args, int from_tty)
|
|
+{
|
|
+ try
|
|
+ {
|
|
+ execute_command (args, from_tty);
|
|
+ }
|
|
+ catch (const gdb_exception_error &ex)
|
|
+ {
|
|
+ exception_print (gdb_stderr, ex);
|
|
+
|
|
+ /* See also execute_gdb_command. */
|
|
+ async_enable_stdin ();
|
|
+ }
|
|
+}
|
|
+
|
|
void _initialize_cli_cmds ();
|
|
void
|
|
_initialize_cli_cmds ()
|
|
@@ -2972,4 +3001,10 @@ when GDB is started."), GDBINIT).release ();
|
|
c = add_cmd ("source", class_support, source_command,
|
|
source_help_text, &cmdlist);
|
|
set_cmd_completer (c, deprecated_filename_completer);
|
|
+
|
|
+ c = add_cmd ("ignore-errors", class_support, ignore_errors_command,
|
|
+ _("Execute a single command, ignoring all errors.\n"
|
|
+ "Only one-line commands are supported.\n"
|
|
+ "This is primarily useful in scripts."), &cmdlist);
|
|
+ set_cmd_completer (c, ignore_errors_command_completer);
|
|
}
|
|
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
|
|
index 47c538520ab..b830d42da72 100644
|
|
--- a/gdb/doc/gdb.texinfo
|
|
+++ b/gdb/doc/gdb.texinfo
|
|
@@ -29472,7 +29472,8 @@ The lines in a command file are generally executed sequentially,
|
|
unless the order of execution is changed by one of the
|
|
@emph{flow-control commands} described below. The commands are not
|
|
printed as they are executed. An error in any command terminates
|
|
-execution of the command file and control is returned to the console.
|
|
+execution of the command file and control is returned to the console,
|
|
+unless the line is prefixed with the @code{ignore-errors} command.
|
|
|
|
@value{GDBN} first searches for @var{filename} in the current directory.
|
|
If the file is not found there, and @var{filename} does not specify a
|
|
@@ -29567,6 +29568,11 @@ the controlling expression.
|
|
@item end
|
|
Terminate the block of commands that are the body of @code{if},
|
|
@code{else}, or @code{while} flow-control commands.
|
|
+
|
|
+@kindex ignore-errors
|
|
+@item ignore-errors
|
|
+This command executes the command specified by its arguments, but
|
|
+doesn't stop execution of the script if the command fails.
|
|
@end table
|
|
|
|
|
|
diff --git a/gdb/testsuite/gdb.base/ignore-errors.exp b/gdb/testsuite/gdb.base/ignore-errors.exp
|
|
new file mode 100644
|
|
index 00000000000..30dac7a94e2
|
|
--- /dev/null
|
|
+++ b/gdb/testsuite/gdb.base/ignore-errors.exp
|
|
@@ -0,0 +1,24 @@
|
|
+# Copyright 2021 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 command ignore-errors.
|
|
+
|
|
+clean_restart
|
|
+
|
|
+gdb_test "source ignore-errors.gdb" \
|
|
+ [multi_line \
|
|
+ "No executable file specified\\." \
|
|
+ "Use the \"file\" or \"exec-file\" command\\." \
|
|
+ "here"]
|
|
diff --git a/gdb/testsuite/gdb.base/ignore-errors.gdb b/gdb/testsuite/gdb.base/ignore-errors.gdb
|
|
new file mode 100644
|
|
index 00000000000..5962ff49b11
|
|
--- /dev/null
|
|
+++ b/gdb/testsuite/gdb.base/ignore-errors.gdb
|
|
@@ -0,0 +1,2 @@
|
|
+ignore-errors run
|
|
+echo here\n
|
|
|
|
base-commit: 1398f45a2641e0e9e0e331681655404ae1d4ed97
|
|
--
|
|
2.43.0
|
|
|