[Lldb-commits] [lldb] 480a383 - Upstream two performance monitor collectors to MachTask

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 15 16:39:57 PDT 2020


Author: Jason Molenda
Date: 2020-06-15T16:37:56-07:00
New Revision: 480a383551e96d9f6fb0ddcdcc9d893faf37e5b3

URL: https://github.com/llvm/llvm-project/commit/480a383551e96d9f6fb0ddcdcc9d893faf37e5b3
DIFF: https://github.com/llvm/llvm-project/commit/480a383551e96d9f6fb0ddcdcc9d893faf37e5b3.diff

LOG: Upstream two performance monitor collectors to MachTask

Add two more perf monitors to MachTask::GetProfileData.

<rdar://problem/63984105>

Added: 
    

Modified: 
    lldb/tools/debugserver/source/MacOSX/MachTask.mm

Removed: 
    


################################################################################
diff  --git a/lldb/tools/debugserver/source/MacOSX/MachTask.mm b/lldb/tools/debugserver/source/MacOSX/MachTask.mm
index 5d18c5628c63..fcbe6e71389e 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachTask.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachTask.mm
@@ -64,6 +64,10 @@
 #include <pmsample.h>
 #endif
 
+extern "C" int
+proc_get_cpumon_params(pid_t pid, int *percentage,
+                       int *interval); // <libproc_internal.h> SPI
+
 //----------------------------------------------------------------------
 // MachTask constructor
 //----------------------------------------------------------------------
@@ -470,6 +474,16 @@ static void get_threads_profile_data(DNBProfileDataScanType scanType,
     }
 #endif
 
+    if (scanType & eProfileEnergyCPUCap) {
+      int percentage = -1;
+      int interval = -1;
+      int result = proc_get_cpumon_params(pid, &percentage, &interval);
+      if ((result == 0) && (percentage >= 0) && (interval >= 0)) {
+        profile_data_stream << "cpu_cap_p:" << percentage << ';';
+        profile_data_stream << "cpu_cap_t:" << interval << ';';
+      }
+    }
+
     profile_data_stream << "--end--;";
 
     result = profile_data_stream.str();


        


More information about the lldb-commits mailing list