mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 18:14:13 +08:00
gdb: make thread_info::executing private
Rename thread_info::executing to thread_info::m_executing, and make it private. Add a new get/set member functions, and convert GDB to make use of these. The only real change of interest in this patch is in thread.c where I have deleted the helper function set_executing_thread, and now just use the new set function thread_info::set_executing. However, the old helper function set_executing_thread included some code to reset the thread's stop_pc, so I moved this code into the new function thread_info::set_executing. However, I don't believe there is anywhere that this results in a change of behaviour, previously the executing flag was always set true through a call to set_executing_thread anyway.
This commit is contained in:
parent
9dc2f26777
commit
611841bb1a
@ -1661,7 +1661,7 @@ watchpoint_in_thread_scope (struct watchpoint *b)
|
|||||||
return (b->pspace == current_program_space
|
return (b->pspace == current_program_space
|
||||||
&& (b->watchpoint_thread == null_ptid
|
&& (b->watchpoint_thread == null_ptid
|
||||||
|| (inferior_ptid == b->watchpoint_thread
|
|| (inferior_ptid == b->watchpoint_thread
|
||||||
&& !inferior_thread ()->executing)));
|
&& !inferior_thread ()->executing ())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set watchpoint B to disp_del_at_next_stop, even including its possible
|
/* Set watchpoint B to disp_del_at_next_stop, even including its possible
|
||||||
@ -4512,7 +4512,7 @@ get_bpstat_thread ()
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
thread_info *tp = inferior_thread ();
|
thread_info *tp = inferior_thread ();
|
||||||
if (tp->state == THREAD_EXITED || tp->executing)
|
if (tp->state == THREAD_EXITED || tp->executing ())
|
||||||
return NULL;
|
return NULL;
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
@ -1789,7 +1789,7 @@ has_stack_frames ()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* ... or from a spinning thread. */
|
/* ... or from a spinning thread. */
|
||||||
if (tp->executing)
|
if (tp->executing ())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,15 +287,19 @@ public:
|
|||||||
if the thread does not have a user-given name. */
|
if the thread does not have a user-given name. */
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
|
|
||||||
/* True means the thread is executing. Note: this is different
|
bool executing () const
|
||||||
from saying that there is an active target and we are stopped at
|
{ return m_executing; }
|
||||||
a breakpoint, for instance. This is a real indicator whether the
|
|
||||||
thread is off and running. */
|
/* Set the thread's 'm_executing' field from EXECUTING, and if EXECUTING
|
||||||
bool executing = false;
|
is true also clears the thread's stop_pc. */
|
||||||
|
void set_executing (bool executing);
|
||||||
|
|
||||||
bool resumed () const
|
bool resumed () const
|
||||||
{ return m_resumed; }
|
{ return m_resumed; }
|
||||||
|
|
||||||
|
/* Set the thread's 'm_resumed' field from RESUMED. The thread may also
|
||||||
|
be added to (when RESUMED is true), or removed from (when RESUMED is
|
||||||
|
false), the list of threads with a pending wait status. */
|
||||||
void set_resumed (bool resumed);
|
void set_resumed (bool resumed);
|
||||||
|
|
||||||
/* Frontend view of the thread state. Note that the THREAD_RUNNING/
|
/* Frontend view of the thread state. Note that the THREAD_RUNNING/
|
||||||
@ -488,6 +492,12 @@ private:
|
|||||||
the thread run. */
|
the thread run. */
|
||||||
bool m_resumed = false;
|
bool m_resumed = false;
|
||||||
|
|
||||||
|
/* True means the thread is executing. Note: this is different
|
||||||
|
from saying that there is an active target and we are stopped at
|
||||||
|
a breakpoint, for instance. This is a real indicator whether the
|
||||||
|
thread is off and running. */
|
||||||
|
bool m_executing = false;
|
||||||
|
|
||||||
/* State of inferior thread to restore after GDB is done with an inferior
|
/* State of inferior thread to restore after GDB is done with an inferior
|
||||||
call. See `struct thread_suspend_state'. */
|
call. See `struct thread_suspend_state'. */
|
||||||
thread_suspend_state m_suspend;
|
thread_suspend_state m_suspend;
|
||||||
|
@ -2371,7 +2371,7 @@ proceed_after_attach (inferior *inf)
|
|||||||
scoped_restore_current_thread restore_thread;
|
scoped_restore_current_thread restore_thread;
|
||||||
|
|
||||||
for (thread_info *thread : inf->non_exited_threads ())
|
for (thread_info *thread : inf->non_exited_threads ())
|
||||||
if (!thread->executing
|
if (!thread->executing ()
|
||||||
&& !thread->stop_requested
|
&& !thread->stop_requested
|
||||||
&& thread->stop_signal () == GDB_SIGNAL_0)
|
&& thread->stop_signal () == GDB_SIGNAL_0)
|
||||||
{
|
{
|
||||||
@ -2644,7 +2644,7 @@ notice_new_inferior (thread_info *thr, bool leave_running, int from_tty)
|
|||||||
/* When we "notice" a new inferior we need to do all the things we
|
/* When we "notice" a new inferior we need to do all the things we
|
||||||
would normally do if we had just attached to it. */
|
would normally do if we had just attached to it. */
|
||||||
|
|
||||||
if (thr->executing)
|
if (thr->executing ())
|
||||||
{
|
{
|
||||||
struct inferior *inferior = current_inferior ();
|
struct inferior *inferior = current_inferior ();
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ child_interrupt (struct target_ops *self)
|
|||||||
thread_info *resumed = NULL;
|
thread_info *resumed = NULL;
|
||||||
for (thread_info *thr : all_non_exited_threads ())
|
for (thread_info *thr : all_non_exited_threads ())
|
||||||
{
|
{
|
||||||
if (thr->executing)
|
if (thr->executing ())
|
||||||
{
|
{
|
||||||
resumed = thr;
|
resumed = thr;
|
||||||
break;
|
break;
|
||||||
|
26
gdb/infrun.c
26
gdb/infrun.c
@ -862,7 +862,7 @@ static void
|
|||||||
proceed_after_vfork_done (thread_info *thread)
|
proceed_after_vfork_done (thread_info *thread)
|
||||||
{
|
{
|
||||||
if (thread->state == THREAD_RUNNING
|
if (thread->state == THREAD_RUNNING
|
||||||
&& !thread->executing
|
&& !thread->executing ()
|
||||||
&& !thread->stop_requested
|
&& !thread->stop_requested
|
||||||
&& thread->stop_signal () == GDB_SIGNAL_0)
|
&& thread->stop_signal () == GDB_SIGNAL_0)
|
||||||
{
|
{
|
||||||
@ -1885,7 +1885,7 @@ start_step_over (void)
|
|||||||
|
|
||||||
if (tp->control.trap_expected
|
if (tp->control.trap_expected
|
||||||
|| tp->resumed ()
|
|| tp->resumed ()
|
||||||
|| tp->executing)
|
|| tp->executing ())
|
||||||
{
|
{
|
||||||
internal_error (__FILE__, __LINE__,
|
internal_error (__FILE__, __LINE__,
|
||||||
"[%s] has inconsistent state: "
|
"[%s] has inconsistent state: "
|
||||||
@ -1893,7 +1893,7 @@ start_step_over (void)
|
|||||||
target_pid_to_str (tp->ptid).c_str (),
|
target_pid_to_str (tp->ptid).c_str (),
|
||||||
tp->control.trap_expected,
|
tp->control.trap_expected,
|
||||||
tp->resumed (),
|
tp->resumed (),
|
||||||
tp->executing);
|
tp->executing ());
|
||||||
}
|
}
|
||||||
|
|
||||||
infrun_debug_printf ("resuming [%s] for step-over",
|
infrun_debug_printf ("resuming [%s] for step-over",
|
||||||
@ -3197,7 +3197,7 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
|
|||||||
{
|
{
|
||||||
infrun_debug_printf ("[%s] resumed",
|
infrun_debug_printf ("[%s] resumed",
|
||||||
target_pid_to_str (tp->ptid).c_str ());
|
target_pid_to_str (tp->ptid).c_str ());
|
||||||
gdb_assert (tp->executing || tp->has_pending_waitstatus ());
|
gdb_assert (tp->executing () || tp->has_pending_waitstatus ());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3329,7 +3329,7 @@ infrun_thread_stop_requested (ptid_t ptid)
|
|||||||
{
|
{
|
||||||
if (tp->state != THREAD_RUNNING)
|
if (tp->state != THREAD_RUNNING)
|
||||||
continue;
|
continue;
|
||||||
if (tp->executing)
|
if (tp->executing ())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Remove matching threads from the step-over queue, so
|
/* Remove matching threads from the step-over queue, so
|
||||||
@ -3778,7 +3778,7 @@ prepare_for_detach (void)
|
|||||||
{
|
{
|
||||||
if (thr->displaced_step_state.in_progress ())
|
if (thr->displaced_step_state.in_progress ())
|
||||||
{
|
{
|
||||||
if (thr->executing)
|
if (thr->executing ())
|
||||||
{
|
{
|
||||||
if (!thr->stop_requested)
|
if (!thr->stop_requested)
|
||||||
{
|
{
|
||||||
@ -4806,7 +4806,7 @@ handle_one (const wait_one_event &event)
|
|||||||
t = add_thread (event.target, event.ptid);
|
t = add_thread (event.target, event.ptid);
|
||||||
|
|
||||||
t->stop_requested = 0;
|
t->stop_requested = 0;
|
||||||
t->executing = 0;
|
t->set_executing (false);
|
||||||
t->set_resumed (false);
|
t->set_resumed (false);
|
||||||
t->control.may_range_step = 0;
|
t->control.may_range_step = 0;
|
||||||
|
|
||||||
@ -4947,7 +4947,7 @@ stop_all_threads (void)
|
|||||||
if (!target_is_non_stop_p ())
|
if (!target_is_non_stop_p ())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (t->executing)
|
if (t->executing ())
|
||||||
{
|
{
|
||||||
/* If already stopping, don't request a stop again.
|
/* If already stopping, don't request a stop again.
|
||||||
We just haven't seen the notification yet. */
|
We just haven't seen the notification yet. */
|
||||||
@ -5091,7 +5091,7 @@ handle_no_resumed (struct execution_control_state *ecs)
|
|||||||
|
|
||||||
for (thread_info *thread : all_non_exited_threads ())
|
for (thread_info *thread : all_non_exited_threads ())
|
||||||
{
|
{
|
||||||
if (swap_terminal && thread->executing)
|
if (swap_terminal && thread->executing ())
|
||||||
{
|
{
|
||||||
if (thread->inf != curr_inf)
|
if (thread->inf != curr_inf)
|
||||||
{
|
{
|
||||||
@ -5104,7 +5104,7 @@ handle_no_resumed (struct execution_control_state *ecs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ignore_event
|
if (!ignore_event
|
||||||
&& (thread->executing || thread->has_pending_waitstatus ()))
|
&& (thread->executing () || thread->has_pending_waitstatus ()))
|
||||||
{
|
{
|
||||||
/* Either there were no unwaited-for children left in the
|
/* Either there were no unwaited-for children left in the
|
||||||
target at some point, but there are now, or some target
|
target at some point, but there are now, or some target
|
||||||
@ -5722,7 +5722,7 @@ restart_threads (struct thread_info *event_thread)
|
|||||||
{
|
{
|
||||||
infrun_debug_printf ("restart threads: [%s] resumed",
|
infrun_debug_printf ("restart threads: [%s] resumed",
|
||||||
target_pid_to_str (tp->ptid).c_str ());
|
target_pid_to_str (tp->ptid).c_str ());
|
||||||
gdb_assert (tp->executing || tp->has_pending_waitstatus ());
|
gdb_assert (tp->executing () || tp->has_pending_waitstatus ());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5869,7 +5869,7 @@ finish_step_over (struct execution_control_state *ecs)
|
|||||||
do_target_wait. */
|
do_target_wait. */
|
||||||
tp->set_resumed (true);
|
tp->set_resumed (true);
|
||||||
|
|
||||||
gdb_assert (!tp->executing);
|
gdb_assert (!tp->executing ());
|
||||||
|
|
||||||
regcache = get_thread_regcache (tp);
|
regcache = get_thread_regcache (tp);
|
||||||
tp->set_stop_pc (regcache_read_pc (regcache));
|
tp->set_stop_pc (regcache_read_pc (regcache));
|
||||||
@ -7419,7 +7419,7 @@ restart_after_all_stop_detach (process_stratum_target *proc_target)
|
|||||||
/* If we have any thread that is already executing, then we
|
/* If we have any thread that is already executing, then we
|
||||||
don't need to resume the target -- it is already been
|
don't need to resume the target -- it is already been
|
||||||
resumed. */
|
resumed. */
|
||||||
if (thr->executing)
|
if (thr->executing ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If we have a pending event to process, skip resuming the
|
/* If we have a pending event to process, skip resuming the
|
||||||
|
@ -1280,7 +1280,7 @@ get_detach_signal (struct lwp_info *lp)
|
|||||||
{
|
{
|
||||||
struct thread_info *tp = find_thread_ptid (linux_target, lp->ptid);
|
struct thread_info *tp = find_thread_ptid (linux_target, lp->ptid);
|
||||||
|
|
||||||
if (target_is_non_stop_p () && !tp->executing)
|
if (target_is_non_stop_p () && !tp->executing ())
|
||||||
{
|
{
|
||||||
if (tp->has_pending_waitstatus ())
|
if (tp->has_pending_waitstatus ())
|
||||||
signo = tp->pending_waitstatus ().value.sig;
|
signo = tp->pending_waitstatus ().value.sig;
|
||||||
|
@ -1641,7 +1641,7 @@ thread_db_target::update_thread_list ()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
thread_info *thread = any_live_thread_of_inferior (inf);
|
thread_info *thread = any_live_thread_of_inferior (inf);
|
||||||
if (thread == NULL || thread->executing)
|
if (thread == NULL || thread->executing ())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* It's best to avoid td_ta_thr_iter if possible. That walks
|
/* It's best to avoid td_ta_thr_iter if possible. That walks
|
||||||
|
@ -1998,7 +1998,7 @@ get_thread_current_frame_id (struct thread_info *tp)
|
|||||||
For the former, EXECUTING is true and we're in wait, about to
|
For the former, EXECUTING is true and we're in wait, about to
|
||||||
move the thread. Since we need to recompute the stack, we temporarily
|
move the thread. Since we need to recompute the stack, we temporarily
|
||||||
set EXECUTING to false. */
|
set EXECUTING to false. */
|
||||||
executing = tp->executing;
|
executing = tp->executing ();
|
||||||
set_executing (proc_target, inferior_ptid, false);
|
set_executing (proc_target, inferior_ptid, false);
|
||||||
|
|
||||||
id = null_frame_id;
|
id = null_frame_id;
|
||||||
|
@ -3815,7 +3815,7 @@ target_pass_ctrlc (void)
|
|||||||
{
|
{
|
||||||
/* A thread can be THREAD_STOPPED and executing, while
|
/* A thread can be THREAD_STOPPED and executing, while
|
||||||
running an infcall. */
|
running an infcall. */
|
||||||
if (thr->state == THREAD_RUNNING || thr->executing)
|
if (thr->state == THREAD_RUNNING || thr->executing ())
|
||||||
{
|
{
|
||||||
/* We can get here quite deep in target layers. Avoid
|
/* We can get here quite deep in target layers. Avoid
|
||||||
switching thread context or anything that would
|
switching thread context or anything that would
|
||||||
|
37
gdb/thread.c
37
gdb/thread.c
@ -319,6 +319,16 @@ thread_info::deletable () const
|
|||||||
|
|
||||||
/* See gdbthread.h. */
|
/* See gdbthread.h. */
|
||||||
|
|
||||||
|
void
|
||||||
|
thread_info::set_executing (bool executing)
|
||||||
|
{
|
||||||
|
m_executing = executing;
|
||||||
|
if (executing)
|
||||||
|
this->set_stop_pc (~(CORE_ADDR) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See gdbthread.h. */
|
||||||
|
|
||||||
void
|
void
|
||||||
thread_info::set_resumed (bool resumed)
|
thread_info::set_resumed (bool resumed)
|
||||||
{
|
{
|
||||||
@ -625,13 +635,13 @@ any_live_thread_of_inferior (inferior *inf)
|
|||||||
curr_tp = inferior_thread ();
|
curr_tp = inferior_thread ();
|
||||||
if (curr_tp->state == THREAD_EXITED)
|
if (curr_tp->state == THREAD_EXITED)
|
||||||
curr_tp = NULL;
|
curr_tp = NULL;
|
||||||
else if (!curr_tp->executing)
|
else if (!curr_tp->executing ())
|
||||||
return curr_tp;
|
return curr_tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (thread_info *tp : inf->non_exited_threads ())
|
for (thread_info *tp : inf->non_exited_threads ())
|
||||||
{
|
{
|
||||||
if (!tp->executing)
|
if (!tp->executing ())
|
||||||
return tp;
|
return tp;
|
||||||
|
|
||||||
tp_executing = tp;
|
tp_executing = tp;
|
||||||
@ -841,24 +851,11 @@ set_running (process_stratum_target *targ, ptid_t ptid, bool running)
|
|||||||
gdb::observers::target_resumed.notify (ptid);
|
gdb::observers::target_resumed.notify (ptid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Helper for set_executing. Set's the thread's 'executing' field
|
|
||||||
from EXECUTING, and if EXECUTING is true also clears the thread's
|
|
||||||
stop_pc. */
|
|
||||||
|
|
||||||
static void
|
|
||||||
set_executing_thread (thread_info *thr, bool executing)
|
|
||||||
{
|
|
||||||
thr->executing = executing;
|
|
||||||
if (executing)
|
|
||||||
thr->set_stop_pc (~(CORE_ADDR) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
set_executing (process_stratum_target *targ, ptid_t ptid, bool executing)
|
set_executing (process_stratum_target *targ, ptid_t ptid, bool executing)
|
||||||
{
|
{
|
||||||
for (thread_info *tp : all_non_exited_threads (targ, ptid))
|
for (thread_info *tp : all_non_exited_threads (targ, ptid))
|
||||||
set_executing_thread (tp, executing);
|
tp->set_executing (executing);
|
||||||
|
|
||||||
/* It only takes one running thread to spawn more threads. */
|
/* It only takes one running thread to spawn more threads. */
|
||||||
if (executing)
|
if (executing)
|
||||||
@ -895,7 +892,7 @@ finish_thread_state (process_stratum_target *targ, ptid_t ptid)
|
|||||||
bool any_started = false;
|
bool any_started = false;
|
||||||
|
|
||||||
for (thread_info *tp : all_non_exited_threads (targ, ptid))
|
for (thread_info *tp : all_non_exited_threads (targ, ptid))
|
||||||
if (set_running_thread (tp, tp->executing))
|
if (set_running_thread (tp, tp->executing ()))
|
||||||
any_started = true;
|
any_started = true;
|
||||||
|
|
||||||
if (any_started)
|
if (any_started)
|
||||||
@ -922,7 +919,7 @@ validate_registers_access (void)
|
|||||||
at the prompt) when a thread is not executing for some internal
|
at the prompt) when a thread is not executing for some internal
|
||||||
reason, but is marked running from the user's perspective. E.g.,
|
reason, but is marked running from the user's perspective. E.g.,
|
||||||
the thread is waiting for its turn in the step-over queue. */
|
the thread is waiting for its turn in the step-over queue. */
|
||||||
if (tp->executing)
|
if (tp->executing ())
|
||||||
error (_("Selected thread is running."));
|
error (_("Selected thread is running."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,7 +937,7 @@ can_access_registers_thread (thread_info *thread)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* ... or from a spinning thread. FIXME: see validate_registers_access. */
|
/* ... or from a spinning thread. FIXME: see validate_registers_access. */
|
||||||
if (thread->executing)
|
if (thread->executing ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1997,7 +1994,7 @@ update_threads_executing (void)
|
|||||||
|
|
||||||
for (thread_info *tp : inf->non_exited_threads ())
|
for (thread_info *tp : inf->non_exited_threads ())
|
||||||
{
|
{
|
||||||
if (tp->executing)
|
if (tp->executing ())
|
||||||
{
|
{
|
||||||
targ->threads_executing = true;
|
targ->threads_executing = true;
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user