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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc3/] [gdb/] [testsuite/] [gdb.base/] [signull.exp] - Blame information for rev 513

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# This testcase is part of GDB, the GNU debugger.
2
 
3
# Copyright 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4
 
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program.  If not, see .
17
 
18
# Check that GDB can trigger and backtrace SIGSEGV signal stacks
19
# caused by both accessing (data) and executing (code) at address
20
# zero.
21
 
22
# On function descriptor architectures, a zero descriptor, instead of
23
# a NULL pointer, is used.  That way the NULL code test always
24
# contains a zero code reference.
25
 
26
# For recovery, sigjmp/longjmp are used.
27
 
28
# This also tests backtrace/gdb1476.
29
 
30
if [target_info exists gdb,nosignals] {
31
    verbose "Skipping signull.exp because of nosignals."
32
    continue
33
}
34
 
35
if $tracelevel {
36
    strace $tracelevel
37
}
38
 
39
 
40
set testfile "signull"
41
set srcfile ${testfile}.c
42
set binfile ${objdir}/${subdir}/${testfile}
43
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
44
    untested signull.exp
45
    return -1
46
}
47
 
48
gdb_exit
49
gdb_start
50
gdb_reinitialize_dir $srcdir/$subdir
51
gdb_load ${binfile}
52
 
53
#
54
# Run to `main' where we begin our tests.
55
#
56
 
57
if ![runto_main] then {
58
    gdb_suppress_tests
59
}
60
 
61
# If we can examine what's at memory address 0, it is possible that we
62
# could also execute it.  This could probably make us run away,
63
# executing random code, which could have all sorts of ill effects,
64
# especially on targets without an MMU.  Don't run the tests in that
65
# case.
66
 
67
gdb_test_multiple "x 0" "memory at address 0" {
68
    -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
69
    -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
70
    -re ".*$gdb_prompt $" {
71
        untested "Memory at address 0 is possibly executable"
72
        return
73
    }
74
}
75
 
76
# If an attempt to call a NULL pointer leaves the inferior in main,
77
# then function pointers are descriptors, probe this and remember the
78
# result.
79
 
80
gdb_test_no_output "set test = code_entry_point" \
81
    "set for function pointer probe"
82
set test "probe function pointer"
83
set function_pointer code_entry_point
84
set signame "SIGSEGV"
85
gdb_test_multiple "continue" "$test" {
86
    -re "Program received signal SIGSEGV.*bowler .*$gdb_prompt $" {
87
        set function_pointer code_descriptor
88
        pass "$test (function descriptor)"
89
    }
90
    -re "Program received signal SIGSEGV.*0.*$gdb_prompt $" {
91
        pass "$test (function entry-point)"
92
    }
93
    -re "Program received signal SIGBUS.*0.*$gdb_prompt $" {
94
        set signame SIGBUS
95
        pass "$test (function entry-point)"
96
    }
97
}
98
 
99
# Re-start from scratch, breakpoint the bowler so that control is
100
# regained after each test, and run up to that.
101
rerun_to_main
102
gdb_test "break bowler"
103
gdb_test "break keeper"
104
# By default Stop:Yes Print:Yes Pass:Yes
105
gdb_test "handle SIGSEGV" "SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault"
106
gdb_test "handle SIGBUS" "SIGBUS.*Yes.*Yes.*Yes.*Bus error"
107
 
108
# For the given signal type, check that: the SIGSEGV occures; a
109
# backtrace from the SEGV works; the sigsegv is delivered; a backtrace
110
# through the SEGV works.
111
 
112
proc test_segv { name tag bt_from_segv bt_from_keeper } {
113
    global signame
114
    gdb_test continue "Breakpoint.* bowler.*" "${name}; start with the bowler"
115
    # NB: Don't use $tag in the testname - changes across systems.
116
    gdb_test_no_output "set test = $tag" "${name}; select the pointer type"
117
    gdb_test continue "Program received signal ${signame}.*" \
118
        "${name}; take the ${signame}"
119
    gdb_test backtrace $bt_from_segv "${name}; backtrace from ${signame}"
120
    gdb_test continue "Breakpoint.* keeper.*" "${name}; continue to the keeper"
121
    gdb_test backtrace $bt_from_keeper "${name}; backtrace from keeper through ${signame}"
122
}
123
 
124
test_segv "data read" data_read \
125
    {#0 .* bowler .*#1  .* main .*} \
126
    {#0 .* keeper .*#1  .* handler .*#2 .* bowler .*#3  .* main .*}
127
test_segv "data write" data_write \
128
    {#0 .* bowler .*#1  .* main .*} \
129
    {#0 .* keeper .*#1  .* handler .*#2 .* bowler .*#3  .* main .*}
130
test_segv code $function_pointer \
131
    {#0 .* 0x0+ .*#1 .* bowler .*#2  .* main .*} \
132
    {#0 .* keeper .*#1  .* handler .*#2 .* 0x0+ .*#3 .* bowler .*#4 .* main .*}

powered by: WebSVN 2.1.0

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