1# Copyright 2020 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16load_lib dwarf.exp 17 18# This test can only be run on targets which support DWARF-2 and use gas. 19if {![dwarf2_support]} { 20 return 0 21}; 22 23standard_testfile main.c .S 24 25set executable ${testfile} 26set asm_file [standard_output_file ${srcfile2}] 27 28# We need to know the size of integer types in order to write some of the 29# debugging info we'd like to generate. 30if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] { 31 return -1 32} 33 34# Create the DWARF. 35Dwarf::assemble $asm_file { 36 declare_labels cu_label main_label int_label 37 declare_labels aaa_label 38 set int_size [get_sizeof "int" 4] 39 40 cu {} { 41 cu_label: partial_unit { 42 {language @DW_LANG_C} 43 {name "imported_unit.c"} 44 } { 45 int_label: base_type { 46 {byte_size $int_size sdata} 47 {encoding @DW_ATE_signed} 48 {name int} 49 } 50 51 main_label: subprogram { 52 {name main} 53 {type :$int_label} 54 {external 1 flag} 55 } 56 } 57 } 58 59 cu {} { 60 compile_unit { 61 {language @DW_LANG_C} 62 {name "<artificial>"} 63 } { 64 subprogram { 65 {abstract_origin %$main_label} 66 {MACRO_AT_range {main}} 67 } 68 } 69 } 70} 71 72if { [prepare_for_testing "failed to prepare" ${testfile} \ 73 [list $srcfile $asm_file] {nodebug}] } { 74 return -1 75} 76 77if { [ensure_gdb_index $binfile] == -1 } { 78 return -1 79} 80 81clean_restart ${binfile} 82 83runto main message 84