1 # Copyright 2013-2014 Free Software Foundation, Inc.
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.
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.
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/>.
18 # This test can only be run on targets which support DWARF-2 and use gas.
19 if {![dwarf2_support]} {
23 standard_testfile main.c dwz.S
25 if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
26 object {nodebug}] != ""} {
30 # Start GDB and load object file, compute the function length which is
31 # needed in the Dwarf Assembler below.
32 clean_restart ${testfile}1.o
35 set test "disassemble main"
36 gdb_test_multiple $test $test {
37 -re ".*$hex <\\+($decimal)>:\[^\r\n\]+\r\nEnd of assembler dump\.\r\n$gdb_prompt $" {
38 set main_length $expect_out(1,string)
43 if { $main_length == "" } {
44 # Bail out here, because we can't do the following tests if
45 # $main_length is unknown.
49 # Compute the size of the last instruction.
51 set test "x/2i main+$main_length"
52 gdb_test_multiple $test $test {
53 -re ".*($hex) <main\\+$main_length>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" {
54 set start $expect_out(1,string)
55 set end $expect_out(2,string)
57 set main_length [expr $main_length + $end - $start]
62 if { $main_length == "" } {
63 # Bail out here, because we can't do the following tests if
64 # $main_length is unknown.
71 set asm_file [standard_output_file $srcfile2]
72 Dwarf::assemble $asm_file {
73 declare_labels partial_label int_label int_label2
79 partial_label: partial_unit {} {
83 {high_pc "main + $main_length" addr}
89 compile_unit {{language @DW_LANG_C}} {
90 int_label2: base_type {
93 {encoding @DW_ATE_signed}
99 {const_value 99 data1}
105 {const_value 99 data1}
111 compile_unit {{language @DW_LANG_C}} {
113 {import $partial_label ref_addr}
116 int_label: base_type {
119 {encoding @DW_ATE_signed}
125 {const_value 23 data1}
131 if {[gdb_compile $asm_file ${binfile}2.o object {nodebug}] != ""} {
135 if {[gdb_compile [list ${binfile}1.o ${binfile}2.o] \
136 "${binfile}" executable {}] != ""} {
140 clean_restart ${testfile}
146 gdb_test "p other_int" " = 99"
147 gdb_test "p the_int" " = 23"