Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[lldb][AIX] Adding NativeThreadAIX #139537

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

Merged
merged 4 commits into from
May 16, 2025

Conversation

DhruvSrivastavaX
Copy link
Contributor

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

Description:
Adding NativeThreadAIX base files, along with the implementation of GetName() for AIX,
to be integrated with already merged NativeProcessAIX.

@llvmbot
Copy link
Member

llvmbot commented May 12, 2025

@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

Description:
Adding NativeThreadAIX base files, along with the implementation of GetName() for AIX,
to be integrated with already merged NativeProcessAIX.


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

3 Files Affected:

  • (modified) lldb/source/Plugins/Process/AIX/CMakeLists.txt (+1)
  • (added) lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp (+71)
  • (added) lldb/source/Plugins/Process/AIX/NativeThreadAIX.h (+53)
diff --git a/lldb/source/Plugins/Process/AIX/CMakeLists.txt b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
index 9a3c77bd2ffeb..911f30349ef52 100644
--- a/lldb/source/Plugins/Process/AIX/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_library(lldbPluginProcessAIX
   NativeProcessAIX.cpp
+  NativeThreadAIX.cpp
 
   LINK_LIBS
     lldbCore
diff --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
new file mode 100644
index 0000000000000..c9593fbf08441
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
@@ -0,0 +1,71 @@
+//===-- NativeThreadAIX.cpp ---------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeThreadAIX.h"
+#include "NativeProcessAIX.h"
+#include "lldb/Utility/State.h"
+#include <procinfo.h>
+#include <sys/procfs.h>
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+
+NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
+    : NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
+
+std::string NativeThreadAIX::GetName() {
+  NativeProcessAIX &process = GetProcess();
+  auto BufferOrError = getProcFile(process.GetID(), "psinfo");
+  if (!BufferOrError)
+    return "";
+  auto &Buffer = *BufferOrError;
+  if (Buffer->getBufferSize() < sizeof(psinfo_t))
+    return "";
+  const psinfo_t *psinfo =
+      reinterpret_cast<const psinfo_t *>(Buffer->getBufferStart());
+  return std::string(psinfo->pr_fname);
+}
+
+lldb::StateType NativeThreadAIX::GetState() { return m_state; }
+
+bool NativeThreadAIX::GetStopReason(ThreadStopInfo &stop_info,
+                                    std::string &description) {
+  return false;
+}
+
+Status NativeThreadAIX::SetWatchpoint(lldb::addr_t addr, size_t size,
+                                      uint32_t watch_flags, bool hardware) {
+  return Status();
+}
+
+Status NativeThreadAIX::RemoveWatchpoint(lldb::addr_t addr) {
+  return Status("Clearing hardware watchpoint failed.");
+}
+
+Status NativeThreadAIX::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) {
+  return Status();
+}
+
+Status NativeThreadAIX::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+  return Status("Clearing hardware breakpoint failed.");
+}
+
+NativeProcessAIX &NativeThreadAIX::GetProcess() {
+  return static_cast<NativeProcessAIX &>(m_process);
+}
+
+const NativeProcessAIX &NativeThreadAIX::GetProcess() const {
+  return static_cast<const NativeProcessAIX &>(m_process);
+}
+
+llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
+NativeThreadAIX::GetSiginfo() const {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+                                 "Not implemented");
+}
diff --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
new file mode 100644
index 0000000000000..e32d3db2c5fa2
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
@@ -0,0 +1,53 @@
+//===-- NativeThreadAIX.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_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_
+#define LLDB_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_
+
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+namespace lldb_private::process_aix {
+
+class NativeProcessAIX;
+
+class NativeThreadAIX : public NativeThreadProtocol {
+  friend class NativeProcessAIX;
+
+public:
+  NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid);
+
+  // NativeThreadProtocol Interface
+  std::string GetName() override;
+
+  lldb::StateType GetState() override;
+
+  bool GetStopReason(ThreadStopInfo &stop_info,
+                     std::string &description) override;
+
+  Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
+                       bool hardware) override;
+
+  Status RemoveWatchpoint(lldb::addr_t addr) override;
+
+  Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
+
+  Status RemoveHardwareBreakpoint(lldb::addr_t addr) override;
+
+  NativeProcessAIX &GetProcess();
+
+  const NativeProcessAIX &GetProcess() const;
+
+  llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
+  GetSiginfo() const override;
+
+private:
+  lldb::StateType m_state;
+};
+} // namespace lldb_private::process_aix
+
+#endif // #ifndef LLDB_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_

@DhruvSrivastavaX
Copy link
Contributor Author

Shall I merge it now? @labath

@DhruvSrivastavaX DhruvSrivastavaX requested a review from labath May 15, 2025 12:13
Copy link

github-actions bot commented May 15, 2025

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

Copy link
Collaborator

@labath labath left a comment

Choose a reason for hiding this comment

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

Ship it.

@DhruvSrivastavaX DhruvSrivastavaX merged commit bcb1227 into llvm:main May 16, 2025
10 checks passed
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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.