summaryrefslogtreecommitdiff
path: root/source/Plugins/Process/NetBSD
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:36 +0000
commitef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch)
tree27916256fdeeb57d10d2f3d6948be5d71a703215 /source/Plugins/Process/NetBSD
parent76e0736e7fcfeb179779e49c05604464b1ccd704 (diff)
Notes
Diffstat (limited to 'source/Plugins/Process/NetBSD')
-rw-r--r--source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp117
-rw-r--r--source/Plugins/Process/NetBSD/NativeProcessNetBSD.h10
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp4
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h4
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp11
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h3
-rw-r--r--source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp36
-rw-r--r--source/Plugins/Process/NetBSD/NativeThreadNetBSD.h4
8 files changed, 71 insertions, 118 deletions
diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
index 388989a21f76..387f04afa5b4 100644
--- a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -109,10 +109,8 @@ NativeProcessNetBSD::Factory::Launch(ProcessLaunchInfo &launch_info,
if (status.Fail())
return status.ToError();
- for (const auto &thread_sp : process_up->m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
- SIGSTOP);
- }
+ for (const auto &thread : process_up->m_threads)
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedBySignal(SIGSTOP);
process_up->SetState(StateType::eStateStopped);
return std::move(process_up);
@@ -198,9 +196,9 @@ void NativeProcessNetBSD::MonitorSIGSTOP(lldb::pid_t pid) {
// Handle SIGSTOP from LLGS (LLDB GDB Server)
if (info.psi_siginfo.si_code == SI_USER &&
info.psi_siginfo.si_pid == ::getpid()) {
- /* Stop Tracking All Threads attached to Process */
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
+ /* Stop Tracking all Threads attached to Process */
+ for (const auto &thread : m_threads) {
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedBySignal(
SIGSTOP, &info.psi_siginfo);
}
}
@@ -221,18 +219,15 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) {
switch (info.psi_siginfo.si_code) {
case TRAP_BRKPT:
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)
- ->SetStoppedByBreakpoint();
- FixupBreakpointPCAsNeeded(
- *static_pointer_cast<NativeThreadNetBSD>(thread_sp));
+ for (const auto &thread : m_threads) {
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedByBreakpoint();
+ FixupBreakpointPCAsNeeded(static_cast<NativeThreadNetBSD &>(*thread));
}
SetState(StateType::eStateStopped, true);
break;
case TRAP_TRACE:
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedByTrace();
- }
+ for (const auto &thread : m_threads)
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedByTrace();
SetState(StateType::eStateStopped, true);
break;
case TRAP_EXEC: {
@@ -245,38 +240,35 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) {
// Let our delegate know we have just exec'd.
NotifyDidExec();
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedByExec();
- }
+ for (const auto &thread : m_threads)
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedByExec();
SetState(StateType::eStateStopped, true);
} break;
case TRAP_DBREG: {
// If a watchpoint was hit, report it
uint32_t wp_index;
- Status error =
- static_pointer_cast<NativeThreadNetBSD>(m_threads[info.psi_lwpid])
- ->GetRegisterContext()
- ->GetWatchpointHitIndex(wp_index,
- (uintptr_t)info.psi_siginfo.si_addr);
+ Status error = static_cast<NativeThreadNetBSD &>(*m_threads[info.psi_lwpid])
+ .GetRegisterContext()
+ .GetWatchpointHitIndex(
+ wp_index, (uintptr_t)info.psi_siginfo.si_addr);
if (error.Fail())
LLDB_LOG(log,
"received error while checking for watchpoint hits, pid = "
"{0}, LWP = {1}, error = {2}",
GetID(), info.psi_lwpid, error);
if (wp_index != LLDB_INVALID_INDEX32) {
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)
- ->SetStoppedByWatchpoint(wp_index);
- }
+ for (const auto &thread : m_threads)
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedByWatchpoint(
+ wp_index);
SetState(StateType::eStateStopped, true);
break;
}
// If a breakpoint was hit, report it
uint32_t bp_index;
- error = static_pointer_cast<NativeThreadNetBSD>(m_threads[info.psi_lwpid])
- ->GetRegisterContext()
- ->GetHardwareBreakHitIndex(bp_index,
+ error = static_cast<NativeThreadNetBSD &>(*m_threads[info.psi_lwpid])
+ .GetRegisterContext()
+ .GetHardwareBreakHitIndex(bp_index,
(uintptr_t)info.psi_siginfo.si_addr);
if (error.Fail())
LLDB_LOG(log,
@@ -284,10 +276,8 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) {
"breakpoint hits, pid = {0}, LWP = {1}, error = {2}",
GetID(), info.psi_lwpid, error);
if (bp_index != LLDB_INVALID_INDEX32) {
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)
- ->SetStoppedByBreakpoint();
- }
+ for (const auto &thread : m_threads)
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedByBreakpoint();
SetState(StateType::eStateStopped, true);
break;
}
@@ -300,8 +290,8 @@ void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, int signal) {
const auto siginfo_err =
PtraceWrapper(PT_GET_SIGINFO, pid, &info, sizeof(info));
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
+ for (const auto &thread : m_threads) {
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedBySignal(
info.psi_siginfo.si_signo, &info.psi_siginfo);
}
SetState(StateType::eStateStopped, true);
@@ -351,12 +341,7 @@ NativeProcessNetBSD::FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread) {
Status error;
// Find out the size of a breakpoint (might depend on where we are in the
// code).
- NativeRegisterContextSP context_sp = thread.GetRegisterContext();
- if (!context_sp) {
- error.SetErrorString("cannot get a NativeRegisterContext for the thread");
- LLDB_LOG(log, "failed: {0}", error);
- return error;
- }
+ NativeRegisterContext& context = thread.GetRegisterContext();
uint32_t breakpoint_size = 0;
error = GetSoftwareBreakpointPCOffset(breakpoint_size);
if (error.Fail()) {
@@ -367,7 +352,7 @@ NativeProcessNetBSD::FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread) {
// First try probing for a breakpoint at a software breakpoint location: PC
// - breakpoint size.
const lldb::addr_t initial_pc_addr =
- context_sp->GetPCfromBreakpointLocation();
+ context.GetPCfromBreakpointLocation();
lldb::addr_t breakpoint_addr = initial_pc_addr;
if (breakpoint_size > 0) {
// Do not allow breakpoint probe to wrap around.
@@ -420,7 +405,7 @@ NativeProcessNetBSD::FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread) {
// Change the program counter.
LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(),
thread.GetID(), initial_pc_addr, breakpoint_addr);
- error = context_sp->SetPC(breakpoint_addr);
+ error = context.SetPC(breakpoint_addr);
if (error.Fail()) {
LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(),
thread.GetID(), error);
@@ -433,13 +418,13 @@ Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
LLDB_LOG(log, "pid {0}", GetID());
- const auto &thread_sp = m_threads[0];
+ const auto &thread = m_threads[0];
const ResumeAction *const action =
- resume_actions.GetActionForThread(thread_sp->GetID(), true);
+ resume_actions.GetActionForThread(thread->GetID(), true);
if (action == nullptr) {
LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(),
- thread_sp->GetID());
+ thread->GetID());
return Status();
}
@@ -452,9 +437,8 @@ Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) {
action->signal);
if (!error.Success())
return error;
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetRunning();
- }
+ for (const auto &thread : m_threads)
+ static_cast<NativeThreadNetBSD &>(*thread).SetRunning();
SetState(eStateRunning, true);
break;
}
@@ -464,9 +448,8 @@ Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) {
action->signal);
if (!error.Success())
return error;
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStepping();
- }
+ for (const auto &thread : m_threads)
+ static_cast<NativeThreadNetBSD &>(*thread).SetStepping();
SetState(eStateStepping, true);
break;
@@ -478,7 +461,7 @@ Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) {
return Status("NativeProcessNetBSD::%s (): unexpected state %s specified "
"for pid %" PRIu64 ", tid %" PRIu64,
__FUNCTION__, StateAsCString(action->state), GetID(),
- thread_sp->GetID());
+ thread->GetID());
}
return Status();
@@ -690,11 +673,6 @@ lldb::addr_t NativeProcessNetBSD::GetSharedLibraryInfoAddress() {
size_t NativeProcessNetBSD::UpdateThreads() { return m_threads.size(); }
-bool NativeProcessNetBSD::GetArchitecture(ArchSpec &arch) const {
- arch = m_arch;
- return true;
-}
-
Status NativeProcessNetBSD::SetBreakpoint(lldb::addr_t addr, uint32_t size,
bool hardware) {
if (hardware)
@@ -764,9 +742,9 @@ void NativeProcessNetBSD::SigchldHandler() {
}
bool NativeProcessNetBSD::HasThreadNoLock(lldb::tid_t thread_id) {
- for (auto thread_sp : m_threads) {
- assert(thread_sp && "thread list should not contain NULL threads");
- if (thread_sp->GetID() == thread_id) {
+ for (const auto &thread : m_threads) {
+ assert(thread && "thread list should not contain NULL threads");
+ if (thread->GetID() == thread_id) {
// We have this thread.
return true;
}
@@ -776,7 +754,7 @@ bool NativeProcessNetBSD::HasThreadNoLock(lldb::tid_t thread_id) {
return false;
}
-NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) {
+NativeThreadNetBSD &NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
LLDB_LOG(log, "pid {0} adding thread with tid {1}", GetID(), thread_id);
@@ -788,9 +766,8 @@ NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) {
if (m_threads.empty())
SetCurrentThreadID(thread_id);
- auto thread_sp = std::make_shared<NativeThreadNetBSD>(*this, thread_id);
- m_threads.push_back(thread_sp);
- return thread_sp;
+ m_threads.push_back(llvm::make_unique<NativeThreadNetBSD>(*this, thread_id));
+ return static_cast<NativeThreadNetBSD &>(*m_threads.back());
}
Status NativeProcessNetBSD::Attach() {
@@ -811,10 +788,8 @@ Status NativeProcessNetBSD::Attach() {
if (status.Fail())
return status;
- for (const auto &thread_sp : m_threads) {
- static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
- SIGSTOP);
- }
+ for (const auto &thread : m_threads)
+ static_cast<NativeThreadNetBSD &>(*thread).SetStoppedBySignal(SIGSTOP);
// Let our process instance know the thread has stopped.
SetState(StateType::eStateStopped);
@@ -928,7 +903,7 @@ Status NativeProcessNetBSD::ReinitializeThreads() {
}
// Reinitialize from scratch threads and register them in process
while (info.pl_lwpid != 0) {
- NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid);
+ AddThread(info.pl_lwpid);
error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info));
if (error.Fail()) {
return error;
diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
index 2cbd5e30ab23..7090fce34fc9 100644
--- a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
+++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
@@ -10,12 +10,8 @@
#ifndef liblldb_NativeProcessNetBSD_H_
#define liblldb_NativeProcessNetBSD_H_
-// C++ Includes
-
-// Other libraries and framework includes
-
-#include "lldb/Core/ArchSpec.h"
#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/FileSpec.h"
#include "NativeThreadNetBSD.h"
@@ -77,7 +73,7 @@ public:
size_t UpdateThreads() override;
- bool GetArchitecture(ArchSpec &arch) const override;
+ const ArchSpec &GetArchitecture() const override { return m_arch; }
Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
bool hardware) override;
@@ -121,7 +117,7 @@ private:
bool HasThreadNoLock(lldb::tid_t thread_id);
- NativeThreadNetBSDSP AddThread(lldb::tid_t thread_id);
+ NativeThreadNetBSD &AddThread(lldb::tid_t thread_id);
void MonitorCallback(lldb::pid_t pid, int signal);
void MonitorExited(lldb::pid_t pid, WaitStatus status);
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
index dde86880c41a..d4fef6342439 100644
--- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
@@ -20,9 +20,9 @@ using namespace lldb_private::process_netbsd;
// clang-format on
NativeRegisterContextNetBSD::NativeRegisterContextNetBSD(
- NativeThreadProtocol &native_thread, uint32_t concrete_frame_idx,
+ NativeThreadProtocol &native_thread,
RegisterInfoInterface *reg_info_interface_p)
- : NativeRegisterContextRegisterInfo(native_thread, concrete_frame_idx,
+ : NativeRegisterContextRegisterInfo(native_thread,
reg_info_interface_p) {}
Status NativeRegisterContextNetBSD::ReadGPR() {
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
index d96b7aea0048..b81430e7f5ac 100644
--- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
@@ -21,7 +21,6 @@ namespace process_netbsd {
class NativeRegisterContextNetBSD : public NativeRegisterContextRegisterInfo {
public:
NativeRegisterContextNetBSD(NativeThreadProtocol &native_thread,
- uint32_t concrete_frame_idx,
RegisterInfoInterface *reg_info_interface_p);
// This function is implemented in the NativeRegisterContextNetBSD_*
@@ -31,8 +30,7 @@ public:
// executable.
static NativeRegisterContextNetBSD *
CreateHostNativeRegisterContextNetBSD(const ArchSpec &target_arch,
- NativeThreadProtocol &native_thread,
- uint32_t concrete_frame_idx);
+ NativeThreadProtocol &native_thread);
protected:
virtual Status ReadGPR();
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
index 9690da0e1374..347c15ae5b23 100644
--- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -149,10 +149,8 @@ const int fpu_save = []() -> int {
NativeRegisterContextNetBSD *
NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(
- const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
- uint32_t concrete_frame_idx) {
- return new NativeRegisterContextNetBSD_x86_64(target_arch, native_thread,
- concrete_frame_idx);
+ const ArchSpec &target_arch, NativeThreadProtocol &native_thread) {
+ return new NativeRegisterContextNetBSD_x86_64(target_arch, native_thread);
}
// ----------------------------------------------------------------------------
@@ -169,9 +167,8 @@ CreateRegisterInfoInterface(const ArchSpec &target_arch) {
}
NativeRegisterContextNetBSD_x86_64::NativeRegisterContextNetBSD_x86_64(
- const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
- uint32_t concrete_frame_idx)
- : NativeRegisterContextNetBSD(native_thread, concrete_frame_idx,
+ const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
+ : NativeRegisterContextNetBSD(native_thread,
CreateRegisterInfoInterface(target_arch)),
m_gpr_x86_64(), m_fpr_x86_64(), m_dbr_x86_64() {}
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
index 5f5a6a0792e4..c55ddfec6615 100644
--- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
@@ -30,8 +30,7 @@ class NativeProcessNetBSD;
class NativeRegisterContextNetBSD_x86_64 : public NativeRegisterContextNetBSD {
public:
NativeRegisterContextNetBSD_x86_64(const ArchSpec &target_arch,
- NativeThreadProtocol &native_thread,
- uint32_t concrete_frame_idx);
+ NativeThreadProtocol &native_thread);
uint32_t GetRegisterSetCount() const override;
const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
index 1fd7400bf800..83f1da78d01d 100644
--- a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -27,7 +27,9 @@ using namespace lldb_private::process_netbsd;
NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD &process,
lldb::tid_t tid)
: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
- m_stop_info(), m_reg_context_sp(), m_stop_description() {}
+ m_stop_info(), m_reg_context_up(
+NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(process.GetArchitecture(), *this)
+), m_stop_description() {}
void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo,
const siginfo_t *info) {
@@ -77,10 +79,10 @@ void NativeThreadNetBSD::SetStoppedByWatchpoint(uint32_t wp_index) {
lldbassert(wp_index != LLDB_INVALID_INDEX32 && "wp_index cannot be invalid");
std::ostringstream ostr;
- ostr << GetRegisterContext()->GetWatchpointAddress(wp_index) << " ";
+ ostr << GetRegisterContext().GetWatchpointAddress(wp_index) << " ";
ostr << wp_index;
- ostr << " " << GetRegisterContext()->GetWatchpointHitAddress(wp_index);
+ ostr << " " << GetRegisterContext().GetWatchpointHitAddress(wp_index);
m_stop_description = ostr.str();
@@ -139,21 +141,9 @@ bool NativeThreadNetBSD::GetStopReason(ThreadStopInfo &stop_info,
llvm_unreachable("unhandled StateType!");
}
-NativeRegisterContextSP NativeThreadNetBSD::GetRegisterContext() {
- // Return the register context if we already created it.
- if (m_reg_context_sp)
- return m_reg_context_sp;
-
- ArchSpec target_arch;
- if (!m_process.GetArchitecture(target_arch))
- return NativeRegisterContextSP();
-
- const uint32_t concrete_frame_idx = 0;
- m_reg_context_sp.reset(
- NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(
- target_arch, *this, concrete_frame_idx));
-
- return m_reg_context_sp;
+NativeRegisterContext& NativeThreadNetBSD::GetRegisterContext() {
+ assert(m_reg_context_up);
+return *m_reg_context_up;
}
Status NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size,
@@ -165,8 +155,7 @@ Status NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size,
Status error = RemoveWatchpoint(addr);
if (error.Fail())
return error;
- NativeRegisterContextSP reg_ctx = GetRegisterContext();
- uint32_t wp_index = reg_ctx->SetHardwareWatchpoint(addr, size, watch_flags);
+ uint32_t wp_index = GetRegisterContext().SetHardwareWatchpoint(addr, size, watch_flags);
if (wp_index == LLDB_INVALID_INDEX32)
return Status("Setting hardware watchpoint failed.");
m_watchpoint_index_map.insert({addr, wp_index});
@@ -179,7 +168,7 @@ Status NativeThreadNetBSD::RemoveWatchpoint(lldb::addr_t addr) {
return Status();
uint32_t wp_index = wp->second;
m_watchpoint_index_map.erase(wp);
- if (GetRegisterContext()->ClearHardwareWatchpoint(wp_index))
+ if (GetRegisterContext().ClearHardwareWatchpoint(wp_index))
return Status();
return Status("Clearing hardware watchpoint failed.");
}
@@ -193,8 +182,7 @@ Status NativeThreadNetBSD::SetHardwareBreakpoint(lldb::addr_t addr,
if (error.Fail())
return error;
- NativeRegisterContextSP reg_ctx = GetRegisterContext();
- uint32_t bp_index = reg_ctx->SetHardwareBreakpoint(addr, size);
+ uint32_t bp_index = GetRegisterContext().SetHardwareBreakpoint(addr, size);
if (bp_index == LLDB_INVALID_INDEX32)
return Status("Setting hardware breakpoint failed.");
@@ -209,7 +197,7 @@ Status NativeThreadNetBSD::RemoveHardwareBreakpoint(lldb::addr_t addr) {
return Status();
uint32_t bp_index = bp->second;
- if (GetRegisterContext()->ClearHardwareBreakpoint(bp_index)) {
+ if (GetRegisterContext().ClearHardwareBreakpoint(bp_index)) {
m_hw_break_index_map.erase(bp);
return Status();
}
diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
index 1e3f587be5f5..72426244c112 100644
--- a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
+++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
@@ -37,7 +37,7 @@ public:
bool GetStopReason(ThreadStopInfo &stop_info,
std::string &description) override;
- NativeRegisterContextSP GetRegisterContext() override;
+ NativeRegisterContext& GetRegisterContext() override;
Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
bool hardware) override;
@@ -67,7 +67,7 @@ private:
// ---------------------------------------------------------------------
lldb::StateType m_state;
ThreadStopInfo m_stop_info;
- NativeRegisterContextSP m_reg_context_sp;
+ std::unique_ptr<NativeRegisterContext> m_reg_context_up;
std::string m_stop_description;
using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
WatchpointIndexMap m_watchpoint_index_map;