From: Alan Hayward <Alan.Hayward@arm.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
nd <nd@arm.com>
Subject: Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4)
Date: Fri, 05 May 2017 08:04:00 -0000 [thread overview]
Message-ID: <806B436F-EFA1-4200-AC54-9036D166C9B9@arm.com> (raw)
In-Reply-To: <86y3v7uf9j.fsf@gmail.com>
> On 11 Apr 2017, at 16:37, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> Alan Hayward <Alan.Hayward@arm.com> writes:
>
> Hi Alan,
> There are different ways of getting rid of MAX_REGISTER_SIZE, let us try
> some simple approaches first. Some uses of MAX_REGISTER_SIZE still
> can't be removed, but let us start from easy part.
>
Patch split into multiple parts.
This part adds two new regcache functions: raw_supply_signed and
raw_collect_signed.
Tested on a --enable-targets=all build using make check with board files
unix and native-gdbserver.
I do not have a MIPS machine to test on.
Ok to commit?
2017-05-05 Alan Hayward <alan.hayward@arm.com>
* mips-fbsd-tdep.c (mips_fbsd_supply_reg): Use raw_supply_signed.
(mips_fbsd_collect_reg): Use raw_collect_signed.
* mips-linux-tdep.c (supply_32bit_reg): Use raw_supply_signed.
(mips64_fill_gregset): Use raw_collect_signed.
(mips64_fill_fpregset): Use raw_supply_signed.
* regcache.c (regcache::raw_supply_signed): New function.
(regcache::raw_collect_signed): New function.
* regcache.h (regcache::raw_supply_signed): New declaration.
(regcache::raw_collect_signed): New declaration.
Last login: Fri May 5 08:55:03 on ttys000
alahay01@C02N40NHFH04:~
[08:56:55] $ cat Downloads/rb7439.patch
diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c
index 00fae0ec60ddc9e645d3236efe29f2f9e9ceab5c..4785bf9a115fa74fb7f48eac388a7e3df2f0304d 100644
--- a/gdb/mips-fbsd-tdep.c
+++ b/gdb/mips-fbsd-tdep.c
@@ -63,13 +63,10 @@ mips_fbsd_supply_reg (struct regcache *regcache, int regnum, const void *addr,
else
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte buf[MAX_REGISTER_SIZE];
LONGEST val;
val = extract_signed_integer ((const gdb_byte *) addr, len, byte_order);
- store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
- val);
- regcache_raw_supply (regcache, regnum, buf);
+ regcache->raw_supply_signed (regnum, val);
}
}
@@ -90,12 +87,7 @@ mips_fbsd_collect_reg (const struct regcache *regcache, int regnum, void *addr,
else
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte buf[MAX_REGISTER_SIZE];
- LONGEST val;
-
- regcache_raw_collect (regcache, regnum, buf);
- val = extract_signed_integer (buf, register_size (gdbarch, regnum),
- byte_order);
+ LONGEST val = regcache->raw_collect_signed (regnum);
store_signed_integer ((gdb_byte *) addr, len, byte_order, val);
}
}
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index 48a582a16c934abe6e8f87c46a6009649c606d49..5325d75420a71451b63cbadbf4e33d4fcf233fa4 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -118,11 +118,10 @@ supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte buf[MAX_REGISTER_SIZE];
- store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
- extract_signed_integer ((const gdb_byte *) addr, 4,
- byte_order));
- regcache_raw_supply (regcache, regnum, buf);
+ LONGEST val;
+
+ val = extract_signed_integer ((const gdb_byte *) addr, 4, byte_order);
+ regcache->raw_supply_signed (regnum, val);
}
/* Unpack an elf_gregset_t into GDB's register cache. */
@@ -460,12 +459,7 @@ mips64_fill_gregset (const struct regcache *regcache,
if (regaddr != -1)
{
- gdb_byte buf[MAX_REGISTER_SIZE];
- LONGEST val;
-
- regcache_raw_collect (regcache, regno, buf);
- val = extract_signed_integer (buf, register_size (gdbarch, regno),
- byte_order);
+ LONGEST val = regcache->raw_collect_signed (regno);
dst = regp + regaddr;
store_signed_integer ((gdb_byte *) dst, 8, byte_order, val);
}
@@ -564,23 +558,13 @@ mips64_fill_fpregset (const struct regcache *regcache,
}
else if (regno == mips_regnum (gdbarch)->fp_control_status)
{
- gdb_byte buf[MAX_REGISTER_SIZE];
- LONGEST val;
-
- regcache_raw_collect (regcache, regno, buf);
- val = extract_signed_integer (buf, register_size (gdbarch, regno),
- byte_order);
+ LONGEST val = regcache->raw_collect_signed (regno);
to = (gdb_byte *) (*fpregsetp + 32);
store_signed_integer (to, 4, byte_order, val);
}
else if (regno == mips_regnum (gdbarch)->fp_implementation_revision)
{
- gdb_byte buf[MAX_REGISTER_SIZE];
- LONGEST val;
-
- regcache_raw_collect (regcache, regno, buf);
- val = extract_signed_integer (buf, register_size (gdbarch, regno),
- byte_order);
+ LONGEST val = regcache->raw_collect_signed (regno);
to = (gdb_byte *) (*fpregsetp + 32) + 4;
store_signed_integer (to, 4, byte_order, val);
}
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 4dcfccbac70f0f962bf5e5596d035fda42322795..76f5bdfdf6cefd6d963be950aefcc275de7a820b 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -294,10 +294,14 @@ public:
void raw_collect (int regnum, void *buf) const;
+ LONGEST raw_collect_signed (int regnum) const;
+
void raw_supply (int regnum, const void *buf);
void raw_supply_zeroed (int regnum);
+ void raw_supply_signed (int regnum, LONGEST val);
+
void raw_copy (int regnum, struct regcache *src_regcache);
enum register_status get_register_status (int regnum) const;
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 957b265c28d929376c3b7d8c100ea355d8292b94..c9fbc997a3fa33fb576db7f57da4501043ff4e9d 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1228,6 +1228,26 @@ regcache::raw_supply_zeroed (int regnum)
m_register_status[regnum] = REG_VALID;
}
+/* Supply register REGNUM, whose contents are stored in signed VAL, to
+ REGCACHE. */
+
+void
+regcache::raw_supply_signed (int regnum, LONGEST val)
+{
+ enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch);
+ gdb_byte *regbuf;
+ size_t size;
+
+ gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ gdb_assert (!m_readonly_p);
+
+ regbuf = register_buffer (regnum);
+ size = m_descr->sizeof_register[regnum];
+
+ store_signed_integer (regbuf, size, byte_order, val);
+ m_register_status[regnum] = REG_VALID;
+}
+
/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
void
@@ -1251,6 +1271,23 @@ regcache::raw_collect (int regnum, void *buf) const
memcpy (buf, regbuf, size);
}
+/* Collect register REGNUM from REGCACHE and extract its contents into a signed
+ LONGEST. */
+
+LONGEST
+regcache::raw_collect_signed (int regnum) const
+{
+ enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch);
+ const gdb_byte *regbuf;
+ size_t size;
+
+ gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+
+ regbuf = register_buffer (regnum);
+ size = m_descr->sizeof_register[regnum];
+ return extract_signed_integer (regbuf, size, byte_order);
+}
+
void
regcache::raw_copy (int regnum, struct regcache *src_regcache)
{
next prev parent reply other threads:[~2017-05-05 8:04 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-04 10:12 [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE Alan Hayward
2017-04-04 17:19 ` John Baldwin
2017-04-05 10:27 ` Alan Hayward
2017-04-11 15:37 ` Yao Qi
2017-05-05 8:03 ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (1/4) Alan Hayward
2017-05-05 21:44 ` Yao Qi
2017-05-05 8:04 ` Alan Hayward [this message]
2017-05-05 19:51 ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4) John Baldwin
2017-05-12 8:53 ` Yao Qi
2017-05-16 11:16 ` Alan Hayward
2017-05-22 12:07 ` Yao Qi
2017-05-22 16:05 ` Alan Hayward
2017-05-22 17:15 ` Pedro Alves
2017-05-23 17:49 ` Alan Hayward
2017-05-23 18:30 ` Pedro Alves
2017-05-24 9:08 ` Alan Hayward
2017-05-24 9:29 ` Pedro Alves
[not found] ` <40597975-9458-e9af-8915-9d303bb1ed98@redhat.com>
2017-05-24 10:20 ` Alan Hayward
[not found] ` <d32041ef-9df3-316a-68ca-3fe2a2797539@redhat.com>
2017-05-24 19:45 ` Alan Hayward
2017-05-25 10:46 ` Pedro Alves
2017-05-25 11:43 ` Yao Qi
2017-05-25 11:48 ` Pedro Alves
2017-05-26 8:54 ` Alan Hayward
2017-05-26 10:26 ` Pedro Alves
2017-05-26 15:30 ` Alan Hayward
2017-05-26 15:49 ` Pedro Alves
2017-05-26 16:18 ` Alan Hayward
2017-05-26 16:00 ` John Baldwin
2017-05-05 8:04 ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (3/4) Alan Hayward
2017-05-05 21:54 ` Yao Qi
2017-05-05 8:04 ` [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (4/4) Alan Hayward
[not found] ` <434A7317-C19A-4B53-8CB1-C7B4ACEC7D17@arm.com>
2017-06-08 20:27 ` Maciej W. Rozycki
2017-06-09 10:31 ` Alan Hayward
[not found] ` <ebebb23e-e61b-5eff-b666-f2632e554322@redhat.com>
2017-06-09 11:48 ` Maciej W. Rozycki
2017-06-09 12:05 ` Pedro Alves
2017-06-09 13:23 ` Maciej W. Rozycki
2017-06-09 14:29 ` Pedro Alves
2017-06-12 9:09 ` Alan Hayward
2017-06-12 18:11 ` Pedro Alves
2017-06-12 14:29 ` Maciej W. Rozycki
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=806B436F-EFA1-4200-AC54-9036D166C9B9@arm.com \
--to=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
--cc=qiyaoltc@gmail.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