This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC/WIP PATCH 14/14] Fix manythreads.exp test


As infrun only decides to stop or not all threads after handling the
event the target reported, threads can now appear or disappear after
"Program received signal SIGFOO" and presenting the prompt, which
breaks the manythreads.exp test.  This fixes it.
---
 gdb/testsuite/gdb.threads/manythreads.exp |   52 +++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/manythreads.exp b/gdb/testsuite/gdb.threads/manythreads.exp
index 12a25b9..168beac 100644
--- a/gdb/testsuite/gdb.threads/manythreads.exp
+++ b/gdb/testsuite/gdb.threads/manythreads.exp
@@ -112,10 +112,39 @@ gdb_test_multiple "continue" "second continue" {
   }
 }
 
+# Note that in the tests below, we can't suffix the "Program received
+# signal SIGINT" regexes with $gdb_prompt, as doing so would mean that
+# e.g. with,
+#
+# Program received signal SIGINT, Interrupt.
+# [New Thread FOO]
+# [Switching to Thread BAR]
+# 0xdeadbeef in bar () from bar.so
+# (gdb)
+#
+# the [New ...] or [... exited] regexes would eat the "Program
+# received ..." bit.  [New FOO] and [FOO exited] may appear while GDB
+# is stopping threads.
+
 # Wait another second.  If the program stops on its own, GDB has failed
 # to handle duplicate SIGINTs sent to multiple threads.
 set failed 0
 remote_expect host 1 {
+  -re "Program received signal SIGINT" {
+
+    # Eat the prompt.
+    gdb_expect {
+      -re "$gdb_prompt $" {
+      }
+    }
+
+    if { $failed == 0 } {
+      fail "check for duplicate SIGINT"
+    }
+    send_gdb "continue\n"
+    set failed 1
+    exp_continue
+  }
   -re "\\\[New \[^\]\]*\\\]\r\n" {
     exp_continue -continue_timer
   }
@@ -125,14 +154,6 @@ remote_expect host 1 {
   -re "Thread \[^\n\]* executing\r\n" {
     exp_continue -continue_timer
   }
-  -re "Program received signal SIGINT.*$gdb_prompt $" {
-    if { $failed == 0 } {
-      fail "check for duplicate SIGINT"
-    }
-    send_gdb "continue\n"
-    set failed 1
-    exp_continue
-  }
   timeout {
     if { $failed == 0 } {
       pass "check for duplicate SIGINT"
@@ -144,6 +165,18 @@ remote_expect host 1 {
 send_gdb "\003"
 set message "stop threads 2"
 gdb_test_multiple "" "stop threads 2" {
+  -re "Program received signal SIGINT" {
+
+    # Eat the prompt.
+    gdb_expect {
+      -re "$gdb_prompt $" {
+	pass "$message"
+      }
+      timeout {
+	fail "$message (timeout)"
+      }
+    }
+  }
   -re "\\\[New \[^\]\]*\\\]\r\n" {
     exp_continue
   }
@@ -153,9 +186,6 @@ gdb_test_multiple "" "stop threads 2" {
   -re "Thread \[^\n\]* executing\r\n" {
     exp_continue
   }
-  -re "Program received signal SIGINT.*$gdb_prompt $" {
-    pass "$message"
-  }
   timeout {
     fail "$message (timeout)"
   }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]