From patchwork Wed Apr 12 08:34:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 19989 Received: (qmail 116116 invoked by alias); 12 Apr 2017 08:34:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 116087 invoked by uid 89); 12 Apr 2017 08:34:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR02-VE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr20079.outbound.protection.outlook.com (HELO EUR02-VE1-obe.outbound.protection.outlook.com) (40.107.2.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Apr 2017 08:34:54 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0102.eurprd08.prod.outlook.com (10.160.211.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Wed, 12 Apr 2017 08:34:51 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::c065:778f:9924:8660]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::c065:778f:9924:8660%14]) with mapi id 15.01.1019.026; Wed, 12 Apr 2017 08:34:52 +0000 From: Alan Hayward To: Yao Qi CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH 11/11] Add SH_MAX_REGISTER_SIZE and SH64_MAX_REGISTER_SIZE Date: Wed, 12 Apr 2017 08:34:51 +0000 Message-ID: <45FE08DA-87EC-48FB-97EC-8463A473126F@arm.com> References: <8637dfw5kl.fsf@gmail.com> In-Reply-To: <8637dfw5kl.fsf@gmail.com> authentication-results: gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=none action=none header.from=arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-microsoft-exchange-diagnostics: 1; AM3PR08MB0102; 7:QpZp0HF/jggrpbfhXnkEVotUN1/Iu64WzZ5H6BSAfzQsSRZVFpuiknCVZLIPZCNxOJ3FhxjNqx0/OKVoGlmyxGcwo5s0bt5+UMDRWmukiWN+M675qlLI+bRFzdTsJY+n60hQux9mqGBJVX+erWSOFMyeJQk9P9U+xsXVg0N3cBdK1nbLgFTjV6qSP09zwDlXH1sO9JNkzyaK9LoWlhNr1u5KOKo8/HQKo/PbYZ8eel7Gd4PeCNQbwO0WnD0uISwTvUm9H0J9l6uTJ6g7qReSrQJvNUaEa90Dbu987zGpoKMiCWvv73wlkJKlCG6C4i+5goO/NMt2lAaS76S9rbPmOg== x-ms-office365-filtering-correlation-id: 188a4346-5469-4aef-b78a-08d4817eca0a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081); SRVR:AM3PR08MB0102; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(6072148); SRVR:AM3PR08MB0102; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0102; x-forefront-prvs: 027578BB13 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39850400002)(39840400002)(39860400002)(39450400003)(39410400002)(39400400002)(24454002)(377424004)(6486002)(5660300001)(8936002)(5250100002)(575784001)(4326008)(6506006)(8676002)(66066001)(3660700001)(229853002)(53936002)(81166006)(33656002)(39060400002)(6246003)(53546009)(86362001)(82746002)(83716003)(25786009)(76176999)(54356999)(50986999)(99286003)(7736002)(54906002)(6436002)(305945005)(38730400002)(6512007)(3280700002)(6916009)(2950100002)(1411001)(110136004)(2906002)(189998001)(2900100001)(36756003)(3846002)(102836003)(6116002)(15760500002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0102; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <1AEF4BC24FB50744B1F3E32400B5B8E2@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2017 08:34:51.6360 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0102 > On 11 Apr 2017, at 12:23, Yao Qi wrote: > > Alan Hayward 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 * 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)