Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Fredrik Hederstierna via Gdb-patches <gdb-patches@sourceware.org>
To: Luis Machado <luis.machado@linaro.org>,
	Andrew Burgess <andrew.burgess@embecosm.com>
Cc: Simon Marchi <simark@simark.ca>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	Paul Mathieu <paulmathieu@google.com>
Subject: [PATCH] sim: arm: add support for handling core dumps
Date: Mon, 21 Jun 2021 06:30:49 +0000	[thread overview]
Message-ID: <AM8PR10MB465804161D9A886045785A32EF0A9@AM8PR10MB4658.EURPRD10.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <0327e6b6-2a4e-cf4f-333c-5f3cde18c49c@linaro.org>

The ARM simulator does not support all registers, and also crash in case of entering zero length when fetching registers.
This patch allow gcore to also work in ARM simulator, though by default it seems to dump full memory space 4GB, so core files get very large, though seems to work ok anyhow.

BR Fredrik


diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 857a52a9a51..2820e456cf7 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -4246,6 +4246,10 @@ arm_register_sim_regno (struct gdbarch *gdbarch, int regnum)
   if (regnum >= ARM_WCGR0_REGNUM && regnum <= ARM_WCGR7_REGNUM)
     return regnum - ARM_WCGR0_REGNUM + SIM_ARM_IWMMXT_COP1R8_REGNUM;
 
+  /* The current GDB ARM simulator does not support D0-D31 nor FPSCR.  */
+  if (regnum >= ARM_D0_REGNUM && regnum <= ARM_FPSCR_REGNUM)
+    return -1;
+
   if (reg < NUM_GREGS)
     return SIM_ARM_R0_REGNUM + reg;
   reg -= NUM_GREGS;
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index e697d55a6b5..2a8a539b939 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -526,6 +526,10 @@ arm_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 
   init ();
 
+  /* Check that memory and length are valid before fetching the register.  */
+  if ((memory == NULL) || (length == 0))
+    return 0;
+
   switch ((enum sim_arm_regs) rn)
     {
     case SIM_ARM_R0_REGNUM:


  reply	other threads:[~2021-06-21  6:31 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-17  0:02 [PATCH] gdb: add support for handling core dumps on arm-none-eabi Fredrik Hederstierna via Gdb-patches
2020-10-19  2:08 ` Simon Marchi
2020-10-19 13:13   ` Luis Machado via Gdb-patches
2020-10-19 13:15   ` Alan Hayward via Gdb-patches
2020-10-19 15:25   ` Paul Mathieu via Gdb-patches
2020-10-20 11:41     ` Fredrik Hederstierna via Gdb-patches
2020-10-20 12:39       ` Simon Marchi
2020-10-20 14:00         ` Fredrik Hederstierna via Gdb-patches
2020-10-20 15:04           ` Simon Marchi
2020-10-20 22:05             ` Fredrik Hederstierna via Gdb-patches
2020-10-20 23:06               ` Simon Marchi
2020-10-22  0:52                 ` Fredrik Hederstierna via Gdb-patches
2020-10-22  1:24                   ` Simon Marchi
2020-10-22  1:49                   ` Simon Marchi
2020-10-22 22:32                     ` Fredrik Hederstierna via Gdb-patches
2020-10-23  0:37                       ` Simon Marchi
2020-10-25 21:06                         ` Fredrik Hederstierna via Gdb-patches
2020-10-26 11:24                           ` Luis Machado via Gdb-patches
2020-10-26 15:49                             ` Fredrik Hederstierna via Gdb-patches
2020-10-27 16:53                               ` Paul Mathieu via Gdb-patches
2021-01-14 12:36                                 ` Fredrik Hederstierna via Gdb-patches
2021-01-14 12:50                                   ` Luis Machado via Gdb-patches
2021-01-18 11:09                                     ` Andrew Burgess
2021-01-18 14:01                                       ` Luis Machado via Gdb-patches
2021-06-21  6:30                                         ` Fredrik Hederstierna via Gdb-patches [this message]
2021-06-22  3:20                                           ` [PATCH] sim: arm: add support for handling core dumps Mike Frysinger via Gdb-patches
2021-06-24 13:01                                             ` Alan Hayward via Gdb-patches
2021-06-29  9:11                                               ` Fredrik Hederstierna via Gdb-patches
2021-01-18 11:01                                   ` [PATCH] gdb: add support for handling core dumps on arm-none-eabi Andrew Burgess
2021-06-22  2:16                           ` Mike Frysinger via Gdb-patches
2020-10-20 19:34       ` [PATCH] gdb: Support corefiles for arm-none-eabi Fredrik Hederstierna
2020-10-20 21:49       ` Fredrik Hederstierna
2020-10-20 21:58       ` [PATCH v2] Support for corefiles for arm-none-eabi target Fredrik Hederstierna
2020-10-21  2:51         ` Simon Marchi
2020-10-21 14:38         ` Luis Machado via Gdb-patches
2020-10-22  0:44       ` [PATCH v3][PR gdb/14383]: gdb: corefile support " Fredrik Hederstierna
2020-10-22  0:44         ` [PATCH v3][PR gdb/14383]: Support for corefiles " Fredrik Hederstierna
2020-10-25 20:46       ` [PATCH] " Fredrik Hederstierna
2020-10-25 20:50       ` [PATCH v4][PR gdb/14383] " Fredrik Hederstierna

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=AM8PR10MB465804161D9A886045785A32EF0A9@AM8PR10MB4658.EURPRD10.PROD.OUTLOOK.COM \
    --to=gdb-patches@sourceware.org \
    --cc=andrew.burgess@embecosm.com \
    --cc=fredrik.hederstierna@verisure.com \
    --cc=luis.machado@linaro.org \
    --cc=paulmathieu@google.com \
    --cc=simark@simark.ca \
    /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