aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Host/common/NativeProcessProtocol.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-08-22 19:00:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-11-13 20:39:49 +0000
commitfe6060f10f634930ff71b7c50291ddc610da2475 (patch)
tree1483580c790bd4d27b6500a7542b5ee00534d3cc /contrib/llvm-project/lldb/source/Host/common/NativeProcessProtocol.cpp
parentb61bce17f346d79cecfd8f195a64b10f77be43b1 (diff)
parent344a3780b2e33f6ca763666c380202b18aab72a3 (diff)
Diffstat (limited to 'contrib/llvm-project/lldb/source/Host/common/NativeProcessProtocol.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Host/common/NativeProcessProtocol.cpp72
1 files changed, 20 insertions, 52 deletions
diff --git a/contrib/llvm-project/lldb/source/Host/common/NativeProcessProtocol.cpp b/contrib/llvm-project/lldb/source/Host/common/NativeProcessProtocol.cpp
index 070fda664678..ea80a05430f7 100644
--- a/contrib/llvm-project/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/contrib/llvm-project/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -25,10 +25,8 @@ using namespace lldb_private;
NativeProcessProtocol::NativeProcessProtocol(lldb::pid_t pid, int terminal_fd,
NativeDelegate &delegate)
- : m_pid(pid), m_terminal_fd(terminal_fd) {
- bool registered = RegisterNativeDelegate(delegate);
- assert(registered);
- (void)registered;
+ : m_pid(pid), m_delegate(delegate), m_terminal_fd(terminal_fd) {
+ delegate.InitializeDelegate(this);
}
lldb_private::Status NativeProcessProtocol::Interrupt() {
@@ -54,6 +52,19 @@ NativeProcessProtocol::GetMemoryRegionInfo(lldb::addr_t load_addr,
return Status("not implemented");
}
+lldb_private::Status
+NativeProcessProtocol::ReadMemoryTags(int32_t type, lldb::addr_t addr,
+ size_t len, std::vector<uint8_t> &tags) {
+ return Status("not implemented");
+}
+
+lldb_private::Status
+NativeProcessProtocol::WriteMemoryTags(int32_t type, lldb::addr_t addr,
+ size_t len,
+ const std::vector<uint8_t> &tags) {
+ return Status("not implemented");
+}
+
llvm::Optional<WaitStatus> NativeProcessProtocol::GetExitStatus() {
if (m_state == lldb::eStateExited)
return m_exit_status;
@@ -295,64 +306,21 @@ Status NativeProcessProtocol::RemoveHardwareBreakpoint(lldb::addr_t addr) {
return error;
}
-bool NativeProcessProtocol::RegisterNativeDelegate(
- NativeDelegate &native_delegate) {
- std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
- if (llvm::is_contained(m_delegates, &native_delegate))
- return false;
-
- m_delegates.push_back(&native_delegate);
- native_delegate.InitializeDelegate(this);
- return true;
-}
-
-bool NativeProcessProtocol::UnregisterNativeDelegate(
- NativeDelegate &native_delegate) {
- std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
-
- const auto initial_size = m_delegates.size();
- m_delegates.erase(
- remove(m_delegates.begin(), m_delegates.end(), &native_delegate),
- m_delegates.end());
-
- // We removed the delegate if the count of delegates shrank after removing
- // all copies of the given native_delegate from the vector.
- return m_delegates.size() < initial_size;
-}
-
void NativeProcessProtocol::SynchronouslyNotifyProcessStateChanged(
lldb::StateType state) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
- for (auto native_delegate : m_delegates)
- native_delegate->ProcessStateChanged(this, state);
+ m_delegate.ProcessStateChanged(this, state);
- if (log) {
- if (!m_delegates.empty()) {
- LLDB_LOGF(log,
- "NativeProcessProtocol::%s: sent state notification [%s] "
- "from process %" PRIu64,
- __FUNCTION__, lldb_private::StateAsCString(state), GetID());
- } else {
- LLDB_LOGF(log,
- "NativeProcessProtocol::%s: would send state notification "
- "[%s] from process %" PRIu64 ", but no delegates",
- __FUNCTION__, lldb_private::StateAsCString(state), GetID());
- }
- }
+ LLDB_LOG(log, "sent state notification [{0}] from process {1}", state,
+ GetID());
}
void NativeProcessProtocol::NotifyDidExec() {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- LLDB_LOGF(log, "NativeProcessProtocol::%s - preparing to call delegates",
- __FUNCTION__);
+ LLDB_LOG(log, "process {0} exec()ed", GetID());
- {
- std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
- for (auto native_delegate : m_delegates)
- native_delegate->DidExec(this);
- }
+ m_delegate.DidExec(this);
}
Status NativeProcessProtocol::SetSoftwareBreakpoint(lldb::addr_t addr,