From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7dWJBTjoql/NFAAAWB0awg (envelope-from ) for ; Tue, 10 Nov 2020 14:21:28 -0500 Received: by simark.ca (Postfix, from userid 112) id 0BD131F08B; Tue, 10 Nov 2020 14:21:28 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=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 CC9881E58E for ; Tue, 10 Nov 2020 14:21:26 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3AAD6386F818; Tue, 10 Nov 2020 19:21:26 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 2318A386F03C for ; Tue, 10 Nov 2020 19:21:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2318A386F03C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (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 BC7D01E58E; Tue, 10 Nov 2020 14:21:23 -0500 (EST) Subject: Re: [PATCH][gdb/testsuite] Add gdb.dwarf2/fission-multi-cu-clang.exp To: Tom de Vries , gdb-patches@sourceware.org References: <20201105164017.GA26390@delia> From: Simon Marchi Message-ID: <09afb982-34dc-0488-1df7-7534042b787f@simark.ca> Date: Tue, 10 Nov 2020 14:21:23 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201105164017.GA26390@delia> Content-Type: text/plain; charset=utf-8 Content-Language: fr 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-11-05 11:40 a.m., Tom de Vries wrote: > Hi, > > Test-case gdb.dwarf2/fission-multi-cu.exp uses an .S file that is > intended to represent output of clang -g -gsplit-dwarf -flto. > > PR26834 - "[gsplit-dwarf] Sharing .debug_line entry between CUs results in too > many symtabs" is open about the fact that the test-case doesn't seem to be > properly handled atm. > > The question is how serious that is: the actual output of clang-10 -g > -gsplit-dwarf -flto seems to be handled ok. What seems more serious is that > there's currently no test-case exercising the actual clang output. > > Add a dwarf assembly test-case that resembles clang-10 -g -gsplit-dwarf -flto > output. So, if gdb.dwarf2/fission-multi-cu.exp was meant to represent the output of `clang -g -gsplit-dwarf -flto` but does it wrong, why not just fix that test? Or does it represent gcc's output, which is different from clang's? Concretely, what's the difference between the layout of the two variants? > diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.exp b/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.exp > new file mode 100644 > index 0000000000..db8ef09f21 > --- /dev/null > +++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.exp > @@ -0,0 +1,285 @@ > +# Copyright 2020 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . Can you add a short comment at the top of the exp file saying what the test intends to test? > + > +load_lib dwarf.exp > + > +# We run objcopy locally to split out the .dwo file. > +if [is_remote host] { > + return 0 > +} > + > +# This test can only be run on targets which support DWARF-2 and use gas. > +if ![dwarf2_support] { > + return 0 > +} > + > +# This test can only be run on x86-64 targets. > +if {![istarget x86_64-*] || ![is_lp64_target]} { > + return 0 > +} > + > +standard_testfile .c -dw.S > + > +# The sources we're pretending to compile. > +set src1 fission-multi-cu1.c > +set src2 fission-multi-cu2.c > + > +lassign \ > + [function_range main \ > + "${srcdir}/${subdir}/${srcfile}"] \ > + main_start main_length > + > +lassign \ > + [function_range func \ > + "${srcdir}/${subdir}/${srcfile}"] \ > + func_start func_length > + > +set debug_addr \ > + [list \ > + ".Laddr_table_base0:" \ > + " .quad $func_start" \ > + " .quad $main_start"] > + > +set asm_file [standard_output_file $srcfile2] > +Dwarf::assemble $asm_file { > + declare_labels Llines1 Llines2 int_type_cu1 int_type_cu2 Lmain Lfunc > + global srcdir subdir srcfile src1 src2 > + global main_start main_length > + global func_start func_length > + > + set dwo_file "fission-multi-cu-clang-dw.dwo" > + > + set debug_gnu_pubtypes \ > + [list \ > + ".long .LpubTypes_end0-.LpubTypes_begin0" \ > + ".LpubTypes_begin0:" \ > + ".short 2 # DWARF Version" \ > + ".long .Lcu1_begin # Offset of Compilation Unit Info" \ > + ".long .Lcu1_end - .Lcu1_begin # Compilation Unit Length" \ > + \ > + ".long $int_type_cu1 - .Lcu3_begin # DIE offset" \ > + ".byte 144 # Attributes: TYPE, STATIC" \ > + ".asciz \"int\" # External Name" \ > + \ > + ".long 0 # End Mark" \ > + ".LpubTypes_end0:" \ > + \ > + ".long .LpubTypes_end1-.LpubTypes_begin1" \ > + ".LpubTypes_begin1:" \ > + ".short 2 # DWARF Version" \ > + ".long .Lcu2_begin # Offset of Compilation Unit Info" \ > + ".long .Lcu2_end - .Lcu2_begin # Compilation Unit Length" \ > + \ > + ".long $int_type_cu2 - .Lcu4_begin # DIE offset" \ > + ".byte 144 # Attributes: TYPE, STATIC" \ > + ".asciz \"int\" # External Name" \ > + \ > + ".long 0 # End Mark" \ > + ".LpubTypes_end1:"] > + > + set debug_gnu_pubnames \ > + [list \ > + ".long .LpubNames_end0-.LpubNames_begin0" \ > + ".LpubNames_begin0:" \ > + ".short 2 # DWARF Version" \ > + ".long .Lcu1_begin # Offset of Compilation Unit Info" \ > + ".long .Lcu1_end - .Lcu1_begin # Compilation Unit Length" \ > + \ > + ".long $Lfunc - .Lcu3_begin # DIE offset" \ > + ".byte 48 # Attributes: FUNCTION, EXTERNAL" \ > + ".asciz \"func\" # External Name" \ > + \ > + ".long 0 # End Mark" \ > + ".LpubNames_end0:" \ > + \ > + ".long .LpubNames_end1-.LpubNames_begin1" \ > + ".LpubNames_begin1:" \ > + ".short 2 # DWARF Version" \ > + ".long .Lcu2_begin # Offset of Compilation Unit Info" \ > + ".long .Lcu2_end - .Lcu2_begin # Compilation Unit Length" \ > + \ > + ".long $Lmain - .Lcu4_begin # DIE offset" \ > + ".byte 48 # Attributes: FUNCTION, EXTERNAL" \ > + ".asciz \"main\" # External Name" \ > + \ > + ".long 0 # End Mark" \ > + ".LpubNames_end1:" \ > + ] > + > + cu { } { > + compile_unit { > + {language @DW_LANG_C} > + {name $src1} > + {stmt_list $Llines1 DW_FORM_sec_offset} > + {MACRO_AT_range {func}} > + {GNU_addr_base .Laddr_table_base0} > + {GNU_pubnames 1} > + {GNU_dwo_name $dwo_file} > + {DW_AT_GNU_dwo_id 0x1df972c106d3763d} > + } { > + } > + } > + > + cu {} { > + compile_unit { > + {language @DW_LANG_C} > + {name $src2} > + {stmt_list $Llines2 DW_FORM_sec_offset} > + {MACRO_AT_range {main}} > + {GNU_addr_base .Laddr_table_base0} > + {GNU_pubnames 1} > + {GNU_dwo_name $dwo_file} > + {DW_AT_GNU_dwo_id 0xa9964b563d050e18} > + } { > + } > + } > + > + lines {version 2} Llines1 { > + include_dir "${srcdir}/${subdir}" > + file_name $src1 1 > + > + program { > + {DW_LNE_set_address $func_start} > + {line 20} > + {DW_LNS_copy} > + > + {DW_LNE_set_address func_label} > + {line 21} > + {DW_LNS_copy} > + > + {DW_LNE_set_address func_label_2} > + {DW_LNE_end_sequence} > + } > + } > + > + lines {version 2} Llines2 { > + include_dir "${srcdir}/${subdir}" > + file_name $src2 1 > + > + program { > + {DW_LNE_set_address $main_start} > + {line 22} > + {DW_LNS_copy} > + > + {DW_LNE_set_address main_label} > + {line 23} > + {DW_LNS_copy} > + > + {DW_LNE_set_address main_label_2} > + {DW_LNE_end_sequence} > + } > + } > + > + _defer_output .debug_addr { > + global debug_addr > + _emit [join $debug_addr "\n"] > + } > + > + _defer_output .debug_gnu_pubnames { > + _emit [join $debug_gnu_pubnames "\n"] > + } > + > + _defer_output .debug_gnu_pubtype { > + _emit [join $debug_gnu_pubtypes "\n"] > + } > + > + cu { fission first } { After reading the previous patches, I didn't really understand how what's going on with "fission first" and "fission last" and how it interacts with share_abbrev. Can you give me a very brief summary of how the two .dwo are generated? > + compile_unit { > + {language @DW_LANG_C} > + {name $src1} > + {GNU_dwo_name $dwo_file} > + {DW_AT_GNU_dwo_id 0x1df972c106d3763d} > + } { > + Lfunc: subprogram { > + {external 1 flag} > + {name func} > + {low_pc 0 DW_FORM_GNU_addr_index} > + {high_pc $func_length DW_FORM_data4} > + {type :$int_type_cu1} > + {decl_file 1 udata} > + } { > + DW_TAG_formal_parameter { > + {type :$int_type_cu1} > + {name arg} > + {DW_AT_const_value -1 DW_FORM_sdata} > + } > + } > + int_type_cu1: base_type { > + {name "int"} > + {encoding @DW_ATE_signed} > + {byte_size 4 DW_FORM_sdata} > + } > + } > + } > + > + cu { fission last } { > + compile_unit { > + {language @DW_LANG_C} > + {name $src2} > + {GNU_dwo_name $dwo_file} > + {DW_AT_GNU_dwo_id 0xa9964b563d050e18} > + } { > + Lmain: subprogram { > + {external 1 flag} > + {name main} > + {low_pc 1 DW_FORM_GNU_addr_index} > + {high_pc $main_length DW_FORM_data4} > + {type :$int_type_cu2} > + {decl_file 1 udata} > + } > + int_type_cu2: base_type { > + {name "int"} > + {encoding @DW_ATE_signed} > + {byte_size 4 DW_FORM_sdata} > + } > + } > + } > + > +} > + > +if [build_executable_from_fission_assembler \ > + "$testfile.exp" "$binfile" [list $asm_file] [list $srcfile] {nodebug}] { > + return -1 > +} > + > + > +gdb_exit > +gdb_start > +gdb_reinitialize_dir $srcdir/$subdir clean_restart? Simon