[clang] [lldb] [llvm] Test branch1 (PR #108178)

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 11 02:57:59 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-llvm-binary-utilities

Author: None (Lakshmi-Surekha)

<details>
<summary>Changes</summary>



---

Patch is 388.71 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/108178.diff


129 Files Affected:

- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+5-1) 
- (modified) lldb/CMakeLists.txt (+4) 
- (added) lldb/NOTICE.TXT (+7) 
- (modified) lldb/cmake/modules/LLDBConfig.cmake (+1-1) 
- (modified) lldb/include/lldb/Core/Module.h (+3) 
- (modified) lldb/include/lldb/Core/ModuleSpec.h (+21-2) 
- (modified) lldb/include/lldb/Host/HostGetOpt.h (+1-1) 
- (modified) lldb/include/lldb/Host/HostInfo.h (+3) 
- (modified) lldb/include/lldb/Host/HostInfoBase.h (+1-1) 
- (modified) lldb/include/lldb/Host/XML.h (+5) 
- (added) lldb/include/lldb/Host/aix/AbstractSocket.h (+25) 
- (added) lldb/include/lldb/Host/aix/Host.h (+22) 
- (added) lldb/include/lldb/Host/aix/HostInfoAIX.h (+42) 
- (added) lldb/include/lldb/Host/aix/Ptrace.h (+62) 
- (added) lldb/include/lldb/Host/aix/Support.h (+29) 
- (added) lldb/include/lldb/Host/aix/Uio.h (+23) 
- (modified) lldb/include/lldb/Host/common/GetOptInc.h (+3-3) 
- (modified) lldb/include/lldb/Symbol/ObjectFile.h (+5) 
- (modified) lldb/include/lldb/Target/ABI.h (+6) 
- (modified) lldb/include/lldb/Target/DynamicLoader.h (+6) 
- (modified) lldb/include/lldb/Target/Process.h (+14) 
- (modified) lldb/include/lldb/Target/RegisterContextUnwind.h (+4) 
- (modified) lldb/include/lldb/Target/ThreadPlanCallFunction.h (+6) 
- (modified) lldb/include/lldb/Utility/StringExtractorGDBRemote.h (+1) 
- (modified) lldb/include/lldb/lldb-private-enumerations.h (+1) 
- (modified) lldb/source/API/CMakeLists.txt (+108) 
- (modified) lldb/source/API/SBBreakpoint.cpp (+3-3) 
- (modified) lldb/source/API/SBBreakpointLocation.cpp (+3-3) 
- (modified) lldb/source/API/SBBreakpointName.cpp (+2-2) 
- (modified) lldb/source/Core/DynamicLoader.cpp (+10) 
- (modified) lldb/source/Core/Mangled.cpp (+2) 
- (modified) lldb/source/Core/Module.cpp (+12) 
- (modified) lldb/source/Core/Section.cpp (+4) 
- (modified) lldb/source/Expression/DWARFExpression.cpp (+5-5) 
- (modified) lldb/source/Host/CMakeLists.txt (+13) 
- (added) lldb/source/Host/aix/AbstractSocket.cpp (+21) 
- (added) lldb/source/Host/aix/Host.cpp (+304) 
- (added) lldb/source/Host/aix/HostInfoAIX.cpp (+215) 
- (added) lldb/source/Host/aix/Support.cpp (+44) 
- (modified) lldb/source/Host/common/GetOptInc.cpp (+1-1) 
- (modified) lldb/source/Host/common/Host.cpp (+174-6) 
- (added) lldb/source/Host/common/LICENSE.aix-netbsd.txt (+125) 
- (modified) lldb/source/Host/common/XML.cpp (+3) 
- (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+2) 
- (modified) lldb/source/Host/posix/FileSystemPosix.cpp (+2) 
- (modified) lldb/source/Host/posix/MainLoopPosix.cpp (+17) 
- (modified) lldb/source/Host/posix/ProcessLauncherPosixFork.cpp (+5) 
- (modified) lldb/source/Initialization/CMakeLists.txt (+1-1) 
- (modified) lldb/source/Initialization/SystemInitializerCommon.cpp (+2-2) 
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp (+130-1) 
- (modified) lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.h (+6) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/CMakeLists.txt (+11) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/DynamicLoaderAIXDYLD.cpp (+272) 
- (added) lldb/source/Plugins/DynamicLoader/AIX-DYLD/DynamicLoaderAIXDYLD.h (+55) 
- (modified) lldb/source/Plugins/DynamicLoader/CMakeLists.txt (+1) 
- (modified) lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (+2-2) 
- (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+1-1) 
- (modified) lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp (+193-3) 
- (modified) lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h (+14) 
- (modified) lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp (+1-1) 
- (modified) lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp (+7-7) 
- (modified) lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp (+1-1) 
- (modified) lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (+4) 
- (modified) lldb/source/Plugins/Language/ObjC/Cocoa.cpp (+2) 
- (modified) lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp (+1-1) 
- (modified) lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (+1-1) 
- (added) lldb/source/Plugins/ObjectContainer/Big-Archive/CMakeLists.txt (+10) 
- (added) lldb/source/Plugins/ObjectContainer/Big-Archive/ObjectContainerBigArchive.cpp (+522) 
- (added) lldb/source/Plugins/ObjectContainer/Big-Archive/ObjectContainerBigArchive.h (+177) 
- (modified) lldb/source/Plugins/ObjectContainer/CMakeLists.txt (+1) 
- (modified) lldb/source/Plugins/ObjectFile/CMakeLists.txt (+1) 
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+3-3) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp (+2) 
- (modified) lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp (+14-1) 
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (+16-2) 
- (added) lldb/source/Plugins/ObjectFile/XCOFF/CMakeLists.txt (+13) 
- (added) lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp (+780) 
- (added) lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h (+243) 
- (modified) lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp (+1-1) 
- (added) lldb/source/Plugins/Platform/AIX/CMakeLists.txt (+13) 
- (added) lldb/source/Plugins/Platform/AIX/PlatformAIX.cpp (+471) 
- (added) lldb/source/Plugins/Platform/AIX/PlatformAIX.h (+74) 
- (modified) lldb/source/Plugins/Platform/CMakeLists.txt (+1) 
- (added) lldb/source/Plugins/Process/AIX/CMakeLists.txt (+19) 
- (added) lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp (+2048) 
- (added) lldb/source/Plugins/Process/AIX/NativeProcessAIX.h (+283) 
- (added) lldb/source/Plugins/Process/AIX/NativeRegisterContextAIX.cpp (+157) 
- (added) lldb/source/Plugins/Process/AIX/NativeRegisterContextAIX.h (+133) 
- (added) lldb/source/Plugins/Process/AIX/NativeRegisterContextAIX_ppc64.cpp (+744) 
- (added) lldb/source/Plugins/Process/AIX/NativeRegisterContextAIX_ppc64.h (+138) 
- (added) lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp (+526) 
- (added) lldb/source/Plugins/Process/AIX/NativeThreadAIX.h (+126) 
- (modified) lldb/source/Plugins/Process/CMakeLists.txt (+3) 
- (modified) lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (+33) 
- (modified) lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp (+4) 
- (modified) lldb/source/Plugins/Process/Utility/ThreadMemory.cpp (+1-1) 
- (modified) lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt (+5) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+30) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (+7) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (+28) 
- (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h (+2) 
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+12-1) 
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (+8) 
- (modified) lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp (+4-4) 
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt (+5) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp (+4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (+11-1) 
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp (+1-1) 
- (modified) lldb/source/Symbol/DWARFCallFrameInfo.cpp (+2-2) 
- (modified) lldb/source/Target/ABI.cpp (+9) 
- (modified) lldb/source/Target/CMakeLists.txt (+5) 
- (modified) lldb/source/Target/Process.cpp (+10) 
- (modified) lldb/source/Target/RegisterContextUnwind.cpp (+46) 
- (modified) lldb/source/Target/ThreadPlanCallFunction.cpp (+34) 
- (modified) lldb/source/Target/UnwindLLDB.cpp (+15) 
- (modified) lldb/source/Utility/ArchSpec.cpp (+17-1) 
- (modified) lldb/source/Utility/StringExtractorGDBRemote.cpp (+2) 
- (modified) lldb/test/CMakeLists.txt (+1-1) 
- (modified) lldb/tools/driver/CMakeLists.txt (+5) 
- (modified) lldb/tools/driver/Driver.cpp (+4-1) 
- (modified) lldb/tools/lldb-dap/CMakeLists.txt (+4) 
- (modified) lldb/tools/lldb-server/CMakeLists.txt (+7) 
- (modified) lldb/tools/lldb-server/SystemInitializerLLGS.cpp (+15) 
- (modified) lldb/tools/lldb-server/lldb-gdbserver.cpp (+4) 
- (modified) lldb/unittests/Host/MainLoopTest.cpp (+3-1) 
- (modified) lldb/unittests/Host/PipeTest.cpp (+2) 
- (modified) lldb/unittests/Host/posix/TerminalTest.cpp (+4) 
- (modified) llvm/include/llvm/Object/XCOFFObjectFile.h (+3-1) 
- (modified) llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp (+13-2) 


``````````diff
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 30f3911a8b03c2..fc91981db68c12 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -5052,10 +5052,14 @@ std::string CGObjCCommonMac::GetSectionName(StringRef Section,
   case llvm::Triple::COFF:
     assert(Section.starts_with("__") && "expected the name to begin with __");
     return ("." + Section.substr(2) + "$B").str();
+  case llvm::Triple::XCOFF:
+    // Hack to allow "p 10+1" on AIX for lldb
+    assert(Section.substr(0, 2) == "__" &&
+           "expected the name to begin with __");
+    return Section.substr(2).str();
   case llvm::Triple::Wasm:
   case llvm::Triple::GOFF:
   case llvm::Triple::SPIRV:
-  case llvm::Triple::XCOFF:
   case llvm::Triple::DXContainer:
     llvm::report_fatal_error(
         "Objective-C support is unimplemented for object file format");
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 59cdc4593463c1..2e9ae0d0b3221c 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -38,6 +38,10 @@ endif()
 include(LLDBConfig)
 include(AddLLDB)
 
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  add_definitions("-D__AIX__")
+endif()
+
 # Define the LLDB_CONFIGURATION_xxx matching the build type.
 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
   add_definitions(-DLLDB_CONFIGURATION_DEBUG)
diff --git a/lldb/NOTICE.TXT b/lldb/NOTICE.TXT
new file mode 100644
index 00000000000000..d814272967476e
--- /dev/null
+++ b/lldb/NOTICE.TXT
@@ -0,0 +1,7 @@
+
+This product contains small piece of code to support AIX, taken from netbsd.
+
+  * LICENSE:
+    * lldb/source/Host/common/LICENSE.aix-netbsd.txt (OpenSSL License)
+  * HOMEPAGE:
+    * https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/crypto/external/bsd/openssl/dist
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index a60921990cf775..a0f118a11984c2 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -299,7 +299,7 @@ endif()
 
 # Figure out if lldb could use lldb-server.  If so, then we'll
 # ensure we build lldb-server when an lldb target is being built.
-if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|Windows")
+if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|Windows|AIX")
   set(LLDB_CAN_USE_LLDB_SERVER ON)
 else()
   set(LLDB_CAN_USE_LLDB_SERVER OFF)
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 5589c1c9a350dc..3829386562795c 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -196,6 +196,9 @@ class Module : public std::enable_shared_from_this<Module>,
   bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset,
                       bool &changed);
 
+  bool SetLoadAddressByType(Target &target, lldb::addr_t value,
+                            bool value_is_offset, bool &changed, int type_id);
+
   /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
   ///
   /// \see SymbolContextScope
diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h
index 4cbbbfa8a26e13..4fe06412b6b0b8 100644
--- a/lldb/include/lldb/Core/ModuleSpec.h
+++ b/lldb/include/lldb/Core/ModuleSpec.h
@@ -21,6 +21,7 @@
 
 #include <mutex>
 #include <vector>
+#include <string.h>
 
 namespace lldb_private {
 
@@ -41,8 +42,26 @@ class ModuleSpec {
   }
 
   ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch)
-      : m_file(file_spec), m_arch(arch), m_object_offset(0),
-        m_object_size(FileSystem::Instance().GetByteSize(file_spec)) {}
+      : m_arch(arch), m_object_offset(0) {
+    // parse object inside module format for example: /usr/ccs/lib/libc.a(shr_64.o)
+    llvm::SmallString<256> path_with_object;
+    file_spec.GetPath(path_with_object);
+    if (strstr(path_with_object.c_str(), "(") != nullptr) {
+      char *part;
+      char *str = (char *)path_with_object.c_str();
+      part = strtok(str, "()");
+      assert(part);
+      llvm::StringRef file_name(part);
+      part = strtok(nullptr, "()");
+      assert(part);
+      m_object_name = ConstString(part);
+      m_file = FileSpec(file_name);
+      m_object_size = FileSystem::Instance().GetByteSize(m_file);
+    } else {
+      m_file = file_spec;
+      m_object_size = FileSystem::Instance().GetByteSize(file_spec);
+    }
+  }
 
   FileSpec *GetFileSpecPtr() { return (m_file ? &m_file : nullptr); }
 
diff --git a/lldb/include/lldb/Host/HostGetOpt.h b/lldb/include/lldb/Host/HostGetOpt.h
index 52cfdf4dbb89c2..f450e561d6afb1 100644
--- a/lldb/include/lldb/Host/HostGetOpt.h
+++ b/lldb/include/lldb/Host/HostGetOpt.h
@@ -9,7 +9,7 @@
 #ifndef LLDB_HOST_HOSTGETOPT_H
 #define LLDB_HOST_HOSTGETOPT_H
 
-#if !defined(_MSC_VER) && !defined(__NetBSD__)
+#if !defined(_MSC_VER) && !defined(__NetBSD__) && !defined(__AIX__)
 
 #include <getopt.h>
 #include <unistd.h>
diff --git a/lldb/include/lldb/Host/HostInfo.h b/lldb/include/lldb/Host/HostInfo.h
index b7010d69d88e7f..156df8cf6901df 100644
--- a/lldb/include/lldb/Host/HostInfo.h
+++ b/lldb/include/lldb/Host/HostInfo.h
@@ -55,6 +55,9 @@
 #elif defined(__APPLE__)
 #include "lldb/Host/macosx/HostInfoMacOSX.h"
 #define HOST_INFO_TYPE HostInfoMacOSX
+#elif defined(__AIX__)
+#include "lldb/Host/aix/HostInfoAIX.h"
+#define HOST_INFO_TYPE HostInfoAIX
 #else
 #include "lldb/Host/posix/HostInfoPosix.h"
 #define HOST_INFO_TYPE HostInfoPosix
diff --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h
index 705aad559f3b78..29e6acf39bfb24 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -149,6 +149,7 @@ class HostInfoBase {
     return {};
   }
 
+  static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
   /// Returns the distribution id of the host
   ///
   /// This will be something like "ubuntu", "fedora", etc. on Linux.
@@ -158,7 +159,6 @@ class HostInfoBase {
   static llvm::StringRef GetDistributionId() { return llvm::StringRef(); }
 
 protected:
-  static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
   static bool ComputeSupportExeDirectory(FileSpec &file_spec);
   static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
   static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
diff --git a/lldb/include/lldb/Host/XML.h b/lldb/include/lldb/Host/XML.h
index da0f9cd7aa8c06..cf359f7726d5d6 100644
--- a/lldb/include/lldb/Host/XML.h
+++ b/lldb/include/lldb/Host/XML.h
@@ -11,6 +11,11 @@
 
 #include "lldb/Host/Config.h"
 
+#if defined(__AIX__)
+//FIXME for AIX
+#undef LLDB_ENABLE_LIBXML2
+#endif
+
 #if LLDB_ENABLE_LIBXML2
 #include <libxml/xmlreader.h>
 #endif
diff --git a/lldb/include/lldb/Host/aix/AbstractSocket.h b/lldb/include/lldb/Host/aix/AbstractSocket.h
new file mode 100644
index 00000000000000..78a567a6b90953
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/AbstractSocket.h
@@ -0,0 +1,25 @@
+//===-- AbstractSocket.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_AbstractSocket_h_
+#define liblldb_AbstractSocket_h_
+
+#include "lldb/Host/posix/DomainSocket.h"
+
+namespace lldb_private {
+class AbstractSocket : public DomainSocket {
+public:
+  AbstractSocket(bool child_processes_inherit);
+
+protected:
+  size_t GetNameOffset() const override;
+  void DeleteSocketFile(llvm::StringRef name) override;
+};
+}
+
+#endif // ifndef liblldb_AbstractSocket_h_
diff --git a/lldb/include/lldb/Host/aix/Host.h b/lldb/include/lldb/Host/aix/Host.h
new file mode 100644
index 00000000000000..1e3487752995fb
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/Host.h
@@ -0,0 +1,22 @@
+//===-- Host.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_HOST_AIX_HOST_H
+#define LLDB_HOST_AIX_HOST_H
+
+#include "lldb/lldb-types.h"
+#include <optional>
+
+namespace lldb_private {
+
+// Get PID (i.e. the primary thread ID) corresponding to the specified TID.
+std::optional<lldb::pid_t> getPIDForTID(lldb::pid_t tid);
+
+} // namespace lldb_private
+
+#endif // #ifndef LLDB_HOST_AIX_HOST_H
diff --git a/lldb/include/lldb/Host/aix/HostInfoAIX.h b/lldb/include/lldb/Host/aix/HostInfoAIX.h
new file mode 100644
index 00000000000000..ced4cf34d38a81
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/HostInfoAIX.h
@@ -0,0 +1,42 @@
+//===-- HostInfoAIX.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_Host_aix_HostInfoAIX_h_
+#define lldb_Host_aix_HostInfoAIX_h_
+
+#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/FileSpec.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/VersionTuple.h"
+
+#include <string>
+
+namespace lldb_private {
+
+class HostInfoAIX : public HostInfoPosix {
+  friend class HostInfoBase;
+
+public:
+  static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr);
+  static void Terminate();
+
+  static llvm::VersionTuple GetOSVersion();
+  static std::optional<std::string> GetOSBuildString();
+  static llvm::StringRef GetDistributionId();
+  static FileSpec GetProgramFileSpec();
+
+protected:
+  static bool ComputeSupportExeDirectory(FileSpec &file_spec);
+  static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
+  static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
+  static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
+                                             ArchSpec &arch_64);
+};
+}
+
+#endif
diff --git a/lldb/include/lldb/Host/aix/Ptrace.h b/lldb/include/lldb/Host/aix/Ptrace.h
new file mode 100644
index 00000000000000..88928f18102d7c
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/Ptrace.h
@@ -0,0 +1,62 @@
+//===-- 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)
+#endif
+#ifndef PTRACE_SETREGS
+#define PTRACE_SETREGS          (PT_COMMAND_MAX+2)
+#endif
+#ifndef PTRACE_GETFPREGS
+#define PTRACE_GETFPREGS        (PT_COMMAND_MAX+3)
+#endif
+#ifndef PTRACE_SETFPREGS
+#define PTRACE_SETFPREGS        (PT_COMMAND_MAX+4)
+#endif
+#ifndef PTRACE_GETREGSET
+#define PTRACE_GETREGSET 0x4204
+#endif
+#ifndef PTRACE_SETREGSET
+#define PTRACE_SETREGSET 0x4205
+#endif
+#ifndef PTRACE_GET_THREAD_AREA
+#define PTRACE_GET_THREAD_AREA  (PT_COMMAND_MAX+5)
+#endif
+#ifndef PTRACE_ARCH_PRCTL
+#define PTRACE_ARCH_PRCTL       (PT_COMMAND_MAX+6)
+#endif
+#ifndef ARCH_GET_FS
+#define ARCH_SET_GS 0x1001
+#define ARCH_SET_FS 0x1002
+#define ARCH_GET_FS 0x1003
+#define ARCH_GET_GS 0x1004
+#endif
+#ifndef PTRACE_PEEKMTETAGS
+#define PTRACE_PEEKMTETAGS      (PT_COMMAND_MAX+7)
+#endif
+#ifndef PTRACE_POKEMTETAGS
+#define PTRACE_POKEMTETAGS      (PT_COMMAND_MAX+8)
+#endif
+#ifndef PTRACE_GETVRREGS
+#define PTRACE_GETVRREGS        (PT_COMMAND_MAX+9)
+#endif
+#ifndef PTRACE_GETVSRREGS
+#define PTRACE_GETVSRREGS       (PT_COMMAND_MAX+10)
+#endif
+
+#endif // liblldb_Host_aix_Ptrace_h_
diff --git a/lldb/include/lldb/Host/aix/Support.h b/lldb/include/lldb/Host/aix/Support.h
new file mode 100644
index 00000000000000..27d6c2b50a35b0
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/Support.h
@@ -0,0 +1,29 @@
+//===-- Support.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_HOST_AIX_SUPPORT_H
+#define LLDB_HOST_AIX_SUPPORT_H
+
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include <memory>
+
+namespace lldb_private {
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file);
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+getProcFile(::pid_t pid, const llvm::Twine &file);
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+getProcFile(const llvm::Twine &file);
+
+} // namespace lldb_private
+
+#endif // #ifndef LLDB_HOST_AIX_SUPPORT_H
diff --git a/lldb/include/lldb/Host/aix/Uio.h b/lldb/include/lldb/Host/aix/Uio.h
new file mode 100644
index 00000000000000..acf79ecc6a1d0d
--- /dev/null
+++ b/lldb/include/lldb/Host/aix/Uio.h
@@ -0,0 +1,23 @@
+//===-- Uio.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Host_aix_Uio_h_
+#define liblldb_Host_aix_Uio_h_
+
+#include "lldb/Host/Config.h"
+#include <sys/uio.h>
+
+// We shall provide our own implementation of process_vm_readv if it is not
+// present
+#if !HAVE_PROCESS_VM_READV
+ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
+                         unsigned long liovcnt, const struct iovec *remote_iov,
+                         unsigned long riovcnt, unsigned long flags);
+#endif
+
+#endif // liblldb_Host_aix_Uio_h_
diff --git a/lldb/include/lldb/Host/common/GetOptInc.h b/lldb/include/lldb/Host/common/GetOptInc.h
index 3fb9add4795417..ebb475bfaf6b8d 100644
--- a/lldb/include/lldb/Host/common/GetOptInc.h
+++ b/lldb/include/lldb/Host/common/GetOptInc.h
@@ -11,11 +11,11 @@
 
 #include "lldb/lldb-defines.h"
 
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__AIX__)
 #define REPLACE_GETOPT
 #define REPLACE_GETOPT_LONG
 #endif
-#if defined(_MSC_VER) || defined(__NetBSD__)
+#if defined(_MSC_VER) || defined(__NetBSD__) || defined(__AIX__)
 #define REPLACE_GETOPT_LONG_ONLY
 #endif
 
@@ -35,7 +35,7 @@ struct option {
   int val;
 };
 
-int getopt(int argc, char *const argv[], const char *optstring);
+int getopt(int argc, char *const argv[], const char *optstring) throw();
 
 // from getopt.h
 extern char *optarg;
diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index d89314d44bf671..49be7bd88da604 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -401,6 +401,11 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
     return false;
   }
 
+  virtual bool SetLoadAddressByType(Target &target, lldb::addr_t value,
+                              bool value_is_offset, int type_id) {
+    return false;
+  }
+
   /// Gets whether endian swapping should occur when extracting data from this
   /// object file.
   ///
diff --git a/lldb/include/lldb/Target/ABI.h b/lldb/include/lldb/Target/ABI.h
index 7b646d743346b7..281a89951ef885 100644
--- a/lldb/include/lldb/Target/ABI.h
+++ b/lldb/include/lldb/Target/ABI.h
@@ -47,6 +47,12 @@ class ABI : public PluginInterface {
                                   lldb::addr_t returnAddress,
                                   llvm::ArrayRef<lldb::addr_t> args) const = 0;
 
+  virtual bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+                                  lldb::addr_t functionAddress,
+                                  lldb::addr_t tocAddress,
+                                  lldb::addr_t returnAddress,
+                                  llvm::ArrayRef<lldb::addr_t> args) const;
+
   // Prepare trivial call used from ThreadPlanFunctionCallUsingABI
   // AD:
   //  . Because i don't want to change other ABI's this is not declared pure
diff --git a/lldb/include/lldb/Target/DynamicLoader.h b/lldb/include/lldb/Target/DynamicLoader.h
index 0629e2faae7e9e..7dccd317c2dca1 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -359,6 +359,12 @@ class DynamicLoader : public PluginInterface {
                                     lldb::addr_t base_addr,
                                     bool base_addr_is_offset);
 
+  virtual void UpdateLoadedSectionsByType(lldb::ModuleSP module,
+                                    lldb::addr_t link_map_addr,
+                                    lldb::addr_t base_addr,
+                                    bool base_addr_is_offset,
+                                    int type_id);
+
   // Utility method so base classes can share implementation of
   // UpdateLoadedSections
   void UpdateLoadedSectionsCommon(lldb::ModuleSP module, lldb::addr_t base_addr,
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 9cf6f50558570b..2f44dc3bfd86f5 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -63,6 +63,10 @@
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/VersionTuple.h"
 
+#if defined(__AIX__)
+struct ld_xinfo;
+#endif
+
 namespace lldb_private {
 
 template <typename B, typename S> struct Range;
@@ -1921,6 +1925,10 @@ class Process : public std::enable_shared_from_this<Process>,
   Status GetMemoryRegionInfo(lldb::addr_t load_addr,
                              MemoryRegionInfo &range_info);
 
+#if defined(__AIX__)
+  Status GetLDXINFO(struct ld_xinfo *info_ptr);
+#endif
+
   /// Obtain all the mapped memory regions within this process.
   ///
   /// \param[out] region_list
@@ -2861,6 +2869,12 @@ void PruneThreadPlans();
     return Status("Process::DoGetMemoryRegionInfo() not supported");
   }
 
+#if defined(__AIX__)
+  virtual Status DoGetLDXINFO(struct ld_xinfo *info_ptr) {
+    return Status("Process::DoGetLDXINFO() not supported");
+  }
+#endif
+
   /// Provide an override value in the subclass for lldb's
   /// CPU-based logic for whether watchpoint exceptions are
   /// received before or after an instruction executes.
diff --git a/lldb/include/lldb/Target/RegisterContextUnwind.h b/lldb/include/lldb/Target/RegisterContextUnwind.h
index ef8ae884038663..00a95853800edd 100644
--- a/lldb/include/lldb/Target/RegisterContextUnwind.h
+++ b/lldb/include/lldb/Target/RegisterContextUnwind.h
@@ -67,6 +67,10 @@ class RegisterContextUnwind : public lldb_private::RegisterContext {
 
   bool ReadPC(lldb::addr_t &start_pc);
 
+#ifdef __AIX__
+  bool ReadLR(lldb::addr_t &lr);
+#endif
+
   // Indicates whether this frame *behaves* like frame zero -- the currently
   // executing frame -- or not.  This can be true in the middle of the stack
   // above asynchronous trap handlers (sigtramp) for instance.
diff --git a/lldb/include/lldb/Target/ThreadPlanCallFunction.h b/lldb/include/lldb/Target/ThreadPlanCallFunction.h
index cb6e7caebb4adf..7880db1592e04a 100644
--- a/lldb/include/lldb/Target/ThreadPlanCallFunction.h
+++ b/lldb/include/lldb/Target/ThreadPlanCallFunction.h
@@ -27,6 +27,12 @@ class ThreadPlanCallFunction : public ThreadPlan {
                          llvm::ArrayRef<lldb::addr_t> args,
                          const EvaluateExpressionOptions &options);
 
+  ThreadPlanCallFunction(Thread &thread, const Address &function,
+                         const Address &toc,
+                 ...
[truncated]

``````````

</details>


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


More information about the cfe-commits mailing list