https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/74191
PT_STOP was introduced with NetBSD 9.0. >From a52f402403beeb9aefbc28e80622b9d3bfb30d63 Mon Sep 17 00:00:00 2001 From: Brad Smith <b...@comstyle.com> Date: Sat, 2 Dec 2023 05:52:53 -0500 Subject: [PATCH] [lldb] Fix building on NetBSD 8.x --- .../Process/NetBSD/NativeProcessNetBSD.cpp | 27 +++++++++++++++++-- .../Process/NetBSD/NativeProcessNetBSD.h | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp index 26c562bd4790..7f3e1a008727 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -379,6 +379,29 @@ void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, int signal) { SetState(StateType::eStateStopped, true); } +Status NativeProcessNetBSD::StopProcess(lldb::pid_t pid) { +#ifdef PT_STOP + return PtraceWrapper(PT_STOP, pid); +#else + Log *log = GetLog(POSIXLog::Ptrace); + Status error; + int ret; + + errno = 0; + ret = kill(pid, SIGSTOP); + + if (ret == -1) + error.SetErrorToErrno(); + + LLDB_LOG(log, "kill({0}, SIGSTOP)", pid); + + if (error.Fail()) + LLDB_LOG(log, "kill() failed: {0}", error); + + return error; +#endif +} + Status NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data, int *result) { Log *log = GetLog(POSIXLog::Ptrace); @@ -531,7 +554,7 @@ Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) { return ret; } -Status NativeProcessNetBSD::Halt() { return PtraceWrapper(PT_STOP, GetID()); } +Status NativeProcessNetBSD::Halt() { return StopProcess(GetID()); } Status NativeProcessNetBSD::Detach() { Status error; @@ -556,7 +579,7 @@ Status NativeProcessNetBSD::Signal(int signo) { } Status NativeProcessNetBSD::Interrupt() { - return PtraceWrapper(PT_STOP, GetID()); + return StopProcess(GetID()); } Status NativeProcessNetBSD::Kill() { diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h index 86724fdd5b7e..f3d07651384f 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h +++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h @@ -88,6 +88,7 @@ class NativeProcessNetBSD : public NativeProcessELF { // Interface used by NativeRegisterContext-derived classes. static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, int data = 0, int *result = nullptr); + static Status StopProcess(lldb::pid_t pid); llvm::Expected<std::string> SaveCore(llvm::StringRef path_hint) override; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits