From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UF85HPsqpF8EdwAAWB0awg (envelope-from ) for ; Thu, 05 Nov 2020 11:40:27 -0500 Received: by simark.ca (Postfix, from userid 112) id 6F5751F08B; Thu, 5 Nov 2020 11:40:27 -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 0D6611E552 for ; Thu, 5 Nov 2020 11:40:26 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5F9039F8417; Thu, 5 Nov 2020 16:40:25 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 5BE2F386F478 for ; Thu, 5 Nov 2020 16:40:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5BE2F386F478 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5BB06ADCD for ; Thu, 5 Nov 2020 16:40:20 +0000 (UTC) Date: Thu, 5 Nov 2020 17:40:18 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Add gdb.dwarf2/fission-multi-cu-clang.exp Message-ID: <20201105164017.GA26390@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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" 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. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/testsuite] Add gdb.dwarf2/fission-multi-cu-clang.exp gdb/testsuite/ChangeLog: 2020-11-05 Tom de Vries * lib/dwarf.exp (_handle_DW_FORM): Add handling of DW_FORM_GNU_addr_index. (_default_form): Add handling of DW_AT_GNU_dwo_name, DW_AT_GNU_addr_base, DW_AT_GNU_pubnames and DW_AT_GNU_dwo_id. * gdb.dwarf2/fission-multi-cu-clang.c: New test. * gdb.dwarf2/fission-multi-cu-clang.exp: New file. --- gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.c | 34 +++ .../gdb.dwarf2/fission-multi-cu-clang.exp | 285 +++++++++++++++++++++ gdb/testsuite/lib/dwarf.exp | 16 +- 3 files changed, 332 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.c b/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.c new file mode 100644 index 0000000000..d7ecef3c65 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu-clang.c @@ -0,0 +1,34 @@ +/* This testcase is part of GDB, the GNU debugger. + + 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 . */ + +int +func (int arg) +{ + asm ("func_label: .globl func_label"); + int res = arg + 1; + asm ("func_label_2: .globl func_label_2"); + return res; +} + +int +main (void) +{ + asm ("main_label: .globl main_label"); + int res = func (-1); + asm ("main_label_2: .globl main_label_2"); + return res; +} 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 . + +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 } { + 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 +# Make sure we can find the .dwo file, regardless of whether we're +# running in parallel mode. +gdb_test_no_output "set debug-file-directory [file dirname $binfile]" \ + "set debug-file-directory" +gdb_load $binfile + +if ![runto_main] { + return -1 +} + +# Do a few basic things to verify we're finding the DWO debug info. + +gdb_test "ptype main" "type = int \\(\\)" +gdb_test "ptype func" "type = int \\(int\\)" + +gdb_test "frame" "#0 *main \\(\\) at .*$src2:$decimal.*" \ + "frame in main" + +gdb_test "break func" "Breakpoint.*at.* file .*$src1, line .*" + +gdb_test "continue" "Breakpoint.* func \\(arg=-1\\).*" \ + "continue to func" + +gdb_test "frame" "#0 *func \\(arg=-1\\) at .*$src1:$decimal.*" \ + "frame in func" diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index c18130b74d..72bc1ee172 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -500,7 +500,8 @@ namespace eval Dwarf { } DW_FORM_ref_udata - - DW_FORM_udata { + DW_FORM_udata - + DW_FORM_GNU_addr_index { _op .uleb128 $value } @@ -573,7 +574,6 @@ namespace eval Dwarf { DW_FORM_strx3 - DW_FORM_strx4 - - DW_FORM_GNU_addr_index - DW_FORM_GNU_str_index - DW_FORM_GNU_ref_alt - DW_FORM_GNU_strp_alt - @@ -628,9 +628,19 @@ namespace eval Dwarf { DW_AT_comp_dir - DW_AT_linkage_name - DW_AT_MIPS_linkage_name - - DW_AT_name { + DW_AT_name - + DW_AT_GNU_dwo_name { return DW_FORM_string } + DW_AT_GNU_addr_base { + return DW_FORM_sec_offset + } + DW_AT_GNU_pubnames { + return DW_FORM_flag_present + } + DW_AT_GNU_dwo_id { + return DW_FORM_data8 + } } return "" }