From patchwork Wed May 3 10:56:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 20233 Received: (qmail 64888 invoked by alias); 3 May 2017 10:56:40 -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 64044 invoked by uid 89); 3 May 2017 10:56:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 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=regi, defer X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-eopbgr30075.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.107.3.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 May 2017 10:56:36 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0103.eurprd08.prod.outlook.com (10.160.211.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.12; Wed, 3 May 2017 10:56:36 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::b823:64c1:afc5:3a08]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::b823:64c1:afc5:3a08%17]) with mapi id 15.01.1061.021; Wed, 3 May 2017 10:56:35 +0000 From: Alan Hayward To: Pedro Alves CC: Yao Qi , "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH 8/11] Add FRV_MAX_REGISTER_SIZE Date: Wed, 3 May 2017 10:56:35 +0000 Message-ID: References: <3B3BD949-1C9D-44FF-AB6A-03091ECA49D0@arm.com> <867f2rw9br.fsf@gmail.com> <22BD364F-A9A9-4E21-BC47-96A320760640@arm.com> <86d1bqba87.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-microsoft-exchange-diagnostics: 1; AM3PR08MB0103; 7:9tTxgNOVrbfaLWmPK0xJf6ZXbA2+NQ96rqFBjTo6ZCAgKndUavI0lLLo+wLZETYJj57a5YYpSnZBeUWL7mfzO9rITjossQN2plv4DZe2P7Bt7jiopwnqDu05YIe6yeR4pViCiWetG90yo0WKOY2qeRX9qknihAHFggmUz4/7qznk5GZ8eWJPVk5XIlNjJGRs7yikMuXK9s0NtR2QVeBd+spTgu0XePHHQAIByD2MDjnZAKv1Vfze7fkNWeI0oWpEtuIRXYJxrfXfu0HrjWlstWgZ1ltK3DOP6H+cGnOMtYgMJONBAzEI7Vbm7WavypEYYgXsiM1lLvm1q3PNon9zEQ== x-ms-office365-filtering-correlation-id: 83bae950-a8d6-4469-a9e6-08d492131160 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075); SRVR:AM3PR08MB0103; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123555025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148); SRVR:AM3PR08MB0103; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0103; x-forefront-prvs: 029651C7A1 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39840400002)(39450400003)(39860400002)(39850400002)(39410400002)(39400400002)(377424004)(377454003)(24454002)(50986999)(229853002)(66066001)(6486002)(33656002)(76176999)(6506006)(6436002)(86362001)(54356999)(8936002)(2906002)(3660700001)(81166006)(8676002)(93886004)(3280700002)(39060400002)(6246003)(7736002)(189998001)(25786009)(53546009)(478600001)(36756003)(3846002)(6116002)(305945005)(53936002)(102836003)(83716003)(99286003)(54906002)(2950100002)(6512007)(6916009)(38730400002)(5660300001)(5250100002)(2900100001)(4326008)(110136004)(82746002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0103; 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: 03 May 2017 10:56:35.6695 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0103 > On 3 May 2017, at 10:27, Pedro Alves wrote: > > On 05/03/2017 09:44 AM, Yao Qi wrote: >> Alan Hayward writes: >> >> Hi Alan, >> regcache.c is updated, so please update your patch. >> >>> I considered making regcache_raw_supply_zero call regcache_raw_supply, but >>> in the end it made more sense to make it completely separate. >> >> You can call raw_supply (regnum, NULL) and then set the status to REG_VALID. >> > > I think I agree with Alan -- if we defer to raw_supply, then I'd still prefer > that the memset is still done in regcache_raw_supply_zero, because whether > unavailable registers actually have a contents buffer at all is > implementation detail. We currently zero REG_UNVAILABLE registers in raw_supply, > but that could change. (And if we reuse raw_supply as is, then memset, we'll > memset twice.) > > BTW, note that gdbserver has an equivalent function, called > "supply_register_zeroed". > Agreed. I didn't want somebody in the future to change raw_supply and cause raw_supply_zero to break. Patch updated to head and raw_supply_zero moved into regcache class. Tested on a --enable-targets=all using make check with board files unix and native-gdbserver. Ok to commit? Alan. 2017-05-03 Alan Hayward * frv-linux-tdep.c (frv_linux_supply_gregset): Use raw_supply_zero. * regcache.c (regcache::raw_supply_zero): New function. * regcache.h (regcache::raw_supply_zero: New declaration. diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c index eb87f93058b0287e8f05c585d1b6aa1ff2bffb78..30e5bf00c199a0193ea6cac3a14070445492d3fe 100644 --- a/gdb/frv-linux-tdep.c +++ b/gdb/frv-linux-tdep.c @@ -413,17 +413,14 @@ frv_linux_supply_gregset (const struct regset *regset, int regnum, const void *gregs, size_t len) { int regi; - char zerobuf[MAX_REGISTER_SIZE]; - - memset (zerobuf, 0, MAX_REGISTER_SIZE); /* gr0 always contains 0. Also, the kernel passes the TBR value in this slot. */ - regcache_raw_supply (regcache, first_gpr_regnum, zerobuf); + regcache->raw_supply_zero (first_gpr_regnum); /* Fill gr32, ..., gr63 with zeros. */ for (regi = first_gpr_regnum + 32; regi <= last_gpr_regnum; regi++) - regcache_raw_supply (regcache, regi, zerobuf); + regcache->raw_supply_zero (regi); regcache_supply_regset (regset, regcache, regnum, gregs, len); } diff --git a/gdb/regcache.h b/gdb/regcache.h index 346d290b752d8809f78b72c104ccbc2f5574d83c..ee949597d5691b692b1162a92bc328266fdc160a 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -296,6 +296,8 @@ public: void raw_supply (int regnum, const void *buf); + void raw_supply_zero (int regnum); + void raw_copy (int regnum, struct regcache *src_regcache); enum register_status get_register_status (int regnum) const; diff --git a/gdb/regcache.c b/gdb/regcache.c index 748c30e2d4c5f572e9741f73a39c4bc555d1d663..89c2eb55e29af9a806a684382dc928c307ff934b 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1208,6 +1208,26 @@ regcache::raw_supply (int regnum, const void *buf) } } +/* Supply register REGNUM with zeroed value to REGCACHE. This is not the same + as calling raw_supply with NULL (which will set the state to + unavailable). */ + +void +regcache::raw_supply_zero (int regnum) +{ + void *regbuf; + size_t size; + + gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); + gdb_assert (!m_readonly_p); + + regbuf = register_buffer (regnum); + size = m_descr->sizeof_register[regnum]; + + memset (regbuf, 0, size); + m_register_status[regnum] = REG_VALID; +} + /* Collect register REGNUM from REGCACHE and store its contents in BUF. */ void