summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-09-21 22:49:54 +0100
committerPedro Alves <palves@redhat.com>2016-09-21 22:49:54 +0100
commita34c6b303b3e173189f1f0c761a61c89a1e99ba4 (patch)
treeb323bdf42ee096a705551b710458be658db85f19
parentd289fba077198d3f71a8a12e27168d06e9543cf1 (diff)
downloadbinutils-gdb-users/palves/user-context-selection-for-simon.tar.gz
-rw-r--r--gdb/testsuite/gdb.mi/user-selected-context-sync.c20
-rw-r--r--gdb/testsuite/gdb.mi/user-selected-context-sync.exp62
2 files changed, 65 insertions, 17 deletions
diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.c b/gdb/testsuite/gdb.mi/user-selected-context-sync.c
index 6967f5707a7..7cfbb9916cc 100644
--- a/gdb/testsuite/gdb.mi/user-selected-context-sync.c
+++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.c
@@ -24,10 +24,14 @@
static int volatile quit = 0;
+pthread_barrier_t barrier;
+
static void
child_sub_function (void)
{
- while (!quit); /* thread loop line */
+ pthread_barrier_wait (&barrier);
+
+ while (1); /* thread loop line */
}
static void *
@@ -44,18 +48,16 @@ main (void)
int i = 0;
pthread_t threads[NUM_THREADS];
+ // alarm (30);
+
+ pthread_barrier_init (&barrier, NULL, 3);
+
for (i = 0; i < NUM_THREADS; i++)
pthread_create (&threads[i], NULL, child_function, NULL);
-
- /* Leave enough time for the threads to reach their infinite loop. */
- sleep (1);
- i = 0; /* main break line */
+ pthread_barrier_wait (&barrier);
- sleep (2);
-
- /* Allow the test to exit cleanly. */
- quit = 1;
+ i = 0; /* main break line */
for (i = 0; i < NUM_THREADS; i++)
pthread_join (threads[i], NULL);
diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
index f809485fa6a..47c9eb68438 100644
--- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
+++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
@@ -249,7 +249,15 @@ proc make_cli_in_mi_re { command cli_in_mi_mode mode event inf cli_thread
# Continue inferior INF until the breakpoint indicating the threads are started.
proc test_continue_to_start { mode inf } {
- global gdb_prompt gdb_spawn_id gdb_main_spawn_id
+ global gdb_prompt
+ global gdb_spawn_id gdb_main_spawn_id mi_spawn_id
+ global srcfile
+
+ global async
+
+ # MI async events sent to the secondary UI aren't suffixed with an
+ # MI prompt.
+ set async 1
if { $gdb_spawn_id != $gdb_main_spawn_id } {
error "This should not happen."
@@ -257,7 +265,34 @@ proc test_continue_to_start { mode inf } {
with_test_prefix "inferior $inf" {
with_spawn_id $gdb_main_spawn_id {
- gdb_continue_to_breakpoint "main breakpoint"
+
+ gdb_breakpoint [gdb_get_line_number "main break line"]
+ gdb_continue_to_breakpoint "run to breakpoint"
+
+ with_spawn_id $mi_spawn_id {
+ mi_expect_stop "breakpoint-hit" "main" ".*" "$srcfile" ".*" {"" "disp=\"keep\""} "main stop"
+ }
+
+ global srcfile thread_loop_line
+ global decimal
+
+ gdb_test "break $srcfile:$thread_loop_line thread $inf.2" \
+ "Breakpoint $decimal .*$srcfile, line $thread_loop_line\\\." \
+ "set breakpoint thread 1"
+
+ gdb_test "break $srcfile:$thread_loop_line thread $inf.3" \
+ "Breakpoint $decimal .*$srcfile, line $thread_loop_line\\\." \
+ "set breakpoint thread 2"
+
+ gdb_continue_to_breakpoint "loop line breakpoint 1"
+ with_spawn_id $mi_spawn_id {
+ mi_expect_stop "breakpoint-hit" "child_sub_function" ".*" ".*$srcfile" ".*" {"" "disp=\"keep\""} "MI loop line breakpoint 1"
+ }
+
+ gdb_continue_to_breakpoint "loop line breakpoint 2"
+ with_spawn_id $mi_spawn_id {
+ mi_expect_stop "breakpoint-hit" "child_sub_function" ".*" ".*$srcfile" ".*" {"" "disp=\"keep\""} "MI loop line breakpoint 2"
+ }
if { $mode == "non-stop" } {
gdb_test "thread $inf.2" ".*" "switch to thread $inf.2"
@@ -282,6 +317,7 @@ proc test_setup { mode } {
global gdb_main_spawn_id mi_spawn_id
global decimal binfile main_bp_line
global GDBFLAGS
+ global thread_loop_line
mi_gdb_exit
@@ -305,17 +341,27 @@ proc test_setup { mode } {
}
with_spawn_id $gdb_main_spawn_id {
- gdb_test "break $srcfile:$main_bp_line" \
- "Breakpoint $decimal .*$srcfile, line $main_bp_line\\\." \
- "set breakpoint"
-
test_continue_to_start $mode 1
# Add a second inferior.
gdb_test "add-inferior" "Added inferior 2" "Add inferior 2"
gdb_test "inferior 2" ".*" "switch to inferior 2"
gdb_load ${binfile}
- gdb_test "start" "Temporary breakpoint.*Starting program.*"
+
+ send_gdb "start\n"
+
+ # Consume MI output first, which is much more chatty. If gdb
+ # writes more to the tty than fits in its buffer, gdb hangs
+ # until something consumes the tty output. So if we expected
+ # CLI output first, it might never arrive, because GDB could
+ # be blocked writting to the MI tty before it ever wrote the
+ # CLI output...
+ with_spawn_id $mi_spawn_id {
+ mi_expect_stop "breakpoint-hit" "main" ".*" "$srcfile" ".*" {"" "disp=\"del\""} "main stop"
+ }
+
+ gdb_test "" "Temporary breakpoint.*Starting program.*"
+
test_continue_to_start $mode 2
gdb_test "inferior 1" ".*" "switch back to inferior 1"
}
@@ -1118,7 +1164,7 @@ proc test_cli_in_mi_frame { mode cli_in_mi_mode } {
}
}
-foreach_with_prefix mode { "all-stop" "non-stop" } {
+foreach_with_prefix mode { "all-stop" } {
with_test_prefix_procname test_setup $mode
# Test selecting inferior, thread and frame from CLI