From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 34C9DK6JzGbuKRUAWB0awg (envelope-from ) for ; Mon, 26 Aug 2024 09:57:02 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=HVjmxa74; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 287741E0D0; Mon, 26 Aug 2024 09:57:02 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 166F31E0AC for ; Mon, 26 Aug 2024 09:57:00 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 71A3E385C6CD for ; Mon, 26 Aug 2024 13:56:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71A3E385C6CD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1724680619; bh=awoB+hxoucyhrkuiqaF0baf69q2aBpA/9mhsuNrHqGI=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HVjmxa740VDNQUIW5Ui3D32+Utbkx3CJSt6wr9dmYGfruotZKbpW+yaYDG2CvwCAA GXTKPgyX+IB9gTST+GzOFbuWzOKBNypTFZBydY+65sOmYZaEtKsd9vIyOnavtL8231 UkUUh5ZO1a70Z6cmWxcpOYC29HsBCV5eATbuI7mk= Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id C20AC3858C60 for ; Mon, 26 Aug 2024 13:56:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C20AC3858C60 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C20AC3858C60 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1724680582; cv=pass; b=J0JSLW11DSI7QsmGBDq5kk6B7BAlYz2KeoRCDJxGMrz8cKZXM8PFiBM6sPF1DT2DMR/CQpXXoFBs8DOICSSy5JRR7h0N0csrYz8PDNhl6A5b06KWcuaTVXL26IVmFQfCJpoVXvk5EGf1yzuz0StFC7JooJrygFUr6TOkhoG5ozI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1724680582; c=relaxed/simple; bh=mjy8Omvx+A+RKt/sQaRVXhHCyA64h2RyQTSd5VWYlsc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ABWiWWnD1tDoB96wzrx8opngKClJqwyChPVhXvvGQhBlvnQKzND4UzuVbBCzhIOmfXCR7nKyrijm3Li+COm/pk7Mog9KiyePsFe9t7fNjUujeOsrLeaxnNL+M6IK0p+Z29qPNws1vlSOAxLi6GrC7lpyalb0NvhCV8pD4sR1cXE= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R10" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4WssfB3XbMz429P; Mon, 26 Aug 2024 13:56:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WssfB2gxvz4hD6; Mon, 26 Aug 2024 13:56:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724680578; a=rsa-sha256; cv=none; b=x9hnud0XdEs+oVEXiRm+e5RHIaFz4U/cWdRKNf4+LkbnhiIcTniOmVctEfIr463KhN/Rm8 1hfwhfPWBrVXQtAyOHv5JLp8ezMu9rjubLK19tEJgzpOQ4gyyBgUpf7BEj9kNRGxfD75wU EorXOgHq3xLAvqEzILG/o0LGbq59KoWhq3Zol0NI/CvFkS7fl/YzLw1kPEL+cFwH4ZqeH1 FjjqQJw4KUxfjvE6vTGbtZYBrCMzoraiPhJyzawus4YCAY+A89lRR7KqF7GGN3ksztaMTM eK9nhxx4H/NFlaO9gajeJ2Sgh+CndHWgIAu7RcYLu/HfetZS5k/9TRGbmGbmsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724680578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=awoB+hxoucyhrkuiqaF0baf69q2aBpA/9mhsuNrHqGI=; b=OpdCWnFowmGgI8YhRXgkVbQhepRe5OxnBlFg8SBu5O0J2y/B7VgFgyPiLeQdsIs1R8vSwS wUV/Wb+gicJwfnwYPaG/RQfK1Y7EsthCARE+GyUycogPnJiLjBU+L42okkalkqN9DWQ2LZ hREfhTTeTikNqmijnbCe3Ir87dSdHp6ssUAbgsntpFCG3xhoAnOoyYhbI/S2y65+T5a0ov t7jFGDAFOo9IWg6rTFAlSEsfJTN8R+ha+c4t/nq4GFS1WdoSZ5aCEGk+hAsyZM/W4IqeaA o8KVp/E+Yy60b8NfpkOkQKkG1f3Vvx5vE8an/FBtWURK0JPX/JWRTikLkWyBGA== Received: from [IPV6:2601:5c0:4200:b830:c5a1:58af:8e53:f773] (unknown [IPv6:2601:5c0:4200:b830:c5a1:58af:8e53:f773]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4WssfB1PGsz13sV; Mon, 26 Aug 2024 13:56:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <5e7cd9ea-f5b5-4ad6-9ae4-dbc33a66b23f@FreeBSD.org> Date: Mon, 26 Aug 2024 09:56:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Expose Frame Type and Stop Reason in python Unwinder API Content-Language: en-US To: Andrew Wock , gdb@sourceware.org References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: John Baldwin via Gdb Reply-To: John Baldwin Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" On 8/21/24 22:28, Andrew Wock via Gdb wrote: > Hello, > > Recently I wrote a kernel trapframe unwinder using the python API, and > I was able to successfully extract the registers from the trapframe. > However, sometimes gdb would throw the "previous frame inner to this > frame" error on me. This is because unwinding a trapframe sometimes > results in unwinding to a different stack. > > The way this is fixed in the internal unwinder API is that there are > special frame types such as SIGTRAMP_FRAME which don't get checked for > that error. > > Additionally, some trapframes unwind into userspace. In those cases > I'd like to be able to stop the backtrace by setting a stop reason. > More broadly this would be useful for any case where a user wants to > stop the stacktrace at a certain point for whatever their use case is. > > I'm interested in moving forward and writing a patch for this. > > One implementation detail I noticed that complicates this > implementation is that all python unwinders are internally modeled as > a single C unwinder in py-unwind.c:974. I believe that in order to > support a frame type feature, each unwinder will need to be modeled as > an independent C unwinder. Yes, I think that's true, or you'd need to have one unwinder per frame type that you tie all the related unwinders to? > I am proposing this here to get community feedback on whether this > feature should be supported. The other check I've run into is when you have a NULL function pointer that raises a fault. There is a check that aborts unwinding unless the frame type is SIGTRAMP_FRAME IIRC. I use custom unwinders in C++ for FreeBSD's kgdb so that they can use SIGTRAMP_FRAME to get around that limitation. -- John Baldwin