From patchwork Fri Feb 24 10:06:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 19367 Received: (qmail 21284 invoked by alias); 24 Feb 2017 10:06:50 -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 19377 invoked by uid 89); 24 Feb 2017 10:06:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 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=bright, transfer, Transfer X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-he1eur01on0088.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (104.47.0.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Feb 2017 10:06:46 +0000 Received: from VI1PR0801MB1822.eurprd08.prod.outlook.com (10.168.68.7) by VI1PR0801MB1824.eurprd08.prod.outlook.com (10.168.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Fri, 24 Feb 2017 10:06:42 +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.0919.018; Fri, 24 Feb 2017 10:06:42 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: [PATCH] Remove MAX_REGISTER_SIZE from remote.c Date: Fri, 24 Feb 2017 10:06:42 +0000 Message-ID: <00284BCB-10B9-41A6-BEFA-7873F4BB3B95@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-office365-filtering-correlation-id: 85847666-c9a6-4b45-ba13-08d45c9cd532 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:VI1PR0801MB1824; x-microsoft-exchange-diagnostics: 1; VI1PR0801MB1824; 7:GAtYpDl/xH87srpQkFAhj4VCUG5jn3Xp7B6QI9nmYxINpQpl1RqgJyzNPMAEdrv20YEbNEPnGT9dNMNOPfiOM2zeB/uXir+gFmtLET6DDWKUdghADOlgQyVEScqiScCZCZNRW1cX5xk9I3fH/GImePKeHYbkapY2KRXY7v1QLwtCi4iOxgGs5Yr3OdY2Jrmr1E97y/lxc4b/UG8PijpPb9XCaTqbQ2NN4Mh/9kt9Ina2imWP4yy6WCNlmBaMCnO2UuBJfO4A9bskqDcN29e7Ikew7DzvGKVYGc90tzNATsx6kkqkplUgxJ/+7wLL2oyZ1ErfIBTiAheicszZ9hQi6g== 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)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123558025)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(6072148); SRVR:VI1PR0801MB1824; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1824; x-forefront-prvs: 0228DDDDD7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39850400002)(39410400002)(39840400002)(39860400002)(39450400003)(377424004)(199003)(189002)(3660700001)(86362001)(68736007)(575784001)(7736002)(81166006)(305945005)(50986999)(101416001)(81156014)(83716003)(54356999)(3280700002)(8936002)(53936002)(33656002)(8676002)(92566002)(110136004)(189998001)(97736004)(5640700003)(38730400002)(25786008)(450100001)(122556002)(66066001)(6436002)(106116001)(105586002)(99286003)(106356001)(6512007)(5660300001)(6916009)(2900100001)(2351001)(3846002)(6116002)(82746002)(102836003)(4326007)(77096006)(6506006)(6486002)(36756003)(2906002)(2501003)(104396002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB1824; H:VI1PR0801MB1822.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <0403022F5581A44FA4EE959BC81C29C0@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Feb 2017 10:06:42.3003 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1824 remote_prepare_to_store only needs to make sure the value is cache is valid. Create a new function (split from regcache_raw_read) to do this. Tested using make check with board files unix and native-gdbserver. Ok to commit? Alan. 2017-02-24 Alan Hayward * regcache.c (regcache_raw_update): New function. (regcache_raw_read): Move code to regcache_raw_update. * regcache.h (regcache_raw_update): New declaration. * remote.c (remote_prepare_to_store): Call regcache_raw_update. diff --git a/gdb/regcache.h b/gdb/regcache.h index e5a7cf553279b8cc0d546ec1b8274cbf97e246d5..e1495f61426f879386b905ab1e97421bdd061bf5 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -50,6 +50,10 @@ extern struct address_space *get_regcache_aspace (const struct regcache *); enum register_status regcache_register_status (const struct regcache *regcache, int regnum); +/* Make certain that the register REGNUM in REGCACHE is up-to-date. */ + +void regcache_raw_update (struct regcache *regcache, int regnum); + /* Transfer a raw register [0..NUM_REGS) between core-gdb and the regcache. The read variants return the status of the register. */ diff --git a/gdb/regcache.c b/gdb/regcache.c index eed1bd84c8a9dd07ee77f0c3269e49e78081b127..f190eda0e47c5c03744fc26263505d1c30ea1ee8 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -642,15 +642,17 @@ registers_changed (void) alloca (0); } -enum register_status -regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf) +void +regcache_raw_update (struct regcache *regcache, int regnum) { - gdb_assert (regcache != NULL && buf != NULL); - gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); /* Make certain that the register cache is up-to-date with respect to the current thread. This switching shouldn't be necessary only there is still only one target side register cache. Sigh! On the bright side, at least there is a regcache object. */ + + gdb_assert (regcache != NULL); + gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); + if (!regcache->readonly_p && regcache_register_status (regcache, regnum) == REG_UNKNOWN) { @@ -666,6 +668,13 @@ regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf) if (regcache->register_status[regnum] == REG_UNKNOWN) regcache->register_status[regnum] = REG_UNAVAILABLE; } +} + +enum register_status +regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf) +{ + gdb_assert (buf != NULL); + regcache_raw_update (regcache, regnum); if (regcache->register_status[regnum] != REG_VALID) memset (buf, 0, regcache->descr->sizeof_register[regnum]); diff --git a/gdb/remote.c b/gdb/remote.c index 3befbd3d154ee4f0fbf65120d783b8af447b3fbe..87fb6e02ea3df3d8fecaf3fecc45790bdbfb6f6f 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7759,7 +7759,6 @@ remote_prepare_to_store (struct target_ops *self, struct regcache *regcache) { struct remote_arch_state *rsa = get_remote_arch_state (); int i; - gdb_byte buf[MAX_REGISTER_SIZE]; /* Make sure the entire registers array is valid. */ switch (packet_support (PACKET_P)) @@ -7769,7 +7768,7 @@ remote_prepare_to_store (struct target_ops *self, struct regcache *regcache) /* Make sure all the necessary registers are cached. */ for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++) if (rsa->regs[i].in_g_packet) - regcache_raw_read (regcache, rsa->regs[i].regnum, buf); + regcache_raw_update (regcache, rsa->regs[i].regnum); break; case PACKET_ENABLE: break;