diff options
-rw-r--r-- | gdb/infrun.c | 17 | ||||
-rw-r--r-- | gdb/testsuite/gdb.threads/fork-plus-threads.exp | 33 |
2 files changed, 43 insertions, 7 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c index c311240..1505140 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4278,6 +4278,18 @@ fetch_inferior_event () reinstalled here. */ } + /* Handling this event might have caused some inferiors to become prunable. + For example, the exit of an inferior that was automatically added. Try + to get rid of them. Keeping those around slows down things linearly. + + Note that this never removes the current inferior. Therefore, call this + after RESTORE_THREAD went out of scope, in case the event inferior (which was + temporarily made the current inferior) is meant to be deleted. + + Call this before all_uis_check_sync_execution_done, so that notifications about + removed inferiors appear before the prompt. */ + prune_inferiors (); + /* If a UI was in sync execution mode, and now isn't, restore its prompt (a synchronous execution command has finished, and we're ready for input). */ @@ -8769,11 +8781,6 @@ normal_stop (void) breakpoint_auto_delete (inferior_thread ()->control.stop_bpstat); } - /* Try to get rid of automatically added inferiors that are no - longer needed. Keeping those around slows down things linearly. - Note that this never removes the current inferior. */ - prune_inferiors (); - return 0; } diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp index bc09c89..26fbef7 100644 --- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp +++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp @@ -76,6 +76,16 @@ proc do_test { detach-on-fork } { set saw_cannot_remove_breakpoints 0 set saw_thread_stopped 0 + set expected_num_inferior_exits [expr ${detach-on-fork} == "off" ? 11 : 1] + + # Flags indicating if we have see the exit for each inferior. + for {set i 1} {$i <= $expected_num_inferior_exits} {incr i} { + set inferior_exits_seen($i) 0 + } + + # Number of inferior exits seen so far. + set num_inferior_exits_seen 0 + set test "inferior 1 exited" gdb_test_multiple "" $test { -re "Cannot remove breakpoints" { @@ -94,11 +104,30 @@ proc do_test { detach-on-fork } { # Avoid timeout with check-read1 exp_continue } - -re "Inferior 1 \(\[^\r\n\]+\) exited normally" { - pass $test + -re "Inferior ($::decimal) \(\[^\r\n\]+\) exited normally" { + set infnum $expect_out(1,string) + incr num_inferior_exits_seen + incr inferior_exits_seen($infnum) 1 + + if { $num_inferior_exits_seen == $expected_num_inferior_exits } { + pass $test + } else { + exp_continue + } } } + # Verify that we got all the inferior exits we expected. + set num_ok_exits 0 + for {set i 1} {$i <= $expected_num_inferior_exits} {incr i} { + if { $inferior_exits_seen($i) == 1 } { + incr num_ok_exits + } + } + + gdb_assert { $num_ok_exits == $expected_num_inferior_exits } \ + "seen all expected inferior exits" + gdb_assert !$saw_cannot_remove_breakpoints \ "no failure to remove breakpoints" gdb_assert !$saw_thread_stopped \ |