Skip to content

Commit b96bae2

Browse files
authored
[lldb] Fix building on NetBSD 8.x (#74191)
PT_STOP was introduced with NetBSD 9.0.
1 parent c1e2457 commit b96bae2

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,29 @@ void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, int signal) {
379379
SetState(StateType::eStateStopped, true);
380380
}
381381

382+
Status NativeProcessNetBSD::StopProcess(lldb::pid_t pid) {
383+
#ifdef PT_STOP
384+
return PtraceWrapper(PT_STOP, pid);
385+
#else
386+
Log *log = GetLog(POSIXLog::Ptrace);
387+
Status error;
388+
int ret;
389+
390+
errno = 0;
391+
ret = kill(pid, SIGSTOP);
392+
393+
if (ret == -1)
394+
error.SetErrorToErrno();
395+
396+
LLDB_LOG(log, "kill({0}, SIGSTOP)", pid);
397+
398+
if (error.Fail())
399+
LLDB_LOG(log, "kill() failed: {0}", error);
400+
401+
return error;
402+
#endif
403+
}
404+
382405
Status NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
383406
int data, int *result) {
384407
Log *log = GetLog(POSIXLog::Ptrace);
@@ -531,7 +554,7 @@ Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) {
531554
return ret;
532555
}
533556

534-
Status NativeProcessNetBSD::Halt() { return PtraceWrapper(PT_STOP, GetID()); }
557+
Status NativeProcessNetBSD::Halt() { return StopProcess(GetID()); }
535558

536559
Status NativeProcessNetBSD::Detach() {
537560
Status error;
@@ -555,9 +578,7 @@ Status NativeProcessNetBSD::Signal(int signo) {
555578
return error;
556579
}
557580

558-
Status NativeProcessNetBSD::Interrupt() {
559-
return PtraceWrapper(PT_STOP, GetID());
560-
}
581+
Status NativeProcessNetBSD::Interrupt() { return StopProcess(GetID()); }
561582

562583
Status NativeProcessNetBSD::Kill() {
563584
Log *log = GetLog(POSIXLog::Process);

lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class NativeProcessNetBSD : public NativeProcessELF {
8888
// Interface used by NativeRegisterContext-derived classes.
8989
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
9090
int data = 0, int *result = nullptr);
91+
static Status StopProcess(lldb::pid_t pid);
9192

9293
llvm::Expected<std::string> SaveCore(llvm::StringRef path_hint) override;
9394

0 commit comments

Comments
 (0)