- Notifications
You must be signed in to change notification settings - Fork 15.6k
[lldb][AIX] Added Kill() implementation #169454
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
[lldb][AIX] Added Kill() implementation #169454
Conversation
| @llvm/pr-subscribers-lldb Author: Dhruv Srivastava (DhruvSrivastavaX) ChangesThis PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github. The complete changes for porting are present in this draft PR: Description: Full diff: https://github.com/llvm/llvm-project/pull/169454.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp index cd5e3458e60e8..7f3dbbff18ea2 100644 --- a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp +++ b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp @@ -137,6 +137,12 @@ void NativeProcessAIX::Manager::SigchldHandler() { auto wait_result = WaitPid(); if (!wait_result) return; + lldb::pid_t pid = wait_result->first; + WaitStatus status = wait_result->second; + + llvm::any_of(m_processes, [&](NativeProcessAIX *process) { + return process->TryHandleWaitStatus(pid, status); + }); } } @@ -187,7 +193,41 @@ Status NativeProcessAIX::Signal(int signo) { return Status("unsupported"); } Status NativeProcessAIX::Interrupt() { return Status("unsupported"); } -Status NativeProcessAIX::Kill() { return Status("unsupported"); } +Status NativeProcessAIX::Kill() { + + Log *log = GetLog(POSIXLog::Process); + LLDB_LOG(log, "pid {0}", GetID()); + + Status error; + + switch (m_state) { + case StateType::eStateInvalid: + case StateType::eStateExited: + case StateType::eStateCrashed: + case StateType::eStateDetached: + case StateType::eStateUnloaded: + // Nothing to do - the process is already dead. + LLDB_LOG(log, "ignored for PID {0} due to current state: {1}", GetID(), + m_state); + return error; + + case StateType::eStateConnected: + case StateType::eStateAttaching: + case StateType::eStateLaunching: + case StateType::eStateStopped: + case StateType::eStateRunning: + case StateType::eStateStepping: + case StateType::eStateSuspended: + // We can try to kill a process in these states. + break; + } + + llvm::Error result = + (PtraceWrapper(PT_KILL, GetID(), nullptr, nullptr, 0)).takeError(); + if (!result) + error.FromErrorString("Kill failed"); + return error; +} Status NativeProcessAIX::ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) { @@ -237,6 +277,7 @@ llvm::Expected<int> NativeProcessAIX::PtraceWrapper(int req, lldb::pid_t pid, switch (req) { case PT_ATTACH: case PT_DETACH: + case PT_KILL: ret = ptrace64(req, pid, 0, 0, nullptr); break; default: |
DavidSpickett left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine now, just some potentially stray changes to clarify.
DavidSpickett left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Do you need me to merge it for you?
Thanks! I'll merge, no problem |
This PR is in reference to porting LLDB on AIX.
Link to discussions on llvm discourse and github.
Complete changes together in this draft:
Description:
Extending Kill and SigchldHandler for NativeProcessAIX.
Ref: AIX ptrace