Skip to content

[lldb] Fix building on NetBSD 8.x #74191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -555,9 +578,7 @@ Status NativeProcessNetBSD::Signal(int signo) {
return error;
}

Status NativeProcessNetBSD::Interrupt() {
return PtraceWrapper(PT_STOP, GetID());
}
Status NativeProcessNetBSD::Interrupt() { return StopProcess(GetID()); }

Status NativeProcessNetBSD::Kill() {
Log *log = GetLog(POSIXLog::Process);
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down