[llvm] 75b5541 - [llvm-exegesis] Switch to using PTRACE_ATTACH instead of PTRACE_SEIZE
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 6 19:58:07 PDT 2023
Author: Aiden Grossman
Date: 2023-07-06T19:40:19-07:00
New Revision: 75b5541fe5d096d115d213cb8dc8a10cf3d11fbd
URL: https://github.com/llvm/llvm-project/commit/75b5541fe5d096d115d213cb8dc8a10cf3d11fbd
DIFF: https://github.com/llvm/llvm-project/commit/75b5541fe5d096d115d213cb8dc8a10cf3d11fbd.diff
LOG: [llvm-exegesis] Switch to using PTRACE_ATTACH instead of PTRACE_SEIZE
This patch switches from using PTRACE_SEIZE within the subprocess
benchmark runner for llvm-exegesis as PTRACE_SEIZE was introduced in
Linux kernel 3.4. Some LLVM users were reporting build failures as they
are using Kernel versions older than 3.4 (such as on CentOS/RHEL 6),
hence the patch.
Added:
Modified:
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 6d0b754a7c899c..ba91f5d89fea07 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -7,6 +7,8 @@
//===----------------------------------------------------------------------===//
#include <array>
+#include <cerrno>
+#include <iostream>
#include <memory>
#include <string>
@@ -249,10 +251,21 @@ class SubProcessFunctionExecutorImpl
"to child process failed: " +
Twine(strerror(errno)));
- if (ptrace(PTRACE_SEIZE, ParentOrChildPID, NULL, NULL) != 0)
- return make_error<Failure>("Failed to seize the child process: " +
+ if (ptrace(PTRACE_ATTACH, ParentOrChildPID, NULL, NULL) != 0)
+ return make_error<Failure>("Failed to attach to the child process: " +
Twine(strerror(errno)));
+ if (wait(NULL) == -1) {
+ return make_error<Failure>(
+ "Failed to wait for child process to stop after attaching: " +
+ Twine(strerror(errno)));
+ }
+
+ if (ptrace(PTRACE_CONT, ParentOrChildPID, NULL, NULL) != 0)
+ return make_error<Failure>(
+ "Failed to continue execution of the child process: " +
+ Twine(strerror(errno)));
+
int ChildStatus;
if (wait(&ChildStatus) == -1) {
return make_error<Failure>(
More information about the llvm-commits
mailing list