[compiler-rt] [sanitizer_common] Handle ptrace on Linux/sparc64 (PR #109310)

Rainer Orth via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 09:14:03 PDT 2024


================
@@ -2530,18 +2530,26 @@ PRE_SYSCALL(ptrace)(long request, long pid, long addr, long data) {
 #  if !SANITIZER_ANDROID &&                                                   \
       (defined(__i386) || defined(__x86_64) || defined(__mips64) ||           \
        defined(__powerpc64__) || defined(__aarch64__) || defined(__s390__) || \
-       defined(__loongarch__) || SANITIZER_RISCV64)
-  if (data) {
+       defined(__loongarch__) || SANITIZER_RISCV64 || defined(__sparc__))
+  long data_arg = data;
----------------
rorth wrote:

That's really nice, thanks.  I made only a few minor adjustments, primarily having the `ptrace_data_arg` template match the `ptrace` arg order.

One caveat, though: it doesn't work to put this into `sanitizer_common_ptrace.h`: in that case, the `ptrace_*` declarations are missing.  I've chosen `sanitizer_platform_limits_posix.h` where the latter already are.  However, I had to include that file in both `sanitizer_common_interceptors.inc` ( a generic file, although the `ptrace` interceptor is in a Linux-only section) and `sanitizer_common_syscalls.inc` (Linux-specific, so shouldn't be an issue).

Please let me know if this is ok?

https://github.com/llvm/llvm-project/pull/109310


More information about the llvm-commits mailing list