Expose process instance info via SB API
Summary:
Implement SBProcessInfo to wrap lldb_private::ProcessInstanceInfo,
and add SBProcess::GetProcessInfo() to retrieve info like parent ID,
group ID, user ID etc. from a live process.
Differential Revision: https://reviews.llvm.org/D35881
llvm-svn: 309664
diff --git a/lldb/scripts/interface/SBProcess.i b/lldb/scripts/interface/SBProcess.i
index 527442e..55d39f8 100644
--- a/lldb/scripts/interface/SBProcess.i
+++ b/lldb/scripts/interface/SBProcess.i
@@ -417,6 +417,18 @@
lldb::SBMemoryRegionInfoList
GetMemoryRegions();
+ %feature("autodoc", "
+ Get information about the process.
+ Valid process info will only be returned when the process is alive,
+ use IsValid() to check if the info returned is valid.
+
+ process_info = process.GetProcessInfo()
+ if process_info.IsValid():
+ process_info.GetProcessID()
+ ") GetProcessInfo;
+ lldb::SBProcessInfo
+ GetProcessInfo();
+
%pythoncode %{
def __get_is_alive__(self):
'''Returns "True" if the process is currently alive, "False" otherwise'''
diff --git a/lldb/scripts/interface/SBProcessInfo.i b/lldb/scripts/interface/SBProcessInfo.i
new file mode 100644
index 0000000..7332e67
--- /dev/null
+++ b/lldb/scripts/interface/SBProcessInfo.i
@@ -0,0 +1,66 @@
+//===-- SWIG Interface for SBProcessInfo-------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Describes an existing process and any discoverable information that pertains to
+that process."
+) SBProcessInfo;
+
+class SBProcessInfo
+{
+public:
+ SBProcessInfo();
+
+ SBProcessInfo (const SBProcessInfo &rhs);
+
+ ~SBProcessInfo ();
+
+ bool
+ IsValid ();
+
+ const char *
+ GetName ();
+
+ SBFileSpec
+ GetExecutableFile ();
+
+ lldb::pid_t
+ GetProcessID ();
+
+ uint32_t
+ GetUserID ();
+
+ uint32_t
+ GetGroupID ();
+
+ bool
+ UserIDIsValid ();
+
+ bool
+ GroupIDIsValid ();
+
+ uint32_t
+ GetEffectiveUserID ();
+
+ uint32_t
+ GetEffectiveGroupID ();
+
+ bool
+ EffectiveUserIDIsValid ();
+
+ bool
+ EffectiveGroupIDIsValid ();
+
+ lldb::pid_t
+ GetParentProcessID ();
+};
+
+} // namespace lldb
diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig
index 8345a4b..044cfc0 100644
--- a/lldb/scripts/lldb.swig
+++ b/lldb/scripts/lldb.swig
@@ -111,6 +111,7 @@
#include "lldb/API/SBModuleSpec.h"
#include "lldb/API/SBPlatform.h"
#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBProcessInfo.h"
#include "lldb/API/SBQueue.h"
#include "lldb/API/SBQueueItem.h"
#include "lldb/API/SBSection.h"
@@ -196,6 +197,7 @@
%include "./interface/SBModuleSpec.i"
%include "./interface/SBPlatform.i"
%include "./interface/SBProcess.i"
+%include "./interface/SBProcessInfo.i"
%include "./interface/SBQueue.i"
%include "./interface/SBQueueItem.i"
%include "./interface/SBSection.i"