From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 4E0653849AC9 for ; Wed, 8 May 2024 08:53:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E0653849AC9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4E0653849AC9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715158423; cv=none; b=VmapfEuC36zdVPWNw6XfKDDRofP/Qz77Wxrp6bVBQDzxLgbOFtNngHkRSvTxQiatMRI9G9FyFk6K2XLdgVo65yrJX/zhdXSQVm0GuRiNH/g8WO8kpWYdUPwW9mUHRCE2G3RZWQ19f1MQWmL/qQ4GbKIdXpsZGLM+csbXIHxoULg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715158423; c=relaxed/simple; bh=6ze88ESeuHfYc8M8YZrdw/sD1QxXHxU62xON6aFpNv4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=oxlkQg621dB18vfDjzJ77zTwl3tzCR5pMLqU7qZm9wLzCQqjxf78YnXtmqvrOs5f7MmNd7zMBJZ/096JqJpOOYiMAGlUaBv22hwTYiZwg3MVCyG2IIo6tNSWqQMLzFUqqyrQ/SjWoqqyMxsXjViAEsv/2lHWDTiB2b/Y2P85pJc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (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) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 381995C6B6 for ; Wed, 8 May 2024 08:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715158420; h=from:from:reply-to: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=Pwj2t8MS7GFfC9ycTYchiExDzBtarK+OElmvIYqyPEc=; b=EeK4+Yoab5DusF/i+divf8CCp6FcFDwb2z7mN4sC5eMw+1xfJSHtLI2tsovwO1TENO4h3C 1b3dQSBSv1QJqAV8sSmjLUXYh6D/cTwF6ro14TnGHhYD5OQd7+AMhLIRgw9llHTdSXzyM7 58YjpeW2h2ENOUXRlv9SCatVsLd/LWQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715158420; h=from:from:reply-to: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=Pwj2t8MS7GFfC9ycTYchiExDzBtarK+OElmvIYqyPEc=; b=4xrA8p3Gh8gnUaV1GpFLmPaaUPWMtT8LTb7+3TP39ZLHa25JivYxDda8zIiESErL56CzAT kZex6eLY36DU/TBg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715158420; h=from:from:reply-to: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=Pwj2t8MS7GFfC9ycTYchiExDzBtarK+OElmvIYqyPEc=; b=EeK4+Yoab5DusF/i+divf8CCp6FcFDwb2z7mN4sC5eMw+1xfJSHtLI2tsovwO1TENO4h3C 1b3dQSBSv1QJqAV8sSmjLUXYh6D/cTwF6ro14TnGHhYD5OQd7+AMhLIRgw9llHTdSXzyM7 58YjpeW2h2ENOUXRlv9SCatVsLd/LWQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715158420; h=from:from:reply-to: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=Pwj2t8MS7GFfC9ycTYchiExDzBtarK+OElmvIYqyPEc=; b=4xrA8p3Gh8gnUaV1GpFLmPaaUPWMtT8LTb7+3TP39ZLHa25JivYxDda8zIiESErL56CzAT kZex6eLY36DU/TBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 24C081386E for ; Wed, 8 May 2024 08:53:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id a/9yB5Q9O2aWEAAAD6G6ig (envelope-from ) for ; Wed, 08 May 2024 08:53:40 +0000 Message-ID: <394e6f8a-d119-4824-b5cf-2aa874871d06@suse.de> Date: Wed, 8 May 2024 10:54:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PING^2][PATCH] [gdb/python] Make gdb.UnwindInfo.add_saved_register more robust From: Tom de Vries To: gdb-patches@sourceware.org References: <20240302123653.16923-1-tdevries@suse.de> <889b6a20-4895-4519-aef0-8214587deb26@suse.de> Content-Language: en-US In-Reply-To: <889b6a20-4895-4519-aef0-8214587deb26@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spamd-Result: default: False [-4.29 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+] X-Spam-Score: -4.29 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: 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 >>    "", >> - 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 >