1 # Copyright 2021 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 test checks that GDB can find the dwo file when the path to the
17 # dwo embedded in the executable is relative.
21 # This test can only be run on targets which support DWARF-2 and use gas.
22 if {![dwarf2_support]} {
26 standard_testfile .c -dw.S
28 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
32 set asm_file [standard_output_file $srcfile2]
33 Dwarf::assemble $asm_file {
34 global srcfile gdb_test_file_name
36 set debug_addr_base -1
38 # The information that will be split out into the .dwo file.
41 # Capture the current index into .debug_addr so we can fill in
42 # DW_AT_GNU_addr_base later.
43 set debug_addr_base [debug_addr_label]
49 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
51 declare_labels int4_type struct_type
53 int4_type: DW_TAG_base_type {
54 {DW_AT_byte_size 4 DW_FORM_sdata}
55 {DW_AT_encoding @DW_ATE_signed}
59 struct_type: DW_TAG_structure_type {
61 {DW_AT_byte_size 12 DW_FORM_sdata}
66 {data_member_location 0 data1}
71 {data_member_location 4 data1}
76 {data_member_location 8 data1}
81 {DW_AT_name global_var}
82 {DW_AT_type :$struct_type}
84 DW_OP_GNU_addr_index [gdb_target_symbol global_var]
91 {DW_AT_name main DW_FORM_string}
92 {MACRO_AT_func {main}}
97 # The information that will remain in the .o file.
100 {DW_AT_GNU_dwo_name ${gdb_test_file_name}.dwo DW_FORM_strp}
102 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
103 {DW_AT_GNU_addr_base $debug_addr_base}
110 # Compile both source files to create the executable. As we compile
111 # ASM_FILE we split out the debug information into the dwo file.
112 set object_file [standard_output_file ${testfile}.o]
113 if { [build_executable_and_dwo_files "${testfile}.exp" ${testfile} {nodebug} \
114 [list $asm_file {nodebug split-dwo} ${object_file}] \
115 [list $srcfile {nodebug}]] } {
116 perror "failed to compile ${gdb_test_file_name}"
120 # Now we can start GDB.
121 clean_restart ${testfile}
127 # Print the type of global_var. This type information is entirely
128 # fictional, it only exists in the DWARF. If we don't have the DWARF
129 # information then there's no way we can print this.
130 gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}"