]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/fission-relative-dwo.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / fission-relative-dwo.exp
CommitLineData
1d506c26 1# Copyright 2021-2024 Free Software Foundation, Inc.
56d467f4
CT
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
19load_lib dwarf.exp
20
21# This test can only be run on targets which support DWARF-2 and use gas.
ce8d533e 22require dwarf2_support
56d467f4
CT
23
24standard_testfile .c -dw.S
25
56d467f4
CT
26set asm_file [standard_output_file $srcfile2]
27Dwarf::assemble $asm_file {
28 global srcfile gdb_test_file_name
29
30 set debug_addr_base -1
31
32 # The information that will be split out into the .dwo file.
33 cu {fission 1} {
34
35 # Capture the current index into .debug_addr so we can fill in
36 # DW_AT_GNU_addr_base later.
37 set debug_addr_base [debug_addr_label]
38
39 compile_unit {
40 {language @DW_LANG_C}
41 {name ${srcfile}}
42 {DW_AT_comp_dir .}
43 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
44 } {
45 declare_labels int4_type struct_type
46
47 int4_type: DW_TAG_base_type {
48 {DW_AT_byte_size 4 DW_FORM_sdata}
49 {DW_AT_encoding @DW_ATE_signed}
50 {DW_AT_name integer}
51 }
52
53 struct_type: DW_TAG_structure_type {
54 {DW_AT_name "foo_t"}
55 {DW_AT_byte_size 12 DW_FORM_sdata}
56 } {
57 member {
58 {name "aa"}
59 {type :$int4_type}
60 {data_member_location 0 data1}
61 }
62 member {
63 {name "bb"}
64 {type :$int4_type}
65 {data_member_location 4 data1}
66 }
67 member {
68 {name "cc"}
69 {type :$int4_type}
70 {data_member_location 8 data1}
71 }
72 }
73
74 DW_TAG_variable {
75 {DW_AT_name global_var}
76 {DW_AT_type :$struct_type}
77 {DW_AT_location {
78 DW_OP_GNU_addr_index [gdb_target_symbol global_var]
79 } SPECIAL_expr}
80 {external 1 flag}
81 }
82
83 subprogram {
84 {external 1 flag}
85 {DW_AT_name main DW_FORM_string}
86 {MACRO_AT_func {main}}
87 }
88 }
89 }
90
91 # The information that will remain in the .o file.
92 cu {} {
93 compile_unit {
94 {DW_AT_GNU_dwo_name ${gdb_test_file_name}.dwo DW_FORM_strp}
95 {DW_AT_comp_dir .}
96 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
97 {DW_AT_GNU_addr_base $debug_addr_base}
98 } {
99 # Nothing.
100 }
101 }
102}
103
104# Compile both source files to create the executable. As we compile
105# ASM_FILE we split out the debug information into the dwo file.
106set object_file [standard_output_file ${testfile}.o]
107if { [build_executable_and_dwo_files "${testfile}.exp" ${testfile} {nodebug} \
108 [list $asm_file {nodebug split-dwo} ${object_file}] \
109 [list $srcfile {nodebug}]] } {
56d467f4
CT
110 return -1
111}
112
113# Now we can start GDB.
114clean_restart ${testfile}
115
116if ![runto_main] {
117 return -1
118}
119
120# Print the type of global_var. This type information is entirely
121# fictional, it only exists in the DWARF. If we don't have the DWARF
122# information then there's no way we can print this.
123gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}"