From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by sourceware.org (Postfix) with ESMTPS id 328DB3858C55 for ; Thu, 13 Oct 2022 13:25:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 328DB3858C55 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f54.google.com with SMTP id bg9-20020a05600c3c8900b003bf249616b0so1424902wmb.3 for ; Thu, 13 Oct 2022 06:25:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2muxQsdxHl46yQIAoJSgLcAyK4BPhl/s9o91bxkRB30=; b=tf55zmCQsWHZ9hcrU7nYubZTocxhNHjuJWc9Ue9IYYpQ22hTMaCbGrZQ0KJrrMwV9+ zoYbJwkece13EZWWQaQLyAAJDQH0TL8E8Vq6id556/9iaXHki80cdsoB5x6+r56+K1BZ C7o2/iV4Q9FzQbmas2IWgJCfp3FKNdksydmn+bR6Zf8rSqe+pO8EFFuw95ooUuOI+owD UBKM8A3UiQ22kwEIL5Xj55w4C2AzERfXhMV9rY4TC4GpEVXbDf1QemeRa8fdEwEUQdLJ daLprHJv+HxVZaQKtAqoW3G8sRFEQ1rnYFYemQ6/pbYbIfP9BJcIgLjQxWiR/KpdswsI f9DA== X-Gm-Message-State: ACrzQf1H1AOrhyhO/qSo3R5LnxjGsGYWswXRS7HcTQW/sNtOugWy1bak RNcZ1PehE8pDZibeCJzux4hx7N9zfsh0lA== X-Google-Smtp-Source: AMsMyM7ngytDR7Al24sImzE8WX+P6g3kYsUvITScBzQlcVueZA6c3ak7EaT1MuBtfNno3jMKL+Zr8A== X-Received: by 2002:a1c:7407:0:b0:3c6:cc25:c02f with SMTP id p7-20020a1c7407000000b003c6cc25c02fmr6476394wmc.124.1665667555418; Thu, 13 Oct 2022 06:25:55 -0700 (PDT) Received: from ?IPv6:2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653? ([2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653]) by smtp.gmail.com with ESMTPSA id j37-20020a05600c1c2500b003c6b874a0dfsm5522538wms.14.2022.10.13.06.25.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Oct 2022 06:25:54 -0700 (PDT) Subject: Re: [PATCH v2] gdb/arm: Stop unwinding on error, but do not assert To: Torbjorn SVENSSON , gdb-patches@sourceware.org References: <20221013091740.645783-1-torbjorn.svensson@foss.st.com> <9cc66b68-94b4-ed24-f4b5-93a441b8a70d@palves.net> <06178385-10b2-83cf-c0ff-aa6b90dfe2ac@foss.st.com> From: Pedro Alves Message-ID: <7f42d38e-a756-0949-b72b-26954cce7bea@palves.net> Date: Thu, 13 Oct 2022 14:25:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <06178385-10b2-83cf-c0ff-aa6b90dfe2ac@foss.st.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, BODY_8BITS, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 13 Oct 2022 13:25:58 -0000 On 2022-10-13 1:24 p.m., Torbjorn SVENSSON wrote: > Hi Pedro, > > On 2022-10-13 13:21, Pedro Alves wrote: >> On 2022-10-13 10:17 a.m., Torbjörn SVENSSON via Gdb-patches wrote: >> >>> +  /* Unwind of this frame is not possible.  Return outer_frame_id to stop the >>> +     unwinding.  */ >>> +  if (cache == NULL) >>> +    { >>> +      *this_id = outer_frame_id; >>> +      return; >>> +    } >> >> Please let's not add more uses of outer_frame_id if we can avoid it.  We're getting >> close to eliminating it.  Can a cache object still be returned, and then a frame id >> be successfully computed? > > The problem is that it's not always possible to know what registers that was written on the stack or if there was padding between 2 frames on the stack. > If a cache object is returned, wouldn't that imply that the content of this frame is supposed to be valid? But that info is useful to unwind the prev frame from this_frame. The contents of registers for this_frame are unwound from this_frame->next. The info needed to compute a frame id should be available. On 2022-10-13 1:24 p.m., Torbjorn SVENSSON wrote: >> Alternatively, you can implement a frame_unwind::stop_reason callback and return >> UNWIND_OUTERMOST, which is already done in arm-tdep.c in other scenarios too. > > Is it guaranteed that the prev_register method won't be called for a cache object that have the UNWIND_OUTERMOST stop reason? That's how outer_frame_id manages to stop unwinding, because of the default implementation, here: /* The default frame unwinder stop_reason callback. */ enum unwind_stop_reason default_frame_unwind_stop_reason (frame_info_ptr this_frame, void **this_cache) { struct frame_id this_id = get_frame_id (this_frame); if (this_id == outer_frame_id) return UNWIND_OUTERMOST; else return UNWIND_NO_REASON; } You hit this in frame.c: /* Check that this frame is unwindable. If it isn't, don't try to unwind to the prev frame. */ this_frame->stop_reason = this_frame->unwind->stop_reason (this_frame, &this_frame->prologue_cache); if (this_frame->stop_reason != UNWIND_NO_REASON) { frame_debug_printf (" -> nullptr // %s", frame_stop_reason_symbol_string (this_frame->stop_reason)); return NULL; } > If so, I suppose the struct arm_prologue_cache could be extended with another member that indicates if the frame was > successfully unwinded or if there were some problem and the UNWIND_OUTERMOST should be returned. Would this be okay? Yes.