From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sHfyAwLE62KWlSAAWB0awg (envelope-from ) for ; Thu, 04 Aug 2022 09:05:06 -0400 Received: by simark.ca (Postfix, from userid 112) id 0E0931EA05; Thu, 4 Aug 2022 09:05:06 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=swp5SMy7; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A561F1E9EB for ; Thu, 4 Aug 2022 09:05:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 531C0385E012 for ; Thu, 4 Aug 2022 13:05:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 531C0385E012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1659618305; bh=u6J9E/JwKSKW6VMpLpBDaiQT3q5It5vDZZUsmEzypyY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=swp5SMy7MgWW5EwQ4WvjofkFv/ZbQypWQ+wFVYur/pw5sPU5E65ASAPflU5b953yw ZEJ74Bu3mHYObl4kGtmSw4AXqIs5FKxD/by8wFqkvl406+0Jdq1KZFKufuxNFFis3I 2LimAU51yubZpDlDFuG3XC4zsi25dW5hm1rzWwVw= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id ED7053851169 for ; Thu, 4 Aug 2022 13:04:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED7053851169 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3ED084E2D8; Thu, 4 Aug 2022 13:04:24 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 25FD913A94; Thu, 4 Aug 2022 13:04:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id LGERCNjD62KyUgAAMHmgww (envelope-from ); Thu, 04 Aug 2022 13:04:24 +0000 Date: Thu, 4 Aug 2022 15:04:22 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/tdep] Fix gdb.base/large-frame.exp for aarch64 Message-ID: <20220804130419.GA25032@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, On aarch64, I run into: ... FAIL: gdb.base/large-frame.exp: optimize=-O0: backtrace ... The problem is that the architecture-specific prologue analyzer fails to handle the first two insns in the prologue properly: ... 0000000000400610 : 400610: d2880210 mov x16, #0x4010 400614: cb3063ff sub sp, sp, x16 400618: a9007bfd stp x29, x30, [sp] 40061c: 910003fd mov x29, sp 400620: 910043a0 add x0, x29, #0x10 400624: 97fffff0 bl 4005e4 ... so we get: ... $ gdb -q -batch ./outputs/gdb.base/large-frame/large-frame-O0 -ex "b func" Breakpoint 1 at 0x400614 ... Fix this by: - fixing the support for the first insn to extract the immediate operand, and - adding support for the second insn, such that we have: ... Breakpoint 1 at 0x400624 ... Note that we're overshooting by one insn (0x400620 is the first insn after the prologue), but that's a pre-existing problem. Tested on aarch64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29408 Any comments? Thanks, - Tom [gdb/tdep] Fix gdb.base/large-frame.exp for aarch64 --- gdb/aarch64-tdep.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 8670197a888..f747ebda1ab 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -340,6 +340,20 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, if (rn == AARCH64_SP_REGNUM && rd == AARCH64_FP_REGNUM) seen_stack_set = true; } + else if (inst.opcode->iclass == addsub_ext + && strcmp ("sub", inst.opcode->name) == 0) + { + unsigned rd = inst.operands[0].reg.regno; + unsigned rn = inst.operands[1].reg.regno; + unsigned rm = inst.operands[2].reg.regno; + + gdb_assert (aarch64_num_of_operands (inst.opcode) == 3); + gdb_assert (inst.operands[0].type == AARCH64_OPND_Rd_SP); + gdb_assert (inst.operands[1].type == AARCH64_OPND_Rn_SP); + gdb_assert (inst.operands[2].type == AARCH64_OPND_Rm_EXT); + + regs[rd] = pv_subtract (regs[rn], regs[rm]); + } else if (inst.opcode->iclass == pcreladdr && inst.operands[1].type == AARCH64_OPND_ADDR_ADRP) { @@ -370,14 +384,20 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, } else if (inst.opcode->op == OP_MOVZ) { + unsigned rd = inst.operands[0].reg.regno; + + gdb_assert (aarch64_num_of_operands (inst.opcode) == 2); gdb_assert (inst.operands[0].type == AARCH64_OPND_Rd); + gdb_assert (inst.operands[1].type == AARCH64_OPND_HALF); + gdb_assert (inst.operands[1].shifter.kind == AARCH64_MOD_LSL); /* If this shows up before we set the stack, keep going. Otherwise stop the analysis. */ if (seen_stack_set) break; - regs[inst.operands[0].reg.regno] = pv_unknown (); + regs[rd] = pv_constant (inst.operands[1].imm.value + << inst.operands[1].shifter.amount); } else if (inst.opcode->iclass == log_shift && strcmp (inst.opcode->name, "orr") == 0)