Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: gdb/testsuite/gdb.base/siginfo-thread.exp

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/testsuite/gdb.base/siginfo-thread.c ('k') | gdb/testsuite/gdb.base/signals.exp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2004, 2007-2008, 2010-2012 Free Software Foundation, Inc. 1 # Copyright 2004-2013 Free Software Foundation, Inc.
2 2
3 # This program is free software; you can redistribute it and/or modify 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 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 5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version. 6 # (at your option) any later version.
7 # 7 #
8 # This program is distributed in the hope that it will be useful, 8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 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/>. 14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 15
16 16
17 # The program siginfo-obj.c arranges for a signal handler registered 17 # Multi-threaded siginfo test.
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 18
24 if [target_info exists gdb,nosignals] { 19 if [target_info exists gdb,nosignals] {
25 verbose "Skipping siginfo-obj.exp because of nosignals." 20 verbose "Skipping siginfo-thread.exp because of nosignals."
26 continue 21 continue
27 } 22 }
28 23
29 if { ! [istarget "i?86-*-linux*"] 24 if { ! [istarget "i?86-*-linux*"]
30 && ! [istarget "x86_64-*-linux*"] 25 && ! [istarget "x86_64-*-linux*"]
31 && ! [istarget "arm*-*-linux*"] } { 26 && ! [istarget "arm*-*-linux*"] } {
32 verbose "Skipping siginfo-obj.exp because of lack of support." 27 verbose "Skipping siginfo-thread.exp because of lack of support."
33 return 28 return
34 } 29 }
35 30
31 standard_testfile .c
36 32
37 set testfile siginfo-obj 33 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" \
38 set srcfile ${testfile}.c 34 » "${binfile}" executable {debug}] != "" } {
39 set binfile ${objdir}/${subdir}/${testfile}
40 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb ug}] != "" } {
41 untested "Couldn't compile ${srcfile}.c"
42 return -1 35 return -1
43 } 36 }
44 37
45 # get things started 38 clean_restart $binfile
46 gdb_exit
47 gdb_start
48 gdb_reinitialize_dir $srcdir/$subdir
49 gdb_load ${binfile}
50 39
51 # Advance to main 40 # Advance to main
52 if { ![runto_main] } then { 41 if { ![runto_main] } then {
53 gdb_suppress_tests; 42 gdb_suppress_tests
54 } 43 }
55 44
56 # Run to the signal. 45 # Run to the signal.
57 gdb_test "continue" ".*Program received signal SIGSEGV.*" "continue to signal" 46 gdb_test "continue" ".*Program received signal SIGSEGV.*" "continue to signal"
58 47
48 # Try to generate a core file, for a later test.
49 set gcorefile [standard_output_file $testfile.gcore]
50 set gcore_created [gdb_gcore_cmd $gcorefile "save a core file"]
51
59 set ssi_addr "" 52 set ssi_addr ""
60 set test "Extract si_addr" 53 set test "Extract si_addr"
61 gdb_test_multiple "p \$_siginfo" "$test" { 54 gdb_test_multiple "p \$_siginfo" "$test" {
62 -re "si_addr = ($hex).*$gdb_prompt $" { 55 -re "si_addr = ($hex).*$gdb_prompt $" {
63 set ssi_addr $expect_out(1,string) 56 set ssi_addr $expect_out(1,string)
64 pass "$test" 57 pass "$test"
65 } 58 }
66 } 59 }
67 60
68 set test "Extract si_errno" 61 set test "Extract si_errno"
(...skipping 23 matching lines...) Expand all
92 set bp_location [gdb_get_line_number "set breakpoint here"] 85 set bp_location [gdb_get_line_number "set breakpoint here"]
93 86
94 gdb_test "break $bp_location" 87 gdb_test "break $bp_location"
95 gdb_test "continue" ".* handler .*" "continue to handler" 88 gdb_test "continue" ".* handler .*" "continue to handler"
96 89
97 gdb_test "p ssi_addr" " = \\(void \\*\\) $ssi_addr" 90 gdb_test "p ssi_addr" " = \\(void \\*\\) $ssi_addr"
98 gdb_test "p ssi_errno" " = $ssi_errno" 91 gdb_test "p ssi_errno" " = $ssi_errno"
99 gdb_test "p ssi_code" " = $ssi_code" 92 gdb_test "p ssi_code" " = $ssi_code"
100 gdb_test "p ssi_signo" " = $ssi_signo" 93 gdb_test "p ssi_signo" " = $ssi_signo"
101 94
102 # Again, but this time, patch si_addr and check that the inferior sees 95 gdb_test "thread 1" ".*"
103 # the changed value. 96 # siginfo is available here -- it shows SIGSTOP -- so we test to make
97 # sure that we have a different signal from the SEGV thread.
98 gdb_test "p \$_siginfo.si_signo == $ssi_signo" " = 0" \
99 "test signal in main thread"
104 100
105 # Advance to main 101 # Test siginfo preservation in core files.
106 if { ![runto_main] } then { 102 if {$gcore_created} {
107 gdb_suppress_tests; 103 clean_restart $binfile
104
105 gdb_test "core $gcorefile" "Core was generated by.*" \
106 » "core [file tail $gcorefile]"
107
108 gdb_test "p \$_siginfo.si_signo" " = $ssi_signo" \
109 » "p \$_siginfo.si_signo from core file"
110 gdb_test "p \$_siginfo.si_errno" " = $ssi_errno" \
111 » "p \$_siginfo.si_errno from core file"
112 gdb_test "p \$_siginfo.si_code" " = $ssi_code" \
113 » "p \$_siginfo.si_code from core file"
114 gdb_test "p \$_siginfo._sifields._sigfault.si_addr" \
115 » " = \\(void \\*\\) $ssi_addr" \
116 » "p \$_siginfo._sifields._sigfault.si_addr from core file"
117
118 # We don't know which thread will be signalled, so we simply
119 # ensure that only one thread got a SEGV.
120 gdb_test_no_output "set variable \$count = 0"
121 foreach thread {1 2} {
122 » gdb_test "thread $thread" ".*" "select thread $thread with core file"
123 » gdb_test_no_output \
124 » "set variable \$count += (\$_siginfo.si_signo == $ssi_signo)" \
125 » "update counter in thread $thread"
126 }
127 gdb_test "print \$count" " = 1"
108 } 128 }
109
110 # Run to the signal.
111 gdb_test "continue" ".*Program received signal SIGSEGV.*" "continue to signal"
112
113 set test "Set si_addr"
114 gdb_test "p \$_siginfo._sifields._sigfault.si_addr = 0x666" " = \\(void \\*\\) 0 x666"
115 gdb_test "p \$_siginfo.si_errno = 666" " = 666"
116 gdb_test "p \$_siginfo.si_code = 999" " = 999"
117 gdb_test "p \$_siginfo.si_signo = 11" " = 11"
118
119 gdb_test "break $bp_location"
120 gdb_test "continue" ".* handler .*" "continue to handler"
121
122 gdb_test "p ssi_addr" " = \\(void \\*\\) 0x666"
123 gdb_test "p ssi_errno" " = 666"
124 gdb_test "p ssi_code" " = 999"
125 gdb_test "p ssi_signo" " = 11"
OLDNEW
« no previous file with comments | « gdb/testsuite/gdb.base/siginfo-thread.c ('k') | gdb/testsuite/gdb.base/signals.exp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698