1 1.1 christos # Copyright 2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos # Test-case that checks architecture-specific prologue analyzers. 17 1.1 christos 18 1.1 christos standard_testfile 19 1.1 christos 20 1.1 christos if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ 21 1.1 christos {nodebug}] } { 22 1.1 christos return -1 23 1.1 christos } 24 1.1 christos 25 1.1 christos proc do_test { f } { 26 1.1 christos set bp_addr "" 27 1.1 christos gdb_test_multiple "break $f" "" { 28 1.1 christos -re -wrap "Breakpoint $::decimal at ($::hex)" { 29 1.1 christos set bp_addr $expect_out(1,string) 30 1.1 christos pass $gdb_test_name 31 1.1 christos } 32 1.1 christos } 33 1.1 christos 34 1.1 christos if { $bp_addr == "" } { 35 1.1 christos return 36 1.1 christos } 37 1.1 christos 38 1.1 christos set prologue_end_addr "" 39 1.1 christos gdb_test_multiple "p /x &${f}_prologue_end" "" { 40 1.1 christos -re -wrap " = ($::hex)" { 41 1.1 christos set prologue_end_addr $expect_out(1,string) 42 1.1 christos pass $gdb_test_name 43 1.1 christos } 44 1.1 christos } 45 1.1 christos 46 1.1 christos if { $prologue_end_addr == "" } { 47 1.1 christos return 48 1.1 christos } 49 1.1 christos 50 1.1 christos set test {$bp_addr == $prologue_end_addr} 51 1.1 christos if { [expr $test] } { 52 1.1 christos pass $test 53 1.1 christos } elseif { $bp_addr < $prologue_end_addr } { 54 1.1 christos # We'll allow this. For instance, amd64 has a prologue 55 1.1 christos # analyzer that doesn't skip the 3rd instruction here, which saves an 56 1.1 christos # argument register to stack: 57 1.1 christos # 58 1.1 christos # 00000000004004ae <f2>: 59 1.1 christos # 4004ae: 55 push %rbp 60 1.1 christos # 4004af: 48 89 e5 mov %rsp,%rbp 61 1.1 christos # 4004b2: 89 7d fc mov %edi,-0x4(%rbp) 62 1.1 christos # 00000000004004b5 <f2_prologue_end>: 63 1.1 christos # 64 1.1 christos pass "$test (skipped less than possible)" 65 1.1 christos } elseif { $bp_addr > $prologue_end_addr } { 66 1.1 christos fail "$test (skipped too much)" 67 1.1 christos } else { 68 1.1 christos fail "$test" 69 1.1 christos } 70 1.1 christos } 71 1.1 christos 72 1.1 christos foreach f { f1 f2 f3 f4 } { 73 1.1 christos with_test_prefix $f { 74 1.1 christos do_test $f 75 1.1 christos } 76 1.1 christos } 77