Skip to content

Conversation

@delcypher
Copy link
Contributor

This patch adds LLDBLog::InstrumentationRuntime as a log channel to provide an appropriate channel for instrumentation runtime plugins as previously one did not exist.

A small use of the channel is added to illustrate its use. The logging added is not intended to be comprehensive.

This is primarily motivated by an -fbounds-safety instrumentation plugin (swiftlang#11835).

rdar://164920875

@llvmbot
Copy link
Member

llvmbot commented Nov 18, 2025

@llvm/pr-subscribers-lldb

Author: Dan Liew (delcypher)

Changes

This patch adds LLDBLog::InstrumentationRuntime as a log channel to provide an appropriate channel for instrumentation runtime plugins as previously one did not exist.

A small use of the channel is added to illustrate its use. The logging added is not intended to be comprehensive.

This is primarily motivated by an -fbounds-safety instrumentation plugin (swiftlang#11835).

rdar://164920875


Full diff: https://github.com/llvm/llvm-project/pull/168508.diff

3 Files Affected:

  • (modified) lldb/include/lldb/Utility/LLDBLog.h (+2-1)
  • (modified) lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp (+4-1)
  • (modified) lldb/source/Utility/LLDBLog.cpp (+3)
diff --git a/lldb/include/lldb/Utility/LLDBLog.h b/lldb/include/lldb/Utility/LLDBLog.h
index 18e4a3ca73507..ac360bfdf8cee 100644
--- a/lldb/include/lldb/Utility/LLDBLog.h
+++ b/lldb/include/lldb/Utility/LLDBLog.h
@@ -50,7 +50,8 @@ enum class LLDBLog : Log::MaskType {
   OnDemand = Log::ChannelFlag<31>,
   Source = Log::ChannelFlag<32>,
   Disassembler = Log::ChannelFlag<33>,
-  LLVM_MARK_AS_BITMASK_ENUM(Disassembler),
+  InstrumentationRuntime = Log::ChannelFlag<34>,
+  LLVM_MARK_AS_BITMASK_ENUM(InstrumentationRuntime),
 };
 
 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
diff --git a/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp b/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
index 38c334bfb78ac..8b3702335d012 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
@@ -199,6 +199,7 @@ bool ReportRetriever::NotifyBreakpointHit(ProcessSP process_sp,
                                           StoppointCallbackContext *context,
                                           user_id_t break_id,
                                           user_id_t break_loc_id) {
+  auto *log = GetLog(LLDBLog::InstrumentationRuntime);
   // Make sure this is the right process
   if (!process_sp || process_sp != context->exe_ctx_ref.GetProcessSP())
     return false;
@@ -207,8 +208,10 @@ bool ReportRetriever::NotifyBreakpointHit(ProcessSP process_sp,
     return false;
 
   StructuredData::ObjectSP report = RetrieveReportData(process_sp);
-  if (!report || report->GetType() != lldb::eStructuredDataTypeDictionary)
+  if (!report || report->GetType() != lldb::eStructuredDataTypeDictionary) {
+    LLDB_LOGF(log, "ReportRetriever::RetrieveReportData() failed");
     return false;
+  }
 
   std::string description = FormatDescription(report);
 
diff --git a/lldb/source/Utility/LLDBLog.cpp b/lldb/source/Utility/LLDBLog.cpp
index 613dae42064a8..a08764d84edd2 100644
--- a/lldb/source/Utility/LLDBLog.cpp
+++ b/lldb/source/Utility/LLDBLog.cpp
@@ -67,6 +67,9 @@ static constexpr Log::Category g_categories[] = {
     {{"disassembler"},
      {"log disassembler related activities"},
      LLDBLog::Disassembler},
+    {{"instrumentation-runtime"},
+     {"log instrumentation runtime plugin related activities"},
+     LLDBLog::InstrumentationRuntime},
 };
 
 static Log::Channel g_log_channel(g_categories,

@github-actions
Copy link

🐧 Linux x64 Test Results

  • 33126 tests passed
  • 494 tests skipped

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

Surprised we haven't logged anything from InstrumentationRuntime before

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with Michael's comment addressed.

@jimingham
Copy link
Collaborator

LGTM also.

@delcypher delcypher force-pushed the dliew/lldb-instrumentation-plugin-log-handle branch from 94f1518 to 40e7cf2 Compare November 18, 2025 18:41
This patch adds `LLDBLog::InstrumentationRuntime` as a log channel to
provide an appropriate channel for instrumentation runtime plugins as
previously one did not exist.

A small use of the channel is added to illustrate its use. The logging
added is not intended to be comprehensive.

This is primarily motivated by an `-fbounds-safety` instrumentation
plugin (swiftlang#11835).

rdar://164920875
@delcypher delcypher force-pushed the dliew/lldb-instrumentation-plugin-log-handle branch from 40e7cf2 to c8cffb1 Compare November 18, 2025 18:46
@delcypher delcypher merged commit 46565f3 into llvm:main Nov 18, 2025
6 of 8 checks passed
delcypher added a commit to delcypher/apple-llvm-project that referenced this pull request Nov 18, 2025
This patch adds `LLDBLog::InstrumentationRuntime` as a log channel to
provide an appropriate channel for instrumentation runtime plugins as
previously one did not exist.

A small use of the channel is added to illustrate its use. The logging
added is not intended to be comprehensive.

This is primarily motivated by an `-fbounds-safety` instrumentation
plugin (swiftlang#11835).

rdar://164920875
(cherry picked from commit 46565f3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants