Remove superfluous semicolons from testsuite throughout.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / siginfo-obj.exp
CommitLineData
28e7fd62 1# Copyright 2004-2013 Free Software Foundation, Inc.
4aa995e1
PA
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 <http://www.gnu.org/licenses/>.
15
16
17# The program siginfo-obj.c arranges for a signal handler registered
18# using sigaction's sa_sigaction / SA_SIGINFO to be called with
19# si_addr filled in.
20
21# This test confirms that we can inspect signal info using the
22# $_siginfo convenience variable.
23
24if [target_info exists gdb,nosignals] {
25 verbose "Skipping siginfo-obj.exp because of nosignals."
26 continue
27}
28
29if { ! [istarget "i?86-*-linux*"]
30 && ! [istarget "x86_64-*-linux*"]
31 && ! [istarget "arm*-*-linux*"] } {
32 verbose "Skipping siginfo-obj.exp because of lack of support."
33 return
34}
35
4aa995e1
PA
36
37set testfile siginfo-obj
38set srcfile ${testfile}.c
39set binfile ${objdir}/${subdir}/${testfile}
40if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
41 untested "Couldn't compile ${srcfile}.c"
42 return -1
43}
44
45# get things started
46gdb_exit
47gdb_start
48gdb_reinitialize_dir $srcdir/$subdir
49gdb_load ${binfile}
50
51# Advance to main
52if { ![runto_main] } then {
4ec70201 53 gdb_suppress_tests
4aa995e1
PA
54}
55
56# Run to the signal.
57gdb_test "continue" ".*Program received signal SIGSEGV.*" "continue to signal"
58
9015683b
TT
59# Try to generate a core file, for a later test.
60set gcorefile [standard_output_file $testfile.gcore]
61set gcore_created [gdb_gcore_cmd $gcorefile "save a core file"]
62
4aa995e1
PA
63set ssi_addr ""
64set test "Extract si_addr"
65gdb_test_multiple "p \$_siginfo" "$test" {
66 -re "si_addr = ($hex).*$gdb_prompt $" {
67 set ssi_addr $expect_out(1,string)
68 pass "$test"
69 }
70}
71
72set test "Extract si_errno"
73gdb_test_multiple "p \$_siginfo" "$test" {
74 -re "si_errno = (\[0-9\]\+).*$gdb_prompt $" {
75 set ssi_errno $expect_out(1,string)
76 pass "$test"
77 }
78}
79
80set test "Extract si_code"
81gdb_test_multiple "p \$_siginfo" "$test" {
82 -re "si_code = (\[0-9\]\+).*$gdb_prompt $" {
83 set ssi_code $expect_out(1,string)
84 pass "$test"
85 }
86}
87
88set test "Extract si_signo"
89gdb_test_multiple "p \$_siginfo" "$test" {
90 -re "si_signo = (\[0-9\]\+).*$gdb_prompt $" {
91 set ssi_signo $expect_out(1,string)
92 pass "$test"
93 }
94}
95
96set bp_location [gdb_get_line_number "set breakpoint here"]
97
98gdb_test "break $bp_location"
99gdb_test "continue" ".* handler .*" "continue to handler"
100
101gdb_test "p ssi_addr" " = \\(void \\*\\) $ssi_addr"
102gdb_test "p ssi_errno" " = $ssi_errno"
103gdb_test "p ssi_code" " = $ssi_code"
104gdb_test "p ssi_signo" " = $ssi_signo"
105
106# Again, but this time, patch si_addr and check that the inferior sees
107# the changed value.
108
109# Advance to main
110if { ![runto_main] } then {
4ec70201 111 gdb_suppress_tests
4aa995e1
PA
112}
113
114# Run to the signal.
115gdb_test "continue" ".*Program received signal SIGSEGV.*" "continue to signal"
116
117set test "Set si_addr"
118gdb_test "p \$_siginfo._sifields._sigfault.si_addr = 0x666" " = \\(void \\*\\) 0x666"
119gdb_test "p \$_siginfo.si_errno = 666" " = 666"
120gdb_test "p \$_siginfo.si_code = 999" " = 999"
121gdb_test "p \$_siginfo.si_signo = 11" " = 11"
122
123gdb_test "break $bp_location"
124gdb_test "continue" ".* handler .*" "continue to handler"
125
126gdb_test "p ssi_addr" " = \\(void \\*\\) 0x666"
127gdb_test "p ssi_errno" " = 666"
128gdb_test "p ssi_code" " = 999"
129gdb_test "p ssi_signo" " = 11"
9015683b
TT
130
131# Test siginfo preservation in core files.
132if {$gcore_created} {
133 clean_restart $binfile
134
135 gdb_test "core $gcorefile" "Core was generated by.*" \
136 "core [file tail $gcorefile]"
137
138 gdb_test "p \$_siginfo.si_signo" " = $ssi_signo" \
139 "p \$_siginfo.si_signo from core file"
140 gdb_test "p \$_siginfo.si_errno" " = $ssi_errno" \
141 "p \$_siginfo.si_errno from core file"
142 gdb_test "p \$_siginfo.si_code" " = $ssi_code" \
143 "p \$_siginfo.si_code from core file"
144 gdb_test "p \$_siginfo._sifields._sigfault.si_addr" \
145 " = \\(void \\*\\) $ssi_addr" \
146 "p \$_siginfo._sifields._sigfault.si_addr from core file"
147}
This page took 0.539852 seconds and 4 git commands to generate.