diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6fa5ba50dcd..b9493e44e19 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2015-08-25 Don Breazeal + + * infrun.c (follow_exec): Re-order operations for + handling follow-exec-mode "new". + (handle_inferior_event_1): Assign ecs->event_thread + to the current thread. + * remote.c (get_remote_arch_state): Add an assertion. + 2015-08-26 Pedro Alves * MAINTAINERS: Add Markus Metzger as btrace maintainer. diff --git a/gdb/infrun.c b/gdb/infrun.c index 1e224b1785b..c3e7dd78842 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1187,12 +1187,16 @@ follow_exec (ptid_t ptid, char *execd_pathname) /* The user wants to keep the old inferior and program spaces around. Create a new fresh one, and switch to it. */ - inf = add_inferior (current_inferior ()->pid); + /* Do exit processing for the original inferior before adding + the new inferior so we don't have two active inferiors with + the same ptid, which can confuse find_inferior_ptid. */ + exit_inferior_num_silent (current_inferior ()->num); + + inf = add_inferior (pid); pspace = add_program_space (maybe_new_address_space ()); inf->pspace = pspace; inf->aspace = pspace->aspace; - - exit_inferior_num_silent (current_inferior ()->num); + add_thread (ptid); set_current_inferior (inf); set_current_program_space (pspace); @@ -4978,6 +4982,11 @@ Cannot fill $_exitsignal with the correct signal number.\n")); stop. */ follow_exec (inferior_ptid, ecs->ws.value.execd_pathname); + /* In follow_exec we may have deleted the original thread and + created a new one. Make sure that the event thread is the + execd thread for that case (this is a nop otherwise). */ + ecs->event_thread = inferior_thread (); + ecs->event_thread->control.stop_bpstat = bpstat_stop_status (get_regcache_aspace (get_current_regcache ()), stop_pc, ecs->ptid, &ecs->ws); diff --git a/gdb/remote.c b/gdb/remote.c index e01927719b0..6c9a1b3e972 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -600,6 +600,7 @@ static struct gdbarch_data *remote_gdbarch_data_handle; static struct remote_arch_state * get_remote_arch_state (void) { + gdb_assert (target_gdbarch () != NULL); return gdbarch_data (target_gdbarch (), remote_gdbarch_data_handle); }