diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-01-25 16:24:44 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-01-25 16:24:44 +0000 |
commit | f13a9a0cf7d13b9ea51b0df4b9fa469652f92338 (patch) | |
tree | acf1cdd98977228eb7d17153203a6317ed0859e8 /gdb/testsuite/gdb.dwarf2/implptr-64bit.exp | |
parent | Handle DW_OP_GNU_implicit_pointer in dwarf assembler (diff) | |
download | binutils-gdb-f13a9a0cf7d13b9ea51b0df4b9fa469652f92338.tar.gz binutils-gdb-f13a9a0cf7d13b9ea51b0df4b9fa469652f92338.tar.bz2 binutils-gdb-f13a9a0cf7d13b9ea51b0df4b9fa469652f92338.zip |
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.
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2/implptr-64bit.exp')
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/implptr-64bit.exp | 118 |
1 files changed, 109 insertions, 9 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp b/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp index b4dcbdeb802..963cdc68ef2 100644 --- a/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp +++ b/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp @@ -19,21 +19,121 @@ if {![dwarf2_support]} { return 0 } -standard_testfile .S -set mainfile main.c +standard_testfile main.c proc test { dwarf_version offset_size addr_size ref_addr_size two_cu } { - global testfile srcfile mainfile + global testfile srcfile - # 32-bit targets do not support any of the testcases; keep quiet there. - set opts {quiet} - foreach n { dwarf_version offset_size addr_size ref_addr_size two_cu } { - lappend opts "additional_flags=-D[string toupper $n]=[expr "\$$n"]" + 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 } + } + } + } + } + } } - set name "d${dwarf_version}o${offset_size}a${addr_size}r${ref_addr_size}t${two_cu}" + # 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 "${srcfile} ${mainfile}" $opts] { + if [prepare_for_testing "failed to prepare" $executable "${asm_file} ${srcfile}" $opts] { return -1 } |