From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 06C873858D1E; Sat, 2 Mar 2024 08:52:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06C873858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1709369568; bh=9xfk63uaJTWEvQWABFrK2iUTOUBAvQu8WKGurIvc0rQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p5j5McoiChHu+pMPrpqJdHI+zFCTZpIZ2Nyc8mz/EQqzogWqEbr3ipQG5m5kPtxlu 2/j2lACb3cDZEyhlaygdMGMG786lXmtj4VKa0emF36SF0NNMkPo953bpYcR0zwZL5Q 3I0KNpr0Z/6XzXHOCXKuD23RgHf5oDAnDgKPtNG8= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug python/31437] [gdb/python] Unavailable register breaks python unwinding Date: Sat, 02 Mar 2024 08:52:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: python X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31437 --- Comment #2 from Tom de Vries --- I realized it's cleaner to go with a fix in unwind_infopy_add_saved_registe= r: ... diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 56f925bc57f..1c1289f7e7d 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -362,6 +362,18 @@ unwind_infopy_add_saved_register (PyObject *self, PyOb= ject *args, PyObject *kw) return nullptr; } + if (value->optimized_out () || !value->entirely_available ()) + { + /* If we allow this value to be registered here, pyuw_sniffer is goi= ng + to run into an exception when trying to access its contents. + Throwing an exception here just puts a burden on the user to + implement the same checks on the user side. We could return False + here and True otherwise, but again that might require changes in u= ser + code. So, handle this with minimal impact for the user, while + improving robustness: silently ignore the register/value pair. */ + Py_RETURN_NONE; + } + gdbpy_ref<> new_value =3D gdbpy_ref<>::new_reference (pyo_reg_value); bool found =3D false; for (saved_reg ® : *unwind_info->saved_regs) ... I'll test this and submit. --=20 You are receiving this mail because: You are on the CC list for the bug.=