From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PING^2][PATCH] [gdb/python] Make gdb.UnwindInfo.add_saved_register more robust
Date: Wed, 8 May 2024 10:54:18 +0200 [thread overview]
Message-ID: <394e6f8a-d119-4824-b5cf-2aa874871d06@suse.de> (raw)
In-Reply-To: <889b6a20-4895-4519-aef0-8214587deb26@suse.de>
On 3/19/24 10:34, Tom de Vries wrote:
> On 3/2/24 13:36, Tom de Vries wrote:
>> On arm-linux, until commit bbb12eb9c84 ("gdb/arm: Remove tpidruro
>> register
>> from non-FreeBSD target descriptions") I ran into:
>> ...
>> FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 5: \
>> backtrace when the unwind is broken at frame 5
>> ...
>>
>> What happens is the following:
>> - the TestUnwinder from inline-frame-cycle-unwind.py calls
>> gdb.UnwindInfo.add_saved_register with reg == tpidruro and value
>> "<unavailable>",
>> - pyuw_sniffer calls value->contents ().data () to access the value of
>> the
>> register, which throws an UNAVAILABLE_ERROR,
>> - this causes the TestUnwinder unwinder to fail, after which another
>> unwinder
>> succeeds and returns the correct frame, and
>> - the test-case fails because it's counting on the TestUnwinder to
>> succeed and
>> return an incorrect frame.
>>
>> Fix this by checking for !value::entirely_available as well as
>> valued::optimized_out in unwind_infopy_add_saved_register.
>>
>> Tested on x86_64-linux and arm-linux.
>>
>
> Ping.
>
Ping once more.
Also found that this fixes the gdb.base/inline-frame-cycle-unwind.exp
failure on ppc64le reported in PR30548.
Thanks,
- Tom
>> PR python/31437
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31437
>> ---
>> gdb/python/py-unwind.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> 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,
>> PyObject *args, PyObject *kw)
>> return nullptr;
>> }
>> + if (value->optimized_out () || !value->entirely_available ())
>> + {
>> + /* If we allow this value to be registered here, pyuw_sniffer
>> is going
>> + 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
>> user
>> + 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 = gdbpy_ref<>::new_reference (pyo_reg_value);
>> bool found = false;
>> for (saved_reg ® : *unwind_info->saved_regs)
>>
>> base-commit: a6a3b67fa9052bba81ed91a38569c11ecb95baf1
>
next prev parent reply other threads:[~2024-05-08 8:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-02 12:36 [PATCH] " Tom de Vries
2024-03-19 9:34 ` [PING][PATCH] " Tom de Vries
2024-05-08 8:54 ` Tom de Vries [this message]
2024-05-08 12:02 ` [PATCH] " Andrew Burgess
2024-05-08 15:52 ` Tom Tromey
2024-05-09 10:03 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=394e6f8a-d119-4824-b5cf-2aa874871d06@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).