No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.arch / pa-nullify.exp
blobfcc7f82bde16ebf8b7163a9da379bb3cc179337e
1 # Copyright 2004 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # This file is part of the gdb testsuite.
19 if $tracelevel {
20 strace $tracelevel
23 set prms_id 0
24 set bug_id 0
26 # Test handling of nullified instructions for the pa target.
28 switch -glob -- [istarget] {
29 "hppa-*-*" {
30 set testfile "pa-nullify"
32 "hppa64-*-*" {
33 set testfile "pa64-nullify"
35 "*" {
36 verbose "Skipping hppa nullification tests."
37 return
41 set srcfile ${testfile}.s
42 set binfile ${objdir}/${subdir}/${testfile}
43 set gcorefile ${objdir}/${subdir}/${testfile}.gcore
45 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] != "" } {
46 unsupported "Testcase compile failed."
47 return -1
50 gdb_exit
51 gdb_start
52 gdb_reinitialize_dir $srcdir/$subdir
53 gdb_load ${binfile}
55 # In the first test, we do a "step" on a function whose last instruction
56 # contains a branch-with-nullify. The instruction in the delay slot belongs
57 # to the next function. We verify that when we step off the first function
58 # that we end up back at the caller and not at the second instruction.
60 gdb_breakpoint foo
61 gdb_test "run" "Breakpoint 1, .* in foo.*" "Breakpoint at foo"
63 set test "stepi till main"
64 gdb_test_multiple "stepi" "${test}" {
65 -re ".*in foo.*$gdb_prompt $" {
66 send_gdb "stepi\n"
67 exp_continue -continue_timer
69 -re ".*in bar.*$gdb_prompt $" {
70 fail $test
72 -re ".*in main.*$gdb_prompt $" {
73 pass $test
77 # In the second test, we verify that we can get a proper backtrace
78 # even when we are in a nullified instruction that belongs to the next function.
79 # We also verify that when stepping over a branch-with-nullify insn that we
80 # stay on the same insn for two steps.
82 proc get_addr_of_sym { sym } {
83 set addr 0
84 global gdb_prompt
85 global hex
87 set test "get address of $sym"
88 gdb_test_multiple "print $sym" $test {
89 -re ".*($hex) <$sym>.*$gdb_prompt $" {
90 set addr $expect_out(1,string)
91 pass $test
95 return $addr
98 if { ! [ runto_main ] } then { gdb_suppress_tests; }
100 set foo [get_addr_of_sym "foo"]
101 set bar [get_addr_of_sym "bar"]
102 set foo_last "(bar - 4)"
104 gdb_breakpoint "*$foo_last"
106 gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*"
107 gdb_test "backtrace" "in foo.*in main.*" "Backtrace from last insn in foo"
108 gdb_test "stepi" "in foo.*" "stepi to nullified instruction stays in foo"
109 gdb_test "backtrace" "in foo.*in main.*" "Backtrace from nullified insn"
110 gdb_test "stepi" "in main.*" "stepi to main"
112 # In the third test, we verify that backtraces from nullified instructions
113 # work even in coredumps
115 proc gen_core { test } {
116 global gcorefile
117 global gdb_prompt
118 set gcore_works 0
119 set escapedfilename [string_to_regexp $gcorefile]
121 # gcore is not yet implemented for HPUX
122 setup_xfail hppa*-*-hpux*
124 gdb_test_multiple "gcore $gcorefile" "$test: gcore" {
125 -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
126 pass "$test: gcore"
127 set gcore_works 1
129 -re "Undefined command.*$gdb_prompt $" {
130 fail "$test: gcore (undefined command)"
132 -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
133 fail "$test: gcore (can't create corefile)"
137 return $gcore_works
140 proc test_core_bt { test } {
141 global gcorefile
143 gdb_test "core $gcorefile" "Core was generated by.*" \
144 "$test: load core file" "A program is being debugged already.*" "y"
146 gdb_test "backtrace" ".*in foo.*in main.*" "$test: backtrace in gcore"
149 set test "core at last insn in foo"
150 if { ! [ runto_main ] } then { gdb_suppress_tests; }
151 gdb_breakpoint "*$foo_last"
152 gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
153 if [gen_core $test] {
154 test_core_bt $test
157 set test "core at nullified insn"
158 if { ! [ runto_main ] } then { gdb_suppress_tests; }
159 gdb_breakpoint "*$foo_last"
160 gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
161 gdb_test "stepi" ".*in foo.*" "$test: step to nullified instruction"
162 if [gen_core $test] {
163 test_core_bt $test