From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0Bv7GbLJ/mB5WQAAWB0awg (envelope-from ) for ; Mon, 26 Jul 2021 10:41:54 -0400 Received: by simark.ca (Postfix, from userid 112) id 5B57D1EDFE; Mon, 26 Jul 2021 10:41:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3FFEE1E813 for ; Mon, 26 Jul 2021 10:41:52 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABEE5393A41B for ; Mon, 26 Jul 2021 14:41:51 +0000 (GMT) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 18F1A3899014 for ; Mon, 26 Jul 2021 14:41:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 18F1A3899014 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4AECA1FD36; Mon, 26 Jul 2021 14:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627310489; 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=GVREoyjaGWNi2MkGTeixg0jQrOIAQfeKnRFjUsQEQyc=; b=HzcSNGgmLcEoBGOHWANW4hSpXJV5wAnNj1VHATSJebCckjXHOtg4fPM3GRGvZScVsWwMcw RVBnGlm8ZEbg1Wi1pcjjfXujiWagoO5+igXJB24lcNl4kHZezBRN4/34vViWtccfyXQ4JQ QqoAzl2Eu7bAZcC/9XqDAZK6c/4e1kQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627310489; 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=GVREoyjaGWNi2MkGTeixg0jQrOIAQfeKnRFjUsQEQyc=; b=sLrO1ofLwalC5eDi6jniYpwzL3T2OrTwy6oa5LbZWSlwRwHQKJTUfMqjsY13lPpc5kxNyi wEnEu6La+NBaIJCQ== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 2269F13A91; Mon, 26 Jul 2021 14:41:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id oRxPBpnJ/mAgFwAAGKfGzw (envelope-from ); Mon, 26 Jul 2021 14:41:29 +0000 Subject: Re: [PATCH][gdb/symtab] Fix unhandled dwarf expression opcode with gcc-11 -gdwarf-5 To: Simon Marchi , gdb-patches@sourceware.org References: <20210725072237.GA31689@delia> From: Tom de Vries Message-ID: <3aab540b-f859-4310-a802-5416e3603282@suse.de> Date: Mon, 26 Jul 2021 16:41:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 7/26/21 3:49 PM, Simon Marchi wrote: > On 2021-07-25 3:22 a.m., Tom de Vries wrote: >> Hi, >> >> [ I've confused things by forgetting to add -gdwarf-4 in $subject of >> commit 0057a7ee0d9 "[gdb/testsuite] Add KFAILs for gdb.ada FAILs with >> gcc-11". So I'm adding here -gdwarf-5 in $subject, even though -gdwarf-5 is >> the default for gcc-11. I keep getting confused because of working with a >> system gcc-11 compiler that was patched to switch the default back to >> -gdwarf-4. ] >> >> When running test-case gdb.ada/arrayptr.exp with gcc-11 (and default >> -gdwarf-5), I run into: >> ... >> (gdb) print pa_ptr.all^M >> Unhandled dwarf expression opcode 0xff^M >> (gdb) FAIL: gdb.ada/arrayptr.exp: scenario=all: print pa_ptr.all >> ... >> >> What happens is that pa_ptr: >> ... >> <2><1523>: Abbrev Number: 3 (DW_TAG_variable) >> <1524> DW_AT_name : pa_ptr >> <1529> DW_AT_type : <0x14fa> >> ... >> has type: >> ... >> <2><14fa>: Abbrev Number: 2 (DW_TAG_typedef) >> <14fb> DW_AT_name : foo__packed_array_ptr >> <1500> DW_AT_type : <0x1504> >> <2><1504>: Abbrev Number: 4 (DW_TAG_pointer_type) >> <1505> DW_AT_byte_size : 8 >> <1505> DW_AT_type : <0x1509> >> ... >> which is a pointer to a subrange: >> ... >> <2><1509>: Abbrev Number: 12 (DW_TAG_subrange_type) >> <150a> DW_AT_lower_bound : 0 >> <150b> DW_AT_upper_bound : 0x3fffffffffffffffff >> <151b> DW_AT_name : foo__packed_array >> <151f> DW_AT_type : <0x15cc> >> <1523> DW_AT_artificial : 1 >> <1><15cc>: Abbrev Number: 5 (DW_TAG_base_type) >> <15cd> DW_AT_byte_size : 16 >> <15ce> DW_AT_encoding : 7 (unsigned) >> <15cf> DW_AT_name : long_long_long_unsigned >> <15d3> DW_AT_artificial : 1 >> ... >> with upper bound of form DW_FORM_data16. >> >> In gdb/dwarf/attribute.h we have: >> ... >> /* Return non-zero if ATTR's value falls in the 'constant' class, or >> zero otherwise. When this function returns true, you can apply >> the constant_value method to it. >> ... >> DW_FORM_data16 is not considered as constant_value cannot handle >> that. */ >> bool form_is_constant () const; >> ... >> so instead we have attribute::form_is_block (DW_FORM_data16) == true. >> >> Then in attr_to_dynamic_prop for the upper bound, we get a PROC_LOCEXPR >> instead of a PROP_CONST and end up trying to evaluate the constant >> 0x3fffffffffffffffff as if it were a locexpr, which causes the >> "Unhandled dwarf expression opcode 0xff". >> >> In contrast, with -gdwarf-4 we have: >> ... >> <164c> DW_AT_upper_bound : 18 byte block: \ >> 9e 10 ff ff ff ff ff ff ff ff 3f 0 0 0 0 0 0 0 \ >> (DW_OP_implicit_value 16 byte block: \ >> ff ff ff ff ff ff ff ff 3f 0 0 0 0 0 0 0 ) >> ... >> >> Fix the dwarf error by translating the DW_FORM_data16 constant into a >> PROC_LOCEXPR, effectively by prepending 0x9e 0x10, such that we have same >> result as with -gdwarf-4: > > Why is DW_FORM_data16 is handled as a block at the moment? > > It just looks wrong that DW_FORM_data16 is treated as a block and not a > constant. It would be more logical to have this end up as a constant > dynamic property, it would be more efficient than evaluating a location > expression. Ah, but the const_val field is a LONGEST, we can't fit a 16 > bytes number in there. But we can encode that value as a location > expression, I see. > Indeed. See PR20991. > However, this high bounds value stored as a location expression won't be > very useful anyway. In most places (see get_discrete_high_bound), we > just return 0 if the property is not constant. But we did evaluate it, > the current interfaces that evaluate dynamic properties return CORE_ADDR > or LONGEST, all 64-bit values, so we could not return that value. So if > the property that you create was ever evaluated, it wouldn't yield a > valid result anyway. I quickly tried to find a way to make GDB evaluate > it to see what happens, but couldn't find one. > > If we ever want such a large high bound value to be useful, I think that > some interfaces and some code would need to be converted to use > arbitrary precision integers (using GMP maybe). And then > dynamic_prop_data::const_val could be a GMP type instead of a LONGEST, > allowing it to store that 16 bytes value. In which case we would > probably undo your patch here, because, if we can store the 16-byte > value as a constant directly, there's no need to convert it to a > location expression. > Yes, if we'd address PR20991 then this patch might be reverted. I don't see that as a problem. What I see as a problem is that we currently give the user the confusing "Unhandled dwarf expression opcode 0xff" which suggests either: - there's a compiler problem, or - gdb needs to handle the dwarf expression opcode 0xff, and neither is correct. With this patch, we give: ... That operation is not available on integers of more than 8 bytes. ... which points nicely to PR20991. Thanks, - Tom