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