From patchwork Thu Apr 11 08:53:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 32258 Received: (qmail 102589 invoked by alias); 11 Apr 2019 08:53:59 -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 102575 invoked by uid 89); 11 Apr 2019 08:53:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=gdbarch, aarch64-tdep.c, UD:aarch64-tdep.c, aarch64tdepc X-HELO: EUR04-DB3-obe.outbound.protection.outlook.com Received: from mail-eopbgr60080.outbound.protection.outlook.com (HELO EUR04-DB3-obe.outbound.protection.outlook.com) (40.107.6.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Apr 2019 08:53:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2plnC2Uu0Ku7HkB+NpjAGQqojf1freHKaB4OAelgqkQ=; b=FYwJd2Hld06pJkRL0a3Z7cKDmt1MH3BmYu9VUHi6eIsVNbzy9WeR3jWAGA9DMt9+cRLieFlGlTBq919Ow0q7WYAntxA8Re2sURcN4K0lg6L7/xxfqnUoMqlh/tu39BnRo9sj6hj90V6sYeehVoB5WkjyCbek43/Fhw+s5jAOSKg= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2536.eurprd08.prod.outlook.com (10.172.252.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.21; Thu, 11 Apr 2019 08:53:53 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::399b:3a32:bff9:827e]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::399b:3a32:bff9:827e%10]) with mapi id 15.20.1771.016; Thu, 11 Apr 2019 08:53:53 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [OBV/PUSHED][PATCH] AArch64: Ensure regcache is reset between tests Date: Thu, 11 Apr 2019 08:53:53 +0000 Message-ID: <20190411085344.15374-1-alan.hayward@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-IsSubscribed: yes A recent change made the AArch64 self tests resuse the saved regs cache, rather than creating a new one. Ensure it is reset to default values between tests. Do this by splitting the reset functionality from trad_frame_alloc_saved_regs into a new function. Fixes selftest on AArch64. gdb/ChangeLog: * aarch64-tdep.c (aarch64_analyze_prologue_test): Reset saved regs. * trad-frame.c (trad_frame_reset_saved_regs): New function. (trad_frame_alloc_saved_regs): Call trad_frame_reset_saved_regs. * trad-frame.h (trad_frame_reset_saved_regs): New declaration. --- gdb/ChangeLog | 7 +++++++ gdb/aarch64-tdep.c | 2 ++ gdb/trad-frame.c | 21 +++++++++++++++------ gdb/trad-frame.h | 3 +++ 4 files changed, 27 insertions(+), 6 deletions(-) -- 2.20.1 (Apple Git-117) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cc6762dc78..a5cbc89972 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2019-04-11 Alan Hayward + + * aarch64-tdep.c (aarch64_analyze_prologue_test): Reset saved regs. + * trad-frame.c (trad_frame_reset_saved_regs): New function. + (trad_frame_alloc_saved_regs): Call trad_frame_reset_saved_regs. + * trad-frame.h (trad_frame_reset_saved_regs): New declaration. + 2019-04-10 Kevin Buettner * amd64-linux-nat.c (amd64_linux_collect_native_gregset): New diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 7eecb52eb1..1b3977bfaf 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -665,6 +665,7 @@ aarch64_analyze_prologue_test (void) }; instruction_reader_test reader (insns); + trad_frame_reset_saved_regs (gdbarch, cache.saved_regs); CORE_ADDR end = aarch64_analyze_prologue (gdbarch, 0, 128, &cache, reader); SELF_CHECK (end == 4 * 5); @@ -707,6 +708,7 @@ aarch64_analyze_prologue_test (void) }; instruction_reader_test reader (insns); + trad_frame_reset_saved_regs (gdbarch, cache.saved_regs); CORE_ADDR end = aarch64_analyze_prologue (gdbarch, 0, 128, &cache, reader); diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c index 3cb295309c..d9114753c5 100644 --- a/gdb/trad-frame.c +++ b/gdb/trad-frame.c @@ -44,19 +44,28 @@ trad_frame_cache_zalloc (struct frame_info *this_frame) return this_trad_cache; } +/* See trad-frame.h. */ + +void +trad_frame_reset_saved_regs (struct gdbarch *gdbarch, + struct trad_frame_saved_reg *regs) +{ + int numregs = gdbarch_num_cooked_regs (gdbarch); + for (int regnum = 0; regnum < numregs; regnum++) + { + regs[regnum].realreg = regnum; + regs[regnum].addr = -1; + } +} + struct trad_frame_saved_reg * trad_frame_alloc_saved_regs (struct gdbarch *gdbarch) { - int regnum; int numregs = gdbarch_num_cooked_regs (gdbarch); struct trad_frame_saved_reg *this_saved_regs = FRAME_OBSTACK_CALLOC (numregs, struct trad_frame_saved_reg); - for (regnum = 0; regnum < numregs; regnum++) - { - this_saved_regs[regnum].realreg = regnum; - this_saved_regs[regnum].addr = -1; - } + trad_frame_reset_saved_regs (gdbarch, this_saved_regs); return this_saved_regs; } diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h index dd80d1b83c..f947e586a1 100644 --- a/gdb/trad-frame.h +++ b/gdb/trad-frame.h @@ -113,6 +113,9 @@ int trad_frame_addr_p (struct trad_frame_saved_reg this_saved_regs[], int trad_frame_realreg_p (struct trad_frame_saved_reg this_saved_regs[], int regnum); +/* Reset the save regs cache, setting register values to -1. */ +void trad_frame_reset_saved_regs (struct gdbarch *gdbarch, + struct trad_frame_saved_reg *regs); /* Return a freshly allocated (and initialized) trad_frame array. */ struct trad_frame_saved_reg *trad_frame_alloc_saved_regs (struct frame_info *);