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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
# Copyright 2011-2018 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/>.
load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
return 0
}
standard_testfile main.c
proc test { dwarf_version offset_size addr_size ref_addr_size two_cu } {
global testfile srcfile
set name "d${dwarf_version}o${offset_size}a${addr_size}r${ref_addr_size}t${two_cu}"
# Make some DWARF for the test.
set asm_file [standard_output_file ${testfile}-${name}.S]
Dwarf::assemble $asm_file {
upvar dwarf_version dwarf_version
upvar addr_size addr_size
upvar offset_size offset_size
upvar ref_addr_size ref_addr_size
upvar two_cu two_cu
set is_64 [expr { $offset_size == 4 ? 0 : 1 }]
cu {
version $dwarf_version
addr_size $addr_size
is_64 $is_64
} {
compile_unit {
{ producer "GNU C 4.4.3" }
{ language @DW_LANG_C89 }
{ name 1.c }
} {
declare_labels struct_label variable_label int_label pointer_label
int_label: base_type {
{ byte_size 4 DW_FORM_sdata }
{ DW_AT_encoding @DW_ATE_signed }
{ name int }
}
struct_label: structure_type {
{ name s }
{ byte_size 4 sdata }
} {
member {
{ name f }
{ type :$int_label }
{ data_member_location 0 data1 }
}
}
pointer_label: pointer_type {
{ byte_size $Dwarf::_cu_addr_size sdata }
{ type :$struct_label }
}
variable_label: DW_TAG_variable {
{ name v }
{ location {
DW_OP_implicit_value 0x1 0x1 0x1 0x1
} SPECIAL_expr}
{ type :$struct_label "DW_FORM_ref$ref_addr_size" }
}
if { !$two_cu } {
subprogram {
{ name main }
{ low_pc main addr }
{ high_pc "main+0x100" addr }
{ type %$int_label }
{ external 1 flag }
} {
DW_TAG_variable {
{ name p }
{ location {
GNU_implicit_pointer $variable_label 0
} SPECIAL_expr }
{ type :$pointer_label "DW_FORM_ref$ref_addr_size" }
}
}
}
}
}
if { $two_cu } {
cu {
version $dwarf_version
addr_size $addr_size
is_64 $is_64
} {
compile_unit {
{ producer "GNU C 4.4.3" }
{ language @DW_LANG_C89 }
{ name 1.c }
} {
subprogram {
{ name main }
{ low_pc main addr }
{ high_pc "main+0x100" addr }
{ type %$int_label }
{ external 1 flag }
} {
DW_TAG_variable {
{ name p }
{ location {
GNU_implicit_pointer $variable_label 0
} SPECIAL_expr }
{ type %$pointer_label }
}
}
}
}
}
}
# 32-bit targets do not support any of the testcases; keep quiet there.
set opts {quiet}
set executable ${testfile}-${name}
if [prepare_for_testing "failed to prepare" $executable "${asm_file} ${srcfile}" $opts] {
return -1
}
if ![runto_main] {
return -1
}
gdb_test "p/x p->f" " = 0x1010101" $name
}
# DWARF_VERSION OFFSET_SIZE ADDR_SIZE REF_ADDR_SIZE TWO_CU
test 2 8 4 4 0
test 2 4 8 8 0
test 3 8 4 8 0
test 3 4 8 4 0
test 2 8 4 4 1
test 2 4 8 8 1
test 3 8 4 8 1
test 3 4 8 4 1
|