This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 9/11] Add MN10300_MAX_REGISTER_SIZE (2)
- From: Alan Hayward <Alan dot Hayward at arm dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Thu, 8 Jun 2017 09:41:59 +0000
- Subject: Re: [PATCH 9/11] Add MN10300_MAX_REGISTER_SIZE (2)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=arm.com;
- Nodisclaimer: True
- References: <466CF7AB-4D05-4A4B-9FB9-80513E7ABF1C@arm.com> <8A16DE9D-BE32-4CEF-9144-8D78F3A803B4@arm.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
> On 4 May 2017, at 16:17, Alan Hayward <Alan.Hayward@arm.com> wrote:
>
>
>> On 4 Apr 2017, at 11:15, Alan Hayward <Alan.Hayward@arm.com> wrote:
>>
I’ve rebased this patch due to Yao’s unit test changes.
MN10300_MAX_REGISTER_SIZE is set to 64 to ensure nothing breaks.
I don't have a MN10300 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-08 Alan Hayward <alan.hayward@arm.com>
* mn10300-tdep.c (MN10300_MAX_REGISTER_SIZE): Add.
(mn10300_extract_return_value): Use MN10300_MAX_REGISTER_SIZE.
(mn10300_push_dummy_call): Likewise.
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index f8dd762cf0a27d6e84c28da3021a9c7971743b9e..669bfa1bce5cdeb4d4b9a357f4e5e520ce5de730 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -40,6 +40,9 @@
/* The am33-2 has 64 registers. */
#define MN10300_MAX_NUM_REGS 64
+/* Big enough to hold the size of the largest register in bytes. */
+#define MN10300_MAX_REGISTER_SIZE 64
+
/* This structure holds the results of a prologue analysis. */
struct mn10300_prologue
{
@@ -196,7 +199,7 @@ static void
mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type,
struct regcache *regcache, void *valbuf)
{
- gdb_byte buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[MN10300_MAX_REGISTER_SIZE];
int len = TYPE_LENGTH (type);
int reg, regsz;
@@ -206,6 +209,7 @@ mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type,
reg = 0;
regsz = register_size (gdbarch, reg);
+ gdb_assert (regsz <= MN10300_MAX_REGISTER_SIZE);
if (len <= regsz)
{
regcache_raw_read (regcache, reg, buf);
@@ -1224,7 +1228,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
int stack_offset = 0;
int argnum;
const gdb_byte *val;
- gdb_byte valbuf[MAX_REGISTER_SIZE];
+ gdb_byte valbuf[MN10300_MAX_REGISTER_SIZE];
/* This should be a nop, but align the stack just in case something
went wrong. Stacks are four byte aligned on the mn10300. */
@@ -1266,6 +1270,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
{
/* Change to pointer-to-type. */
arg_len = push_size;
+ gdb_assert (push_size <= MN10300_MAX_REGISTER_SIZE);
store_unsigned_integer (valbuf, push_size, byte_order,
value_address (*args));
val = &valbuf[0];