mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-03 21:34:46 +08:00
PR gdb/9747:
* gdbthread.h (finish_thread_state, finish_thread_state_cleanup): Declare. * thread.c (finish_thread_state, finish_thread_state_cleanup): New. * infrun.c (wait_for_inferior, fetch_inferior_event): If an error is thrown while handling an event, finish the thread state. (normal_stop): Use finish_thread_state cleanup. * infcmd.c (run_command_1): If an error is thrown while starting the inferior, finish the thread state.
This commit is contained in:
49
gdb/thread.c
49
gdb/thread.c
@ -632,6 +632,55 @@ set_stop_requested (ptid_t ptid, int stop)
|
||||
observer_notify_thread_stop_requested (ptid);
|
||||
}
|
||||
|
||||
void
|
||||
finish_thread_state (ptid_t ptid)
|
||||
{
|
||||
struct thread_info *tp;
|
||||
int all;
|
||||
int any_started = 0;
|
||||
|
||||
all = ptid_equal (ptid, minus_one_ptid);
|
||||
|
||||
if (all || ptid_is_pid (ptid))
|
||||
{
|
||||
for (tp = thread_list; tp; tp = tp->next)
|
||||
{
|
||||
if (tp->state_ == THREAD_EXITED)
|
||||
continue;
|
||||
if (all || ptid_get_pid (ptid) == ptid_get_pid (tp->ptid))
|
||||
{
|
||||
if (tp->executing_ && tp->state_ == THREAD_STOPPED)
|
||||
any_started = 1;
|
||||
tp->state_ = tp->executing_ ? THREAD_RUNNING : THREAD_STOPPED;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tp = find_thread_pid (ptid);
|
||||
gdb_assert (tp);
|
||||
if (tp->state_ != THREAD_EXITED)
|
||||
{
|
||||
if (tp->executing_ && tp->state_ == THREAD_STOPPED)
|
||||
any_started = 1;
|
||||
tp->state_ = tp->executing_ ? THREAD_RUNNING : THREAD_STOPPED;
|
||||
}
|
||||
}
|
||||
|
||||
if (any_started)
|
||||
observer_notify_target_resumed (ptid);
|
||||
}
|
||||
|
||||
void
|
||||
finish_thread_state_cleanup (void *arg)
|
||||
{
|
||||
ptid_t *ptid_p = arg;
|
||||
|
||||
gdb_assert (arg);
|
||||
|
||||
finish_thread_state (*ptid_p);
|
||||
}
|
||||
|
||||
/* Prints the list of threads and their details on UIOUT.
|
||||
This is a version of 'info_thread_command' suitable for
|
||||
use from MI.
|
||||
|
Reference in New Issue
Block a user