[Lldb-commits] [lldb] r343368 - [SBAPI/Target] Expose SetStatistics(bool enable)/GetStatistics().

Davide Italiano via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 28 16:27:54 PDT 2018


Author: davide
Date: Fri Sep 28 16:27:54 2018
New Revision: 343368

URL: http://llvm.org/viewvc/llvm-project?rev=343368&view=rev
Log:
[SBAPI/Target] Expose SetStatistics(bool enable)/GetStatistics().

<rdar://problem/44875808>

Modified:
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py
    lldb/trunk/scripts/interface/SBTarget.i
    lldb/trunk/source/API/SBTarget.cpp

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=343368&r1=343367&r2=343368&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Fri Sep 28 16:27:54 2018
@@ -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();
 
   //------------------------------------------------------------------

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py?rev=343368&r1=343367&r2=343368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py Fri Sep 28 16:27:54 2018
@@ -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)

Modified: lldb/trunk/scripts/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBTarget.i?rev=343368&r1=343367&r2=343368&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/interface/SBTarget.i Fri Sep 28 16:27:54 2018
@@ -1019,6 +1019,10 @@ public:
     void
     SetLaunchInfo (const lldb::SBLaunchInfo &launch_info);
 
+    void SetCollectingStats(bool v);
+
+    bool GetCollectingStats();
+
     lldb::SBStructuredData GetStatistics();
 
     bool

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=343368&r1=343367&r2=343368&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Fri Sep 28 16:27:54 2018
@@ -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);




More information about the lldb-commits mailing list