+mi_expect_stop "breakpoint-hit" "pendfunc1" ".*" ".*" ".*" \
+ { "" "disp=\"keep\"" } \
+ "Run till MI pending breakpoint on pendfunc1"
+
+mi_send_resuming_command "exec-continue" "continuing execution to skip conditional bp"
+
+# We should not stop on the conditional breakpoint yet, but we stop on the original bp.
+mi_expect_stop "breakpoint-hit" "pendfunc1" ".*" ".*" ".*" \
+ { "" "disp=\"keep\"" } \
+ "Run till MI pending breakpoint on pendfunc1 a second time"
+
+mi_send_resuming_command "exec-continue" "continuing execution to conditional bp"
+
+# Now we should stop on the conditional breakpoint.
+mi_expect_stop "breakpoint-hit" "pendfunc2" "\{name=\"x\",value=\"4\"\}" ".*" ".*" \
+ { "" "disp=\"keep\"" } \
+ "Run till MI pending breakpoint on pendfunc2 with x==4"
+
+mi_send_resuming_command "exec-continue" "continuing execution to thread creation"
+
+# Stop on thread creation so we can set a pending breakpoint with a thread cond.
+mi_expect_stop "breakpoint-hit" "thread_func" ".*" ".*" ".*" \
+ { "" "disp=\"keep\"" } \
+ "Run till MI pending breakpoint on thread_func"
+
+# Delete thread creation breakpoint to enable more than 1 thread to be created.
+mi_gdb_test "-break-delete 3" "\\^done" "delete breakpoint 3"
+
+# Set pending breakpoint with a thread via MI.
+mi_gdb_test "-break-insert -p 2 -f pendfunc3" \
+ ".*\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"pendfunc3\",thread=\"2\",thread=\"2\",times=\"0\",original-location=\"pendfunc3\"\}"\
+ "MI pending breakpoint on pendfunc3"
+
+mi_send_resuming_command "exec-continue" "continuing execution to thread condition"
+
+# Check if we stopped in thread 2 like we should.
+set testname "run till MI pending breakpoint on pendfunc3 on thread 2"
+gdb_expect {
+ -re "\\*stopped,reason=\"breakpoint-hit\",disp=\"keep\",bkptno=\"4\",frame=\{addr=\"$hex\",func=\"pendfunc3\".*thread-id=\"2\".*" {
+ pass $testname
+ return 0
+ }
+ timeout {
+ fail "$testname (timeout)"
+ return -1
+ }
+}