[Lldb-commits] [lldb] [lldb][AIX] Adding AIX version of ptrace64 (PR #120390)
Dhruv Srivastava via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 19 02:16:43 PST 2024
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/120390
>From 6361863d1533361146677c3bac8ce325ed2721a9 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Wed, 18 Dec 2024 03:10:23 -0600
Subject: [PATCH 1/2] Added AIX version of ptrace
---
lldb/source/Host/posix/ProcessLauncherPosixFork.cpp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
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...
>From 912d449c514bfaa844c7eb2886af9e73d03e3bdf Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Wed, 18 Dec 2024 05:54:46 -0600
Subject: [PATCH 2/2] Optimized
---
lldb/source/Host/posix/ProcessLauncherPosixFork.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
index 0e162d04c35837..7b8b42a4b7fe07 100644
--- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -192,13 +192,12 @@ 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
+#ifdef _AIX
if (ptrace64(PT_TRACE_ME, 0, 0, 0, nullptr) == -1)
- ExitWithError(error_fd, "ptrace");
+#else
+ if (ptrace(PT_TRACE_ME, 0, nullptr, 0) == -1)
#endif
+ ExitWithError(error_fd, "ptrace");
}
// Execute. We should never return...
More information about the lldb-commits
mailing list