566d756c1a86f59736c4826e7d8f9bf4415c8d12
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / fission-relative-dwo.exp
1 # Copyright 2021 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
16 # This test checks that GDB can find the dwo file when the path to the
17 # dwo embedded in the executable is relative.
18
19 load_lib dwarf.exp
20
21 # This test can only be run on targets which support DWARF-2 and use gas.
22 if {![dwarf2_support]} {
23 return 0
24 }
25
26 standard_testfile .c -dw.S
27
28 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
29 return -1
30 }
31
32 set asm_file [standard_output_file $srcfile2]
33 Dwarf::assemble $asm_file {
34 global srcfile gdb_test_file_name
35
36 set debug_addr_base -1
37
38 # The information that will be split out into the .dwo file.
39 cu {fission 1} {
40
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]
44
45 compile_unit {
46 {language @DW_LANG_C}
47 {name ${srcfile}}
48 {DW_AT_comp_dir .}
49 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
50 } {
51 declare_labels int4_type struct_type
52
53 int4_type: DW_TAG_base_type {
54 {DW_AT_byte_size 4 DW_FORM_sdata}
55 {DW_AT_encoding @DW_ATE_signed}
56 {DW_AT_name integer}
57 }
58
59 struct_type: DW_TAG_structure_type {
60 {DW_AT_name "foo_t"}
61 {DW_AT_byte_size 12 DW_FORM_sdata}
62 } {
63 member {
64 {name "aa"}
65 {type :$int4_type}
66 {data_member_location 0 data1}
67 }
68 member {
69 {name "bb"}
70 {type :$int4_type}
71 {data_member_location 4 data1}
72 }
73 member {
74 {name "cc"}
75 {type :$int4_type}
76 {data_member_location 8 data1}
77 }
78 }
79
80 DW_TAG_variable {
81 {DW_AT_name global_var}
82 {DW_AT_type :$struct_type}
83 {DW_AT_location {
84 DW_OP_GNU_addr_index [gdb_target_symbol global_var]
85 } SPECIAL_expr}
86 {external 1 flag}
87 }
88
89 subprogram {
90 {external 1 flag}
91 {DW_AT_name main DW_FORM_string}
92 {MACRO_AT_func {main}}
93 }
94 }
95 }
96
97 # The information that will remain in the .o file.
98 cu {} {
99 compile_unit {
100 {DW_AT_GNU_dwo_name ${gdb_test_file_name}.dwo DW_FORM_strp}
101 {DW_AT_comp_dir .}
102 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
103 {DW_AT_GNU_addr_base $debug_addr_base}
104 } {
105 # Nothing.
106 }
107 }
108 }
109
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}"
117 return -1
118 }
119
120 # Now we can start GDB.
121 clean_restart ${testfile}
122
123 if ![runto_main] {
124 return -1
125 }
126
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\\}"
This page took 0.036389 seconds and 3 git commands to generate.