[Lldb-commits] [lldb] [lldb][AIX] Added Ptrace extensions for AIX (PR #108000)

Dhruv Srivastava via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 10 06:17:38 PDT 2024


================
@@ -0,0 +1,44 @@
+//===-- Ptrace.h ------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This file defines ptrace functions & structures
+
+#ifndef liblldb_Host_aix_Ptrace_h_
+#define liblldb_Host_aix_Ptrace_h_
+
+#include <sys/ptrace.h>
+
+#define DEBUG_PTRACE_MAXBYTES 20
+
+// Support ptrace extensions even when compiled without required kernel support
+#ifndef PTRACE_GETREGS
+#define PTRACE_GETREGS (PT_COMMAND_MAX + 1)
----------------
DhruvSrivastavaX wrote:

> This PT_COMMAND_MAX is provided by some AIX include file, correct?
> 
> If that's correct then using it like this is fine because PTrace.h is only included in code built natively.
> 
> Do you have public documentation for these ptrace numbers? Perhaps there is a man page like https://man7.org/linux/man-pages/man2/ptrace.2.html? It would be good to include a link to that in the PR description.

Although it is defined in AIX's system header `sys/ptrace.h` , its not been mentioned in AIX public documentation. 
For other defines, here is the link though:
https://www.ibm.com/docs/en/aix/7.2?topic=p-ptrace-ptracex-ptrace64-subroutine




> ersions. If you're only going to support building lldb on AIX version >=X (where `X` may even be the most recent version of the OS) then you only need to provide the symbols that aren't available on every supported version. If all the supported versions of AIX define these symbols, then you don't need to define anything here (and maybe you don't even need this file).

We are actually using these defines do some emulation in the NativeProcess files, hence the need for them. Please take a look here:
https://github.com/llvm/llvm-project/pull/102601/files#diff-932a7c13bbba2ce92d14f75c525489f726af9e95f955df24b3f840727e9f757a



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


More information about the lldb-commits mailing list