From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0O4oJ1eUNGZ0GgQAWB0awg (envelope-from ) for ; Fri, 03 May 2024 03:37:59 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xcGIKjlA; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=meQ99TI0; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xcGIKjlA; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=meQ99TI0; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9A2451E0C1; Fri, 3 May 2024 03:37:59 -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 6D8091E030 for ; Fri, 3 May 2024 03:37:57 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E8AD3849AFE for ; Fri, 3 May 2024 07:37:56 +0000 (GMT) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id A098F385E836 for ; Fri, 3 May 2024 07:37:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A098F385E836 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 A098F385E836 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714721857; cv=none; b=T3pvVUQbK1xZ5kutsXDjD36WQ74CVzacJB3qEIS1Lkx8Z3vUV660WXHJlXRHKkCD/isLfRlZyQolMplpkOZuhg3H9pzDLotmzNs4gVvhfS/HN1zia59tS/7f1s3V+8aoiFojxazDeteAv2UcX+tyumIHvucpIpSyQ6Oll/c369s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714721857; c=relaxed/simple; bh=iq3f5RX508LWxDqh6UulBQ8KAlyXV2uNg4Hft1qbADo=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=rcbWNMM1+hf4JziKQvnHQT2tTsE1mms2V6n8oGx0jXIq+6DjZ8AoSqy0L62AZuKvY6G+zZuTvaknwaYw+vb0MvWDZKtJD5gii7cloab2ydzsTBd2KKSjyXczYNRflkOCP/ZxPGcnUhNmlke+U/SCyhd5lH2rpeaZfsQPh0D39lU= 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-out1.suse.de (Postfix) with ESMTPS id B335422B5A; Fri, 3 May 2024 07:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1714721854; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mrw3tDKQJpUSg1ez1jasirSEqYR1M+67Xr904USemAY=; b=xcGIKjlAmmY1FFrU2Uz63I+0iepoCNfig5P8qwRhpZqA5wzbTLrjLjUwRYj/mL9wRTg6Qd 2wJgkRjSoCyGiPLvT2BXsX6DrnDygzB/K6mhHmNEWkS7Lfi2m2QF7QI8kAwaooJRg9bV1k 3tKnOzkPxbeUert+2+nRp8v+HVdwQuw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1714721854; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mrw3tDKQJpUSg1ez1jasirSEqYR1M+67Xr904USemAY=; b=meQ99TI0qAnOHMKlP63fRwr8aAL9oxKXZV/AwEdoDZ9llwz3fyzVqxVQEwOWL+9BqxPSKX rJfLpTYPe2/T3zCw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1714721854; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mrw3tDKQJpUSg1ez1jasirSEqYR1M+67Xr904USemAY=; b=xcGIKjlAmmY1FFrU2Uz63I+0iepoCNfig5P8qwRhpZqA5wzbTLrjLjUwRYj/mL9wRTg6Qd 2wJgkRjSoCyGiPLvT2BXsX6DrnDygzB/K6mhHmNEWkS7Lfi2m2QF7QI8kAwaooJRg9bV1k 3tKnOzkPxbeUert+2+nRp8v+HVdwQuw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1714721854; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mrw3tDKQJpUSg1ez1jasirSEqYR1M+67Xr904USemAY=; b=meQ99TI0qAnOHMKlP63fRwr8aAL9oxKXZV/AwEdoDZ9llwz3fyzVqxVQEwOWL+9BqxPSKX rJfLpTYPe2/T3zCw== 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 9A451139CB; Fri, 3 May 2024 07:37:34 +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 08c7JD6UNGYwCwAAD6G6ig (envelope-from ); Fri, 03 May 2024 07:37:34 +0000 Message-ID: Date: Fri, 3 May 2024 09:37:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/exp] Fix cast handling for indirection To: Kevin Buettner Cc: gdb-patches@sourceware.org References: <20240502154902.22575-1-tdevries@suse.de> <20240502193145.5da7327d@f39-zbm-amd> Content-Language: en-US From: Tom de Vries In-Reply-To: <20240502193145.5da7327d@f39-zbm-amd> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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)[-0.997]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Spam-Score: -4.29 X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org On 5/3/24 04:31, Kevin Buettner wrote: > On Thu, 2 May 2024 17:49:02 +0200 > Tom de Vries wrote: > >> Consider a test-case compiled without debug info, containing: >> ... >> char a = 'a'; >> >> char * >> a_loc (void) >> { >> return &a; >> } >> ... >> >> We get: >> ... >> (gdb) p (char)*a_loc () >> Cannot access memory at address 0x10 >> ... >> >> There's a bug in unop_ind_base_operation::evaluate that evaluates >> "(char)*a_loc ()" the same as: >> ... >> (gdb) p (char)*(char)a_loc () > Hi Kevin, thanks for the review. > This surprised me. I would have thought that the evaluation would > have been: > > (char)*(int)a_loc () > > ...due to the fact that functions lacking an explicit return type > return 'int' in traditional C. > Default-to-int was my first guess, but after debugging and investigating the code in unop_ind_base_operation::evaluate, I realized that the cast (passed in expect_type) is passed unmodified to the dereferenced expression. I used this in the test-case, by changing the cast from int to char, to maximize the changes that the PR will produce an incorrect pointer. >> Cannot access memory at address 0x10 >> ... >> >> Fix this by instead evaluating it the same as: >> ... >> (gdb) p (char)*(char *)a_loc () >> $1 = 97 'a' >> ... >> >> Tested on x86_64-linux. >> >> PR exp/31693 >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31693 > > Aside from the (possible) nit in the commit log that I mention > above, the patch and test case look good to me. > > Approved-by: Kevin Buettner > Thanks, pushed unmodified. - Tom > Kevin >