From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 6B8CB3858432 for ; Tue, 19 Mar 2024 09:32:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B8CB3858432 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 6B8CB3858432 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710840782; cv=none; b=bLvY3jqmG9IjMx3DWTuMP6osLKQyCVNWcD3p+RGrc0xE6H0cYLaFOqclw64UlaQFhVtDQZkQOG8w8LBs0heBf9V2hYYwwQXdU/kip2rzO3hYQk6Hi5k+X/dGg50WKdB1vsHy61wqkhYNssleUSsNngXxu27j5cZKv/Ydjxt44Qc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710840782; c=relaxed/simple; bh=6qbdehLTvvqPzCa1+sMRuNpAwS+USq3jch1tfDLiLVI=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=Ouo3stoeekzVv+FGxMDb80yP0Ft3lFSRHAXrkRIKoujgrC5pojFmgJ441ri5MYkp9/sljvvhyTWtPyP2DhCXshJMdn5ChgWu9l4toZCbiv8mWRMmkCpj3L+L6opcluJQUBPF6NwsGGdzyd29kmBZn7YCzxMReG8OW43vDg2mwbk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 52A3237605 for ; Tue, 19 Mar 2024 09:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1710840776; 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=Rw6+UPymd74rNe6iJb6ySPwxuVWw7IpNy6tqXaCIEAM=; b=QaRQ4xjsKLDf7JH0cbfQo00i/2pxNNiz7KC36h8CRnEnR/4BFhcF9ChbFP9DJ/2gqWP6bc +4gYIIiMiNT12hBylPMpmFkz6+wwUgazetvMN99udK3mU+IOnKt6eSJUHVS1nUZbzyhC+B OhTpirW+bmM42pfzMPSXrdK/p8yCoN0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1710840776; 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=Rw6+UPymd74rNe6iJb6ySPwxuVWw7IpNy6tqXaCIEAM=; b=oil478oz5CjTSxJnIHEc+25FYyw1dW04SXVTKcDDFWGf24BKbcReii1I9wCrXOQ4+fL+WI Fa//wpLP0+EYAfDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1710840775; 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=Rw6+UPymd74rNe6iJb6ySPwxuVWw7IpNy6tqXaCIEAM=; b=Kt/2x9x5pREznK+xerlGN9Gnojd1Kd2dgfycboKI/PT6ez9N5Yxbw8MfGgFDCR9rlmKpnR PQDvVYfBNdznQOrWUvdEK4dd8dR5Xe/wM0KDpeAC5VNFGZYmex0b3pwf6o+dZZ+rX45Q8Z dUr9RLep2RgFsfWPvKVrgmrmZpVfZYE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1710840775; 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=Rw6+UPymd74rNe6iJb6ySPwxuVWw7IpNy6tqXaCIEAM=; b=h23ftp/8tA19MKINa2XhOnuWMOasxZE/HqaQqDecExlxvZJELNpl8I2SAn2fvM7yZBFUsu B0PummwmgQdfJtDQ== 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 3C795136A5 for ; Tue, 19 Mar 2024 09:32:55 +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 gc/yDMdb+WUrFgAAD6G6ig (envelope-from ) for ; Tue, 19 Mar 2024 09:32:55 +0000 Message-ID: <889b6a20-4895-4519-aef0-8214587deb26@suse.de> Date: Tue, 19 Mar 2024 10:34:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PING][PATCH] [gdb/python] Make gdb.UnwindInfo.add_saved_register more robust Content-Language: en-US From: Tom de Vries To: gdb-patches@sourceware.org References: <20240302123653.16923-1-tdevries@suse.de> In-Reply-To: <20240302123653.16923-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -4.50 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.50 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,inline-frame-cycle-unwind.py:url,sourceware.org:url]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from] X-Spam-Level: Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="Kt/2x9x5"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="h23ftp/8" X-Rspamd-Queue-Id: 52A3237605 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: 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. 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