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:
Andrew Burgess 2021-08-10 11:20:44 +01:00
parent 9dc2f26777
commit 611841bb1a
11 changed files with 55 additions and 48 deletions

View file

@ -319,6 +319,16 @@ thread_info::deletable () const
/* 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
thread_info::set_resumed (bool resumed)
{
@ -625,13 +635,13 @@ any_live_thread_of_inferior (inferior *inf)
curr_tp = inferior_thread ();
if (curr_tp->state == THREAD_EXITED)
curr_tp = NULL;
else if (!curr_tp->executing)
else if (!curr_tp->executing ())
return curr_tp;
}
for (thread_info *tp : inf->non_exited_threads ())
{
if (!tp->executing)
if (!tp->executing ())
return 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);
}
/* 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
set_executing (process_stratum_target *targ, ptid_t ptid, bool executing)
{
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. */
if (executing)
@ -895,7 +892,7 @@ finish_thread_state (process_stratum_target *targ, ptid_t ptid)
bool any_started = false;
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;
if (any_started)
@ -922,7 +919,7 @@ validate_registers_access (void)
at the prompt) when a thread is not executing for some internal
reason, but is marked running from the user's perspective. E.g.,
the thread is waiting for its turn in the step-over queue. */
if (tp->executing)
if (tp->executing ())
error (_("Selected thread is running."));
}
@ -940,7 +937,7 @@ can_access_registers_thread (thread_info *thread)
return false;
/* ... or from a spinning thread. FIXME: see validate_registers_access. */
if (thread->executing)
if (thread->executing ())
return false;
return true;
@ -1997,7 +1994,7 @@ update_threads_executing (void)
for (thread_info *tp : inf->non_exited_threads ())
{
if (tp->executing)
if (tp->executing ())
{
targ->threads_executing = true;
return;