From patchwork Sun Dec 8 10:29:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 36586 Received: (qmail 37093 invoked by alias); 8 Dec 2019 10:29:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 37084 invoked by uid 89); 8 Dec 2019 10:29:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=artificial X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Dec 2019 10:29:46 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E1EA6AEF1; Sun, 8 Dec 2019 10:29:43 +0000 (UTC) Subject: [committed] Fix inter-CU references using intra-CU form in imported-unit To: Kevin Buettner , gdb-patches@sourceware.org References: <20191014001842.27413-1-kevinb@redhat.com> <20191014001842.27413-3-kevinb@redhat.com> From: Tom de Vries Message-ID: Date: Sun, 8 Dec 2019 11:29:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <20191014001842.27413-3-kevinb@redhat.com> X-IsSubscribed: yes [ was: Re: [PATCH 2/2] Test case for BZ 25065 ] On 14-10-2019 02:18, Kevin Buettner wrote: > + cu {} { > + compile_unit { > + {language @DW_LANG_C_plus_plus} > + {name ""} > + } { > + imported_unit { > + {import :$cu_label ref_addr} > + } > + subprogram { > + {abstract_origin :$main_label} > + {low_pc $main_start addr} > + {high_pc "$main_start + $main_length" addr} > + } { > + subprogram { > + {abstract_origin :$doit_label} > + {low_pc $doit_start addr} > + {high_pc "$doit_start + $doit_length" addr} > + } { > + formal_parameter { > + {abstract_origin :$doit_self_label} > + } > + } > + DW_TAG_variable { > + {abstract_origin :$foo_label} > + {location 4 data1} > + } > + } > + } > + } > + > + cu {} { > + cu_label: compile_unit { > + {language @DW_LANG_C_plus_plus} > + {name "imported_unit.c"} > + } { > + int_label: base_type { > + {byte_size $int_size sdata} > + {encoding @DW_ATE_signed} > + {name int} > + } > + > + main_label: subprogram { > + {name main} > + {type :$int_label} > + {external 1 flag} > + } { > + Foo_label: class_type { > + {name Foo} > + {byte_size 1 sdata} > + } { > + doit_label: subprogram { > + {name doit} > + {type :$int_label} > + {accessibility 1 DW_FORM_data1} > + } { > + doit_self_label: formal_parameter { > + {name this} > + {artificial 1 DW_FORM_flag_present} > + {type :$Foo_pointer_type} > + } > + } > + Foo_pointer_type: pointer_type { > + {byte_size $addr_size sdata} > + {type :$Foo_label} > + } > + } > + foo_label: DW_TAG_variable { > + {name foo} > + {type :$Foo_label} > + } > + } > + } > + } > +} Hi, I've committed the test-case fix attached below. Thanks, - Tom Fix inter-CU references using intra-CU form in imported-unit When running the gdb testsuite with the cc-with-dwz board, I run into: ... Running gdb/testsuite/gdb.dwarf2/imported-unit.exp ... gdb compile failed, dwz: gdb.dwarf2/imported-unit/imported-unit: \ Couldn't find DIE referenced by DW_AT_abstract_origin cc-with-tweaks.sh: dwz did not modify gdb.dwarf2/imported-unit/imported-unit. ... The problem is that the DW_AT_abstract_origin reference here: ... <0>: Abbrev Number: 2 (DW_TAG_compile_unit) <1>: Abbrev Number: 4 (DW_TAG_subprogram) DW_AT_abstract_origin: <0x142> DW_AT_low_pc : 0x4004b2 DW_AT_high_pc : 0x4004c8 ... referring to a DIE in another compilation unit here: ... <0><129>: Abbrev Number: 2 (DW_TAG_compile_unit) <1><142>: Abbrev Number: 4 (DW_TAG_subprogram) <143> DW_AT_name : main <148> DW_AT_type : <0x13b> <14c> DW_AT_external : 1 ... is encoded using intra-CU reference form DW_FORM_ref4 instead of intra-CU reference DW_FORM_ref_addr: ... 4 DW_TAG_subprogram [has children] DW_AT_abstract_origin DW_FORM_ref4 DW_AT_low_pc DW_FORM_addr DW_AT_high_pc DW_FORM_addr DW_AT value: 0 DW_FORM value: 0 ... Fix this in the DWARF assembler by making all inter-CU references use the '%' label prefix. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-12-08 Tom de Vries * gdb.dwarf2/imported-unit.exp: Fix inter-CU references. Change-Id: I690ff18c3943705ed478453531b176ff74700f3c --- gdb/testsuite/gdb.dwarf2/imported-unit.exp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit.exp b/gdb/testsuite/gdb.dwarf2/imported-unit.exp index 25d44874c12..bf535120349 100644 --- a/gdb/testsuite/gdb.dwarf2/imported-unit.exp +++ b/gdb/testsuite/gdb.dwarf2/imported-unit.exp @@ -73,24 +73,24 @@ Dwarf::assemble $asm_file { {name ""} } { imported_unit { - {import :$cu_label ref_addr} + {import %$cu_label} } subprogram { - {abstract_origin :$main_label} + {abstract_origin %$main_label} {low_pc $main_start addr} {high_pc "$main_start + $main_length" addr} } { subprogram { - {abstract_origin :$doit_label} + {abstract_origin %$doit_label} {low_pc $doit_start addr} {high_pc "$doit_start + $doit_length" addr} } { formal_parameter { - {abstract_origin :$doit_self_label} + {abstract_origin %$doit_self_label} } } DW_TAG_variable { - {abstract_origin :$foo_label} + {abstract_origin %$foo_label} {location 4 data1} } }