-
Notifications
You must be signed in to change notification settings - Fork 14k
[lldb][AIX] Adding AIX version of ptrace64 #120390
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
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:
Adding changes for minimal build for lldb binary on AIX. Review Request: @labath @DavidSpickett Full diff: https://github.com/llvm/llvm-project/pull/120390.diff 1 Files Affected:
diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
index 4a9469bde2f186..0e162d04c35837 100644
--- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -21,8 +21,8 @@
#include <sys/wait.h>
#include <unistd.h>
-#include <sstream>
#include <csignal>
+#include <sstream>
#ifdef __ANDROID__
#include <android/api-level.h>
@@ -47,8 +47,7 @@ static void write_string(int error_fd, const char *str) {
(void)r;
}
-[[noreturn]] static void ExitWithError(int error_fd,
- const char *operation) {
+[[noreturn]] static void ExitWithError(int error_fd, const char *operation) {
int err = errno;
write_string(error_fd, operation);
write_string(error_fd, " failed: ");
@@ -193,8 +192,13 @@ struct ForkLaunchInfo {
}
// Start tracing this child that is about to exec.
+#if !defined(_AIX)
if (ptrace(PT_TRACE_ME, 0, nullptr, 0) == -1)
ExitWithError(error_fd, "ptrace");
+#else
+ if (ptrace64(PT_TRACE_ME, 0, 0, 0, nullptr) == -1)
+ ExitWithError(error_fd, "ptrace");
+#endif
}
// Execute. We should never return...
|
Please link to the English docs - https://www.ibm.com/docs/en/aix/7.3?topic=p-ptrace-ptracex-ptrace64-subroutine instead. |
Apologies for the blunder, I myself dont speak French by the way. 😀 Corrected |
Can you summarise the need for ptrace64? Mainly, will this only apply to launching a process or does it apply to any ptrace call? I wonder:
|
I am kinda impressed how many languages they have available, but the downside is that Google seems to love choosing a non-English one for me. |
True. Pretty much same for me. It will always be either Japanese or Korean. French is a new addition perhaps. 😄 |
Yes, to handle the 64-bit debuggees in AIX, we would need the ptrace64 call. It will apply to all the ptrace calls in general. |
AIX ptrace (ptrace,ptracex,ptrace64) has a different format, so we would need an AIX specific case anyway. |
Thanks. Yes I see that the majority of existing calls are in, for example, lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp. And a lot are going via a Ptracewrapper that is also per platform. This PosixFork is one of the few doing a direct call in generic code. I am wondering if it should be |
@labath what do you think? |
…20459) 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. #101657 The complete changes for porting are present in this draft PR: #102601 Added clang-format changes for ProcessLauncherPosixFork.cpp which will be followed by ptrace changes in: - #120390
I think this is fine. We could come up with an abstraction for this, but I don't think it's necessary for a simple change like this. Like @DhruvSrivastavaX said, the rest of the ptrace calls are going to be in platform-specific code. |
…ork.cpp (#120459) 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. llvm/llvm-project#101657 The complete changes for porting are present in this draft PR: llvm/llvm-project#102601 Added clang-format changes for ProcessLauncherPosixFork.cpp which will be followed by ptrace changes in: - llvm/llvm-project#120390
This 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:
Extending LLDB to work on AIX #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
Review Request: @labath @DavidSpickett