OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.arch/] [pa-nullify.exp] - Blame information for rev 840

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 2004, 2007, 2008 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 .
15
#
16
# This file is part of the gdb testsuite.
17
 
18
if $tracelevel {
19
    strace $tracelevel
20
}
21
 
22
set prms_id 0
23
set bug_id 0
24
 
25
# Test handling of nullified instructions for the pa target.
26
 
27
switch -glob -- [istarget] {
28
    "hppa-*-*" {
29
        set testfile "pa-nullify"
30
    }
31
    "hppa64-*-*" {
32
        set testfile "pa64-nullify"
33
    }
34
    "*" {
35
        verbose "Skipping hppa nullification tests."
36
        return
37
    }
38
}
39
 
40
set srcfile ${testfile}.s
41
set binfile ${objdir}/${subdir}/${testfile}
42
set gcorefile ${objdir}/${subdir}/${testfile}.gcore
43
 
44
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] != "" } {
45
    unsupported "Testcase compile failed."
46
    return -1
47
}
48
 
49
gdb_exit
50
gdb_start
51
gdb_reinitialize_dir $srcdir/$subdir
52
gdb_load ${binfile}
53
 
54
# In the first test, we do a "step" on a function whose last instruction
55
# contains a branch-with-nullify.  The instruction in the delay slot belongs
56
# to the next function.  We verify that when we step off the first function
57
# that we end up back at the caller and not at the second instruction.
58
 
59
gdb_breakpoint foo
60
gdb_test "run" "Breakpoint 1, .* in foo.*" "Breakpoint at foo"
61
 
62
set test "stepi till main"
63
gdb_test_multiple "stepi" "${test}" {
64
  -re ".*in foo.*$gdb_prompt $" {
65
    send_gdb "stepi\n"
66
    exp_continue -continue_timer
67
  }
68
  -re ".*in bar.*$gdb_prompt $" {
69
    fail $test
70
  }
71
  -re ".*in main.*$gdb_prompt $" {
72
    pass $test
73
  }
74
}
75
 
76
# In the second test, we verify that we can get a proper backtrace
77
# even when we are in a nullified instruction that belongs to the next function.
78
# We also verify that when stepping over a branch-with-nullify insn that we
79
# stay on the same insn for two steps.
80
 
81
proc get_addr_of_sym { sym } {
82
  set addr 0
83
  global gdb_prompt
84
  global hex
85
 
86
  set test "get address of $sym"
87
  gdb_test_multiple "print $sym" $test {
88
    -re ".*($hex) <$sym>.*$gdb_prompt $" {
89
      set addr $expect_out(1,string)
90
      pass $test
91
    }
92
  }
93
 
94
  return $addr
95
}
96
 
97
if { ! [ runto_main ] } then { gdb_suppress_tests; }
98
 
99
set foo [get_addr_of_sym "foo"]
100
set bar [get_addr_of_sym "bar"]
101
set foo_last "(bar - 4)"
102
 
103
gdb_breakpoint "*$foo_last"
104
 
105
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*"
106
gdb_test "backtrace" "in foo.*in main.*" "Backtrace from last insn in foo"
107
gdb_test "stepi" "in foo.*" "stepi to nullified instruction stays in foo"
108
gdb_test "backtrace" "in foo.*in main.*" "Backtrace from nullified insn"
109
gdb_test "stepi" "in main.*" "stepi to main"
110
 
111
# In the third test, we verify that backtraces from nullified instructions
112
# work even in coredumps
113
 
114
proc gen_core { test } {
115
  global gcorefile
116
  global gdb_prompt
117
  set gcore_works 0
118
  set escapedfilename [string_to_regexp $gcorefile]
119
 
120
  # gcore is not yet implemented for HPUX
121
  setup_xfail hppa*-*-hpux*
122
 
123
  gdb_test_multiple "gcore $gcorefile" "$test: gcore" {
124
    -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
125
      pass "$test: gcore"
126
      set gcore_works 1
127
    }
128
    -re "Undefined command.*$gdb_prompt $" {
129
      fail "$test: gcore (undefined command)"
130
    }
131
    -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
132
      fail "$test: gcore (can't create corefile)"
133
    }
134
  }
135
 
136
  return $gcore_works
137
}
138
 
139
proc test_core_bt { test } {
140
  global gcorefile
141
 
142
  gdb_test "core $gcorefile" "Core was generated by.*" \
143
    "$test: load core file" "A program is being debugged already.*" "y"
144
 
145
  gdb_test "backtrace" ".*in foo.*in main.*" "$test: backtrace in gcore"
146
}
147
 
148
set test "core at last insn in foo"
149
if { ! [ runto_main ] } then { gdb_suppress_tests; }
150
gdb_breakpoint "*$foo_last"
151
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
152
if [gen_core $test] {
153
  test_core_bt $test
154
}
155
 
156
set test "core at nullified insn"
157
if { ! [ runto_main ] } then { gdb_suppress_tests; }
158
gdb_breakpoint "*$foo_last"
159
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
160
gdb_test "stepi" ".*in foo.*" "$test: step to nullified instruction"
161
if [gen_core $test] {
162
  test_core_bt $test
163
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.