public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: Qinwei <qinwei@sunnorth.com.cn>
Subject: [PATCH v2 10/13] SCORE: Fill 'collect_regset' in regset structure.
Date: Wed, 25 Jun 2014 16:49:00 -0000	[thread overview]
Message-ID: <1403714949-28133-11-git-send-email-arnez@linux.vnet.ibm.com> (raw)
In-Reply-To: <1403714949-28133-1-git-send-email-arnez@linux.vnet.ibm.com>

gdb/
	* score-tdep.c (score7_linux_supply_gregset): Delete function.
	Move logic to...
	(score7_linux_gregmap): ... this new register map.
	(SCORE7_LINUX_SIZEOF_GREGSET): New macro.
	(score7_linux_gregset): Refer to register map, replace supply
	method by regcache_supply_regset, and add collect method.
	(score7_linux_regset_from_core_section): Replace
	sizeof(elf_gregset_t) by SCORE7_LINUX_SIZEOF_GREGSET.
	* score-tdep.h (SCORE_EPC_REGNUM): New enum value.
	(struct pt_regs): Delete structure definition.
	(elf_gregset_t): Delete typedef.
---
 gdb/score-tdep.c | 72 +++++++++++++++++++-------------------------------------
 gdb/score-tdep.h | 34 +-------------------------
 2 files changed, 25 insertions(+), 81 deletions(-)

diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index c224189..90afdf3 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -1398,59 +1398,34 @@ score_prologue_frame_base_sniffer (struct frame_info *this_frame)
   return &score_prologue_frame_base;
 }
 
-/* Core file support (dirty hack)
-  
-   The core file MUST be generated by GNU/Linux on S+core.  */
-
-static void
-score7_linux_supply_gregset(const struct regset *regset,
-                struct regcache *regcache,
-                int regnum, const void *gregs_buf, size_t len)
-{
-  int regno;
-  elf_gregset_t *gregs;
-
-  gdb_assert (regset != NULL);
-  gdb_assert ((regcache != NULL) && (gregs_buf != NULL));
-
-  gregs = (elf_gregset_t *) gregs_buf;
-
-  for (regno = 0; regno < 32; regno++)
-    if (regnum == -1 || regnum == regno)
-      regcache_raw_supply (regcache, regno, gregs->regs + regno);
+/* Core file support.  */
 
+static const struct regcache_map_entry score7_linux_gregmap[] =
   {
-    struct sreg {
-      int regnum;
-      void *buf;
-    } sregs [] = {
-      { 55, &(gregs->cel) },  /* CEL */
-      { 54, &(gregs->ceh) },  /* CEH */
-      { 53, &(gregs->sr0) },  /* sr0, i.e. cnt or COUNTER */
-      { 52, &(gregs->sr1) },  /* sr1, i.e. lcr or LDCR */
-      { 51, &(gregs->sr1) },  /* sr2, i.e. scr or STCR */
-
-      /* Exception occured at this address, exactly the PC we want */
-      { 49, &(gregs->cp0_epc) }, /* PC */
-
-      { 38, &(gregs->cp0_ema) }, /* EMA */
-      { 37, &(gregs->cp0_epc) }, /* EPC */
-      { 34, &(gregs->cp0_ecr) }, /* ECR */
-      { 33, &(gregs->cp0_condition) }, /* COND */
-      { 32, &(gregs->cp0_psr) }, /* PSR */
-    };
+    { 7 * 4, REGCACHE_MAP_SKIP_BYTES },
+    { 32, 0 },			/* r0 ... r31 */
+    { 1, 55 },			/* CEL */
+    { 1, 54 },			/* CEH */
+    { 1, 53 },			/* sr0, i.e. cnt or COUNTER */
+    { 1, 52 },			/* sr1, i.e. lcr or LDCR */
+    { 1, 51 },			/* sr2, i.e. scr or STCR */
+    /* EPC and PC are stored in the same slot.  */
+    { 1, 37 },			/* EPC */
+    { -4, REGCACHE_MAP_SKIP_BYTES },
+    { 1, 49 },			/* PC */
+    { 1, 38 },			/* EMA */
+    { 1, 32 },			/* PSR */
+    { 1, 34 },			/* ECR */
+    { 1, 33 },			/* COND */
+    { 0 }
+  };
 
-    for (regno = 0; regno < sizeof(sregs)/sizeof(sregs[0]); regno++)
-      if (regnum == -1 || regnum == sregs[regno].regnum)
-	regcache_raw_supply (regcache,
-			     sregs[regno].regnum, sregs[regno].buf);
-  }
-}
+#define SCORE7_LINUX_SIZEOF_GREGSET 196
 
 static const struct regset score7_linux_gregset =
   {
-    NULL,
-    score7_linux_supply_gregset, NULL
+    score7_linux_gregmap,
+    regcache_supply_regset, regcache_collect_regset
   };
 
 /* Return the appropriate register set from the core section identified
@@ -1463,7 +1438,8 @@ score7_linux_regset_from_core_section(struct gdbarch *gdbarch,
   gdb_assert (gdbarch != NULL);
   gdb_assert (sect_name != NULL);
 
-  if (strcmp(sect_name, ".reg") == 0 && sect_size == sizeof(elf_gregset_t))
+  if (strcmp(sect_name, ".reg") == 0
+      && sect_size == SCORE7_LINUX_SIZEOF_GREGSET)
     return &score7_linux_gregset;
 
   return NULL;
diff --git a/gdb/score-tdep.h b/gdb/score-tdep.h
index 02a334e..cef0e6a 100644
--- a/gdb/score-tdep.h
+++ b/gdb/score-tdep.h
@@ -32,6 +32,7 @@ enum gdb_regnum
   SCORE_RA_REGNUM = 3,
   SCORE_A0_REGNUM = 4,
   SCORE_AL_REGNUM = 7,
+  SCORE_EPC_REGNUM = 37,
   SCORE_PC_REGNUM = 49,
 };
 
@@ -46,37 +47,4 @@ enum gdb_regnum
 #define SCORE_INSTLEN          4
 #define SCORE16_INSTLEN        2
 
-/* Forward declarations.  */
-struct regset;
-
-/* Linux Core file support (dirty hack)
-  
-   S+core Linux register set definition, copy from S+core Linux.  */
-struct pt_regs {
-    /* Pad bytes for argument save space on the stack.  */
-    unsigned long pad0[6]; /* may be 4, MIPS accept 6var, SCore
-			      accepts 4 Var--yuchen */
-
-    /* Saved main processor registers.  */
-    unsigned long orig_r4;
-    unsigned long regs[32];
-
-    /* Other saved registers.  */
-    unsigned long cel;
-    unsigned long ceh;
-
-    unsigned long sr0;  /*cnt*/
-    unsigned long sr1;  /*lcr*/
-    unsigned long sr2;  /*scr*/
-
-    /* saved cp0 registers */
-    unsigned long cp0_epc;
-    unsigned long cp0_ema;
-    unsigned long cp0_psr;
-    unsigned long cp0_ecr;
-    unsigned long cp0_condition;
-};
-
-typedef struct pt_regs elf_gregset_t;
-
 #endif /* SCORE_TDEP_H */
-- 
1.8.4.2

  parent reply	other threads:[~2014-06-25 16:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-25 16:49 [PATCH v2 00/13] Regset rework preparations part 2 Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 05/13] ALPHA Linux: Fill 'collect_regset' in regset structures Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 04/13] AARCH64 " Andreas Arnez
2014-07-07  9:57   ` Omair Javaid
2014-06-25 16:49 ` [PATCH v2 01/13] Rename 'descr' field in regset structure to 'regmap' Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 12/13] M68K Linux: Define regset structures Andreas Arnez
2014-07-15 12:13   ` Ulrich Weigand
2014-07-16 18:01     ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 02/13] regcache: Add functions suitable for regset_supply/collect Andreas Arnez
2014-07-07  9:32   ` Omair Javaid
2014-07-08 11:32     ` Andreas Arnez
2014-07-08 19:09       ` Omair Javaid
2014-07-10  7:54         ` Andreas Arnez
2014-07-19 13:10           ` Omair Javaid
2014-06-25 16:49 ` [PATCH v2 07/13] HPPA Linux: Fill 'collect_regset' in regset structures Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 03/13] S390: Migrate to regcache_supply/collect_regset Andreas Arnez
2014-07-15  9:27   ` Ulrich Weigand
2014-07-15 12:07     ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 11/13] TILEGX Linux: Fill 'collect_regset' in regset structure Andreas Arnez
2014-07-15 10:12   ` Ulrich Weigand
2014-07-16 13:30     ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 13/13] IA64 Linux: Define regset structures Andreas Arnez
2014-07-15 13:01   ` Ulrich Weigand
2014-07-18  9:06     ` Andreas Arnez
2014-06-25 16:49 ` Andreas Arnez [this message]
2014-07-15 10:01   ` [PATCH v2 10/13] SCORE: Fill 'collect_regset' in regset structure Ulrich Weigand
2014-07-15 12:25     ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 09/13] NIOS2 Linux: " Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 06/13] FRV Linux: Fill 'collect_regset' in regset structures Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 08/13] M32R Linux: Fill 'collect_regset' in regset structure Andreas Arnez
2014-07-01  8:00 ` [ping][PATCH v2 00/13] Regset rework preparations part 2 Andreas Arnez

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=1403714949-28133-11-git-send-email-arnez@linux.vnet.ibm.com \
    --to=arnez@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qinwei@sunnorth.com.cn \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).