Imported Upstream version 7.9
[platform/upstream/gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-skip-prologue.exp
1 # Copyright 2011-2015 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15 load_lib dwarf.exp
16
17 # Test multiple location breakpoints vs. prologue analysis on -O2 -g code.
18 # when the first statement of a function is an inlined function GDB could
19 # crash.  Map of this testcase:
20
21 # File name                            Line number    Starting address
22 # main.c                                         5    func_start
23 # other.c                                        1    func0
24 #       `inlined' called at main.c line 8
25 # main.c                                         9    func1
26 #       func1 = Breakpoint location 1
27 # other.c                                        1    func2
28 #       `inlined2' called at main.c line 11
29 # main.c                                         9    func3
30 #       func3 = Breakpoint location 2
31 #       `otherinline' called at main.c line 9
32 # end of main                                         func_end
33
34 # This test can only be run on targets which support DWARF-2 and use gas.
35 if {![dwarf2_support]} {
36     return 0  
37 }
38
39 standard_testfile
40 set executable ${testfile}
41
42 if [is_ilp32_target] {
43     set ptrbits 32
44 } else {
45     set ptrbits 64
46 }
47
48 if { [build_executable ${testfile}.exp ${executable} \
49           "${testfile}.c ${testfile}.S" \
50           [list additional_flags=-DINLINED \
51                 additional_flags=-DPTRBITS=$ptrbits]] == -1 } {
52     return -1
53 }
54
55 # We need those symbols global to access them from the .S file.
56 set test "strip stub symbols"
57 set objcopy_program [gdb_find_objcopy]
58 set result [catch "exec $objcopy_program                                                        \
59                         -N func0 -N func1 -N func2 -N func3         -N func_start -N func_end   \
60                         -N fund0 -N fund1 -N fund2 -N fund3 -N fund -N fund_start               \
61                         ${binfile}" output]
62 verbose "result is $result"
63 verbose "output is $output"
64 if {$result != 0} {
65     fail $test
66     return
67 }
68 pass $test
69
70 clean_restart $executable
71
72 if ![runto_main] {
73     return -1
74 }
75
76 gdb_breakpoint "func"
77 gdb_continue_to_breakpoint "func"
78
79 # Sanity check GDB has really found 2 locations
80 gdb_test {info break $bpnum} "\r\n2\\.1\[ \t\]\[^\n\]*\r\n2\\.2\[ \t\]\[^\n\]*" "2 locations found"
81
82 gdb_test "p v" " = 0" "no statement got executed"