From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 482A03858D38 for ; Thu, 10 Nov 2022 15:45:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 482A03858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id EDA671E0D3; Thu, 10 Nov 2022 10:45:28 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1668095129; bh=QkY1ejsMtqLD5Ub3Cz3ItHkxVByZCuv7ZtkvgomVR1U=; h=Date:Subject:To:References:From:In-Reply-To:From; b=XWLi5BM7t8O/oRMXIwpXmWNzfqW24gerDjecNcvtqfC3eYZG9s1buhHp11HWw27mg ogDxAkoYcFmfUUxcxxFjcyy2K5sy2+6Dj27yHIcJDQTBKfAPKxHOCZO63hqg3nRd3i nVFi8XMtsFvUZUfv6DQ+d0pqZPnQwzrkjS9WAFL4= Message-ID: <47da246b-e808-deed-0e24-8c9da943442d@simark.ca> Date: Thu, 10 Nov 2022 10:45:28 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v2 2/2] gdb/c++: Improve error messages in overload resolution Content-Language: en-US To: Bruno Larsen , gdb-patches@sourceware.org References: <20221104154744.418906-1-blarsen@redhat.com> <20221104154744.418906-3-blarsen@redhat.com> <860e668a-75b0-3a6a-26e1-5fe11f87ce53@simark.ca> <5eb453d2-5583-eec2-3aa2-ea0880894a71@redhat.com> From: Simon Marchi In-Reply-To: <5eb453d2-5583-eec2-3aa2-ea0880894a71@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,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 11/10/22 10:29, Bruno Larsen via Gdb-patches wrote: > On 10/11/2022 16:19, Simon Marchi wrote: >> >> On 11/4/22 11:47, Bruno Larsen via Gdb-patches wrote: >>> When resolving overloaded functions, GDB relies on knowing relationships >>> between types, i.e. if a type inherits from another. However, some >>> compilers may not add complete information for given types as a way to >>> reduce unnecessary debug information. In these cases, GDB would just say >>> that it couldn't resolve the method or function, with no extra >>> information. >>> >>> The problem is that sometimes the user may not know that the type >>> information is incomplete, and may just assume that there is a bug in >>> GDB. To improve the user experience, we attempt to detect if the >>> overload match failed because of an incomplete type, and warn the user >>> of this. >>> >>> This commit also adds a testcase confirming that the message is only >>> triggered in the correct scenario. This test was not developed as an >>> expansion of gdb.cp/overload.cc because it needed the dwarf assembler, >>> and porting all of overload.cc seemed unnecessary. >> I get some new failures starting from this patch (tested both on Ubuntu >> 22.04 and a fairly recent Arch Linux): >> >> FAIL: gdb.cp/converts.exp: p foo3_1 (0, 1) >> FAIL: gdb.cp/converts.exp: p foo1_7(ta) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo1_type_check (123) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo2_type_check (0, 1) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo2_type_check (1, 0) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo2_type_check (1, 1) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo3_type_check (0, 0, 1) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo3_type_check (0, 1, 0) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo3_type_check (1, 0, 0) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo3_type_check (0, 1, 1) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo3_type_check (1, 1, 0) >> FAIL: gdb.cp/converts.exp: strict type checking on: p foo3_type_check (1, 1, 1) > > /me facepalms > > I'm very sorry, got tunnel visioned in fixing the issue, forgot to run the rest of the tests. Will fix all of these. > >> FAIL: gdb.cp/enum-class.exp: print overload2(77) >> FAIL: gdb.cp/enum-class.exp: print overload3(E1::THERE) >> FAIL: gdb.cp/koenig.exp: p foo(ix) >> FAIL: gdb.cp/koenig.exp: p foo (p_union) >> FAIL: gdb.cp/local-static.exp: c++: print S::method() >> FAIL: gdb.cp/local-static.exp: c++: print S::inline_method() >> FAIL: gdb.cp/local-static.exp: c++: print S2::method() >> FAIL: gdb.cp/local-static.exp: c++: print S2::inline_method() >> FAIL: gdb.cp/operator.exp: namespace alias >> FAIL: gdb.cp/operator.exp: imported declaration >> FAIL: gdb.cp/pr12028.exp: p D::foo(b) >> FAIL: gdb.cp/rvalue-ref-overload.exp: passing lvalue arg to rvalue parameter > However, I'm not getting these fails... is gcc only emitting delaration DIEs for these tests, or is it something else? An example of failure is: 89 print overload2(77)^M 90 Cannot resolve function overload2 to any overloaded instance.^M 91 (gdb) FAIL: gdb.cp/enum-class.exp: print overload2(77) 92 print overload3(E1::THERE)^M 93 Cannot resolve function overload3 to any overloaded instance.^M 94 (gdb) FAIL: gdb.cp/enum-class.exp: print overload3(E1::THERE) I do have these DIEs for overload2: 0x00000658: DW_TAG_subprogram DW_AT_external [DW_FORM_flag_present] (true) DW_AT_name [DW_FORM_strp] ("overload2") DW_AT_decl_file [DW_FORM_implicit_const] ("/home/simark/src/binutils-gdb/gdb/testsuite/gdb.cp/enum-class.cc") DW_AT_decl_line [DW_FORM_data1] (35) DW_AT_decl_column [DW_FORM_implicit_const] (5) DW_AT_linkage_name [DW_FORM_strp] ("_Z9overload22E2") DW_AT_type [DW_FORM_ref4] (0x000005b8 "int") DW_AT_low_pc [DW_FORM_addr] (0x000000000000114d) DW_AT_high_pc [DW_FORM_data8] (0x000000000000000e) DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_call_frame_cfa) DW_AT_call_all_calls [DW_FORM_flag_present] (true) DW_AT_sibling [DW_FORM_ref4] (0x00000689) 0x0000067c: DW_TAG_formal_parameter DW_AT_name [DW_FORM_string] ("v") DW_AT_decl_file [DW_FORM_implicit_const] ("/home/simark/src/binutils-gdb/gdb/testsuite/gdb.cp/enum-class.cc") DW_AT_decl_line [DW_FORM_data1] (35) DW_AT_decl_column [DW_FORM_data1] (0x13) DW_AT_type [DW_FORM_ref4] (0x000005bf "E2") DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg -20) 0x00000688: NULL 0x00000689: DW_TAG_subprogram DW_AT_external [DW_FORM_flag_present] (true) DW_AT_name [DW_FORM_strp] ("overload2") DW_AT_decl_file [DW_FORM_implicit_const] ("/home/simark/src/binutils-gdb/gdb/testsuite/gdb.cp/enum-class.cc") DW_AT_decl_line [DW_FORM_data1] (34) DW_AT_decl_column [DW_FORM_implicit_const] (5) DW_AT_linkage_name [DW_FORM_strp] ("_Z9overload22E1") DW_AT_type [DW_FORM_ref4] (0x000005b8 "int") DW_AT_low_pc [DW_FORM_addr] (0x0000000000001141) DW_AT_high_pc [DW_FORM_data8] (0x000000000000000c) DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_call_frame_cfa) DW_AT_call_all_calls [DW_FORM_flag_present] (true) DW_AT_sibling [DW_FORM_ref4] (0x000006ba) 0x000006ad: DW_TAG_formal_parameter DW_AT_name [DW_FORM_string] ("v") DW_AT_decl_file [DW_FORM_implicit_const] ("/home/simark/src/binutils-gdb/gdb/testsuite/gdb.cp/enum-class.cc") DW_AT_decl_line [DW_FORM_data1] (34) DW_AT_decl_column [DW_FORM_data1] (0x13) DW_AT_type [DW_FORM_ref4] (0x0000059f "E1") DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg -20) 0x000006b9: NULL It's gcc 11.3 for Ubuntu 22.04, gcc 12.2 for Arch Linux. Simon