Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb][AIX] Some base #if _AIX changes of a minimal lldb build #120979

Merged
merged 8 commits into from
Jan 9, 2025

Conversation

DhruvSrivastavaX
Copy link
Contributor

@DhruvSrivastavaX DhruvSrivastavaX commented Dec 23, 2024

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

  1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
  2. Extending LLDB to work on AIX #101657
    The complete changes for porting are present in this draft PR:
    Extending LLDB to work on AIX #102601

Added some base #if _AIX changes for minimal lldb build.
Added a PR for clang-format changes separately, to rebase this on later:

Review Request: @labath @DavidSpickett

@llvmbot
Copy link
Member

llvmbot commented Dec 23, 2024

@llvm/pr-subscribers-lldb

Author: Dhruv Srivastava (DhruvSrivastavaX)

Changes

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

  1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
  2. Extending LLDB to work on AIX #101657
    The complete changes for porting are present in this draft PR:
    Extending LLDB to work on AIX #102601

Added some base #if _AIX changes for minimal lldb build.

Review Request: @labath @DavidSpickett


Full diff: https://github.com/llvm/llvm-project/pull/120979.diff

4 Files Affected:

  • (modified) lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp (+3-4)
  • (modified) lldb/source/Host/posix/DomainSocket.cpp (+5-1)
  • (modified) lldb/source/Host/posix/FileSystemPosix.cpp (+2)
  • (modified) lldb/source/Plugins/Language/ObjC/Cocoa.cpp (+7-8)
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index 6bdc33f8923281..e3d1300cf76eda 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -119,8 +119,7 @@ bool ConnectionFileDescriptor::IsConnected() const {
 
 ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
                                                    Status *error_ptr) {
-  return Connect(
-      path, [](llvm::StringRef) {}, error_ptr);
+  return Connect(path, [](llvm::StringRef) {}, error_ptr);
 }
 
 ConnectionStatus
@@ -716,7 +715,7 @@ ConnectionFileDescriptor::ConnectFD(llvm::StringRef s,
 ConnectionStatus ConnectionFileDescriptor::ConnectFile(
     llvm::StringRef s, socket_id_callback_type socket_id_callback,
     Status *error_ptr) {
-#if LLDB_ENABLE_POSIX
+#if LLDB_ENABLE_POSIX && !defined(_AIX)
   std::string addr_str = s.str();
   // file:///PATH
   int fd = FileSystem::Instance().Open(addr_str.c_str(), O_RDWR);
@@ -747,7 +746,7 @@ ConnectionStatus ConnectionFileDescriptor::ConnectFile(
 
   m_io_sp = std::make_shared<NativeFile>(fd, File::eOpenOptionReadWrite, true);
   return eConnectionStatusSuccess;
-#endif // LLDB_ENABLE_POSIX
+#endif // LLDB_ENABLE_POSIX && !defined(_AIX)
   llvm_unreachable("this function should be only called w/ LLDB_ENABLE_POSIX");
 }
 
diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp
index 9a0b385d998bfc..9f4f12bb481bd0 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -16,6 +16,9 @@
 #include <memory>
 #include <sys/socket.h>
 #include <sys/un.h>
+#ifdef _AIX
+#include <strings.h>
+#endif
 
 using namespace lldb;
 using namespace lldb_private;
@@ -86,7 +89,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
   if (error.Fail())
     return error;
   if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
-        (struct sockaddr *)&saddr_un, saddr_un_len) < 0)
+                                  (struct sockaddr *)&saddr_un,
+                                  saddr_un_len) < 0)
     SetLastError(error);
 
   return error;
diff --git a/lldb/source/Host/posix/FileSystemPosix.cpp b/lldb/source/Host/posix/FileSystemPosix.cpp
index 945e2affc83715..1a84f550662d75 100644
--- a/lldb/source/Host/posix/FileSystemPosix.cpp
+++ b/lldb/source/Host/posix/FileSystemPosix.cpp
@@ -11,7 +11,9 @@
 // C includes
 #include <dirent.h>
 #include <fcntl.h>
+#ifndef _AIX
 #include <sys/mount.h>
+#endif
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/types.h>
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index bbe5d4c611f870..1d79edbede5d67 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -31,7 +31,6 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/bit.h"
 
-
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;
@@ -267,21 +266,21 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
     if (class_name == "NSIndexSet" || class_name == "NSMutableIndexSet") {
       // Foundation version 2000 added a bitmask if the index set fit in 64 bits
       // and a Tagged Pointer version if the bitmask is small enough to fit in
-      // the tagged pointer payload.  
+      // the tagged pointer payload.
       // It also changed the layout (but not the size) of the set descriptor.
 
       // First check whether this is a tagged pointer.  The bitmask will be in
       // the payload of the tagged pointer.
       uint64_t payload;
-      if (runtime->GetFoundationVersion() >= 2000  
-          && descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) {
+      if (runtime->GetFoundationVersion() >= 2000 &&
+          descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) {
         count = llvm::popcount(payload);
         break;
       }
       // The first 32 bits describe the index set in all cases:
       Status error;
       uint32_t mode = process_sp->ReadUnsignedIntegerFromMemory(
-            valobj_addr + ptr_size, 4, 0, error);
+          valobj_addr + ptr_size, 4, 0, error);
       if (error.Fail())
         return false;
       // Now check if the index is held in a bitmask in the object:
@@ -292,7 +291,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
         if ((mode & 2) == 2) {
           // The bitfield is a 64 bit uint at the beginning of the data var.
           uint64_t bitfield = process_sp->ReadUnsignedIntegerFromMemory(
-            valobj_addr + 2 * ptr_size, 8, 0, error);
+              valobj_addr + 2 * ptr_size, 8, 0, error);
           if (error.Fail())
             return false;
           count = llvm::popcount(bitfield);
@@ -309,7 +308,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
           count = 0;
           break;
         }
-      
+
         if ((mode & 2) == 2)
           mode = 1; // this means the set only has one range
         else
@@ -1227,7 +1226,7 @@ bool lldb_private::formatters::ObjCSELSummaryProvider(
 time_t lldb_private::formatters::GetOSXEpoch() {
   static time_t epoch = 0;
   if (!epoch) {
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(_AIX)
     tzset();
     tm tm_epoch;
     tm_epoch.tm_sec = 0;

labath pushed a commit that referenced this pull request Dec 27, 2024
This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. #101657
The complete changes for porting are present in this draft PR:
#102601

Added clang-format changes for changes related to some base #if _AIX
changes:

- #120979
@DhruvSrivastavaX
Copy link
Contributor Author

DhruvSrivastavaX commented Dec 27, 2024

Hi @labath , Please let me know your comments for these changes, I have rebased this for formatting commit.

lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp Outdated Show resolved Hide resolved
lldb/source/Host/posix/DomainSocket.cpp Outdated Show resolved Hide resolved
lldb/source/Host/posix/FileSystemPosix.cpp Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 8, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@DhruvSrivastavaX
Copy link
Contributor Author

Updated the branch @labath @DavidSpickett

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @labath ?

lldb/source/Host/posix/DomainSocket.cpp Outdated Show resolved Hide resolved
@DhruvSrivastavaX DhruvSrivastavaX merged commit 18de1db into llvm:main Jan 9, 2025
7 checks passed
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 10, 2025
…s (#120978)

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. llvm/llvm-project#101657
The complete changes for porting are present in this draft PR:
llvm/llvm-project#102601

Added clang-format changes for changes related to some base #if _AIX
changes:

- llvm/llvm-project#120979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants