From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107120 invoked by alias); 25 Feb 2016 13:15:23 -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 107102 invoked by uid 89); 25 Feb 2016 13:15:23 -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_PASS autolearn=ham version=3.3.2 spammy= X-HELO: usplmg20.ericsson.net Received: from usplmg20.ericsson.net (HELO usplmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 25 Feb 2016 13:15:21 +0000 Received: from EUSAAHC004.ericsson.se (Unknown_Domain [147.117.188.84]) by usplmg20.ericsson.net (Symantec Mail Security) with SMTP id 4D.39.12433.03AFEC65; Thu, 25 Feb 2016 13:57:20 +0100 (CET) Received: from elxa4wqvvz1 (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.84) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 25 Feb 2016 08:15:18 -0500 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> <56CEE928.2080704@redhat.com> User-agent: mu4e 0.9.17; emacs 24.4.1 From: Antoine Tremblay To: Yao Qi CC: Pedro Alves , Antoine Tremblay , Subject: Re: [PATCH 1/4] Teach arm unwinders to terminate gracefully In-Reply-To: <56CEE928.2080704@redhat.com> Date: Thu, 25 Feb 2016 13:15:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00784.txt.bz2 Pedro Alves writes: > 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 > Reading Pedro's description I'm not against the refactoring but it's non trivial to me at the moment at least. I suggest we allow this patch to go in in order to make progress on the arm tracepoint patchset and do that refactoring in a subsequent patch. Would that be OK ? Regards, Antoine