Index: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp =================================================================== --- lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -273,12 +273,14 @@ } switch (pst.pe_report_event) { - case PTRACE_LWP_CREATE: + case PTRACE_LWP_CREATE: { LLDB_LOG(log, "monitoring new thread, pid = {0}, LWP = {1}", GetID(), pst.pe_lwp); - AddThread(pst.pe_lwp); - break; + NativeThreadNetBSD& t = AddThread(pst.pe_lwp); + t.CopyWatchpointsFrom( + static_cast(*GetCurrentThread())); + } break; case PTRACE_LWP_EXIT: LLDB_LOG(log, "removing exited thread, pid = {0}, LWP = {1}", Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h =================================================================== --- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h +++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h @@ -30,6 +30,8 @@ static NativeRegisterContextNetBSD * CreateHostNativeRegisterContextNetBSD(const ArchSpec &target_arch, NativeThreadProtocol &native_thread); + virtual Status + CopyHardwareWatchpointsFrom(NativeRegisterContextNetBSD &source) = 0; protected: Status DoRegisterSet(int req, void *buf); Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h =================================================================== --- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h +++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h @@ -74,6 +74,10 @@ uint32_t NumSupportedHardwareWatchpoints() override; + Status + CopyHardwareWatchpointsFrom(NativeRegisterContextNetBSD &source) + override; + private: // Private member types. enum { GPRegSet, FPRegSet, XStateRegSet, DBRegSet }; Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp =================================================================== --- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -995,4 +995,15 @@ return 4; } +Status NativeRegisterContextNetBSD_x86_64::CopyHardwareWatchpointsFrom( + NativeRegisterContextNetBSD &source) { + auto &r_source = static_cast(source); + Status res = r_source.ReadRegisterSet(DBRegSet); + if (!res.Fail()) { + m_dbr_x86_64 = r_source.m_dbr_x86_64; + res = WriteRegisterSet(DBRegSet); + } + return res; +} + #endif // defined(__x86_64__) Index: lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h =================================================================== --- lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h +++ lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h @@ -62,6 +62,8 @@ void SetRunning(); void SetStepping(); + Status CopyWatchpointsFrom(NativeThreadNetBSD& source); + // Member Variables lldb::StateType m_state; ThreadStopInfo m_stop_info; Index: lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp =================================================================== --- lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp +++ lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -247,3 +247,15 @@ return Status("Clearing hardware breakpoint failed."); } + +Status NativeThreadNetBSD::CopyWatchpointsFrom(NativeThreadNetBSD &source) { + Status s = static_cast(GetRegisterContext()) + .CopyHardwareWatchpointsFrom( + static_cast( + source.GetRegisterContext())); + if (!s.Fail()) { + m_watchpoint_index_map = source.m_watchpoint_index_map; + m_hw_break_index_map = source.m_hw_break_index_map; + } + return s; +}