https://github.com/cmtice created 
https://github.com/llvm/llvm-project/pull/204644

** DO  NOT SUBMIT!! DO NOT SUBMIT!! **

This is for testing and informational purposes only. This is NOT intended to be 
committed to the upstream repository.

>From c15d58138c6583253d08a14dbd1686f130dd2414 Mon Sep 17 00:00:00 2001
From: Caroline Tice <[email protected]>
Date: Tue, 16 Jun 2026 14:01:33 -0700
Subject: [PATCH 1/2] ** DO NOT SUBMIT!! DO NOT SUBMIT!! **

Testing only: Caroline's Timing changes, to measure DIL performance.
---
 lldb/include/lldb/Utility/CarolinesTimers.h | 36 ++++++++
 lldb/source/API/SBFrame.cpp                 | 20 +++++
 lldb/source/Commands/CommandObjectFrame.cpp | 12 +++
 lldb/source/Utility/CMakeLists.txt          |  1 +
 lldb/source/Utility/CarolinesTimers.cpp     | 94 +++++++++++++++++++++
 5 files changed, 163 insertions(+)
 create mode 100644 lldb/include/lldb/Utility/CarolinesTimers.h
 create mode 100644 lldb/source/Utility/CarolinesTimers.cpp

diff --git a/lldb/include/lldb/Utility/CarolinesTimers.h 
b/lldb/include/lldb/Utility/CarolinesTimers.h
new file mode 100644
index 0000000000000..c5c630b17c576
--- /dev/null
+++ b/lldb/include/lldb/Utility/CarolinesTimers.h
@@ -0,0 +1,36 @@
+// This is part of a temporary patch, to collect start-up time pieces in LLDB.
+
+#ifndef LLDB_CAROLINES_TIMERS_H
+#define LLDB_CAROLINES_TIMERS_H
+
+#include "lldb/lldb-defines.h"
+#include "llvm/Support/Chrono.h"
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <string>
+#include <vector>
+
+namespace lldb_private {
+
+enum CarolineTimerEvent {
+  eCarolineStartFrameVar = 0,
+  eCarolineEndFrameVar = 1,
+  eCarolineStartExprEval = 2,
+  eCarolineEndExprEval = 3,
+  //eCarolineStartNameIndexes = 4,
+  //eCarolineEndNameIndexes = 5,
+  //eCarolineStartDwarfIndex = 6,
+  //eCarolineEndDwarfIndex = 7,
+  //eCarolineEndHandleCommand = 8,
+  eCarolineLastItem = 4
+};
+
+void CarolineTimeStamp(CarolineTimerEvent event_kind,
+                       const std::string &expr,
+                       timespec *time_ptr = nullptr);
+
+
+} // namespace lldb_private
+
+#endif // LLDB_CAROLINES_TIMERS_H
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index d6fa72c6252df..3cadbd025ac8d 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -36,6 +36,7 @@
 #include "lldb/Target/StackID.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Utility/CarolinesTimers.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Instrumentation.h"
 #include "lldb/Utility/LLDBLog.h"
@@ -405,11 +406,30 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char 
*var_path,
   if (StackFrame *frame = exe_ctx->GetFramePtr()) {
     VariableSP var_sp;
     Status error;
+    timespec start_time1;
+    timespec start_time2;
+    timespec end_time1;
+    timespec end_time2;
+
+    CarolineTimeStamp(eCarolineStartFrameVar, var_path, &start_time1);
     ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
         var_path, eNoDynamicValues,
         StackFrame::eExpressionPathOptionCheckPtrVsMember |
             StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
         var_sp, error, mode));
+    CarolineTimeStamp(eCarolineEndFrameVar, var_path, &end_time1);
+
+    lldb::ValueObjectSP expr_valobj_sp;
+    Target *target = exe_ctx->GetTargetPtr();
+    SBExpressionOptions options;
+    options.SetFetchDynamicValue(target->GetPreferDynamicValue());
+    options.SetUnwindOnError(true);
+    options.SetIgnoreBreakpoints(true);
+    SourceLanguage language = target->GetLanguage();
+    options.SetLanguage((SBSourceLanguageName)language.name, language.version);
+    CarolineTimeStamp(eCarolineStartExprEval, var_path, &start_time2);
+    target->EvaluateExpression(var_path, frame, expr_valobj_sp, options.ref());
+    CarolineTimeStamp(eCarolineEndExprEval, var_path, &end_time2);
     sb_value.SetSP(value_sp, use_dynamic);
   }
   return sb_value;
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp 
b/lldb/source/Commands/CommandObjectFrame.cpp
index b1cc6c42a04fc..82a9cd0759085 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -29,6 +29,7 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/Args.h"
+#include "lldb/Utility/CarolinesTimers.h"
 #include "lldb/Utility/ValueType.h"
 #include "lldb/ValueObject/ValueObject.h"
 #include "lldb/lldb-enumerations.h"
@@ -705,9 +706,20 @@ may even involve JITing and running code in the target 
program.)");
                 StackFrame::eExpressionPathOptionsInspectAnonymousUnions |
                 StackFrame::eExpressionPathOptionsAllowVarUpdates;
             lldb::VariableSP var_sp;
+            timespec start_time1;
+            timespec start_time2;
+            timespec end_time1;
+            timespec end_time2;
+
+            llvm::StringRef expr_ref = entry.ref();
+            std::string expr = expr_ref.str();
+            CarolineTimeStamp(eCarolineStartFrameVar, expr, &start_time1);
             valobj_sp = frame->GetValueForVariableExpressionPath(
                 entry.ref(), m_varobj_options.use_dynamic, expr_path_options,
                 var_sp, error);
+            CarolineTimeStamp(eCarolineEndFrameVar, expr, &end_time1);
+            CarolineTimeStamp(eCarolineStartExprEval, expr, &start_time2);
+            CarolineTimeStamp(eCarolineEndExprEval, expr, &end_time2);
             if (valobj_sp) {
               result.GetValueObjectList().Append(valobj_sp);
 
diff --git a/lldb/source/Utility/CMakeLists.txt 
b/lldb/source/Utility/CMakeLists.txt
index 3836ab0ec6c29..d04f512a338a6 100644
--- a/lldb/source/Utility/CMakeLists.txt
+++ b/lldb/source/Utility/CMakeLists.txt
@@ -29,6 +29,7 @@ add_lldb_library(lldbUtility NO_INTERNAL_DEPENDENCIES
   Args.cpp
   Baton.cpp
   Broadcaster.cpp
+  CarolinesTimers.cpp
   Checksum.cpp
   CompletionRequest.cpp
   Connection.cpp
diff --git a/lldb/source/Utility/CarolinesTimers.cpp 
b/lldb/source/Utility/CarolinesTimers.cpp
new file mode 100644
index 0000000000000..11c16c0d2f6f8
--- /dev/null
+++ b/lldb/source/Utility/CarolinesTimers.cpp
@@ -0,0 +1,94 @@
+// This is part of a temporary patch, to collect start-up time pieces in LLDB.
+#include "lldb/Utility/CarolinesTimers.h"
+
+#include <cstdio>
+#include <cstdlib>
+#include <ctime>
+#include <filesystem>
+#include <string>
+
+#include <stdio.h>
+
+
+namespace lldb_private {
+
+std::string event_name[(int)CarolineTimerEvent::eCarolineLastItem+1] = {
+  "Start Frame Var", "End Frame Var", "Start ExprEval",
+  "End ExprEval", "Other"
+};
+
+static double CalculateTimeDiff(timespec start, timespec end) {
+  double start_time;
+  double end_time;
+  double diff = 0.0;
+
+  start_time = start.tv_sec + ((double)start.tv_nsec / 1000000000);
+  end_time = end.tv_sec + ((double)end.tv_nsec / 1000000000);
+  diff =  end_time - start_time;
+
+  return diff;
+}
+
+static void CarolineGenerateTimeReport(timespec *time_stamps,
+                                       const std::string& expr) {
+
+  double FrameVar = CalculateTimeDiff(time_stamps[eCarolineStartFrameVar],
+                                       time_stamps[eCarolineEndFrameVar]);
+
+  double ExprEval = CalculateTimeDiff(time_stamps[eCarolineStartExprEval],
+                                       time_stamps[eCarolineEndExprEval]);
+
+  std::filesystem::path file_path =
+      "/usr/local/google/home/cmtice/dil-report.txt";
+  if (std::filesystem::exists(file_path)) {
+    FILE *f = fopen("/usr/local/google/home/cmtice/dil-report.txt", "a");
+    if (f) {
+      fprintf(f, "%s,%f,%f\n", expr.c_str(), FrameVar, ExprEval);
+      fclose(f);
+    }
+  } else {
+    FILE *f = fopen("/usr/local/google/home/cmtice/dil-report.txt", "w");
+    if (f) {
+      fprintf(f, "expr,DIL_time,ExprEval_time\n");
+      fprintf(f, "%s,%f,%f\n", expr.c_str(), FrameVar, ExprEval);
+      fclose(f);
+    }
+  }
+}
+
+void CarolineTimeStamp(CarolineTimerEvent event_kind,
+                       const std::string &in_expr,
+                       timespec *timespec_ptr)
+{
+  timespec ts;
+  static timespec time_stamps[eCarolineLastItem+1];
+  static std::string expr;
+  static bool done = false;
+
+  // if (event_kind == eCarolineStartFrameVar && timespec_ptr) {
+  //ts.tv_sec = timespec_ptr->tv_sec;
+  //ts.tv_nsec = timespec_ptr->tv_nsec;
+    //} else {
+    timespec_get(&ts, TIME_UTC);
+    //}
+  time_stamps[event_kind] = ts;
+
+  bool all_ok = true;
+  if (expr.empty()) {
+    if (event_kind == eCarolineStartFrameVar)
+      expr = std::move(in_expr);
+    else
+      all_ok = false;
+  } else if (expr != in_expr)
+    all_ok = false;
+
+  assert(all_ok && "Something is wrong in Carolines Timers!");
+
+  if (event_kind == eCarolineEndExprEval && !done) {
+    CarolineGenerateTimeReport(time_stamps, expr);
+    //done = true;
+    expr.clear();
+  }
+}
+
+} // namespace lldb_private

>From 82eb0ff626f2442f8b6c64070e75f0aee626f387 Mon Sep 17 00:00:00 2001
From: Caroline Tice <[email protected]>
Date: Thu, 18 Jun 2026 10:20:42 -0700
Subject: [PATCH 2/2] Update interactive command to collece expr evaluator
 numbers.

---
 lldb/source/Commands/CommandObjectFrame.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lldb/source/Commands/CommandObjectFrame.cpp 
b/lldb/source/Commands/CommandObjectFrame.cpp
index 69e11c290b8a8..97b92d694e53c 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -741,7 +741,18 @@ may even involve JITing and running code in the target 
program.)");
                 entry.ref(), m_varobj_options.use_dynamic, expr_path_options,
                 var_sp, error);
             CarolineTimeStamp(eCarolineEndFrameVar, expr, &end_time1);
+            lldb::ValueObjectSP valobj_sp2;
+            std::string fixed_expression;
+            lldb::TargetSP target_sp = frame->CalculateTarget();
+            ExecutionContextScope *exe_scope = target_sp.get();
+            SourceLanguage language = target_sp->GetLanguage();
+            EvaluateExpressionOptions eval_options;
+            eval_options.SetUseDynamic(m_varobj_options.use_dynamic);
+            eval_options.SetUnwindOnError(true);
+            eval_options.SetIgnoreBreakpoints(true);
+            eval_options.SetLanguage(language.name, language.version);
             CarolineTimeStamp(eCarolineStartExprEval, expr, &start_time2);
+            ExpressionResults expr_result = 
target_sp->EvaluateExpression(expr, exe_scope, valobj_sp2, eval_options, 
&fixed_expression);
             CarolineTimeStamp(eCarolineEndExprEval, expr, &end_time2);
             // Check only the `error` argument, because doing
             // `valobj_sp->GetError()` will update the value and potentially

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to