From: Yao Qi <qiyaoltc@gmail.com>
To: Ivo Raisr <ivo.raisr@oracle.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Bug 20936 - provide sparc and sparcv9 target description XML files
Date: Thu, 05 Jan 2017 14:31:00 -0000 [thread overview]
Message-ID: <20170105143109.GA21293@E107787-LIN> (raw)
In-Reply-To: <082f9ac8-3e46-42cd-198d-91866d83ebb8@oracle.com>
On 17-01-04 18:42:27, Ivo Raisr wrote:
> On 12.12.2016 13:53, Yao Qi wrote:
>
> >Hi Ivo,
> >Your patch does two orthogonal things IMO,
> >
> > - Pseudo register support enhancement, patch #1
> > - XML target description support and sparc*-tdep.c updates, patch #2,
> >
> >Can you split them to two patches?
>
> Hi Yao,
>
> Thank you for looking into my changes.
> I think I can see your motivation behind splitting the patch into two,
> for better readability and manageability.
> However my intention was only to provide support for registers
> supplied by target description (Valgrind shadow registers in addition
> to sparc real hardware ones).
> Pseudo register changes were just a necessity to get this done
> because Valgrind shadow registers are considered as "real" registers
> and thus they are numbered before any pseudo registers.
> This also means I cannot draw a clear line between your suggested
> patch #1 and #2. Can you take my whole patch as is?
>
The line is clear to me. I split your patch, and show the patch #1 here.
Does it work for you? Note you still need to add comments to new functions
in the patch below.
--
Yao (é½å°§)
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index fe8d547..b6b782d 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -327,18 +327,28 @@ static const char *sparc32_pseudo_register_names[] =
/* Total number of pseudo registers. */
#define SPARC32_NUM_PSEUDO_REGS ARRAY_SIZE (sparc32_pseudo_register_names)
+static const char *
+sparc32_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
+{
+ regnum -= gdbarch_num_regs (gdbarch);
+
+ if (regnum < SPARC32_NUM_PSEUDO_REGS)
+ return sparc32_pseudo_register_names[regnum];
+
+ internal_error (__FILE__, __LINE__,
+ _("sparc32_pseudo_register_name: bad register number %d"),
+ regnum);
+}
+
/* Return the name of register REGNUM. */
static const char *
sparc32_register_name (struct gdbarch *gdbarch, int regnum)
{
- if (regnum >= 0 && regnum < SPARC32_NUM_REGS)
+ if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch))
return sparc32_register_names[regnum];
- if (regnum < SPARC32_NUM_REGS + SPARC32_NUM_PSEUDO_REGS)
- return sparc32_pseudo_register_names[regnum - SPARC32_NUM_REGS];
-
- return NULL;
+ return sparc32_pseudo_register_name (gdbarch, regnum);
}
\f
/* Construct types for ISA-specific registers. */
@@ -398,6 +408,19 @@ sparc_fsr_type (struct gdbarch *gdbarch)
return tdep->sparc_fsr_type;
}
+static struct type *
+sparc32_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
+{
+ regnum -= gdbarch_num_regs (gdbarch);
+
+ if (regnum >= SPARC32_D0_REGNUM && regnum <= SPARC32_D30_REGNUM)
+ return builtin_type (gdbarch)->builtin_double;
+
+ internal_error (__FILE__, __LINE__,
+ _("sparc32_pseudo_register_type: bad register number %d"),
+ regnum);
+}
+
/* Return the GDB type object for the "standard" data type of data in
register REGNUM. */
@@ -407,9 +430,6 @@ sparc32_register_type (struct gdbarch *gdbarch, int regnum)
if (regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F31_REGNUM)
return builtin_type (gdbarch)->builtin_float;
- if (regnum >= SPARC32_D0_REGNUM && regnum <= SPARC32_D30_REGNUM)
- return builtin_type (gdbarch)->builtin_double;
-
if (regnum == SPARC_SP_REGNUM || regnum == SPARC_FP_REGNUM)
return builtin_type (gdbarch)->builtin_data_ptr;
@@ -422,6 +442,9 @@ sparc32_register_type (struct gdbarch *gdbarch, int regnum)
if (regnum == SPARC32_FSR_REGNUM)
return sparc_fsr_type (gdbarch);
+ if (regnum >= gdbarch_num_regs (gdbarch))
+ return sparc32_pseudo_register_type (gdbarch, regnum);
+
return builtin_type (gdbarch)->builtin_int32;
}
@@ -432,6 +455,7 @@ sparc32_pseudo_register_read (struct gdbarch *gdbarch,
{
enum register_status status;
+ regnum -= gdbarch_num_regs (gdbarch);
gdb_assert (regnum >= SPARC32_D0_REGNUM && regnum <= SPARC32_D30_REGNUM);
regnum = SPARC_F0_REGNUM + 2 * (regnum - SPARC32_D0_REGNUM);
@@ -446,6 +470,7 @@ sparc32_pseudo_register_write (struct gdbarch *gdbarch,
struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
+ regnum -= gdbarch_num_regs (gdbarch);
gdb_assert (regnum >= SPARC32_D0_REGNUM && regnum <= SPARC32_D30_REGNUM);
regnum = SPARC_F0_REGNUM + 2 * (regnum - SPARC32_D0_REGNUM);
diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
index ae0c354..1e00195 100644
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -85,7 +85,7 @@ struct gdbarch_tdep
enum sparc_regnum
{
- SPARC_G0_REGNUM, /* %g0 */
+ SPARC_G0_REGNUM = 0, /* %g0 */
SPARC_G1_REGNUM,
SPARC_G2_REGNUM,
SPARC_G3_REGNUM,
@@ -140,9 +140,12 @@ enum sparc32_regnum
SPARC32_NPC_REGNUM, /* %npc */
SPARC32_FSR_REGNUM, /* %fsr */
SPARC32_CSR_REGNUM, /* %csr */
+};
- /* Pseudo registers. */
- SPARC32_D0_REGNUM, /* %d0 */
+/* Pseudo registers. */
+enum sparc32_pseudo_regnum
+{
+ SPARC32_D0_REGNUM = 0, /* %d0 */
SPARC32_D30_REGNUM /* %d30 */
= SPARC32_D0_REGNUM + 15
};
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index f3e039d..1583a94 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -287,6 +287,29 @@ sparc64_register_name (struct gdbarch *gdbarch, int regnum)
return NULL;
}
+static struct type *
+sparc64_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
+{
+ regnum -= gdbarch_num_regs (gdbarch);
+
+ if (regnum == SPARC64_CWP_REGNUM)
+ return builtin_type (gdbarch)->builtin_int64;
+ if (regnum == SPARC64_PSTATE_REGNUM)
+ return sparc64_pstate_type (gdbarch);
+ if (regnum == SPARC64_ASI_REGNUM)
+ return builtin_type (gdbarch)->builtin_int64;
+ if (regnum == SPARC64_CCR_REGNUM)
+ return builtin_type (gdbarch)->builtin_int64;
+ if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D62_REGNUM)
+ return builtin_type (gdbarch)->builtin_double;
+ if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q60_REGNUM)
+ return builtin_type (gdbarch)->builtin_long_double;
+
+ internal_error (__FILE__, __LINE__,
+ _("sparc64_pseudo_register_type: bad register number %d"),
+ regnum);
+}
+
/* Return the GDB type object for the "standard" data type of data in
register REGNUM. */
@@ -319,19 +342,8 @@ sparc64_register_type (struct gdbarch *gdbarch, int regnum)
return builtin_type (gdbarch)->builtin_int64;
/* Pseudo registers. */
-
- if (regnum == SPARC64_CWP_REGNUM)
- return builtin_type (gdbarch)->builtin_int64;
- if (regnum == SPARC64_PSTATE_REGNUM)
- return sparc64_pstate_type (gdbarch);
- if (regnum == SPARC64_ASI_REGNUM)
- return builtin_type (gdbarch)->builtin_int64;
- if (regnum == SPARC64_CCR_REGNUM)
- return builtin_type (gdbarch)->builtin_int64;
- if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D62_REGNUM)
- return builtin_type (gdbarch)->builtin_double;
- if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q60_REGNUM)
- return builtin_type (gdbarch)->builtin_long_double;
+ if (regnum >= gdbarch_num_regs (gdbarch))
+ return sparc64_pseudo_register_type (gdbarch, regnum);
internal_error (__FILE__, __LINE__, _("invalid regnum"));
}
@@ -344,7 +356,7 @@ sparc64_pseudo_register_read (struct gdbarch *gdbarch,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
enum register_status status;
- gdb_assert (regnum >= SPARC64_NUM_REGS);
+ regnum -= gdbarch_num_regs (gdbarch);
if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM)
{
@@ -421,7 +433,8 @@ sparc64_pseudo_register_write (struct gdbarch *gdbarch,
int regnum, const gdb_byte *buf)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_assert (regnum >= SPARC64_NUM_REGS);
+
+ regnum -= gdbarch_num_regs (gdbarch);
if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM)
{
@@ -638,6 +651,7 @@ static void
sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
const gdb_byte *valbuf, int element, int bitpos)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
int len = TYPE_LENGTH (type);
gdb_assert (element < 16);
@@ -652,14 +666,15 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
gdb_assert (bitpos == 0);
gdb_assert ((element % 2) == 0);
- regnum = SPARC64_Q0_REGNUM + element / 2;
+ regnum = gdbarch_num_regs (gdbarch) + SPARC64_Q0_REGNUM + element / 2;
regcache_cooked_write (regcache, regnum, valbuf);
}
else if (len == 8)
{
gdb_assert (bitpos == 0 || bitpos == 64);
- regnum = SPARC64_D0_REGNUM + element + bitpos / 64;
+ regnum = gdbarch_num_regs (gdbarch) + SPARC64_D0_REGNUM
+ + element + bitpos / 64;
regcache_cooked_write (regcache, regnum, valbuf + (bitpos / 8));
}
else
@@ -712,6 +727,8 @@ static void
sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
gdb_byte *valbuf, int bitpos)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+
if (sparc64_floating_p (type))
{
int len = TYPE_LENGTH (type);
@@ -721,14 +738,15 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
{
gdb_assert (bitpos == 0 || bitpos == 128);
- regnum = SPARC64_Q0_REGNUM + bitpos / 128;
+ regnum = gdbarch_num_regs (gdbarch) + SPARC64_Q0_REGNUM
+ + bitpos / 128;
regcache_cooked_read (regcache, regnum, valbuf + (bitpos / 8));
}
else if (len == 8)
{
gdb_assert (bitpos % 64 == 0 && bitpos >= 0 && bitpos < 256);
- regnum = SPARC64_D0_REGNUM + bitpos / 64;
+ regnum = gdbarch_num_regs (gdbarch) + SPARC64_D0_REGNUM + bitpos / 64;
regcache_cooked_read (regcache, regnum, valbuf + (bitpos / 8));
}
else
@@ -911,13 +929,13 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
/* Float Complex or double Complex arguments. */
if (element < 16)
{
- regnum = SPARC64_D0_REGNUM + element;
+ regnum = gdbarch_num_regs (gdbarch) + SPARC64_D0_REGNUM + element;
if (len == 16)
{
- if (regnum < SPARC64_D30_REGNUM)
+ if (regnum < gdbarch_num_regs (gdbarch) + SPARC64_D30_REGNUM)
regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
- if (regnum < SPARC64_D10_REGNUM)
+ if (regnum < gdbarch_num_regs (gdbarch) + SPARC64_D10_REGNUM)
regcache_cooked_write (regcache,
SPARC_O0_REGNUM + element + 1,
valbuf + 8);
@@ -932,12 +950,14 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
if (element % 2)
element++;
if (element < 16)
- regnum = SPARC64_Q0_REGNUM + element / 2;
+ regnum = gdbarch_num_regs (gdbarch) + SPARC64_Q0_REGNUM
+ + element / 2;
}
else if (len == 8)
{
if (element < 16)
- regnum = SPARC64_D0_REGNUM + element;
+ regnum = gdbarch_num_regs (gdbarch) + SPARC64_D0_REGNUM
+ + element;
}
else if (len == 4)
{
@@ -952,7 +972,8 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
valbuf = buf;
len = 8;
if (element < 16)
- regnum = SPARC64_D0_REGNUM + element;
+ regnum = gdbarch_num_regs (gdbarch) + SPARC64_D0_REGNUM
+ + element;
}
}
else
@@ -969,19 +990,24 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
/* If we're storing the value in a floating-point register,
also store it in the corresponding %0 register(s). */
- if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D10_REGNUM)
- {
- gdb_assert (element < 6);
- regnum = SPARC_O0_REGNUM + element;
- regcache_cooked_write (regcache, regnum, valbuf);
- }
- else if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q8_REGNUM)
- {
- gdb_assert (element < 5);
- regnum = SPARC_O0_REGNUM + element;
- regcache_cooked_write (regcache, regnum, valbuf);
- regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
- }
+ if (regnum >= gdbarch_num_regs (gdbarch))
+ {
+ regnum -= gdbarch_num_regs (gdbarch);
+
+ if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D10_REGNUM)
+ {
+ gdb_assert (element < 6);
+ regnum = SPARC_O0_REGNUM + element;
+ regcache_cooked_write (regcache, regnum, valbuf);
+ }
+ else if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q8_REGNUM)
+ {
+ gdb_assert (element < 5);
+ regnum = SPARC_O0_REGNUM + element;
+ regcache_cooked_write (regcache, regnum, valbuf);
+ regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
+ }
+ }
}
/* Always store the argument in memory. */
diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h
index 13d04b6..324778e 100644
--- a/gdb/sparc64-tdep.h
+++ b/gdb/sparc64-tdep.h
@@ -56,9 +56,12 @@ enum sparc64_regnum
SPARC64_FSR_REGNUM, /* %fsr */
SPARC64_FPRS_REGNUM, /* %fprs */
SPARC64_Y_REGNUM, /* %y */
+};
- /* Pseudo registers. */
- SPARC64_CWP_REGNUM, /* %cwp */
+/* Pseudo registers. */
+enum sparc64_pseudo_regnum
+{
+ SPARC64_CWP_REGNUM = 0, /* %cwp */
SPARC64_PSTATE_REGNUM, /* %pstate */
SPARC64_ASI_REGNUM, /* %asi */
SPARC64_CCR_REGNUM, /* %ccr */
next prev parent reply other threads:[~2017-01-05 14:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-06 11:41 Ivo Raisr
2016-12-06 15:26 ` Yao Qi
2016-12-06 23:46 ` Ivo Raisr
2016-12-06 23:58 ` Ivo Raisr
2016-12-12 12:54 ` Yao Qi
2017-01-04 17:43 ` Ivo Raisr
2017-01-05 14:31 ` Yao Qi [this message]
2017-01-06 15:12 ` Ivo Raisr
2017-01-09 17:35 ` Yao Qi
2017-01-09 21:18 ` Ivo Raisr
2017-01-10 9:29 ` Yao Qi
2017-01-11 13:15 ` Ivo Raisr
2017-01-11 15:46 ` Yao Qi
2017-01-12 11:09 ` Ivo Raisr
2017-01-16 16:50 ` Jose E. Marchesi
2017-01-25 15:46 ` Pedro Alves
2017-01-25 16:05 ` Ivo Raisr
2017-01-25 16:24 ` Pedro Alves
2017-01-25 16:26 ` Ivo Raisr
2017-01-25 16:44 ` Yao Qi
2017-01-17 21:38 ` Ivo Raisr
2017-01-25 5:46 ` Ivo Raisr
2017-01-25 22:42 ` Yao Qi
2017-01-26 11:23 ` Ivo Raisr
2016-12-11 17:23 ` Ivo Raisr
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=20170105143109.GA21293@E107787-LIN \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=ivo.raisr@oracle.com \
/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