binutils-gdb/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp

156 lines
3.6 KiB
Plaintext
Raw Normal View History

# Copyright 2011-2017 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
}
Use dwarf assembler in gdb.dwarf2/implptr-64bit.exp This patch adds a DW_OP_implicit_value in dwarf assembler, and uses dwarf assembler in implptr-64bit.exp. Using dwarf assembler in implptr-64bit.exp exposes some limitations in dwarf assembler, - some variables are not evaluated in the caller's context, so we can not pass variable to assembler, like this Dwarf::assemble $asm_file { cu { version $dwarf_version addr_size $addr_size is_64 $is_64 } { } and {DW_AT_type :$struct_label "DW_FORM_ref$ref_addr_size"} this limitation is fixed by adding "uplevel" and "subst". - dwarf assembler doesn't emit DW_FORM_ref_addr for label referencing. this limitation is fixed by adding a new character "%", { type %$int_label } this means we want to emit DW_FORM_ref_addr for label referencing. - we can't set the form of label referencing offset in dwarf assembler. Nowadays, dwarf assembler guesses the form of labels, which is DW_FORM_ref4. However, in implptr-64bit.exp, both DW_FORM_ref4 and DW_FORM_ref8 is used (see REF_ADDR in implptr-64bit.S). This patch adds the flexibility of setting the form of label reference. Both of them below are valid, {DW_AT_type :$struct_label} {DW_AT_type :$struct_label DW_FORM_ref8} the former form is the default DW_FORM_ref4. I compared the .debug_info of objects without and with this patch applied. There is no changes except abbrev numbers. gdb/testsuite: 2017-01-25 Andreas Arnez <arnez@linux.vnet.ibm.com> Yao Qi <yao.qi@linaro.org> * gdb.dwarf2/implptr-64bit.exp: Use dwarf assembler. * gdb.dwarf2/implptr-64bit.S: Remove. * lib/dwarf.exp (Dwarf): Handle character "%". Evaluate some variables in caller's context. Add DW_OP_implicit_value.
2017-01-25 17:24:44 +01:00
standard_testfile main.c
proc test { dwarf_version offset_size addr_size ref_addr_size two_cu } {
Use dwarf assembler in gdb.dwarf2/implptr-64bit.exp This patch adds a DW_OP_implicit_value in dwarf assembler, and uses dwarf assembler in implptr-64bit.exp. Using dwarf assembler in implptr-64bit.exp exposes some limitations in dwarf assembler, - some variables are not evaluated in the caller's context, so we can not pass variable to assembler, like this Dwarf::assemble $asm_file { cu { version $dwarf_version addr_size $addr_size is_64 $is_64 } { } and {DW_AT_type :$struct_label "DW_FORM_ref$ref_addr_size"} this limitation is fixed by adding "uplevel" and "subst". - dwarf assembler doesn't emit DW_FORM_ref_addr for label referencing. this limitation is fixed by adding a new character "%", { type %$int_label } this means we want to emit DW_FORM_ref_addr for label referencing. - we can't set the form of label referencing offset in dwarf assembler. Nowadays, dwarf assembler guesses the form of labels, which is DW_FORM_ref4. However, in implptr-64bit.exp, both DW_FORM_ref4 and DW_FORM_ref8 is used (see REF_ADDR in implptr-64bit.S). This patch adds the flexibility of setting the form of label reference. Both of them below are valid, {DW_AT_type :$struct_label} {DW_AT_type :$struct_label DW_FORM_ref8} the former form is the default DW_FORM_ref4. I compared the .debug_info of objects without and with this patch applied. There is no changes except abbrev numbers. gdb/testsuite: 2017-01-25 Andreas Arnez <arnez@linux.vnet.ibm.com> Yao Qi <yao.qi@linaro.org> * gdb.dwarf2/implptr-64bit.exp: Use dwarf assembler. * gdb.dwarf2/implptr-64bit.S: Remove. * lib/dwarf.exp (Dwarf): Handle character "%". Evaluate some variables in caller's context. Add DW_OP_implicit_value.
2017-01-25 17:24:44 +01:00
global testfile srcfile
Use dwarf assembler in gdb.dwarf2/implptr-64bit.exp This patch adds a DW_OP_implicit_value in dwarf assembler, and uses dwarf assembler in implptr-64bit.exp. Using dwarf assembler in implptr-64bit.exp exposes some limitations in dwarf assembler, - some variables are not evaluated in the caller's context, so we can not pass variable to assembler, like this Dwarf::assemble $asm_file { cu { version $dwarf_version addr_size $addr_size is_64 $is_64 } { } and {DW_AT_type :$struct_label "DW_FORM_ref$ref_addr_size"} this limitation is fixed by adding "uplevel" and "subst". - dwarf assembler doesn't emit DW_FORM_ref_addr for label referencing. this limitation is fixed by adding a new character "%", { type %$int_label } this means we want to emit DW_FORM_ref_addr for label referencing. - we can't set the form of label referencing offset in dwarf assembler. Nowadays, dwarf assembler guesses the form of labels, which is DW_FORM_ref4. However, in implptr-64bit.exp, both DW_FORM_ref4 and DW_FORM_ref8 is used (see REF_ADDR in implptr-64bit.S). This patch adds the flexibility of setting the form of label reference. Both of them below are valid, {DW_AT_type :$struct_label} {DW_AT_type :$struct_label DW_FORM_ref8} the former form is the default DW_FORM_ref4. I compared the .debug_info of objects without and with this patch applied. There is no changes except abbrev numbers. gdb/testsuite: 2017-01-25 Andreas Arnez <arnez@linux.vnet.ibm.com> Yao Qi <yao.qi@linaro.org> * gdb.dwarf2/implptr-64bit.exp: Use dwarf assembler. * gdb.dwarf2/implptr-64bit.S: Remove. * lib/dwarf.exp (Dwarf): Handle character "%". Evaluate some variables in caller's context. Add DW_OP_implicit_value.
2017-01-25 17:24:44 +01:00
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 }
}
}
}
}
}
}
Use dwarf assembler in gdb.dwarf2/implptr-64bit.exp This patch adds a DW_OP_implicit_value in dwarf assembler, and uses dwarf assembler in implptr-64bit.exp. Using dwarf assembler in implptr-64bit.exp exposes some limitations in dwarf assembler, - some variables are not evaluated in the caller's context, so we can not pass variable to assembler, like this Dwarf::assemble $asm_file { cu { version $dwarf_version addr_size $addr_size is_64 $is_64 } { } and {DW_AT_type :$struct_label "DW_FORM_ref$ref_addr_size"} this limitation is fixed by adding "uplevel" and "subst". - dwarf assembler doesn't emit DW_FORM_ref_addr for label referencing. this limitation is fixed by adding a new character "%", { type %$int_label } this means we want to emit DW_FORM_ref_addr for label referencing. - we can't set the form of label referencing offset in dwarf assembler. Nowadays, dwarf assembler guesses the form of labels, which is DW_FORM_ref4. However, in implptr-64bit.exp, both DW_FORM_ref4 and DW_FORM_ref8 is used (see REF_ADDR in implptr-64bit.S). This patch adds the flexibility of setting the form of label reference. Both of them below are valid, {DW_AT_type :$struct_label} {DW_AT_type :$struct_label DW_FORM_ref8} the former form is the default DW_FORM_ref4. I compared the .debug_info of objects without and with this patch applied. There is no changes except abbrev numbers. gdb/testsuite: 2017-01-25 Andreas Arnez <arnez@linux.vnet.ibm.com> Yao Qi <yao.qi@linaro.org> * gdb.dwarf2/implptr-64bit.exp: Use dwarf assembler. * gdb.dwarf2/implptr-64bit.S: Remove. * lib/dwarf.exp (Dwarf): Handle character "%". Evaluate some variables in caller's context. Add DW_OP_implicit_value.
2017-01-25 17:24:44 +01:00
# 32-bit targets do not support any of the testcases; keep quiet there.
set opts {quiet}
set executable ${testfile}-${name}
Use dwarf assembler in gdb.dwarf2/implptr-64bit.exp This patch adds a DW_OP_implicit_value in dwarf assembler, and uses dwarf assembler in implptr-64bit.exp. Using dwarf assembler in implptr-64bit.exp exposes some limitations in dwarf assembler, - some variables are not evaluated in the caller's context, so we can not pass variable to assembler, like this Dwarf::assemble $asm_file { cu { version $dwarf_version addr_size $addr_size is_64 $is_64 } { } and {DW_AT_type :$struct_label "DW_FORM_ref$ref_addr_size"} this limitation is fixed by adding "uplevel" and "subst". - dwarf assembler doesn't emit DW_FORM_ref_addr for label referencing. this limitation is fixed by adding a new character "%", { type %$int_label } this means we want to emit DW_FORM_ref_addr for label referencing. - we can't set the form of label referencing offset in dwarf assembler. Nowadays, dwarf assembler guesses the form of labels, which is DW_FORM_ref4. However, in implptr-64bit.exp, both DW_FORM_ref4 and DW_FORM_ref8 is used (see REF_ADDR in implptr-64bit.S). This patch adds the flexibility of setting the form of label reference. Both of them below are valid, {DW_AT_type :$struct_label} {DW_AT_type :$struct_label DW_FORM_ref8} the former form is the default DW_FORM_ref4. I compared the .debug_info of objects without and with this patch applied. There is no changes except abbrev numbers. gdb/testsuite: 2017-01-25 Andreas Arnez <arnez@linux.vnet.ibm.com> Yao Qi <yao.qi@linaro.org> * gdb.dwarf2/implptr-64bit.exp: Use dwarf assembler. * gdb.dwarf2/implptr-64bit.S: Remove. * lib/dwarf.exp (Dwarf): Handle character "%". Evaluate some variables in caller's context. Add DW_OP_implicit_value.
2017-01-25 17:24:44 +01:00
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