From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41184 invoked by alias); 23 Mar 2017 14:12:58 -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 41099 invoked by uid 89); 23 Mar 2017 14:12:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 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: EUR02-VE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr20089.outbound.protection.outlook.com (HELO EUR02-VE1-obe.outbound.protection.outlook.com) (40.107.2.89) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Mar 2017 14:12:56 +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.991.14; Thu, 23 Mar 2017 14:12:54 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::a542:8c73:7479:1ad3]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::a542:8c73:7479:1ad3%15]) with mapi id 15.01.0991.017; Thu, 23 Mar 2017 14:12:54 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c Date: Thu, 23 Mar 2017 14:12:00 -0000 Message-ID: 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-exchange-messagesentrepresentingtype: 1 x-microsoft-exchange-diagnostics: 1;AM3PR08MB0102;7:xRE8Pkk+lXl4pBc117YPEa1mvysjPAR2tvFYW675auiDnJ59t6auj2uwZ1ouXfZmmNk4KLeDVmYlMuP1vuMGw5LJxZ1A3FjliUOCb6XCU3cBUq3iQLcxf5g2RMlwn7DwfmTE4O6LJk4ZqXAiZkBXJbUyF5nse4iXJB4s/CnqE62pfOzmnvHvWfeKo31JRBTgUAB22z//dH1+Kv1oPBj4m0vYGIJARUtozwgcMSMwaP4/NpY2iLxOIirgLjabW1FyKK8hsZV99LSY3uyshtKGgMpEcDg6RvaJrDL8ImiPuiTn003NgAnbjfFueWEGhfIQLR8s8h5TTglAiVeTk/Yf3g== x-ms-office365-filtering-correlation-id: e9a15485-46ed-4318-9bdf-08d471f6b2f9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081);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:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558025)(6072148);SRVR:AM3PR08MB0102;BCL:0;PCL:0;RULEID:;SRVR:AM3PR08MB0102; x-forefront-prvs: 0255DF69B9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39840400002)(39850400002)(39410400002)(39860400002)(377424004)(24454002)(36756003)(66066001)(2351001)(33656002)(81166006)(8676002)(8936002)(2900100001)(76176999)(54356999)(50986999)(99286003)(5640700003)(5660300001)(6512007)(83716003)(2501003)(3660700001)(5250100002)(2950100002)(6916009)(53936002)(305945005)(102836003)(3846002)(189998001)(6506006)(110136004)(6486002)(38730400002)(229853002)(6246003)(6436002)(25786009)(575784001)(82746002)(6116002)(4326008)(3280700002)(53546009)(86362001)(7736002)(2906002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM3PR08MB0102;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: 23 Mar 2017 14:12:53.8897 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0102 X-SW-Source: 2017-03/txt/msg00415.txt.bz2 Ping. > On 24 Feb 2017, at 10:03, Alan Hayward wrote: >=20 > Used a std::vector in the first case and struct value in the second. >=20 > Tested using make check with board files unix and native-gdbserver. >=20 > Ok to commit? >=20 > Alan. >=20 >=20 > 2017-02-21 Alan Hayward >=20 > * gdb/remote-sim.c (gdbsim_fetch_register): Use vec instead of array. > (gdbsim_store_register): Read register using value. >=20 >=20 > diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c > index b0c68c617e365c0ea18ac2eca525598b688ffbb5..aeceb06a557eb31778d0a8519= 4fb47ea311eec09 100644 > --- a/gdb/remote-sim.c > +++ b/gdb/remote-sim.c > @@ -439,6 +439,9 @@ gdbsim_fetch_register (struct target_ops *ops, > return; > } >=20 > + int regsize =3D register_size (gdbarch, regno); > + std::vector buf (regsize); > + > switch (gdbarch_register_sim_regno (gdbarch, regno)) > { > case LEGACY_SIM_REGNO_IGNORE: > @@ -447,38 +450,32 @@ gdbsim_fetch_register (struct target_ops *ops, > { > /* For moment treat a `does not exist' register the same way > as an ``unavailable'' register. */ > - gdb_byte buf[MAX_REGISTER_SIZE]; > int nr_bytes; >=20 > - memset (buf, 0, MAX_REGISTER_SIZE); > - regcache_raw_supply (regcache, regno, buf); > + regcache_raw_supply (regcache, regno, buf.data ()); > break; > } >=20 > default: > { > static int warn_user =3D 1; > - gdb_byte buf[MAX_REGISTER_SIZE]; > int nr_bytes; >=20 > gdb_assert (regno >=3D 0 && regno < gdbarch_num_regs (gdbarch)); > - memset (buf, 0, MAX_REGISTER_SIZE); > nr_bytes =3D sim_fetch_register (sim_data->gdbsim_desc, > gdbarch_register_sim_regno > (gdbarch, regno), > - buf, > - register_size (gdbarch, regno)); > + buf.data (), regsize); > if (nr_bytes > 0 > - && nr_bytes !=3D register_size (gdbarch, regno) && warn_user) > + && nr_bytes !=3D regsize && warn_user) > { > fprintf_unfiltered (gdb_stderr, > "Size of register %s (%d/%d) " > "incorrect (%d instead of %d))", > gdbarch_register_name (gdbarch, regno), > regno, > - gdbarch_register_sim_regno > - (gdbarch, regno), > - nr_bytes, register_size (gdbarch, regno)); > + gdbarch_register_sim_regno (gdbarch, regno), > + nr_bytes, regsize); > warn_user =3D 0; > } > /* FIXME: cagney/2002-05-27: Should check `nr_bytes =3D=3D 0' > @@ -486,13 +483,13 @@ gdbsim_fetch_register (struct target_ops *ops, > which registers are fetchable. */ > /* Else if (nr_bytes < 0): an old simulator, that doesn't > think to return the register size. Just assume all is ok. */ > - regcache_raw_supply (regcache, regno, buf); > + regcache_raw_supply (regcache, regno, buf.data ()); > if (remote_debug) > { > fprintf_unfiltered (gdb_stdlog, > "gdbsim_fetch_register: %d", regno); > /* FIXME: We could print something more intelligible. */ > - dump_mem (buf, register_size (gdbarch, regno)); > + dump_mem (buf.data (), regsize); > } > break; > } > @@ -516,15 +513,14 @@ gdbsim_store_register (struct target_ops *ops, > } > else if (gdbarch_register_sim_regno (gdbarch, regno) >=3D 0) > { > - gdb_byte tmp[MAX_REGISTER_SIZE]; > - int nr_bytes; > - > - regcache_cooked_read (regcache, regno, tmp); > - nr_bytes =3D sim_store_register (sim_data->gdbsim_desc, > - gdbarch_register_sim_regno > - (gdbarch, regno), > - tmp, register_size (gdbarch, regno)); > - if (nr_bytes > 0 && nr_bytes !=3D register_size (gdbarch, regno)) > + int regsize =3D register_size (gdbarch, regno); > + int sim_regno =3D gdbarch_register_sim_regno (gdbarch, regno); > + > + struct value *value =3D regcache_cooked_read_value (regcache, regn= o); > + int nr_bytes =3D sim_store_register (sim_data->gdbsim_desc, sim_re= gno, > + value_contents_all (value), regsize); > + > + if (nr_bytes > 0 && nr_bytes !=3D regsize) > internal_error (__FILE__, __LINE__, > _("Register size different to expected")); > if (nr_bytes < 0) > @@ -538,8 +534,11 @@ gdbsim_store_register (struct target_ops *ops, > { > fprintf_unfiltered (gdb_stdlog, "gdbsim_store_register: %d", regno); > /* FIXME: We could print something more intelligible. */ > - dump_mem (tmp, register_size (gdbarch, regno)); > + dump_mem (value_contents_all (value), regsize); > } > + > + release_value (value); > + value_free (value); > } > } >=20