1 # Copyright 2021-2023 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This is a basic first test for using the testsuite's Dwarf assembler to
17 # create split debug information. There's not unique feature of GDB being
18 # tested here, this exists only as a basic test for the testsuite
23 # This test can only be run on targets which support DWARF-2 and use gas.
24 if {![dwarf2_support]} {
28 standard_testfile .c -dw.S
30 set asm_file [standard_output_file $srcfile2]
31 Dwarf::assemble $asm_file {
32 global srcfile binfile objdir
34 set debug_addr_lbl ".unknown!!"
36 # The information that will be split out into the .dwo file.
39 # Capture a label to the current start of the .debug_addr
40 # section. This will be passed to DW_AT_GNU_addr_base in the
42 set debug_addr_lbl [debug_addr_label]
47 {DW_AT_comp_dir ${objdir}}
48 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
50 declare_labels int4_type struct_type
52 int4_type: DW_TAG_base_type {
53 {DW_AT_byte_size 4 DW_FORM_sdata}
54 {DW_AT_encoding @DW_ATE_signed}
58 struct_type: DW_TAG_structure_type {
60 {DW_AT_byte_size 12 DW_FORM_sdata}
65 {data_member_location 0 data1}
70 {data_member_location 4 data1}
75 {data_member_location 8 data1}
80 {DW_AT_name global_var}
81 {DW_AT_type :$struct_type}
83 DW_OP_GNU_addr_index [gdb_target_symbol global_var]
90 {DW_AT_name main DW_FORM_string}
91 {MACRO_AT_func {main}}
96 # The information that will remain in the .o file.
99 {DW_AT_GNU_dwo_name ${binfile}.dwo DW_FORM_strp}
100 {DW_AT_comp_dir ${objdir}}
101 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
102 {DW_AT_GNU_addr_base $debug_addr_lbl}
109 # Compile both source files to create the executable. As we compile
110 # ASM_FILE we split out the debug information into the dwo file.
111 set object_file [standard_output_file ${testfile}.o]
112 if { [build_executable_and_dwo_files "${testfile}.exp" ${binfile} {nodebug} \
113 [list $asm_file {nodebug split-dwo} ${object_file}] \
114 [list $srcfile {nodebug}]] } {
118 # Now we can start GDB.
119 clean_restart ${testfile}
125 # Print the type of global_var. This type information is entirely
126 # fictional, it only exists in the DWARF. If we don't have the DWARF
127 # information then there's no way we can print this.
128 gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}"