From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 146FF385DC00 for ; Fri, 8 May 2020 14:25:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 146FF385DC00 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.220.254]) by mx2.suse.de (Postfix) with ESMTP id D95F0AE2E for ; Fri, 8 May 2020 14:25:14 +0000 (UTC) Date: Fri, 8 May 2020 16:25:09 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [committed][gdb/testsuite] Add gdb.dwarf2/clang-debug-names.c Message-ID: <20200508142508.GA14480@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-Spam-Status: No, score=-19.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 08 May 2020 14:25:23 -0000 Hi, Add test-case with .debug_names section using DW_FORM_ref4. There's currently no support for .debug_names in the dwarf assembler, so we use plain _emit rather than something more structured. Consequently, we cannot use regular declare_labels-generated labels to refer from .debug_names to .debug_info. Instead, we use labels with a predefined name, which we generate using _compute_label, and then define using define_label. This is the test-case for PR25952, so kfail the corresponding test. Tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb/testsuite] Add gdb.dwarf2/clang-debug-names.c gdb/testsuite/ChangeLog: 2020-05-08 Tom de Vries * gdb.dwarf2/clang-debug-names.c: New test. * gdb.dwarf2/clang-debug-names.exp: New file. --- gdb/testsuite/gdb.dwarf2/clang-debug-names.c | 25 ++++ gdb/testsuite/gdb.dwarf2/clang-debug-names.exp | 156 +++++++++++++++++++++++++ 2 files changed, 181 insertions(+) diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names.c b/gdb/testsuite/gdb.dwarf2/clang-debug-names.c new file mode 100644 index 0000000000..d66c192dbf --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/clang-debug-names.c @@ -0,0 +1,25 @@ +/* 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 +main (void) +{ + asm ("main_label: .globl main_label"); + int sum, a, b; + sum = a + b; + return sum; +} diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp new file mode 100644 index 0000000000..8bd60401c4 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp @@ -0,0 +1,156 @@ +# 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 + +# This test can only be run on targets which support DWARF-2 and use gas. +if {![dwarf2_support]} { + return 0 +} + +standard_testfile clang-debug-names.c clang-debug-names-debug.S + +# Set up the DWARF for the test. + +set main_str_label [Dwarf::_compute_label info_string3] +set int_str_label [Dwarf::_compute_label info_string4] +set main_die_label [Dwarf::_compute_label main_die_label] +set int_die_label [Dwarf::_compute_label int_die_label] + +set debug_str \ + [list \ + "$main_str_label:" \ + " .asciz \"main\"" \ + "$int_str_label:" \ + " .asciz \"int\""] + +set debug_names \ + [list \ + " .4byte .Ldebug_names_end - .Ldebug_names_start" \ + ".Ldebug_names_start:" \ + " .short 5 # Header: version" \ + " .short 0 # Header: padding" \ + " .long 1 # Header: compilation unit count" \ + " .long 0 # Header: local type unit count" \ + " .long 0 # Header: foreign type unit count" \ + " .long 2 # Header: bucket count" \ + " .long 2 # Header: name count" \ + " .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 " \ + " # Header: abbreviation table size" \ + " .long 8 # Header: augmentation string size" \ + " .ascii \"LLVM0700\" # Header: augmentation string" \ + " .long .Lcu1_begin # Compilation unit 0" \ + " .long 1 # Bucket 0" \ + " .long 0 # Bucket 1" \ + " .long 193495088 # Hash in Bucket 0" \ + " .long 2090499946 # Hash in Bucket 0" \ + " .long $int_str_label # String in Bucket 0: int" \ + " .long $main_str_label # String in Bucket 0: main" \ + " .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0" \ + " .long .Lnames0-.Lnames_entries0 # Offset in Bucket 0" \ + ".Lnames_abbrev_start0:" \ + " .byte 46 # Abbrev code" \ + " .byte 46 # DW_TAG_subprogram" \ + " .byte 3 # DW_IDX_die_offset" \ + " .byte 19 # DW_FORM_ref4" \ + " .byte 0 # End of abbrev" \ + " .byte 0 # End of abbrev" \ + " .byte 36 # Abbrev code" \ + " .byte 36 # DW_TAG_base_type" \ + " .byte 3 # DW_IDX_die_offset" \ + " .byte 19 # DW_FORM_ref4" \ + " .byte 0 # End of abbrev" \ + " .byte 0 # End of abbrev" \ + " .byte 0 # End of abbrev list" \ + ".Lnames_abbrev_end0:" \ + ".Lnames_entries0:" \ + ".Lnames1:" \ + " .byte 36 # Abbreviation code" \ + " .long $int_die_label - .Lcu1_begin # DW_IDX_die_offset" \ + " .long 0 # End of list: int" \ + ".Lnames0:" \ + " .byte 46 # Abbreviation code" \ + " .long $main_die_label - .Lcu1_begin # DW_IDX_die_offset" \ + " .long 0 # End of list: main" \ + " .p2align 2" \ + ".Ldebug_names_end:"] + +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + global srcdir subdir srcfile + + lassign [function_range main ${srcdir}/${subdir}/${srcfile}] \ + main_start main_length + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_C} + {DW_AT_name clang-debug-names.c} + {DW_AT_comp_dir /tmp} + + } { + global int_die_label + global main_die_label + + define_label $int_die_label + base_type { + {name "int"} + {encoding @DW_ATE_signed} + {byte_size 4 DW_FORM_sdata} + } + + define_label $main_die_label + subprogram { + {name main} + {type :$int_die_label} + {low_pc $main_start addr} + {high_pc "$main_start + $main_length" addr} + } + } + } + + _defer_output .debug_str { + global debug_str + _emit [join $debug_str "\n"] + } + + _defer_output .debug_names { + global debug_names + _emit [join $debug_names "\n"] + } +} + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +set cmd "ptype main" +set pass_re \ + [multi_line \ + $cmd \ + "type = int \\(\\)"] +set kfail_re \ + [multi_line \ + $cmd \ + "type = \\(\\)"] +gdb_test_multiple $cmd "" { + -re -wrap $pass_re { + pass $gdb_test_name + } + -re -wrap $kfail_re { + kfail symtab/25952 $gdb_test_name + } +}