* [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE
@ 2017-04-04 10:16 Alan Hayward
2017-04-11 11:23 ` Yao Qi
0 siblings, 1 reply; 7+ messages in thread
From: Alan Hayward @ 2017-04-04 10:16 UTC (permalink / raw)
To: gdb-patches; +Cc: nd
Max size set to 96bits, which I determined using the various sh*register_type() functions.
Tested on a --enable-targets=all build using make check with board files
unix and native-gdbserver.
I do not have a SH machine to test on.
Ok to commit?
Alan.
2017-04-04 Alan Hayward <alan.hayward@arm.com>
* sh-tdep.c (sh_pseudo_register_read): Use SH_MAX_REGISTER_SIZE.
(sh_pseudo_register_write): Likewise.
* sh64-tdep.c (SH_MAX_REGISTER_SIZE): Add.
(sh64_pseudo_register_read): Use SH64_MAX_REGISTER_SIZE..
(sh64_pseudo_register_write): Likewise.
* sh-tdep.h (SH64_MAX_REGISTER_SIZE): Add.
diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h
index d15ef050e079aec93a8f2578bf6e94ace919061b..ca9bb25c947a7425e6160797ac05019b20fd4bff 100644
--- a/gdb/sh-tdep.h
+++ b/gdb/sh-tdep.h
@@ -82,6 +82,9 @@ enum
FV_LAST_REGNUM = 79
};
+/* Big enough to hold the size of the largest register in bytes. */
+#define SH_MAX_REGISTER_SIZE 12
+
/* This structure describes a register in a core-file. */
struct sh_corefile_regmap
{
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 9b3692dc0c32ffcb53d99f0fc095303d2c221fcb..7e56864202fe9321edb7561c721ef912b3a4f8c5 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1648,7 +1648,7 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, gdb_byte *buffer)
{
int base_regnum;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[SH_MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr == PSEUDO_BANK_REGNUM)
@@ -1687,7 +1687,7 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, const gdb_byte *buffer)
{
int base_regnum, portion;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[SH_MAX_REGISTER_SIZE];
if (reg_nr == PSEUDO_BANK_REGNUM)
{
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 23f5ade3b2e631eeb50cb918a4f36bb8cfbe6131..19fce4fef6aba859491304c171fe16cb41ca3d37 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -122,6 +122,9 @@ enum
FP_LAST_REGNUM = SIM_SH64_FR0_REGNUM + SIM_SH64_NR_FP_REGS - 1
};
+/* Big enough to hold the size of the largest register in bytes. */
+#define SH64_MAX_REGISTER_SIZE 12
+
static const char *
sh64_register_name (struct gdbarch *gdbarch, int reg_nr)
{
@@ -1528,7 +1531,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum;
int offset = 0;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr >= DR0_REGNUM
@@ -1704,7 +1707,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum, portion;
int offset;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
if (reg_nr >= DR0_REGNUM
&& reg_nr <= DR_LAST_REGNUM)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE
2017-04-04 10:16 [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE Alan Hayward
@ 2017-04-11 11:23 ` Yao Qi
2017-04-12 8:34 ` Alan Hayward
0 siblings, 1 reply; 7+ messages in thread
From: Yao Qi @ 2017-04-11 11:23 UTC (permalink / raw)
To: Alan Hayward; +Cc: gdb-patches
Alan Hayward <Alan.Hayward@arm.com> writes:
> diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
> index 9b3692dc0c32ffcb53d99f0fc095303d2c221fcb..7e56864202fe9321edb7561c721ef912b3a4f8c5 100644
> --- a/gdb/sh-tdep.c
> +++ b/gdb/sh-tdep.c
> @@ -1648,7 +1648,7 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
> int reg_nr, gdb_byte *buffer)
> {
> int base_regnum;
> - gdb_byte temp_buffer[MAX_REGISTER_SIZE];
> + gdb_byte temp_buffer[SH_MAX_REGISTER_SIZE];
> enum register_status status;
>
> if (reg_nr == PSEUDO_BANK_REGNUM)
temp_buffer is used for double float register, which is from two fp
registers,
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
{
base_regnum = dr_reg_base_num (gdbarch, reg_nr);
/* Build the value in the provided buffer. */
/* Read the real regs for which this one is an alias. */
status = pseudo_register_read_portions (gdbarch, regcache,
2, base_regnum, temp_buffer);
if (status == REG_VALID)
{
/* We must pay attention to the endiannes. */
sh_register_convert_to_virtual (gdbarch, reg_nr,
register_type (gdbarch, reg_nr),
temp_buffer, buffer);
}
Can you move "temp_buffer" into this block, and define it
gdb_byte temp_buffer[4 * 2] or temp_buffer[SH_FLOAT_REGISTER_SIZE * 2];
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE
2017-04-11 11:23 ` Yao Qi
@ 2017-04-12 8:34 ` Alan Hayward
2017-06-05 16:30 ` Alan Hayward
0 siblings, 1 reply; 7+ messages in thread
From: Alan Hayward @ 2017-04-12 8:34 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, nd
> On 11 Apr 2017, at 12:23, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> Alan Hayward <Alan.Hayward@arm.com> writes:
>
>> diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
>> index 9b3692dc0c32ffcb53d99f0fc095303d2c221fcb..7e56864202fe9321edb7561c721ef912b3a4f8c5 100644
>> --- a/gdb/sh-tdep.c
>> +++ b/gdb/sh-tdep.c
>> @@ -1648,7 +1648,7 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
>> int reg_nr, gdb_byte *buffer)
>> {
>> int base_regnum;
>> - gdb_byte temp_buffer[MAX_REGISTER_SIZE];
>> + gdb_byte temp_buffer[SH_MAX_REGISTER_SIZE];
>> enum register_status status;
>>
>> if (reg_nr == PSEUDO_BANK_REGNUM)
>
> temp_buffer is used for double float register, which is from two fp
> registers,
>
> else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
> {
> base_regnum = dr_reg_base_num (gdbarch, reg_nr);
>
> /* Build the value in the provided buffer. */
> /* Read the real regs for which this one is an alias. */
> status = pseudo_register_read_portions (gdbarch, regcache,
> 2, base_regnum, temp_buffer);
> if (status == REG_VALID)
> {
> /* We must pay attention to the endiannes. */
> sh_register_convert_to_virtual (gdbarch, reg_nr,
> register_type (gdbarch, reg_nr),
> temp_buffer, buffer);
> }
>
> Can you move "temp_buffer" into this block, and define it
>
> gdb_byte temp_buffer[4 * 2] or temp_buffer[SH_FLOAT_REGISTER_SIZE * 2];
>
> --
> Yao (齐尧)
Ok.
There doesn't seem to be the same obvious fix for SH64 (unless you wanted
to define a new buf for each block of the read/write functions).
I don't have a SH machine to test on.
Tested on a --enable-targets=all build using make check with board files
unix and native-gdbserver.
Ok to commit?
Alan.
2017-04-12 Alan Hayward <alan.hayward@arm.com>
* gdb/sh-tdep.c (sh_pseudo_register_read): Remove MAX_REGISTER_SIZE.
(sh_pseudo_register_write): Likewise.
* gdb/sh64-tdep.c (SH64_MAX_REGISTER_SIZE): Add.
(sh64_pseudo_register_read): Use SH64_MAX_REGISTER_SIZE.
(sh64_pseudo_register_write): Likewise
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index f4b4c486fd59715b9eacfecf034653ce570716a9..75bc37c6d77a0d592395e2360549d6831630c017 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1648,13 +1648,14 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, gdb_byte *buffer)
{
int base_regnum;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr == PSEUDO_BANK_REGNUM)
return regcache_raw_read (regcache, BANK_REGNUM, buffer);
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
{
+ /* Enough space for two float registers. */
+ gdb_byte temp_buffer[4 * 2];
base_regnum = dr_reg_base_num (gdbarch, reg_nr);
/* Build the value in the provided buffer. */
@@ -1687,7 +1688,6 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, const gdb_byte *buffer)
{
int base_regnum, portion;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
if (reg_nr == PSEUDO_BANK_REGNUM)
{
@@ -1703,6 +1703,8 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
}
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
{
+ /* Enough space for two float registers. */
+ gdb_byte temp_buffer[4 * 2];
base_regnum = dr_reg_base_num (gdbarch, reg_nr);
/* We must pay attention to the endiannes. */
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 33986fd12ffa37d59a5021cc3dcf25ad6fbceedf..b4cc26503ec2992a5225d8f715661ba9b6409c2a 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -122,6 +122,9 @@ enum
FP_LAST_REGNUM = SIM_SH64_FR0_REGNUM + SIM_SH64_NR_FP_REGS - 1
};
+/* Big enough to hold the size of the largest register in bytes. */
+#define SH64_MAX_REGISTER_SIZE 12
+
static const char *
sh64_register_name (struct gdbarch *gdbarch, int reg_nr)
{
@@ -1528,7 +1531,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum;
int offset = 0;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr >= DR0_REGNUM
@@ -1704,7 +1707,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum, portion;
int offset;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
if (reg_nr >= DR0_REGNUM
&& reg_nr <= DR_LAST_REGNUM)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE
2017-04-12 8:34 ` Alan Hayward
@ 2017-06-05 16:30 ` Alan Hayward
2017-06-06 14:31 ` Yao Qi
0 siblings, 1 reply; 7+ messages in thread
From: Alan Hayward @ 2017-06-05 16:30 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, nd
> On 12 Apr 2017, at 09:34, Alan Hayward <Alan.Hayward@arm.com> wrote:
>
>
>> On 11 Apr 2017, at 12:23, Yao Qi <qiyaoltc@gmail.com> wrote:
>>
>> Alan Hayward <Alan.Hayward@arm.com> writes:
>>
I’ve rebased this patch due to Yao’s unit test changes.
I don't have a SH machine to test on.
Tested on a --enable-targets=all and --enable-libsanitizer build using
make check with board files unix and native-gdbserver.
Ok to commit?
Alan.
2017-06-05 Alan Hayward <alan.hayward@arm.com>
* gdb/sh-tdep.c (sh_pseudo_register_read): Remove MAX_REGISTER_SIZE.
(sh_pseudo_register_write): Likewise.
* gdb/sh64-tdep.c (SH64_MAX_REGISTER_SIZE): Add.
(sh64_pseudo_register_read): Use SH64_MAX_REGISTER_SIZE.
(sh64_pseudo_register_write): Likewise
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 2c2b26847d58808ef912ed4969bc28c799ad9bbd..a87547d4ceda1b6db4157d181ae1b982444a867c 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1648,13 +1648,14 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, gdb_byte *buffer)
{
int base_regnum;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr == PSEUDO_BANK_REGNUM)
return regcache_raw_read (regcache, BANK_REGNUM, buffer);
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
{
+ /* Enough space for two float registers. */
+ gdb_byte temp_buffer[4 * 2];
base_regnum = dr_reg_base_num (gdbarch, reg_nr);
/* Build the value in the provided buffer. */
@@ -1687,7 +1688,6 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, const gdb_byte *buffer)
{
int base_regnum, portion;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
if (reg_nr == PSEUDO_BANK_REGNUM)
{
@@ -1703,6 +1703,8 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
}
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
{
+ /* Enough space for two float registers. */
+ gdb_byte temp_buffer[4 * 2];
base_regnum = dr_reg_base_num (gdbarch, reg_nr);
/* We must pay attention to the endiannes. */
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 06ae04e9da1eff6e2b9e3e977e4f52fa398f69f2..244029501aed1837097f5eb73e6a141cf928d009 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -122,6 +122,9 @@ enum
FP_LAST_REGNUM = SIM_SH64_FR0_REGNUM + SIM_SH64_NR_FP_REGS - 1
};
+/* Big enough to hold the size of the largest register in bytes. */
+#define SH64_MAX_REGISTER_SIZE 12
+
static const char *
sh64_register_name (struct gdbarch *gdbarch, int reg_nr)
{
@@ -1528,7 +1531,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum;
int offset = 0;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr >= DR0_REGNUM
@@ -1704,7 +1707,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum, portion;
int offset;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
+ gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
if (reg_nr >= DR0_REGNUM
&& reg_nr <= DR_LAST_REGNUM)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE
2017-06-05 16:30 ` Alan Hayward
@ 2017-06-06 14:31 ` Yao Qi
2017-06-07 8:27 ` Alan Hayward
0 siblings, 1 reply; 7+ messages in thread
From: Yao Qi @ 2017-06-06 14:31 UTC (permalink / raw)
To: Alan Hayward; +Cc: gdb-patches, nd
Alan Hayward <Alan.Hayward@arm.com> writes:
> @@ -1528,7 +1531,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
> enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> int base_regnum;
> int offset = 0;
> - gdb_byte temp_buffer[MAX_REGISTER_SIZE];
> + gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
> enum register_status status;
>
> if (reg_nr >= DR0_REGNUM
> @@ -1704,7 +1707,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
> enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> int base_regnum, portion;
> int offset;
> - gdb_byte temp_buffer[MAX_REGISTER_SIZE];
> + gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
Could you define temp_buffer in each block where it is used? The size
of register is known at each place. In some places, we don't need to
use temp_buffer, instead, we can use regcache_raw_read_unsigned to
replace regcache_raw_read+extract_unsigned_integer. Then, we don't need
SH64_MAX_REGISTER_SIZE at all.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE
2017-06-06 14:31 ` Yao Qi
@ 2017-06-07 8:27 ` Alan Hayward
2017-06-07 9:01 ` Yao Qi
0 siblings, 1 reply; 7+ messages in thread
From: Alan Hayward @ 2017-06-07 8:27 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, nd
> On 6 Jun 2017, at 15:31, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> Alan Hayward <Alan.Hayward@arm.com> writes:
>
>> @@ -1528,7 +1531,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
>> enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>> int base_regnum;
>> int offset = 0;
>> - gdb_byte temp_buffer[MAX_REGISTER_SIZE];
>> + gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
>> enum register_status status;
>>
>> if (reg_nr >= DR0_REGNUM
>> @@ -1704,7 +1707,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
>> enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>> int base_regnum, portion;
>> int offset;
>> - gdb_byte temp_buffer[MAX_REGISTER_SIZE];
>> + gdb_byte temp_buffer[SH64_MAX_REGISTER_SIZE];
>
> Could you define temp_buffer in each block where it is used? The size
> of register is known at each place. In some places, we don't need to
> use temp_buffer, instead, we can use regcache_raw_read_unsigned to
> replace regcache_raw_read+extract_unsigned_integer. Then, we don't need
> SH64_MAX_REGISTER_SIZE at all.
>
> --
> Yao (齐尧)
That makes sense.
I originally avoided it because it resulted in lots of temp_buffers.
Updated below.
I don't have a SH machine to test on.
Tested on a --enable-targets=all and asan build using
make check with board files unix, native-gdbserver and unittest
Ok to commit?
Alan.
2017-06-07 Alan Hayward <alan.hayward@arm.com>
* gdb/sh-tdep.c (sh_pseudo_register_read): Remove
MAX_REGISTER_SIZE.
(sh_pseudo_register_write): Likewise.
* gdb/sh64-tdep.c (sh64_pseudo_register_read): Remove
MAX_REGISTER_SIZE.
(sh64_pseudo_register_write): Likewise
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 2c2b26847d58808ef912ed4969bc28c799ad9bbd..a87547d4ceda1b6db4157d181ae1b982444a867c 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1648,13 +1648,14 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, gdb_byte *buffer)
{
int base_regnum;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr == PSEUDO_BANK_REGNUM)
return regcache_raw_read (regcache, BANK_REGNUM, buffer);
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
{
+ /* Enough space for two float registers. */
+ gdb_byte temp_buffer[4 * 2];
base_regnum = dr_reg_base_num (gdbarch, reg_nr);
/* Build the value in the provided buffer. */
@@ -1687,7 +1688,6 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, const gdb_byte *buffer)
{
int base_regnum, portion;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
if (reg_nr == PSEUDO_BANK_REGNUM)
{
@@ -1703,6 +1703,8 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
}
else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
{
+ /* Enough space for two float registers. */
+ gdb_byte temp_buffer[4 * 2];
base_regnum = dr_reg_base_num (gdbarch, reg_nr);
/* We must pay attention to the endiannes. */
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 06ae04e9da1eff6e2b9e3e977e4f52fa398f69f2..4eb8947f74a5d3a5be33ca68e34194d6ac9f983c 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -1528,12 +1528,12 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum;
int offset = 0;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
enum register_status status;
if (reg_nr >= DR0_REGNUM
&& reg_nr <= DR_LAST_REGNUM)
{
+ gdb_byte temp_buffer[8];
base_regnum = sh64_dr_reg_base_num (gdbarch, reg_nr);
/* Build the value in the provided buffer. */
@@ -1580,6 +1580,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
else if (reg_nr >= R0_C_REGNUM
&& reg_nr <= T_C_REGNUM)
{
+ gdb_byte temp_buffer[8];
base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr);
/* Build the value in the provided buffer. */
@@ -1607,6 +1608,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
else if (reg_nr >= DR0_C_REGNUM
&& reg_nr <= DR_LAST_C_REGNUM)
{
+ gdb_byte temp_buffer[8];
base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr);
/* DR_C regs are double precision registers obtained by
@@ -1639,8 +1641,8 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
{
int fpscr_base_regnum;
int sr_base_regnum;
- unsigned int fpscr_value;
- unsigned int sr_value;
+ ULONGEST fpscr_value;
+ ULONGEST sr_value;
unsigned int fpscr_c_value;
unsigned int fpscr_c_part1_value;
unsigned int fpscr_c_part2_value;
@@ -1662,18 +1664,14 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
21-31 reserved
*/
/* *INDENT-ON* */
- /* Get FPSCR into a local buffer. */
- status = regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
+ /* Get FPSCR as an int. */
+ status = regcache->raw_read_unsigned (fpscr_base_regnum, &fpscr_value);
if (status != REG_VALID)
return status;
- /* Get value as an int. */
- fpscr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
- /* Get SR into a local buffer */
- status = regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
+ /* Get SR as an int. */
+ status = regcache->raw_read_unsigned (sr_base_regnum, &sr_value);
if (status != REG_VALID)
return status;
- /* Get value as an int. */
- sr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
/* Build the new value. */
fpscr_c_part1_value = fpscr_value & 0x3fffd;
fpscr_c_part2_value = (sr_value & 0x7000) << 6;
@@ -1704,11 +1702,11 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum, portion;
int offset;
- gdb_byte temp_buffer[MAX_REGISTER_SIZE];
if (reg_nr >= DR0_REGNUM
&& reg_nr <= DR_LAST_REGNUM)
{
+ gdb_byte temp_buffer[8];
base_regnum = sh64_dr_reg_base_num (gdbarch, reg_nr);
/* We must pay attention to the endianness. */
sh64_register_convert_to_raw (gdbarch, register_type (gdbarch, reg_nr),
@@ -1752,6 +1750,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
else if (reg_nr >= R0_C_REGNUM
&& reg_nr <= T_C_REGNUM)
{
+ gdb_byte temp_buffer[8];
base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr);
/* reg_nr is 32 bit here, and base_regnum is 64 bits. */
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
@@ -1779,6 +1778,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
else if (reg_nr >= DR0_C_REGNUM
&& reg_nr <= DR_LAST_C_REGNUM)
{
+ gdb_byte temp_buffer[8];
base_regnum = sh64_compact_reg_base_num (gdbarch, reg_nr);
for (portion = 0; portion < 2; portion++)
{
@@ -1813,10 +1813,10 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
{
int fpscr_base_regnum;
int sr_base_regnum;
- unsigned int fpscr_value;
- unsigned int sr_value;
- unsigned int old_fpscr_value;
- unsigned int old_sr_value;
+ ULONGEST fpscr_value;
+ ULONGEST sr_value;
+ ULONGEST old_fpscr_value;
+ ULONGEST old_sr_value;
unsigned int fpscr_c_value;
unsigned int fpscr_mask;
unsigned int sr_mask;
@@ -1847,19 +1847,15 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
fpscr_value = fpscr_c_value & fpscr_mask;
sr_value = (fpscr_value & sr_mask) >> 6;
- regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
- old_fpscr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
+ regcache->raw_read_unsigned (fpscr_base_regnum, &old_fpscr_value);
old_fpscr_value &= 0xfffc0002;
fpscr_value |= old_fpscr_value;
- store_unsigned_integer (temp_buffer, 4, byte_order, fpscr_value);
- regcache_raw_write (regcache, fpscr_base_regnum, temp_buffer);
-
- regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
- old_sr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
+ regcache->raw_write_unsigned (fpscr_base_regnum, fpscr_value);
+
+ regcache->raw_read_unsigned (sr_base_regnum, &old_sr_value);
old_sr_value &= 0xffff8fff;
sr_value |= old_sr_value;
- store_unsigned_integer (temp_buffer, 4, byte_order, sr_value);
- regcache_raw_write (regcache, sr_base_regnum, temp_buffer);
+ regcache->raw_write_unsigned (sr_base_regnum, sr_value);
}
else if (reg_nr == FPUL_C_REGNUM)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE
2017-06-07 8:27 ` Alan Hayward
@ 2017-06-07 9:01 ` Yao Qi
0 siblings, 0 replies; 7+ messages in thread
From: Yao Qi @ 2017-06-07 9:01 UTC (permalink / raw)
To: Alan Hayward; +Cc: gdb-patches, nd
Alan Hayward <Alan.Hayward@arm.com> writes:
> Ok to commit?
>
> 2017-06-07 Alan Hayward <alan.hayward@arm.com>
>
> * gdb/sh-tdep.c (sh_pseudo_register_read): Remove
> MAX_REGISTER_SIZE.
> (sh_pseudo_register_write): Likewise.
> * gdb/sh64-tdep.c (sh64_pseudo_register_read): Remove
> MAX_REGISTER_SIZE.
> (sh64_pseudo_register_write): Likewise
Patch is good to me.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-06-07 9:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 10:16 [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE Alan Hayward
2017-04-11 11:23 ` Yao Qi
2017-04-12 8:34 ` Alan Hayward
2017-06-05 16:30 ` Alan Hayward
2017-06-06 14:31 ` Yao Qi
2017-06-07 8:27 ` Alan Hayward
2017-06-07 9:01 ` Yao Qi
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).