From patchwork Thu Jun 22 13:44:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 21198 Received: (qmail 73354 invoked by alias); 22 Jun 2017 13:44: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 73330 invoked by uid 89); 22 Jun 2017 13:44:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 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= X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0043.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Jun 2017 13:44:07 +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.1199.15; Thu, 22 Jun 2017 13:44:04 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::9063:8caa:1bc4:156f]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::9063:8caa:1bc4:156f%14]) with mapi id 15.01.1178.023; Thu, 22 Jun 2017 13:44:04 +0000 From: Alan Hayward To: Pedro Alves CC: Yao Qi , "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH] Remove an instance of MAX_REGISTER_SIZE from record-full.c Date: Thu, 22 Jun 2017 13:44:04 +0000 Message-ID: References: <69EEE46A-D88C-4B4F-86A2-E35F6DAFD90A@arm.com> <86d1a9a2k9.fsf@gmail.com> In-Reply-To: authentication-results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0104; 7:aBT6wjEfWRBxRZOydiXR554j3jKnXoCcQVGOQBPJPTBMDjfi5NWl2iA2B2au3ni6YycP2li/PZ49/8F1eJt6lV1vNEcfrTbq3CjmhzGvzqU2Ps/wKDwX2LWEBGR+wyIYPmZ2yTZSM4eow/gmq1HetsjEo4ywb3qnrzszveQdvKYQL92z4YXF4Fbv8FPxi3FNyvkXknjXNP+OJYj0SMltgivX3gRRyr7GCQTDCNRxFLIJUGBgf3K/we2skBrXTvFJ7dO7hwaRl9KAcSavJgx8iAtaIPe4tAhSLt0BJ5OVcfQa1N55OdwWmi8hBe5iVbAjpTuCYntckP/bUQpKdnXFsCJEkBHtKJejqXPCcWWS5xcTR6Q5ZcYs2QaM8BMYSYmoaWg4k8ZG6VE0Mp5N0fkGGp9HsaKRjV+PAFwn5ZMSV7pYx4g3u9d/bZa8jthS4WcGiFC8NBEzqidiGQVTk463wmYjOFCrwaDYhkmL6/pF+sha+6GSbqd856rkaTtJuAwo/AhLsM+KbdVh0bDK05cV169P29VUMii7iL5NTUYHd3QHbx4y/Y5Z92z2ORgF7A7p2Prk4Ep2ph/rk2zJfJstWJVXlcxgIFuM7dQOgk+4iySAitXQLUrLAdh/hAHYotdg+W4o9L4e1q3NkFuFmZ4LnQxkEac48hmadxuO+hmOgiSyt4qBKCcXj+u9HYeA9CZGw0bMWl7ZnPaW2Y+ulcj24i99jU6MaS28MTgtpP1dcBRNj/8QLAfRElC7nSUvyUVDla9LNrWi06pWLMeDJMZikOn5pu72KYKJgZBdkQSV0j0= x-ms-office365-filtering-correlation-id: ddc6733d-fbed-4282-c27a-08d4b974bf7c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075); SRVR:AM3PR08MB0104; x-ms-traffictypediagnostic: AM3PR08MB0104: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM3PR08MB0104; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM3PR08MB0104; x-forefront-prvs: 03468CBA43 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39850400002)(39840400002)(39860400002)(39410400002)(39450400003)(39400400002)(24454002)(377454003)(5250100002)(53546010)(99286003)(54906002)(6512007)(6116002)(3846002)(102836003)(14454004)(33656002)(93886004)(305945005)(86362001)(82746002)(3280700002)(3660700001)(6486002)(53936002)(83716003)(110136004)(38730400002)(6246003)(2906002)(6436002)(4326008)(39060400002)(575784001)(25786009)(6506006)(81166006)(8676002)(76176999)(54356999)(50986999)(229853002)(66066001)(81156014)(5660300001)(8936002)(36756003)(72206003)(7736002)(478600001)(6916009)(189998001)(2950100002)(2900100001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0104; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jun 2017 13:44:04.5114 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0104 X-IsSubscribed: yes > On 21 Jun 2017, at 11:52, Pedro Alves wrote: > > On 06/12/2017 02:59 PM, Alan Hayward wrote: > >> diff --git a/gdb/record-full.c b/gdb/record-full.c >> index 31ff558d2a633cff71d3e6082e42f5d6fb88bcf1..4f73e2a5ad0d4a2407b31a1d391e813147e15798 100644 >> --- a/gdb/record-full.c >> +++ b/gdb/record-full.c >> @@ -698,7 +698,7 @@ record_full_exec_insn (struct regcache *regcache, >> { >> case record_full_reg: /* reg */ >> { >> - gdb_byte reg[MAX_REGISTER_SIZE]; >> + gdb_byte *reg = (gdb_byte *) xmalloc (entry->u.reg.len); >> >> if (record_debug > 1) >> fprintf_unfiltered (gdb_stdlog, >> @@ -711,6 +711,7 @@ record_full_exec_insn (struct regcache *regcache, >> regcache_cooked_write (regcache, entry->u.reg.num, >> record_full_get_loc (entry)); >> memcpy (record_full_get_loc (entry), reg, entry->u.reg.len); >> + xfree (reg); > > You can use > gdb::byte_vector reg (entry->u.reg.len); > to avoid the explicit xfree here. > > (and a potential leak if regcache_* throws). > > Thanks, > Pedro Alves > Updated and retested. Ok to commit? Alan. diff --git a/gdb/record-full.c b/gdb/record-full.c index 13a0a78a52acdc20c8c4634118be941b1ff55871..c1a95a75ca67c6ad3b286e4b0ed892b27508108b 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -36,6 +36,7 @@ #include "observer.h" #include "infrun.h" #include "common/gdb_unlinker.h" +#include "common/byte-vector.h" #include @@ -698,7 +699,7 @@ record_full_exec_insn (struct regcache *regcache, { case record_full_reg: /* reg */ { - gdb_byte reg[MAX_REGISTER_SIZE]; + gdb::byte_vector reg (entry->u.reg.len); if (record_debug > 1) fprintf_unfiltered (gdb_stdlog, @@ -707,10 +708,10 @@ record_full_exec_insn (struct regcache *regcache, host_address_to_string (entry), entry->u.reg.num); - regcache_cooked_read (regcache, entry->u.reg.num, reg); + regcache_cooked_read (regcache, entry->u.reg.num, reg.data ()); regcache_cooked_write (regcache, entry->u.reg.num, record_full_get_loc (entry)); - memcpy (record_full_get_loc (entry), reg, entry->u.reg.len); + memcpy (record_full_get_loc (entry), reg.data (), entry->u.reg.len); } break;