diff options
author | Lancelot SIX <lancelot.six@amd.com> | 2022-01-11 10:10:11 -0500 |
---|---|---|
committer | Lancelot SIX <lancelot.six@amd.com> | 2022-02-07 06:12:06 -0500 |
commit | 573269a87c89ae866db556428fe9ea63d6c4db5f (patch) | |
tree | eb6f3111a711e0609ee6db4ff25e17d3ae889194 /gdb/thread.c | |
parent | d08cbc5d3203118da5583296e49273cf82378042 (diff) | |
download | gdb-573269a87c89ae866db556428fe9ea63d6c4db5f.zip gdb-573269a87c89ae866db556428fe9ea63d6c4db5f.tar.gz gdb-573269a87c89ae866db556428fe9ea63d6c4db5f.tar.bz2 |
gdb: make thread_info::m_thread_fsm a std::unique_ptr
While working on function calls, I realized that the thread_fsm member
of struct thread_info is a raw pointer to a resource it owns. This
commit changes the type of the thread_fsm member to a std::unique_ptr in
order to signify this ownership relationship and slightly ease resource
management (no need to manually call delete).
To ensure consistent use, the field is made a private member
(m_thread_fsm). The setter method (set_thread_fsm) can then check
that it is incorrect to associate a FSM to a thread_info object if
another one is already in place. This is ensured by an assertion.
The function run_inferior_call takes an argument as a pointer to a
call_thread_fsm and installs it in it in a thread_info instance. Also
change this function's signature to accept a unique_ptr in order to
signify that the ownership of the call_thread_fsm is transferred during
the call.
No user visible change expected after this commit.
Tested on x86_64-linux with no regression observed.
Change-Id: Ia1224f72a4afa247801ce6650ce82f90224a9ae8
Diffstat (limited to 'gdb/thread.c')
-rw-r--r-- | gdb/thread.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gdb/thread.c b/gdb/thread.c index 611be3f..12f3abd 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -160,11 +160,10 @@ thread_has_single_step_breakpoint_here (struct thread_info *tp, void thread_cancel_execution_command (struct thread_info *thr) { - if (thr->thread_fsm != NULL) + if (thr->thread_fsm () != nullptr) { - thr->thread_fsm->clean_up (thr); - delete thr->thread_fsm; - thr->thread_fsm = NULL; + std::unique_ptr<thread_fsm> fsm = thr->release_thread_fsm (); + fsm->clean_up (thr); } } |