[Lldb-commits] [lldb] ccd9091 - [lldb][NFC] Don't let Process inherit from UserID
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 18 05:34:08 PST 2020
Author: Raphael Isemann
Date: 2020-11-18T14:33:48+01:00
New Revision: ccd9091d4a2fd55cb455e61fa77530e1a5de6e69
URL: https://github.com/llvm/llvm-project/commit/ccd9091d4a2fd55cb455e61fa77530e1a5de6e69
DIFF: https://github.com/llvm/llvm-project/commit/ccd9091d4a2fd55cb455e61fa77530e1a5de6e69.diff
LOG: [lldb][NFC] Don't let Process inherit from UserID
I noticed that Process is inheriting from UserID to store its PID value. This patch
replaces this with a dedicated field in the Process class. This is NFC, but has some
small effects on the code using Process:
* `GetID()` now returns a `lldb::pid_t` like all other process code instead of `lldb::user_id_t`. Both are typedefs for `uint64_t`, so no change in behaviour.
* The equality operators defined for UserID no longer accept Process instances.
* Removes the inherited method `Process::Clear()` which didn't actually clear anything beside the PID value.
We maybe should also remove the getters/setters to `S/GetPID` or something like that. I can update all the code for that
in a follow-up NFC commit.
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D91699
Added:
Modified:
lldb/include/lldb/Target/Process.h
lldb/source/Target/Process.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index a1a9760c0006..2c21b80d7309 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -364,7 +364,6 @@ inline bool operator!=(const ProcessModID &lhs, const ProcessModID &rhs) {
/// A plug-in interface definition class for debugging a process.
class Process : public std::enable_shared_from_this<Process>,
public ProcessProperties,
- public UserID,
public Broadcaster,
public ExecutionContextScope,
public PluginInterface {
@@ -560,6 +559,15 @@ class Process : public std::enable_shared_from_this<Process>,
uint32_t GetAddressByteSize() const;
+ /// Sets the stored pid.
+ ///
+ /// This does not change the pid of underlying process.
+ lldb::pid_t GetID() const { return m_pid; }
+
+ /// Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is
+ /// no known pid.
+ void SetID(lldb::pid_t new_pid) { m_pid = new_pid; }
+
uint32_t GetUniqueID() const { return m_process_unique_id; }
/// Check if a plug-in instance can debug the file in \a module.
@@ -2730,6 +2738,7 @@ void PruneThreadPlans();
// Member variables
std::weak_ptr<Target> m_target_wp; ///< The target that owns this process.
+ lldb::pid_t m_pid = LLDB_INVALID_PROCESS_ID;
ThreadSafeValue<lldb::StateType> m_public_state;
ThreadSafeValue<lldb::StateType>
m_private_state; // The actual state of our process
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 490ca45bfee2..d32d3df5c8e6 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -529,7 +529,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp)
Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
const UnixSignalsSP &unix_signals_sp)
- : ProcessProperties(this), UserID(LLDB_INVALID_PROCESS_ID),
+ : ProcessProperties(this),
Broadcaster((target_sp->GetDebugger().GetBroadcasterManager()),
Process::GetStaticBroadcasterClass().AsCString()),
m_target_wp(target_sp), m_public_state(eStateUnloaded),
More information about the lldb-commits
mailing list