skip-prologue.exp revision 1.1 1 # Copyright 2024 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
16 # Test-case that checks architecture-specific prologue analyzers.
17
18 standard_testfile
19
20 if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
21 {nodebug}] } {
22 return -1
23 }
24
25 proc do_test { f } {
26 set bp_addr ""
27 gdb_test_multiple "break $f" "" {
28 -re -wrap "Breakpoint $::decimal at ($::hex)" {
29 set bp_addr $expect_out(1,string)
30 pass $gdb_test_name
31 }
32 }
33
34 if { $bp_addr == "" } {
35 return
36 }
37
38 set prologue_end_addr ""
39 gdb_test_multiple "p /x &${f}_prologue_end" "" {
40 -re -wrap " = ($::hex)" {
41 set prologue_end_addr $expect_out(1,string)
42 pass $gdb_test_name
43 }
44 }
45
46 if { $prologue_end_addr == "" } {
47 return
48 }
49
50 set test {$bp_addr == $prologue_end_addr}
51 if { [expr $test] } {
52 pass $test
53 } elseif { $bp_addr < $prologue_end_addr } {
54 # We'll allow this. For instance, amd64 has a prologue
55 # analyzer that doesn't skip the 3rd instruction here, which saves an
56 # argument register to stack:
57 #
58 # 00000000004004ae <f2>:
59 # 4004ae: 55 push %rbp
60 # 4004af: 48 89 e5 mov %rsp,%rbp
61 # 4004b2: 89 7d fc mov %edi,-0x4(%rbp)
62 # 00000000004004b5 <f2_prologue_end>:
63 #
64 pass "$test (skipped less than possible)"
65 } elseif { $bp_addr > $prologue_end_addr } {
66 fail "$test (skipped too much)"
67 } else {
68 fail "$test"
69 }
70 }
71
72 foreach f { f1 f2 f3 f4 } {
73 with_test_prefix $f {
74 do_test $f
75 }
76 }
77