From patchwork Mon Jan 9 10:56:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 18818 Received: (qmail 7357 invoked by alias); 9 Jan 2017 10:57:11 -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 7345 invoked by uid 89); 9 Jan 2017 10:57:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2486, Hx-exchange-antispam-report-cfa-test:102415395, sk:alan.ha, alanhaywardarmcom X-HELO: EUR02-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr10064.outbound.protection.outlook.com (HELO EUR02-HE1-obe.outbound.protection.outlook.com) (40.107.1.64) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jan 2017 10:57:00 +0000 Received: from VI1PR0801MB1822.eurprd08.prod.outlook.com (10.168.68.7) by VI1PR0801MB1823.eurprd08.prod.outlook.com (10.168.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.829.7; Mon, 9 Jan 2017 10:56:57 +0000 Received: from VI1PR0801MB1822.eurprd08.prod.outlook.com ([10.168.68.7]) by VI1PR0801MB1822.eurprd08.prod.outlook.com ([10.168.68.7]) with mapi id 15.01.0803.021; Mon, 9 Jan 2017 10:56:57 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: [PATCH 2/3] Allocate data in cached_reg_t Date: Mon, 9 Jan 2017 10:56:56 +0000 Message-ID: <3BD71BF1-BD32-4952-9E54-8FD14EB54987@arm.com> user-agent: Microsoft-MacOutlook/f.1b.0.161010 authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-office365-filtering-correlation-id: 43cdf963-a504-469e-3a83-08d4387e3aec x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:VI1PR0801MB1823; x-microsoft-exchange-diagnostics: 1; VI1PR0801MB1823; 7:AMgvcbJAYTs2+zhKPWmAGxKoR835gUotwsH+r18PX1rtnJnXaYwEY9KHzEy/rh7zlQEm82aXJDirT3KD2o+xeCZ0l/4lL5uNhbgZHTKQNGSqCqg1ra+vYjfVR99M9AsqZczbWpiRuiJwsGvAUo9MktuJzeu6XKGeekCA2M8rG57pjPgsM3Cr2cJbwg9mysmeWrvCmqhV7SMfuBVtEUPwsA+pISzHu/2aIPTmTyC5WImIy/nQHZmX0K9qX2F4X7jmdcl2vPpy68N5h1bpNqkZENELKgDtFS1JNCPIKIw6O2IFdofhzHA7iZ+n0/tdZzMrB+lfFhyoQ6aNJ6bUVGSY5gQYXTIQSSWDzt7WvjlA1RQ3D4M5Tf0A6UYeFFzx7v4Gto4YbWSoN0Swouef9BGM/zuDIQj97C5uFY244PxDupMREajgtUGfC3dgi0XBMa4tQTzg0hzw357ZhAjizF/6lw== nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415395)(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:VI1PR0801MB1823; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1823; x-forefront-prvs: 0182DBBB05 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39450400003)(39840400002)(39410400002)(39850400002)(377424004)(189002)(199003)(83506001)(189998001)(7736002)(38730400001)(6506006)(6486002)(77096006)(33656002)(305945005)(122556002)(86362001)(6512007)(66066001)(3846002)(2906002)(4326007)(6116002)(102836003)(6916009)(450100001)(36756003)(6436002)(99936001)(106116001)(50986999)(54356999)(2351001)(2900100001)(5660300001)(110136003)(97736004)(4001350100001)(92566002)(106356001)(105586002)(81166006)(68736007)(99286003)(8936002)(2501003)(83716003)(8676002)(81156014)(82746002)(3660700001)(25786008)(101416001)(5640700003)(3280700002)(104396002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB1823; H:VI1PR0801MB1822.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jan 2017 10:56:56.9425 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1823 Aarch64 SVE requires a max register size of 256. The current max size in gdb is 64. This is part of a series demonstrating the replacement of MAX_REGISTER_SIZE. In cached_reg_t the data is changed to a pointer, which is allocated using the size of the register being cached. This pointer must be manually freed when deleting a DEF_VEC of cached_reg_t's. Tested on x86. Ok to commit? Thanks, Alan. 2017-01-09 Alan Hayward * remote.c (struct cached_reg): Change data into a pointer. * (stop_reply_dtr): Free data pointers before deleting vector. (process_stop_reply): Likewise. (remote_parse_stop_reply): Allocate space for data diff --git a/gdb/remote.c b/gdb/remote.c index 6da6eb366ae442354fd6a37741335af9a4a5a056..9247d43b094925ff397eb36b450eaba521adfc99 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -6306,7 +6306,7 @@ remote_console_output (char *msg) typedef struct cached_reg { int num; - gdb_byte data[MAX_REGISTER_SIZE]; + gdb_byte *data; } cached_reg_t; DEF_VEC_O(cached_reg_t); @@ -6402,6 +6402,13 @@ static void stop_reply_dtr (struct notif_event *event) { struct stop_reply *r = (struct stop_reply *) event; + cached_reg_t *reg; + int ix; + + for (ix = 0; + VEC_iterate(cached_reg_t, r->regcache, ix, reg); + ix++) + xfree (reg->data); VEC_free (cached_reg_t, r->regcache); } @@ -6974,6 +6981,7 @@ Packet: '%s'\n"), { struct packet_reg *reg = packet_reg_from_pnum (rsa, pnum); cached_reg_t cached_reg; + struct gdbarch *gdbarch = target_gdbarch (); if (reg == NULL) error (_("Remote sent bad register number %s: %s\n\ @@ -6981,14 +6989,14 @@ Packet: '%s'\n"), hex_string (pnum), p, buf); cached_reg.num = reg->regnum; + cached_reg.data = (gdb_byte *) + xmalloc (register_size (gdbarch, reg->regnum)); p = p1 + 1; fieldsize = hex2bin (p, cached_reg.data, - register_size (target_gdbarch (), - reg->regnum)); + register_size (gdbarch, reg->regnum)); p += 2 * fieldsize; - if (fieldsize < register_size (target_gdbarch (), - reg->regnum)) + if (fieldsize < register_size (gdbarch, reg->regnum)) warning (_("Remote reply is too short: %s"), buf); VEC_safe_push (cached_reg_t, event->regcache, &cached_reg); @@ -7211,7 +7219,11 @@ process_stop_reply (struct stop_reply *stop_reply, for (ix = 0; VEC_iterate(cached_reg_t, stop_reply->regcache, ix, reg); ix++) + { regcache_raw_supply (regcache, reg->num, reg->data); + xfree (reg->data); + } + VEC_free (cached_reg_t, stop_reply->regcache); }