From patchwork Thu May 4 15:17:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 20278 Received: (qmail 112848 invoked by alias); 4 May 2017 15:17:31 -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 112823 invoked by uid 89); 4 May 2017 15:17:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Big X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-he1eur01on0054.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (104.47.0.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 May 2017 15:17:28 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0104.eurprd08.prod.outlook.com (10.160.211.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.12; Thu, 4 May 2017 15:17:27 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::b823:64c1:afc5:3a08]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::b823:64c1:afc5:3a08%17]) with mapi id 15.01.1061.021; Thu, 4 May 2017 15:17:27 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: Re: [PATCH 9/11] Add MN10300_MAX_REGISTER_SIZE (2) Date: Thu, 4 May 2017 15:17:27 +0000 Message-ID: <8A16DE9D-BE32-4CEF-9144-8D78F3A803B4@arm.com> References: <466CF7AB-4D05-4A4B-9FB9-80513E7ABF1C@arm.com> In-Reply-To: <466CF7AB-4D05-4A4B-9FB9-80513E7ABF1C@arm.com> authentication-results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; x-microsoft-exchange-diagnostics: 1; AM3PR08MB0104; 7:OfLqLUiTOalq6kQcXPCuOLBkOYZluuAN4U3/7p8US30jqAUFqrfxVfCRn+n7KuP0w6vK0VR7HeaOI/TqW+lTXmpHIfEoe4bBSiZM38R3eKhyCMwPLuNzoFl5eFzIP7CD8Ul4L6pOeCbEKywlOTWH2btaRIBKJXQP3+6gcX5JhsH6DvJx1sVySjuw5fN+GBT4bXrVfJOMo04/rNfdRa+Uwno9UJGpBZk7jOOaB6d6wyt0g22gugtyzYLuvzJZDh2aj4Md6etB6pofDNjP7o3589b00hA5cLcpRMIXYZKx9m9MVwdiiwmxsID3W6PadkeJ4ZuuiVfEOI8UcwU1Wcnohw== x-ms-office365-filtering-correlation-id: 8467051b-0f68-45d0-efd5-08d49300aca6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075); SRVR:AM3PR08MB0104; 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)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123558100)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148); SRVR:AM3PR08MB0104; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0104; x-forefront-prvs: 02973C87BC x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(39410400002)(39400400002)(39840400002)(39850400002)(39450400003)(377424004)(24454002)(102836003)(86362001)(3280700002)(3846002)(110136004)(53936002)(6116002)(99286003)(38730400002)(3660700001)(53546009)(229853002)(7736002)(33656002)(6512007)(189998001)(6506006)(2906002)(6486002)(5660300001)(5640700003)(2501003)(4326008)(66066001)(6436002)(6916009)(2950100002)(2900100001)(50986999)(25786009)(76176999)(305945005)(478600001)(8676002)(8936002)(81166006)(54356999)(2351001)(36756003)(15760500002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0104; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 04 May 2017 15:17:27.0165 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0104 > On 4 Apr 2017, at 11:15, Alan Hayward wrote: > > Max size set to 32bits, which I determined using mn10300_register_type() > > Tested on a --enable-targets=all build using make check with board files > unix and native-gdbserver. > > I do not have a MN10300 machine to test on. > > Ok to commit? > > Alan. Split this into two patches. This patch adds MN10300_MAX_REGISTER_SIZE. Added some asserts to check the new define is big enough. For mn10300_push_dummy_call I could have created a MN10300_PC_REGISTER_SIZE, but it would only be used the once. Also, I could use sizeof(int) instead of adding any defines, but it is probably clearer using MN10300_MAX_REGISTER_SIZE. Tested on a --enable-targets=all build using make check with board files unix and native-gdbserver. I do not have a MN10300 machine to test on. Ok to commit? Alan. 2017-05-04 Alan Hayward * 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 0f5e10fccc54efc9275511bb06e9b27636d0565f..2072e736270cc70f36f1305eb426e9ecb3def7fa 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 4 + /* 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,9 @@ 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]; + + gdb_assert (push_size <= 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. */