From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90532 invoked by alias); 21 Jun 2017 09:30:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 82291 invoked by uid 89); 21 Jun 2017 09:30: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,KAM_LOTSOFHASH,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-eopbgr20045.outbound.protection.outlook.com (HELO EUR02-VE1-obe.outbound.protection.outlook.com) (40.107.2.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Jun 2017 09:30:27 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1178.14; Wed, 21 Jun 2017 09:30:23 +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; Wed, 21 Jun 2017 09:30:23 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: Re: [PATCH] Remove MAX_REGISTER_SIZE from py-unwind.c Date: Wed, 21 Jun 2017 09:30:00 -0000 Message-ID: <80314BB6-6511-4FC5-8B96-4BDA126C83A7@arm.com> References: In-Reply-To: authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM3PR08MB0101;7:OqNRCuH98/iyOQJyaa1dX9HI24PfecDS03fpjmXL46DuD4xuaPcjQ/EeN/iWRWM4BO7p66Dx2NeNJZ8hKeJSW3tO5hBPVmXWSMtUI2YAdVlInCzWSh2X4kP3tlUakMwFzo34XPemTd0GXLYgfF5MK1wGQ7xm7qkcCIcpOpvlvdrKfwaYd5iYlQ5qqfo2I5tDhI1BnRnbUMnEJXkfFcVyT3N5CuFfdCfqqRNMt3EzCVyfwnzvfyiYb68Kn/bxidA9a7Jtr26mRjP7Qo35SVfV1i8ZI5aet0n1ZPQkqIeFkz9dFe3jTpnMEt2BlfYzEbcfLjYp5i0/znBNAX0BMTQRBWnJpxcFsUKth8JOr4phscbY8Kv8fN4GN9OFQCF2lBKW+7PgvCEx3vGZEaMNlsolWJA6HaoMfQc7A2zj6TcbY7aQHD0+UHKYkI7P9U+0sCc72HnVaY4GmWwJmxnuQMBPdfxpD8cnvLiJnA3jkjAsNFAicyFcbhpHIBY0OMshrsJKesc4bILC0owgyzqYDMKr0R5dccCRqAMm3DGAX84jFaV84sdHb0b4dQQOgMaVCB2feu1i8N6P2vUKifVmysjkMff5v7B6yBpH7rzk96m3mIXgv692DRd21jHX08/nYPnzKT6/JqIZCh0X7N2zxwgkbGROy1cTmqRVbBqZR1oyvJi7Sgc8vaPIrzpYZZLXdPuOjAHTwhIj41N9nqOTS8AWG1W15e1/PjbOQRGKJcQ48VFFQhrEkAqv9Rw+YUWMDrNBF9n3GUy/At7wvn9GTr4q8TJruHBZZTUhOxmyPYAyamE= x-ms-office365-filtering-correlation-id: ded5787f-e37e-4510-e1fe-08d4b88824af x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:AM3PR08MB0101; x-ms-traffictypediagnostic: AM3PR08MB0101: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123564025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM3PR08MB0101;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM3PR08MB0101; x-forefront-prvs: 0345CFD558 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39840400002)(39860400002)(39450400003)(39850400002)(39400400002)(39410400002)(377424004)(24454002)(25786009)(102836003)(6116002)(5660300001)(8936002)(4326008)(3846002)(81166006)(8676002)(6512007)(99286003)(189998001)(2501003)(6506006)(5250100002)(5640700003)(110136004)(6436002)(38730400002)(33656002)(53936002)(54356999)(76176999)(53546010)(83716003)(50986999)(2900100001)(305945005)(82746002)(36756003)(6486002)(7736002)(229853002)(66066001)(86362001)(575784001)(2351001)(14454004)(3280700002)(478600001)(3660700001)(6916009)(2950100002)(72206003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM3PR08MB0101;H:AM3PR08MB0101.eurprd08.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jun 2017 09:30:23.4777 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0101 X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00581.txt.bz2 PING > On 12 Jun 2017, at 10:28, Alan Hayward wrote: >=20 > I've moved cached_reg_t from remote.c to regcache.h, > then updated py-unwind.c to use cached_reg_t instead of reg_info. >=20 > Had to make sure registers are individually allocated/deallocated > (in the same way as remote.c). >=20 >=20 > Tested on a --enable-targets=3Dall build. > All tests in gdb.python/python.exp pass. > Also tested with board files unix and native-gdbserver. >=20 > Ok to commit? >=20 > Alan. >=20 > 2017-06-12 Alan Hayward >=20 > * gdb/remote.c (cached_reg): Move from here... > * gdb/regcache.h (cached_reg): ...to here. > * gdb/python/py-unwind.c (struct reg_info): Remove. > (cached_frame_info): Use cached_reg_t. > (pyuw_prev_register): Likewise. > (pyuw_sniffer): Use cached_reg_t and allocate registers. > (pyuw_dealloc_cache): Free all registers. >=20 >=20 >=20 > diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c > index a5c2873697944c1293fdd9f8265dde078378e6c2..91bd02ead7a56325b391a8f30= 7e628d2293d57a2 100644 > --- a/gdb/python/py-unwind.c > +++ b/gdb/python/py-unwind.c > @@ -73,15 +73,6 @@ typedef struct > /* The data we keep for a frame we can unwind: frame ID and an array of > (register_number, register_value) pairs. */ >=20 > -struct reg_info > -{ > - /* Register number. */ > - int number; > - > - /* Register data bytes pointer. */ > - gdb_byte data[MAX_REGISTER_SIZE]; > -}; > - > typedef struct > { > /* Frame ID. */ > @@ -93,7 +84,7 @@ typedef struct > /* Length of the `reg' array below. */ > int reg_count; >=20 > - struct reg_info reg[]; > + cached_reg_t reg[]; > } cached_frame_info; >=20 > extern PyTypeObject pending_frame_object_type > @@ -483,14 +474,14 @@ pyuw_prev_register (struct frame_info *this_frame, = void **cache_ptr, > int regnum) > { > cached_frame_info *cached_frame =3D (cached_frame_info *) *cache_ptr; > - struct reg_info *reg_info =3D cached_frame->reg; > - struct reg_info *reg_info_end =3D reg_info + cached_frame->reg_count; > + cached_reg_t *reg_info =3D cached_frame->reg; > + cached_reg_t *reg_info_end =3D reg_info + cached_frame->reg_count; >=20 > TRACE_PY_UNWIND (1, "%s (frame=3D%p,...,reg=3D%d)\n", __FUNCTION__, thi= s_frame, > regnum); > for (; reg_info < reg_info_end; ++reg_info) > { > - if (regnum =3D=3D reg_info->number) > + if (regnum =3D=3D reg_info->num) > return frame_unwind_got_bytes (this_frame, regnum, reg_info->data= ); > } >=20 > @@ -567,9 +558,7 @@ pyuw_sniffer (const struct frame_unwind *self, struct= frame_info *this_frame, > int i; >=20 > cached_frame > - =3D ((cached_frame_info *) > - xmalloc (sizeof (*cached_frame) > - + reg_count * sizeof (cached_frame->reg[0]))); > + =3D ((cached_frame_info *) xmalloc (sizeof (*cached_frame))); > cached_frame->gdbarch =3D gdbarch; > cached_frame->frame_id =3D unwind_info->frame_id; > cached_frame->reg_count =3D reg_count; > @@ -580,13 +569,14 @@ pyuw_sniffer (const struct frame_unwind *self, stru= ct frame_info *this_frame, > struct value *value =3D value_object_to_value (reg->value); > size_t data_size =3D register_size (gdbarch, reg->number); >=20 > - cached_frame->reg[i].number =3D reg->number; > + cached_frame->reg[i].num =3D reg->number; >=20 > /* `value' validation was done before, just assert. */ > gdb_assert (value !=3D NULL); > gdb_assert (data_size =3D=3D TYPE_LENGTH (value_type (value))); > gdb_assert (data_size <=3D MAX_REGISTER_SIZE); >=20 > + cached_frame->reg[i].data =3D (gdb_byte *) xmalloc (data_size); > memcpy (cached_frame->reg[i].data, value_contents (value), data_s= ize); > } > } > @@ -601,6 +591,13 @@ static void > pyuw_dealloc_cache (struct frame_info *this_frame, void *cache) > { > TRACE_PY_UNWIND (3, "%s: enter", __FUNCTION__); > + cached_frame_info *cached_frame =3D (cached_frame_info *) cache; > + > + for (int i =3D 0; cached_frame->reg_count; i++) > + { > + xfree (cached_frame->reg[i].data); > + } > + > xfree (cache); > } >=20 > diff --git a/gdb/regcache.h b/gdb/regcache.h > index 24521e40ec0bb221d3fd37418d2aa485c08403b7..82026b49a57d64b9688dbce82= bbf5c6529fdc651 100644 > --- a/gdb/regcache.h > +++ b/gdb/regcache.h > @@ -234,6 +234,14 @@ enum regcache_dump_what > regcache_dump_remote > }; >=20 > +/* A (register_number, register_value) pair. */ > + > +typedef struct cached_reg > +{ > + int num; > + gdb_byte *data; > +} cached_reg_t; > + > /* The register cache for storing raw register values. */ >=20 > class regcache > diff --git a/gdb/remote.c b/gdb/remote.c > index 1f8607988444fb0221b87e9ef3e93fbec04c42ea..4a0660f7d91574b84ff2e3978= e1795f7cb69ad93 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -6308,12 +6308,6 @@ remote_console_output (char *msg) > gdb_flush (gdb_stdtarg); > } >=20 > -typedef struct cached_reg > -{ > - int num; > - gdb_byte *data; > -} cached_reg_t; > - > DEF_VEC_O(cached_reg_t); >=20 > typedef struct stop_reply >=20 >=20