aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch
diff options
context:
space:
mode:
authorRandolph Chung <tausq@debian.org>2004-12-03 23:59:53 +0000
committerRandolph Chung <tausq@debian.org>2004-12-03 23:59:53 +0000
commitfe46cd3ab5b2a04cb88f5f34a2d692dc856b3a5a (patch)
treea4fc66eb32398d046eac0d19a30812ca862dc8d6 /gdb/testsuite/gdb.arch
parente1591da4fd88fe7ce7af4f6eb9a597a4abdaf76a (diff)
downloadfsf-binutils-gdb-fe46cd3ab5b2a04cb88f5f34a2d692dc856b3a5a.zip
fsf-binutils-gdb-fe46cd3ab5b2a04cb88f5f34a2d692dc856b3a5a.tar.gz
fsf-binutils-gdb-fe46cd3ab5b2a04cb88f5f34a2d692dc856b3a5a.tar.bz2
2004-12-03 Randolph Chung <tausq@debian.org>
* gdbarch.sh (instruction_nullified): Delete. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * hppa-tdep.c (hppa_target_read_pc): Adjust pc if instruction is nullified. (hppa_unwind_pc): Likewise. (hppa_instruction_nullified): Delete. (hppa_gdbarch_init): Don't set instruction_nullified method. * infrun.c (infwait_states): Remove infwait_nullified_state. (handle_inferior_event): Remove handling of infwait_nullified_state. Remove handling of nullified instructions. testsuite/ * gdb.arch/pa-nullify.exp: New file. * gdb.arch/pa-nullify.s: New file.
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r--gdb/testsuite/gdb.arch/pa-nullify.exp152
-rw-r--r--gdb/testsuite/gdb.arch/pa-nullify.s59
2 files changed, 211 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.arch/pa-nullify.exp b/gdb/testsuite/gdb.arch/pa-nullify.exp
new file mode 100644
index 0000000..4cf5c72
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/pa-nullify.exp
@@ -0,0 +1,152 @@
+# Copyright 2004 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# This file is part of the gdb testsuite.
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+# Test handling of nullified instructions for the pa target.
+
+if ![istarget "hppa*-*-*"] then {
+ verbose "Skipping hppa nullification tests."
+ return
+}
+
+set testfile "pa-nullify"
+set srcfile ${testfile}.s
+set binfile ${objdir}/${subdir}/${testfile}
+set gcorefile ${objdir}/${subdir}/${testfile}.gcore
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] != "" } {
+ unsupported "Testcase compile failed."
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# In the first test, we do a "step" on a function whose last instruction
+# contains a branch-with-nullify. The instruction in the delay slot belongs
+# to the next function. We verify that when we step off the first function
+# that we end up back at the caller and not at the second instruction.
+
+gdb_breakpoint foo
+gdb_test "run" "Breakpoint 1, .* in foo.*" "Breakpoint at foo"
+
+set test "stepi till main"
+gdb_test_multiple "stepi" "${test}" {
+ -re ".*in foo.*$gdb_prompt $" {
+ send_gdb "stepi\n"
+ exp_continue -continue_timer
+ }
+ -re ".*in bar.*$gdb_prompt $" {
+ fail $test
+ }
+ -re ".*in main.*$gdb_prompt $" {
+ pass $test
+ }
+}
+
+# In the second test, we verify that we can get a proper backtrace
+# even when we are in a nullified instruction that belongs to the next function.
+# We also verify that when stepping over a branch-with-nullify insn that we
+# stay on the same insn for two steps.
+
+proc get_addr_of_sym { sym } {
+ set addr 0
+ global gdb_prompt
+ global hex
+
+ set test "get address of $sym"
+ send_gdb "print $sym\n"
+ gdb_test_multiple "print $sym" $test {
+ -re ".*($hex) <$sym>.*$gdb_prompt $" {
+ set addr $expect_out(1,string)
+ pass $test
+ }
+ }
+
+ return $addr
+}
+
+if { ! [ runto_main ] } then { gdb_suppress_tests; }
+
+set foo [get_addr_of_sym "foo"]
+set bar [get_addr_of_sym "bar"]
+set foo_last [expr $bar - 4]
+
+gdb_breakpoint "*$foo_last"
+
+gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*"
+gdb_test "backtrace" "in foo.*in main.*" "Backtrace from last insn in foo"
+gdb_test "stepi" "in foo.*" "stepi to nullified instruction stays in foo"
+gdb_test "backtrace" "in foo.*in main.*" "Backtrace from nullified insn"
+gdb_test "stepi" "in main.*" "stepi to main"
+
+# In the third test, we verify that backtraces from nullified instructions
+# work even in coredumps
+
+proc gen_core { test } {
+ global gcorefile
+ global gdb_prompt
+ set gcore_works 0
+ set escapedfilename [string_to_regexp $gcorefile]
+
+ gdb_test_multiple "gcore $gcorefile" "$test: gcore" {
+ -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
+ pass "$test: gcore"
+ set gcore_works 1
+ }
+ -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
+ fail "$test: gcore"
+ }
+ }
+
+ return $gcore_works
+}
+
+proc test_core_bt { test } {
+ global gcorefile
+
+ gdb_test "core $gcorefile" "Core was generated by.*" \
+ "$test: load core file" "A program is being debugged already.*" "y"
+
+ gdb_test "backtrace" ".*in foo.*in main.*" "$test: backtrace in gcore"
+}
+
+set test "core at last insn in foo"
+if { ! [ runto_main ] } then { gdb_suppress_tests; }
+gdb_breakpoint "*$foo_last"
+gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
+if [gen_core $test] {
+ test_core_bt $test
+}
+
+set test "core at nullified insn"
+if { ! [ runto_main ] } then { gdb_suppress_tests; }
+gdb_breakpoint "*$foo_last"
+gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
+gdb_test "stepi" ".*in foo.*" "$test: step to nullified instruction"
+if [gen_core $test] {
+ test_core_bt $test
+}
diff --git a/gdb/testsuite/gdb.arch/pa-nullify.s b/gdb/testsuite/gdb.arch/pa-nullify.s
new file mode 100644
index 0000000..90269b4
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/pa-nullify.s
@@ -0,0 +1,59 @@
+ .LEVEL 1.1
+ .text
+ .align 4
+.globl foo
+ .type foo, @function
+foo:
+ .PROC
+ .CALLINFO FRAME=64,NO_CALLS,SAVE_SP,ENTRY_GR=3
+ .ENTRY
+ copy %r3,%r1
+ copy %r30,%r3
+ stwm %r1,64(%r30)
+ stw %r26,-36(%r3)
+ ldw -36(%r3),%r19
+ copy %r19,%r28
+ ldo 64(%r3),%r30
+ ldwm -64(%r30),%r3
+ bv,n %r0(%r2)
+ .EXIT
+ .PROCEND
+
+.globl bar
+ .type bar, @function
+bar:
+ .PROC
+ .CALLINFO FRAME=64,NO_CALLS,SAVE_SP,ENTRY_GR=3
+ .ENTRY
+ copy %r3,%r1
+ copy %r30,%r3
+ stwm %r1,64(%r30)
+ ldo 64(%r3),%r30
+ ldwm -64(%r30),%r3
+ bv,n %r0(%r2)
+ .EXIT
+ .PROCEND
+
+.globl main
+ .type main, @function
+main:
+ .PROC
+ .CALLINFO FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3
+ .ENTRY
+ stw %r2,-20(%r30)
+ copy %r3,%r1
+ copy %r30,%r3
+ stwm %r1,64(%r30)
+ stw %r26,-36(%r3)
+ stw %r25,-40(%r3)
+ ldw -36(%r3),%r26
+ bl foo,%r2
+ nop
+ copy %r28,%r19
+ copy %r19,%r28
+ ldw -20(%r3),%r2
+ ldo 64(%r3),%r30
+ ldwm -64(%r30),%r3
+ bv,n %r0(%r2)
+ .EXIT
+ .PROCEND