2008-09-13 Jan Kratochvil Fix a crash on uninitialized ECS->EVENT_THREAD for a newly found thread. * infrun.c (wait_for_inferior): Move this ECS->EVENT_THREAD initialization ... (fetch_inferior_event): ... and this ECS->EVENT_THREAD initialization ... (handle_inferior_event): ... here after ADD_THREAD together with the local ADJUST_PC_AFTER_BREAK call. --- ./gdb/infrun.c 11 Sep 2008 14:21:49 -0000 1.318 +++ ./gdb/infrun.c 12 Sep 2008 22:02:19 -0000 @@ -1568,8 +1568,6 @@ wait_for_inferior (int treat_exec_as_sig else ecs->ptid = target_wait (waiton_ptid, &ecs->ws); - ecs->event_thread = find_thread_pid (ecs->ptid); - if (treat_exec_as_sigtrap && ecs->ws.kind == TARGET_WAITKIND_EXECD) { xfree (ecs->ws.value.execd_pathname); @@ -1645,8 +1643,6 @@ fetch_inferior_event (void *client_data) thread. */ context_switch (ecs->ptid); - ecs->event_thread = find_thread_pid (ecs->ptid); - /* Now figure out what to do with the result of the result. */ handle_inferior_event (ecs); @@ -1854,8 +1850,6 @@ handle_inferior_event (struct execution_ /* Always clear state belonging to the previous time we stopped. */ stop_stack_dummy = 0; - adjust_pc_after_break (ecs); - reinit_frame_cache (); /* If it's a new process, add it to the thread database */ @@ -1868,6 +1862,10 @@ handle_inferior_event (struct execution_ && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event) add_thread (ecs->ptid); + ecs->event_thread = find_thread_pid (ecs->ptid); + + adjust_pc_after_break (ecs); + if (ecs->ws.kind != TARGET_WAITKIND_IGNORE) { /* Mark the non-executing threads accordingly. */