aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dwarf2/fission-absolute-dwo.exp
blob: 6f1d07de925b9ad57efaafcec17a45ac980a7b8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Copyright 2021-2023 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This is a basic first test for using the testsuite's Dwarf assembler to
# create split debug information.  There's not unique feature of GDB being
# tested here, this exists only as a basic test for the testsuite
# infrastructure.

load_lib dwarf.exp

# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support

standard_testfile .c -dw.S

set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
    global srcfile binfile objdir

    set debug_addr_lbl ".unknown!!"

    # The information that will be split out into the .dwo file.
    cu {fission 1} {

	# Capture a label to the current start of the .debug_addr
	# section.  This will be passed to DW_AT_GNU_addr_base in the
	# non-split CU later.
	set debug_addr_lbl [debug_addr_label]

	compile_unit {
            {language @DW_LANG_C}
            {name ${srcfile}}
	    {DW_AT_comp_dir ${objdir}}
	    {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
        } {
	    declare_labels int4_type struct_type

	    int4_type: DW_TAG_base_type {
		{DW_AT_byte_size 4 DW_FORM_sdata}
		{DW_AT_encoding  @DW_ATE_signed}
		{DW_AT_name      integer}
	    }

	    struct_type: DW_TAG_structure_type {
		{DW_AT_name "foo_t"}
		{DW_AT_byte_size 12 DW_FORM_sdata}
	    } {
		member {
		    {name "aa"}
		    {type :$int4_type}
		    {data_member_location 0 data1}
		}
		member {
		    {name "bb"}
		    {type :$int4_type}
		    {data_member_location 4 data1}
		}
		member {
		    {name "cc"}
		    {type :$int4_type}
		    {data_member_location 8 data1}
		}
	    }

	    DW_TAG_variable {
		{DW_AT_name global_var}
		{DW_AT_type :$struct_type}
		{DW_AT_location {
		    DW_OP_GNU_addr_index [gdb_target_symbol global_var]
		} SPECIAL_expr}
		{external 1 flag}
	    }

	    subprogram {
		{external 1 flag}
		{DW_AT_name main DW_FORM_string}
		{MACRO_AT_func {main}}
	    }
	}
    }

    # The information that will remain in the .o file.
    cu {} {
	compile_unit {
            {DW_AT_GNU_dwo_name ${binfile}.dwo DW_FORM_strp}
	    {DW_AT_comp_dir ${objdir}}
	    {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
	    {DW_AT_GNU_addr_base $debug_addr_lbl}
        } {
	    # Nothing.
	}
    }
}

# Compile both source files to create the executable.  As we compile
# ASM_FILE we split out the debug information into the dwo file.
set object_file [standard_output_file ${testfile}.o]
if { [build_executable_and_dwo_files "${testfile}.exp" ${binfile} {nodebug} \
	  [list $asm_file {nodebug split-dwo} ${object_file}] \
	  [list $srcfile {nodebug}]] } {
    return -1
}

# Now we can start GDB.
clean_restart ${testfile}

if ![runto_main] {
    return -1
}

# Print the type of global_var.  This type information is entirely
# fictional, it only exists in the DWARF.  If we don't have the DWARF
# information then there's no way we can print this.
gdb_test "p global_var" " = \\{aa = 0, bb = 0, cc = 0\\}"