diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-08-10 11:20:44 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-09-07 12:44:08 +0100 |
commit | 611841bb1afc689becfab6dd490e1799aabf547d (patch) | |
tree | 9408d2caedec7fd55131479e3bb2964ad7382515 /gdb/thread.c | |
parent | 9dc2f26777b07f9e5aa3220f7a680987ef79e75e (diff) | |
download | binutils-611841bb1afc689becfab6dd490e1799aabf547d.zip binutils-611841bb1afc689becfab6dd490e1799aabf547d.tar.gz binutils-611841bb1afc689becfab6dd490e1799aabf547d.tar.bz2 |
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.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r-- | gdb/thread.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/gdb/thread.c b/gdb/thread.c index a82fb49..c95a918 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -320,6 +320,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) { if (resumed == m_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; |