summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/API/SBTarget.h25
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py9
-rw-r--r--lldb/scripts/interface/SBTarget.i4
-rw-r--r--lldb/source/API/SBTarget.cpp15
4 files changed, 53 insertions, 0 deletions
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index b9a6829d214..6655d7585f1 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -75,6 +75,31 @@ public:
lldb::SBProcess GetProcess();
+ //------------------------------------------------------------------
+ /// Sets whether we should collect statistics on lldb or not.
+ ///
+ /// @param[in] v
+ /// A boolean to control the collection.
+ /// @return
+ /// void
+ //------------------------------------------------------------------
+ void SetCollectingStats(bool v);
+
+ //------------------------------------------------------------------
+ /// Returns whether statistics collection are enabled.
+ ///
+ /// @return
+ /// true if statistics are currently being collected, false
+ /// otherwise.
+ //------------------------------------------------------------------
+ bool GetCollectingStats();
+
+ //------------------------------------------------------------------
+ /// Returns a dump of the collected statistics.
+ ///
+ /// @return
+ /// A SBStructuredData with the statistics collected.
+ //------------------------------------------------------------------
lldb::SBStructuredData GetStatistics();
//------------------------------------------------------------------
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py b/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py
index a6c38ca1d09..f2027eb131c 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py
@@ -17,6 +17,15 @@ class TestStatsAPI(TestBase):
self.build()
exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
+
+ # Test enabling/disabling stats
+ self.assertFalse(target.GetCollectingStats())
+ target.SetCollectingStats(True)
+ self.assertTrue(target.GetCollectingStats())
+ target.SetCollectingStats(False)
+ self.assertFalse(target.GetCollectingStats())
+
+ # Test the function to get the statistics in JSON'ish.
stats = target.GetStatistics()
stream = lldb.SBStream()
res = stats.GetAsJSON(stream)
diff --git a/lldb/scripts/interface/SBTarget.i b/lldb/scripts/interface/SBTarget.i
index 1743b4d0858..1cc806db838 100644
--- a/lldb/scripts/interface/SBTarget.i
+++ b/lldb/scripts/interface/SBTarget.i
@@ -1019,6 +1019,10 @@ public:
void
SetLaunchInfo (const lldb::SBLaunchInfo &launch_info);
+ void SetCollectingStats(bool v);
+
+ bool GetCollectingStats();
+
lldb::SBStructuredData GetStatistics();
bool
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 4d2417c711b..d550de1357b 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -202,6 +202,21 @@ SBStructuredData SBTarget::GetStatistics() {
return data;
}
+void SBTarget::SetCollectingStats(bool v) {
+ TargetSP target_sp(GetSP());
+ if (!target_sp)
+ return;
+ return target_sp->SetCollectingStats(v);
+}
+
+bool SBTarget::GetCollectingStats() {
+ TargetSP target_sp(GetSP());
+ if (!target_sp)
+ return false;
+ return target_sp->GetCollectingStats();
+}
+
+
SBProcess SBTarget::LoadCore(const char *core_file) {
lldb::SBError error; // Ignored
return LoadCore(core_file, error);
OpenPOWER on IntegriCloud