Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package gdb for openSUSE:Factory checked in at 2021-11-06 18:13:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/gdb (Old) and /work/SRC/openSUSE:Factory/.gdb.new.1890 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "gdb" Sat Nov 6 18:13:27 2021 rev:156 rq:929121 version:11.1 Changes: -------- --- /work/SRC/openSUSE:Factory/gdb/gdb.changes 2021-11-01 18:35:48.813339252 +0100 +++ /work/SRC/openSUSE:Factory/.gdb.new.1890/gdb.changes 2021-11-06 18:14:04.968761432 +0100 @@ -1,0 +2,13 @@ +Tue Nov 2 13:03:51 UTC 2021 - Tom de Vries <tdevr...@suse.com> + +- Patches added (add back ignore-errors command, dropped in + 11.1 update): + * gdb-cli-add-ignore-errors-command.patch + +------------------------------------------------------------------- +Mon Nov 1 10:04:24 UTC 2021 - Tom de Vries <tdevr...@suse.com> + +- Patches added [swo#28355]: + * gdb-tdep-aarch64-make-gdbserver-register-set-selection-dynamic.patch + +------------------------------------------------------------------- New: ---- gdb-cli-add-ignore-errors-command.patch gdb-tdep-aarch64-make-gdbserver-register-set-selection-dynamic.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gdb.spec ++++++ --- /var/tmp/diff_new_pack.gwkS86/_old 2021-11-06 18:14:06.684762331 +0100 +++ /var/tmp/diff_new_pack.gwkS86/_new 2021-11-06 18:14:06.688762334 +0100 @@ -358,6 +358,10 @@ Patch2111: gdb-testsuite-work-around-skip_prologue-problems-in-gdb.threads-process-dies-while-detaching.exp.patch #https://sourceware.org/pipermail/gdb-patches/2021-October/182921.html Patch2112: gdb-testsuite-handle-sigill-in-two-gdb.arch-powerpc-test-cases.patch +# https://sourceware.org/pipermail/gdb-patches/2021-November/182985.html +Patch2113: gdb-tdep-aarch64-make-gdbserver-register-set-selection-dynamic.patch +# https://sourceware.org/pipermail/gdb-patches/2021-May/178990.html +Patch2114: gdb-cli-add-ignore-errors-command.patch BuildRequires: bison BuildRequires: flex @@ -772,6 +776,8 @@ %patch2110 -p1 %patch2111 -p1 %patch2112 -p1 +%patch2113 -p1 +%patch2114 -p1 #unpack libipt %if 0%{have_libipt} ++++++ gdb-cli-add-ignore-errors-command.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 <tdevr...@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 <tdevr...@suse.de> * gdb.texinfo (Command Files): Document command ignore-errors. gdb/testsuite/ChangeLog: 2021-05-18 Tom de Vries <tdevr...@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(-) diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 56ae12a0c19..ce8af45a925 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -39,6 +39,7 @@ #include "gdbsupport/filestuff.h" #include "location.h" #include "block.h" +#include "event-top.h" #include "ui-out.h" #include "interps.h" @@ -2249,6 +2250,34 @@ gdb_maint_setting_str_internal_fn (struct gdbarch *gdbarch, gdbarch); } +/* 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 () @@ -2625,4 +2654,10 @@ when GDB is started."), GDBINIT); c = add_cmd ("source", class_support, source_command, source_help_text, &cmdlist); set_cmd_completer (c, 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 025d6bec42a..1700b0305c5 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -27508,7 +27508,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 @@ -27603,6 +27604,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 ++++++ gdb-tdep-aarch64-make-gdbserver-register-set-selection-dynamic.patch ++++++ @@ -, +, @@ --- gdb/arch/aarch64.h | 9 ++ gdbserver/linux-aarch64-low.cc | 185 ++++++++++++++++++--------------- 2 files changed, 110 insertions(+), 84 deletions(-) --- a/gdb/arch/aarch64.h +++ a/gdb/arch/aarch64.h @@ -22,6 +22,15 @@ #include "gdbsupport/tdesc.h" +/* Holds information on what architectural features are available. This is + used to select register sets. */ +struct aarch64_features +{ + bool sve = false; + bool pauth = false; + bool mte = false; +}; + /* Create the aarch64 target description. A non zero VQ value indicates both the presence of SVE and the Vector Quotient - the number of 128bit chunks in an SVE Z register. HAS_PAUTH_P indicates the presence of the PAUTH --- a/gdbserver/linux-aarch64-low.cc +++ a/gdbserver/linux-aarch64-low.cc @@ -196,16 +196,6 @@ is_64bit_tdesc (void) return register_size (regcache->tdesc, 0) == 8; } -/* Return true if the regcache contains the number of SVE registers. */ - -static bool -is_sve_tdesc (void) -{ - struct regcache *regcache = get_thread_regcache (current_thread, 0); - - return tdesc_contains_feature (regcache->tdesc, "org.gnu.gdb.aarch64.sve"); -} - static void aarch64_fill_gregset (struct regcache *regcache, void *buf) { @@ -680,40 +670,6 @@ aarch64_target::low_new_fork (process_info *parent, *child->priv->arch_private = *parent->priv->arch_private; } -/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */ -#define AARCH64_HWCAP_PACA (1 << 30) - -/* Implementation of linux target ops method "low_arch_setup". */ - -void -aarch64_target::low_arch_setup () -{ - unsigned int machine; - int is_elf64; - int tid; - - tid = lwpid_of (current_thread); - - is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine); - - if (is_elf64) - { - uint64_t vq = aarch64_sve_get_vq (tid); - unsigned long hwcap = linux_get_hwcap (8); - unsigned long hwcap2 = linux_get_hwcap2 (8); - bool pauth_p = hwcap & AARCH64_HWCAP_PACA; - /* MTE is AArch64-only. */ - bool mte_p = hwcap2 & HWCAP2_MTE; - - current_process ()->tdesc - = aarch64_linux_read_description (vq, pauth_p, mte_p); - } - else - current_process ()->tdesc = aarch32_linux_read_description (); - - aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread)); -} - /* Wrapper for aarch64_sve_regs_copy_to_reg_buf. */ static void @@ -730,20 +686,36 @@ aarch64_sve_regs_copy_from_regcache (struct regcache *regcache, void *buf) return aarch64_sve_regs_copy_from_reg_buf (regcache, buf); } +/* Array containing all the possible register sets for AArch64/Linux. During + architecture setup, these will be checked against the HWCAP/HWCAP2 bits for + validity and enabled/disabled accordingly. + + Their sizes are set to 0 here, but they will be adjusted later depending + on whether each register set is available or not. */ + static struct regset_info aarch64_regsets[] = { + /* GPR registers. */ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, - sizeof (struct user_pt_regs), GENERAL_REGS, + 0, GENERAL_REGS, aarch64_fill_gregset, aarch64_store_gregset }, + /* Floating Point (FPU) registers. */ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_FPREGSET, - sizeof (struct user_fpsimd_state), FP_REGS, + 0, FP_REGS, aarch64_fill_fpregset, aarch64_store_fpregset }, + /* Scalable Vector Extension (SVE) registers. */ + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_SVE, + 0, EXTENDED_REGS, + aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache + }, + /* PAC registers. */ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK, - AARCH64_PAUTH_REGS_SIZE, OPTIONAL_REGS, - NULL, aarch64_store_pauthregset }, + 0, OPTIONAL_REGS, + nullptr, aarch64_store_pauthregset }, + /* Tagged address control / MTE registers. */ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_TAGGED_ADDR_CTRL, - AARCH64_LINUX_SIZEOF_MTE, OPTIONAL_REGS, aarch64_fill_mteregset, + 0, OPTIONAL_REGS, aarch64_fill_mteregset, aarch64_store_mteregset }, NULL_REGSET }; @@ -752,47 +724,95 @@ static struct regsets_info aarch64_regsets_info = { aarch64_regsets, /* regsets */ 0, /* num_regsets */ - NULL, /* disabled_regsets */ + nullptr, /* disabled_regsets */ }; static struct regs_info regs_info_aarch64 = { - NULL, /* regset_bitmap */ - NULL, /* usrregs */ + nullptr, /* regset_bitmap */ + nullptr, /* usrregs */ &aarch64_regsets_info, }; -static struct regset_info aarch64_sve_regsets[] = +/* Given FEATURES, adjust the available register sets by setting their + sizes. A size of 0 means the register set is disabled and won't be + used. */ + +static void +aarch64_adjust_register_sets (const struct aarch64_features &features) { - { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, - sizeof (struct user_pt_regs), GENERAL_REGS, - aarch64_fill_gregset, aarch64_store_gregset }, - { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_SVE, - SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE), EXTENDED_REGS, - aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache - }, - { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK, - AARCH64_PAUTH_REGS_SIZE, OPTIONAL_REGS, - NULL, aarch64_store_pauthregset }, - { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_TAGGED_ADDR_CTRL, - AARCH64_LINUX_SIZEOF_MTE, OPTIONAL_REGS, aarch64_fill_mteregset, - aarch64_store_mteregset }, - NULL_REGSET -}; + struct regset_info *regset; -static struct regsets_info aarch64_sve_regsets_info = - { - aarch64_sve_regsets, /* regsets. */ - 0, /* num_regsets. */ - NULL, /* disabled_regsets. */ - }; + for (regset = aarch64_regsets; regset->size >= 0; regset++) + { + switch (regset->nt_type) + { + case NT_PRSTATUS: + /* General purpose registers are always present. */ + regset->size = sizeof (struct user_pt_regs); + break; + case NT_FPREGSET: + /* This is unavailable when SVE is present. */ + if (!features.sve) + regset->size = sizeof (struct user_fpsimd_state); + break; + case NT_ARM_SVE: + if (features.sve) + regset->size = SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE); + break; + case NT_ARM_PAC_MASK: + if (features.pauth) + regset->size = AARCH64_PAUTH_REGS_SIZE; + break; + case NT_ARM_TAGGED_ADDR_CTRL: + if (features.mte) + regset->size = AARCH64_LINUX_SIZEOF_MTE; + break; + default: + gdb_assert_not_reached ("Unknown register set found."); + } + } +} -static struct regs_info regs_info_aarch64_sve = - { - NULL, /* regset_bitmap. */ - NULL, /* usrregs. */ - &aarch64_sve_regsets_info, - }; +/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */ +#define AARCH64_HWCAP_PACA (1 << 30) + +/* Implementation of linux target ops method "low_arch_setup". */ + +void +aarch64_target::low_arch_setup () +{ + unsigned int machine; + int is_elf64; + int tid; + + tid = lwpid_of (current_thread); + + is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine); + + if (is_elf64) + { + struct aarch64_features features; + + uint64_t vq = aarch64_sve_get_vq (tid); + features.sve = (vq > 0); + /* A-profile PAC is 64-bit only. */ + features.pauth = linux_get_hwcap (8) & AARCH64_HWCAP_PACA; + /* A-profile MTE is AArch64-only. */ + features.mte = linux_get_hwcap2 (8) & HWCAP2_MTE; + + current_process ()->tdesc + = aarch64_linux_read_description (vq, features.pauth, features.mte); + + /* Adjust the register sets we should use for this particular set of + features. */ + aarch64_adjust_register_sets (features); + } + else + current_process ()->tdesc = aarch32_linux_read_description (); + + aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread)); +} /* Implementation of linux target ops method "get_regs_info". */ @@ -802,9 +822,7 @@ aarch64_target::get_regs_info () if (!is_64bit_tdesc ()) return ®s_info_aarch32; - if (is_sve_tdesc ()) - return ®s_info_aarch64_sve; - + /* AArch64 64-bit registers. */ return ®s_info_aarch64; } @@ -3294,5 +3312,4 @@ initialize_low_arch (void) initialize_low_arch_aarch32 (); initialize_regsets_info (&aarch64_regsets_info); - initialize_regsets_info (&aarch64_sve_regsets_info); } --