From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Cc: jan.kratochvil@redhat.com
Subject: [PATCH 2/2] gdb.threads/attach-into-signal.exp: don't rely on linux native target's internal debug output
Date: Fri, 17 Feb 2012 19:52:00 -0000 [thread overview]
Message-ID: <20120217193750.10029.58857.stgit@hit-nxdomain.opendns.com> (raw)
In-Reply-To: <20120217193546.10029.74207.stgit@hit-nxdomain.opendns.com>
This test relies on Linux native target's debug output ("set debug
lin-lwp 1"), which obviously can't work when testing against GDBserver
(with the extended-remote board).
This patch makes the test more generic, using only regular GDB
functionality, avoiding relying on internal debug output.
The test runs twice, with two variants: once non-threaded, and once
threaded. SIGLARM defaults to noprint, but if we set it to print,
then for the non-threaded case, when we attach and find the main
thread stopping with SIGLARM, we'll see "Program received signal
SIGLARM". For the threaded case, the signal is seen on the non main
thread, so we won't see "Program received signal SIGLARM". Instead,
we check the second thread's siginfo.si_signo. We can't use this
method for the non-threaded case too, because the Linux native target
when attaching finds another signal other than SIGSTOP, puts that
other signal pending, and waits for the SIGSTOP, so siginfo.si_signo
will always show SIGSTOP.
With this, GDBserver fails the test, because it doesn't really support
what's being tested here. Namely, it doesn't deliver the SIGALRM back
to the inferior on detach (so the program ends up on the abort()
call). I have a fix for that, but it needs a bit more cleaning up.
Jan, is this okay with you?
2012-02-17 Pedro Alves <palves@redhat.com>
* gdb.threads/attach-into-signal.exp (corefunc): Don't enable
lin-lwp output. Set SIGALRM to stop. Adjust tests to not rely on
gdb's internal debug output. For the non-threaded case, look for
"Program received signal SIGLARM", for the threaded case, peek at
the thread's siginfo.
---
gdb/testsuite/gdb.threads/attach-into-signal.exp | 57 ++++++++++++++++------
1 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/gdb/testsuite/gdb.threads/attach-into-signal.exp b/gdb/testsuite/gdb.threads/attach-into-signal.exp
index bf4b8a0..c839339 100644
--- a/gdb/testsuite/gdb.threads/attach-into-signal.exp
+++ b/gdb/testsuite/gdb.threads/attach-into-signal.exp
@@ -47,7 +47,6 @@ proc corefunc { threadtype executable } {
lappend pf_prefix "$threadtype:"
clean_restart ${executable}
- gdb_test_no_output "set debug lin-lwp 1" ""
set binfile ${objdir}/${subdir}/${executable}
set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${executable}]
@@ -57,6 +56,8 @@ proc corefunc { threadtype executable } {
return -1
}
+ gdb_test "handle SIGALRM stop print pass" "Yes.*Yes.*Yes.*"
+
# Start the program running and then wait for a bit, to be sure
# that it can be attached to.
# Statistically there is a better chance without giving process a nice.
@@ -99,27 +100,51 @@ proc corefunc { threadtype executable } {
# Main test:
set test "attach (pass $passes), pending signal catch"
if {[gdb_test_multiple "attach $testpid" $test {
- -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*Received Alarm clock.*$gdb_prompt $" {
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*Program received signal SIGALRM.*$gdb_prompt $" {
# nonthreaded:
pass $test
verbose -log "$test succeeded on the attempt # $attempt of $attempts"
set passes [expr $passes + 1]
}
-re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
- # nonthreaded:
- # We just lack the luck, we should try it again.
- set attempt [expr $attempt + 1]
- }
- -re "Attaching to process $testpid.*Received Alarm clock.*$gdb_prompt $" {
- # threaded:
- pass $test
- verbose -log "$test succeeded on the attempt # $attempt of $attempts"
- set passes [expr $passes + 1]
- }
- -re "Attaching to process $testpid.*$gdb_prompt $" {
- # threaded:
- # We just lack the luck, we should try it again.
- set attempt [expr $attempt - 1]
+ set ok 0
+
+ if { $threadtype == "threaded" } {
+ # In the threaded case, the signal is left pending
+ # on the second thread. Check for that by peeking
+ # at the thread's siginfo. SIGALRM is 14, SIGSTOP
+ # is 19.
+
+ # With remote targets, we need to pull the thread
+ # list explicitly before GDB even knows about
+ # thread 2.
+ set test2 "pull thread list"
+ gdb_test_multiple "info threads" $test2 {
+ -re "\r\n$gdb_prompt $" {
+ }
+ }
+
+ set test2 "thread apply 2 print \$_siginfo.si_signo"
+ gdb_test_multiple $test2 $test2 {
+ -re " = 14\r\n$gdb_prompt $" {
+ set ok 1
+ }
+ -re " = 19\r\n$gdb_prompt $" {
+ }
+ }
+ } else {
+ # In the nonthreaded case, GDB should tell the
+ # user about having seen a signal.
+ }
+
+ if { $ok == 0} {
+ # We just lack the luck, we should try it again.
+ set attempt [expr $attempt + 1]
+ } else {
+ pass $test
+ verbose -log "$test succeeded on the attempt # $attempt of $attempts"
+ set passes [expr $passes + 1]
+ }
}
}] != 0 } {
break
next prev parent reply other threads:[~2012-02-17 19:38 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-17 19:37 [PATCH 0/2] gdb.threads/attach-into-signal.exp: prepare for gdbserver Pedro Alves
2012-02-17 19:38 ` [PATCH 1/2] gdb.threads/attach-into-signal.exp: cleanup Pedro Alves
2012-02-17 20:55 ` Tom Tromey
2012-02-17 21:00 ` Pedro Alves
2012-02-17 22:04 ` Tom Tromey
2012-02-20 13:27 ` Pedro Alves
2012-02-21 16:05 ` testsuite: prefix handling Pedro Alves
2012-02-21 18:18 ` Jan Kratochvil
2012-02-21 19:28 ` Pedro Alves
2012-02-21 19:54 ` Tom Tromey
2012-02-21 19:17 ` Tom Tromey
2012-02-21 20:08 ` Pedro Alves
2012-02-21 20:59 ` Pedro Alves
2012-02-21 21:02 ` Tom Tromey
2012-02-21 22:08 ` Pedro Alves
2012-02-21 21:00 ` Tom Tromey
2012-02-21 22:03 ` Pedro Alves
2012-02-17 21:31 ` [PATCH 1/2] gdb.threads/attach-into-signal.exp: cleanup Pedro Alves
2012-03-01 11:47 ` Pedro Alves
2012-02-17 23:55 ` Joel Brobecker
2012-02-20 8:57 ` Jan Kratochvil
2012-02-17 19:52 ` Pedro Alves [this message]
2012-02-20 9:41 ` [PATCH 2/2] gdb.threads/attach-into-signal.exp: don't rely on linux native target's internal debug output Jan Kratochvil
2012-02-20 12:32 ` Pedro Alves
2012-02-20 12:34 ` Jan Kratochvil
2012-02-20 12:37 ` Pedro Alves
2012-02-21 18:17 ` Edjunior Barbosa Machado
2012-02-21 19:11 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120217193750.10029.58857.stgit@hit-nxdomain.opendns.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox