[Lldb-commits] [PATCH] D103375: [lldb/API] Expose triple for SBProcessInfo.

Bruce Mitchener via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 1 21:35:48 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG251a5d9d5239: [lldb/API] Expose triple for SBProcessInfo. (authored by brucem).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103375/new/

https://reviews.llvm.org/D103375

Files:
  lldb/bindings/interface/SBProcessInfo.i
  lldb/include/lldb/API/SBProcessInfo.h
  lldb/source/API/SBProcessInfo.cpp
  lldb/test/API/python_api/process/TestProcessAPI.py


Index: lldb/test/API/python_api/process/TestProcessAPI.py
===================================================================
--- lldb/test/API/python_api/process/TestProcessAPI.py
+++ lldb/test/API/python_api/process/TestProcessAPI.py
@@ -356,6 +356,8 @@
         self.assertNotEqual(
             process_info.GetProcessID(), lldb.LLDB_INVALID_PROCESS_ID,
             "Process ID is valid")
+        triple = process_info.GetTriple()
+        self.assertIsNotNone(triple, "Process has a triple")
 
         # Additional process info varies by platform, so just check that
         # whatever info was retrieved is consistent and nothing blows up.
Index: lldb/source/API/SBProcessInfo.cpp
===================================================================
--- lldb/source/API/SBProcessInfo.cpp
+++ lldb/source/API/SBProcessInfo.cpp
@@ -179,6 +179,21 @@
   return proc_id;
 }
 
+const char *SBProcessInfo::GetTriple() {
+  LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo, GetTriple);
+
+  const char *triple = nullptr;
+  if (m_opaque_up) {
+    const auto &arch = m_opaque_up->GetArchitecture();
+    if (arch.IsValid()) {
+      // Const-ify the string so we don't need to worry about the lifetime of
+      // the string
+      triple = ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
+    }
+  }
+  return triple;
+}
+
 namespace lldb_private {
 namespace repro {
 
@@ -204,6 +219,7 @@
   LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveUserIDIsValid, ());
   LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveGroupIDIsValid, ());
   LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetParentProcessID, ());
+  LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetTriple, ());
 }
 
 }
Index: lldb/include/lldb/API/SBProcessInfo.h
===================================================================
--- lldb/include/lldb/API/SBProcessInfo.h
+++ lldb/include/lldb/API/SBProcessInfo.h
@@ -50,6 +50,9 @@
 
   lldb::pid_t GetParentProcessID();
 
+  /// Return the target triple (arch-vendor-os) for the described process.
+  const char *GetTriple();
+
 private:
   friend class SBProcess;
 
Index: lldb/bindings/interface/SBProcessInfo.i
===================================================================
--- lldb/bindings/interface/SBProcessInfo.i
+++ lldb/bindings/interface/SBProcessInfo.i
@@ -62,6 +62,12 @@
 
     lldb::pid_t
     GetParentProcessID ();
+
+    %feature("docstring",
+    "Return the target triple (arch-vendor-os) for the described process."
+    ) GetTriple;
+    const char *
+    GetTriple ();
 };
 
 } // namespace lldb


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103375.349170.patch
Type: text/x-patch
Size: 2575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210602/7d9ce9f8/attachment.bin>


More information about the lldb-commits mailing list