From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95388 invoked by alias); 3 Apr 2018 01:35:56 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 95368 invoked by uid 89); 3 Apr 2018 01:35:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Apr 2018 01:35:54 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w331ZlLd020562 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 2 Apr 2018 21:35:52 -0400 Received: by simark.ca (Postfix, from userid 112) id 7ADB11E77E; Mon, 2 Apr 2018 21:35:47 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 1486E1E4B2; Mon, 2 Apr 2018 21:35:46 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 03 Apr 2018 01:35:00 -0000 From: Simon Marchi To: Dmitry Antipov Cc: GDB Development , Yao Qi Subject: Re: aarch64-tdep.c:379: internal-error: CORE_ADDR aarch64_analyze_prologue(gdbarch*, CORE_ADDR, CORE_ADDR, aarch64_prologue_cache*, {anonymous}::abstract_instruction_reader&): Assertion `inst.operands[0].qualifier == AARCH64_OPND_QLF_S_D' failed In-Reply-To: References: Message-ID: <72908568cb161628681345981f5c0b87@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.4 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 3 Apr 2018 01:35:47 +0000 X-IsSubscribed: yes X-SW-Source: 2018-04/txt/msg00001.txt.bz2 On 2018-04-02 05:13, Dmitry Antipov wrote: > IIUC a few types of STP and STR instructions are explicitly banned in > aarch64_analyze_prologue(): > > f: > stp x29, x30, [sp, #-160]! > mov x29, sp > stp q0, q1, [sp, #-16]! ; Hmm... > ldp x29, x30, [sp], #160 > ret > .end > > The following dummy self-test... > > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index f08945ea07..42f9d00b64 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -529,6 +529,22 @@ aarch64_analyze_prologue_test (void) > struct gdbarch *gdbarch = gdbarch_find_by_info (info); > SELF_CHECK (gdbarch != NULL); > > + { > + struct aarch64_prologue_cache cache; > + cache.saved_regs = trad_frame_alloc_saved_regs (gdbarch); > + > + static const uint32_t insns[] = { > + 0xa9b67bfd, /* stp x29, x30, [sp, #-160]! */ > + 0x910003fd, /* mov x29, sp */ > + 0xadbf87e0, /* stp q0, q1, [sp, #-16]! */ > + 0xa8ca7bfd, /* ldp x29, x30, [sp], #160 */ > + 0xd65f03c0 /* ret */ > + }; > + > + instruction_reader_test reader (insns); > + (void)aarch64_analyze_prologue (gdbarch, 0, 128, &cache, reader); > + } > + > > ...raises gdb_assert(): > > (gdb) maintenance selftest > Running selftest aarch64-analyze-prologue. > ../../gdb/aarch64-tdep.c:379: internal-error: CORE_ADDR > aarch64_analyze_prologue(gdbarch*, CORE_ADDR, CORE_ADDR, > aarch64_prologue_cache*, {anonymous}::abstract_instruction_reader&): > Assertion `inst.operands[0].qualifier == AARCH64_OPND_QLF_S_D' failed. > > Can someone please explain why it is so? > > Dmitry Hi Dmitry, My guess is that it follows this sentence from the AArch64 ABI [1]: Registers v8-v15 must be preserved by a callee across subroutine calls; the remaining registers (v0-v7, v16-v31)do not need to be preserved (or should be preserved by the caller). Additionally, only the bottom 64-bits of each value stored in v8-v15 need to be preserved. The FPSR is a status register that holds the cumulative exception bits of the floating-point unit. It contains the fields IDC, IXC, UFC, OFC, DZC, IOC and QC. These fields are not preserved across a public interface and may have any value on entry to a subroutine.; it is the responsibility of the caller to preserve larger values So it looks like the GDB code assumes that no-one would ever save the whole registers, because it is not necessary. GDB should not use gdb_assert and crash on bad input. I don't know what it should do instead in that specific case, that's the part that takes more time to think about :). Simon [1] http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf