]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/fission-absolute-dwo.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / fission-absolute-dwo.exp
1 # Copyright 2021-2023 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 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
19 # infrastructure.
20
21 load_lib dwarf.exp
22
23 # This test can only be run on targets which support DWARF-2 and use gas.
24 if {![dwarf2_support]} {
25 return 0
26 }
27
28 standard_testfile .c -dw.S
29
30 set asm_file [standard_output_file $srcfile2]
31 Dwarf::assemble $asm_file {
32 global srcfile binfile objdir
33
34 set debug_addr_lbl ".unknown!!"
35
36 # The information that will be split out into the .dwo file.
37 cu {fission 1} {
38
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
41 # non-split CU later.
42 set debug_addr_lbl [debug_addr_label]
43
44 compile_unit {
45 {language @DW_LANG_C}
46 {name ${srcfile}}
47 {DW_AT_comp_dir ${objdir}}
48 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
49 } {
50 declare_labels int4_type struct_type
51
52 int4_type: DW_TAG_base_type {
53 {DW_AT_byte_size 4 DW_FORM_sdata}
54 {DW_AT_encoding @DW_ATE_signed}
55 {DW_AT_name integer}
56 }
57
58 struct_type: DW_TAG_structure_type {
59 {DW_AT_name "foo_t"}
60 {DW_AT_byte_size 12 DW_FORM_sdata}
61 } {
62 member {
63 {name "aa"}
64 {type :$int4_type}
65 {data_member_location 0 data1}
66 }
67 member {
68 {name "bb"}
69 {type :$int4_type}
70 {data_member_location 4 data1}
71 }
72 member {
73 {name "cc"}
74 {type :$int4_type}
75 {data_member_location 8 data1}
76 }
77 }
78
79 DW_TAG_variable {
80 {DW_AT_name global_var}
81 {DW_AT_type :$struct_type}
82 {DW_AT_location {
83 DW_OP_GNU_addr_index [gdb_target_symbol global_var]
84 } SPECIAL_expr}
85 {external 1 flag}
86 }
87
88 subprogram {
89 {external 1 flag}
90 {DW_AT_name main DW_FORM_string}
91 {MACRO_AT_func {main}}
92 }
93 }
94 }
95
96 # The information that will remain in the .o file.
97 cu {} {
98 compile_unit {
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}
103 } {
104 # Nothing.
105 }
106 }
107 }
108
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}]] } {
115 return -1
116 }
117
118 # Now we can start GDB.
119 clean_restart ${testfile}
120
121 if ![runto_main] {
122 return -1
123 }
124
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\\}"