From 0d4db51c0af4c3aff4b76e190cfa5b25eb334d86 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Mon, 14 Jun 2021 14:19:35 -0300 Subject: [PATCH] Print additional information on capability store errors Augment the warnings about not being able to write to capability registers or write capabilities to memory. Show the command that needs to be entered in the shell to enable this particular mode. gdb/ChangeLog: 2021-06-24 Luis Machado * aarch64-linux-nat.c (store_cregs_to_thread) (aarch64_linux_nat_target::write_capability): Update error message. gdbserver/ChangeLog: 2021-06-24 Luis Machado * linux-aarch64-low.cc (aarch64_target::qxfer_capability): Update error message. --- gdb/aarch64-linux-nat.c | 6 ++++-- gdbserver/linux-aarch64-low.cc | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 189f3170251..7f10ea2f090 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -573,7 +573,8 @@ store_cregs_to_thread (const struct regcache *regcache) regcache->raw_collect (regno++, &cregset.cctlr); if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_MORELLO, &iovec) < 0) - perror_with_name (_("Unable to store capability registers.")); + perror_with_name (_("Unable to store capability registers.\n" + "Please run \"sysctl cheri.ptrace_forge_cap=1\".")); } /* Implement the "fetch_registers" target_ops method. */ @@ -1007,7 +1008,8 @@ aarch64_linux_nat_target::write_capability (CORE_ADDR addr, memcpy (&cap.val, buffer.data () + 1, 16); if (!aarch64_linux_write_capability (tid, addr, cap)) - perror_with_name (_("Unable to write capability from address.")); + perror_with_name (_("Unable to write capability to address.\n" + "Please run \"sysctl cheri.ptrace_forge_cap=1\".")); return true; } diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 9c90f61a6d6..0213fce7022 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -3451,7 +3451,8 @@ aarch64_target::qxfer_capability (const CORE_ADDR address, if (!aarch64_linux_write_capability (tid, address, cap)) { - warning (_("Unable to write capability to address.")); + warning (_("Unable to write capability to address.\n" + "Please run \"sysctl cheri.ptrace_forge_cap=1\".")); return 0; } } -- 2.47.2