From cf0bc8d0321a55f3f166131ec3fe45cdef7d5e3c Mon Sep 17 00:00:00 2001 From: Dhruv Srivastava Date: Fri, 20 Dec 2024 16:38:17 +0530 Subject: [PATCH] [lldb][AIX] Adding AIX version of ptrace64 (#120390) This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. https://github.com/llvm/llvm-project/issues/101657 The complete changes for porting are present in this draft PR: https://github.com/llvm/llvm-project/pull/102601 Adding changes for minimal build for lldb binary on AIX. ptrace64 is needed to debug 64-bit AIX debuggee, and its format is different than the traditional ptrace on other platforms: [AIX ptrace](https://www.ibm.com/docs/en/aix/7.3?topic=p-ptrace-ptracex-ptrace64-subroutine) --- lldb/source/Host/posix/ProcessLauncherPosixFork.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 4a0437b634ee39..7b8b42a4b7fe07 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -192,7 +192,11 @@ struct ForkLaunchInfo { } // Start tracing this child that is about to exec. +#ifdef _AIX + if (ptrace64(PT_TRACE_ME, 0, 0, 0, nullptr) == -1) +#else if (ptrace(PT_TRACE_ME, 0, nullptr, 0) == -1) +#endif ExitWithError(error_fd, "ptrace"); }