From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114652 invoked by alias); 25 Feb 2016 11:44:45 -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 114640 invoked by uid 89); 25 Feb 2016 11:44:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2683 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 25 Feb 2016 11:44:43 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5666CC0B6705; Thu, 25 Feb 2016 11:44:42 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1PBie4c030390; Thu, 25 Feb 2016 06:44:41 -0500 Message-ID: <56CEE928.2080704@redhat.com> Date: Thu, 25 Feb 2016 11:44:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Yao Qi , Antoine Tremblay CC: gdb-patches@sourceware.org Subject: Re: [PATCH 1/4] Teach arm unwinders to terminate gracefully References: <1452188697-23870-1-git-send-email-antoine.tremblay@ericsson.com> <1452188697-23870-2-git-send-email-antoine.tremblay@ericsson.com> <86io1ung0a.fsf@gmail.com> In-Reply-To: <86io1ung0a.fsf@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-02/txt/msg00778.txt.bz2 On 02/12/2016 02:46 PM, Yao Qi wrote: > we can wrap methods of 'struct frame_unwind' with try/catch, and handle > NOT_AVAILABLE_ERROR properly. In this way, each unwinder doesn't have > to worry about unavailable memory at all. > > Pedro, what do you think? Did you try this approach in the rest of 9 > different ways :) (you said you "implemented this differently in about > 10 different ways" in your email) ? I no longer recall exactly what I tried. :-) I think it may be a good idea. There are a few constraints that we need to keep in mind: - Frames that only have the PC available should have distinct frame ids, and it should be distinct from outer_frame_id. (See frame_id_build_unavailable_stack calls). This makes e.g., the frame_id_eq check in tfind_1 work as intended, see: https://sourceware.org/ml/gdb-patches/2013-12/msg00535.html - When an unwind sniffer throws, it'll destroy its struct frame_unwind_cache. So if we don't catch the error, the frame's this_id method can't return something more detailed than outer_frame_id. I don't see this done by wrapping methods of 'struct frame_unwind'. I think it'd work to have an ultimate-fallback unwinder that frame_unwind_find_by_frame returns instead of the internal error at the end. This would return UNWIND_UNAVAILABLE or UNWIND_MEMORY_ERROR in the unwinder->stop_reason method, depending on the error the last registered unwinder thrown. (That last unwinder will always be the arch's heuristic unwinder.) And it would return frame_id_build_unavailable_stack(PC) in the unwinder->this_id method if the last error was UNWIND_UNAVAILABLE, outer_frame_id otherwise (or we add a new frame_id_build_stackless function, to go along with frame_id_build_unavailable_stack). I think that would fix the cases where we end up internal erroring, like in today's Andreas' patch: https://sourceware.org/ml/gdb-patches/2016-02/msg00773.html And then the heuristic unwinders probably no longer need to care to use the safe_read_memory_xxx functions. And it'd fix the bogus cases where the sentinel frame level (-1) shows through, due to: struct frame_info * get_current_frame (void) { ... if (current_frame == NULL) { struct frame_info *sentinel_frame = create_sentinel_frame (current_program_space, get_current_regcache ()); if (catch_exceptions (current_uiout, unwind_to_current_frame, sentinel_frame, RETURN_MASK_ERROR) != 0) { /* Oops! Fake a current frame? Is this useful? It has a PC of zero, for instance. */ current_frame = sentinel_frame; } See recent example here: https://sourceware.org/ml/gdb-patches/2016-01/msg00222.html Thanks, Pedro Alves