Skip to content
Open
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
43 changes: 42 additions & 1 deletion lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}

Expand Down Expand Up @@ -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();
Copy link
Member Author

@DhruvSrivastavaX DhruvSrivastavaX Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SIGKILL on a traced debuggee does not trigger SIGCHLD, thats why we use PT_KILL on AIX.

if (!result)
error.FromErrorString("Kill failed");
return error;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either return the error without modification (assuming there's a Status constructor from llvm::Error), or, if the error back from PTraceWrapper can be formatted, add that to your "Kill failed" message.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see later that the error will be the errno, so you could format that. llvm::Error might have a generic toString type method on it.

}

Status NativeProcessAIX::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
size_t &bytes_read) {
Expand Down Expand Up @@ -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:
Expand Down
Loading