From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72816 invoked by alias); 9 Jul 2015 11:12:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 72791 invoked by uid 89); 9 Jul 2015 11:12:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Jul 2015 11:12:07 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-36-lnuQjtYYRV6fu_EXwjHElw-1; Thu, 09 Jul 2015 12:12:00 +0100 Received: from e105615-lin.cambridge.arm.com ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 9 Jul 2015 12:11:59 +0100 From: Pierre Langlois To: qiyaoltc@gmail.com Cc: Pierre Langlois , gdb-patches@sourceware.org Subject: [PATCH v2 5/8] [AArch64] Teach stub unwinder to terminate gracefully Date: Thu, 09 Jul 2015 11:12:00 -0000 Message-Id: <1436440319-22580-1-git-send-email-pierre.langlois@arm.com> In-Reply-To: <86lheqmwux.fsf@gmail.com> References: <86lheqmwux.fsf@gmail.com> X-MC-Unique: lnuQjtYYRV6fu_EXwjHElw-1 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00279.txt.bz2 Here is the updated patch. Thanks, Pierre --- The stub unwinder is used on AArch64 if the target's memory is not readable at the current PC. For example, the user could try to call at an invalid address such as 0x0, as covered in the gdb.base/signull.exp test case. Many GDB ports use a similar unwinder to handle this case too. If we purposely kill the inferior before examining the trace then we get the following issue: ~~~ ... (gdb) trace f Tracepoint 3 at 0x7fb7fc28c0 (gdb) tstart (gdb) continue ... (gdb) tstop (gdb) tsave /tmp/trace (gdb) kill ... (gdb) target tfile /tmp/trace ... (gdb) tfind Register 31 is not available. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Found trace frame 0, tracepoint 3 #-1 0x0000007fb7fc28c0 in f () ... ^^^ ~~~ This patch teaches the stub unwinder to report to the core frame code with UNWIND_UNAVAILABLE when either the stack pointer of the return address are unavailable to read from the target. gdb/ChangeLog: * aarch64-tdep.c (aarch64_make_stub_cache): Set available_p and swallow NOT_AVAILABLE_ERROR. (aarch64_stub_this_id): Call frame_id_build_unavailable_stack if available_p is not set. (aarch64_stub_frame_unwind_stop_reason): New function. (aarch64_stub_unwind): Install it. --- gdb/aarch64-tdep.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 4a6df25..e791fcf 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1119,13 +1119,38 @@ aarch64_make_stub_cache (struct frame_info *this_fr= ame, void **this_cache) cache->saved_regs =3D trad_frame_alloc_saved_regs (this_frame); *this_cache =3D cache; =20 - cache->prev_sp - =3D get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); - cache->prev_pc =3D get_frame_pc (this_frame); + TRY + { + cache->prev_sp =3D get_frame_register_unsigned (this_frame, + AARCH64_SP_REGNUM); + cache->prev_pc =3D get_frame_pc (this_frame); + cache->available_p =3D 1; + } + CATCH (ex, RETURN_MASK_ERROR) + { + if (ex.error !=3D NOT_AVAILABLE_ERROR) + throw_exception (ex); + } + END_CATCH =20 return cache; } =20 +/* Implement the "stop_reason" frame_unwind method. */ + +static enum unwind_stop_reason +aarch64_stub_frame_unwind_stop_reason (struct frame_info *this_frame, + void **this_cache) +{ + struct aarch64_prologue_cache *cache + =3D aarch64_make_stub_cache (this_frame, this_cache); + + if (!cache->available_p) + return UNWIND_UNAVAILABLE; + + return UNWIND_NO_REASON; +} + /* Our frame ID for a stub frame is the current SP and LR. */ =20 static void @@ -1135,7 +1160,10 @@ aarch64_stub_this_id (struct frame_info *this_frame, struct aarch64_prologue_cache *cache =3D aarch64_make_stub_cache (this_frame, this_cache); =20 - *this_id =3D frame_id_build (cache->prev_sp, cache->prev_pc); + if (cache->available_p) + *this_id =3D frame_id_build (cache->prev_sp, cache->prev_pc); + else + *this_id =3D frame_id_build_unavailable_stack (cache->prev_pc); } =20 /* Implement the "sniffer" frame_unwind method. */ @@ -1162,7 +1190,7 @@ aarch64_stub_unwind_sniffer (const struct frame_unwin= d *self, struct frame_unwind aarch64_stub_unwind =3D { NORMAL_FRAME, - default_frame_unwind_stop_reason, + aarch64_stub_frame_unwind_stop_reason, aarch64_stub_this_id, aarch64_prologue_prev_register, NULL, --=20 2.1.0