[Lldb-commits] [lldb] 39a4da2 - [lldb][asan] Add temporary logging to ReportRetriever

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 6 23:10:00 PST 2025


Author: Michael Buch
Date: 2025-03-07T07:09:18Z
New Revision: 39a4da20d88d797824f0e7be0f732ccaf0c7eee4

URL: https://github.com/llvm/llvm-project/commit/39a4da20d88d797824f0e7be0f732ccaf0c7eee4
DIFF: https://github.com/llvm/llvm-project/commit/39a4da20d88d797824f0e7be0f732ccaf0c7eee4.diff

LOG: [lldb][asan] Add temporary logging to ReportRetriever

`TestReportData.py` is failing on the macOS CI with:
```
Traceback (most recent call last):
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1784, in test_method
    return attrvalue(self)
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 148, in wrapper
    return func(*args, **kwargs)
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/API/functionalities/asan/TestReportData.py", line 28, in test_libsanitizers_asan
    self.asan_tests(libsanitizers=True)
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/API/functionalities/asan/TestReportData.py", line 60, in asan_tests
    self.expect(
  File "/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2490, in expect
    self.fail(log_msg)
AssertionError: Ran command:
"thread list"

Got output:
Process 3474 stopped
* thread #1: tid = 0x38b5e9, 0x00007ff80f563b52 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT

Expecting sub string: "stopped" (was found)
Expecting sub string: "stop reason = Use of deallocated memory" (was not found)
Process should be stopped due to ASan report
```

There isn't much to go off of in the log, so adding more to help us debug this.

Added: 
    

Modified: 
    lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
    lldb/test/API/functionalities/asan/TestReportData.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp b/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
index 96489248022eb..006d8aa9b4dbe 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Expression/UserExpression.h"
 #include "lldb/Target/InstrumentationRuntimeStopInfo.h"
+#include "lldb/Utility/LLDBLog.h"
 #include "lldb/ValueObject/ValueObject.h"
 
 using namespace lldb;
@@ -84,6 +85,8 @@ ReportRetriever::RetrieveReportData(const ProcessSP process_sp) {
   options.SetLanguage(eLanguageTypeObjC_plus_plus);
 
   if (auto m = GetPreferredAsanModule(process_sp->GetTarget())) {
+    LLDB_LOGF(GetLog(LLDBLog::Expressions), "Using preferred ASAN module: %s",
+              m->GetFileSpec().GetFilename().AsCString(""));
     SymbolContextList sc_list;
     sc_list.Append(SymbolContext(std::move(m)));
     options.SetPreferredSymbolContexts(std::move(sc_list));
@@ -105,11 +108,16 @@ ReportRetriever::RetrieveReportData(const ProcessSP process_sp) {
     return StructuredData::ObjectSP();
   }
 
+  LLDB_LOGF(GetLog(LLDBLog::Expressions),
+            "Successfully ran ASAN report retriever utility expression");
+
   int present = return_value_sp->GetValueForExpressionPath(".present")
                     ->GetValueAsUnsigned(0);
   if (present != 1)
     return StructuredData::ObjectSP();
 
+  LLDB_LOGF(GetLog(LLDBLog::Expressions), "Retrieving report.1");
+
   addr_t pc =
       return_value_sp->GetValueForExpressionPath(".pc")->GetValueAsUnsigned(0);
   addr_t bp =
@@ -135,6 +143,8 @@ ReportRetriever::RetrieveReportData(const ProcessSP process_sp) {
   if (!dict)
     return StructuredData::ObjectSP();
 
+  LLDB_LOGF(GetLog(LLDBLog::Expressions), "Retrieving report.2");
+
   dict->AddStringItem("instrumentation_class", "AddressSanitizer");
   dict->AddStringItem("stop_type", "fatal_error");
   dict->AddIntegerItem("pc", pc);

diff  --git a/lldb/test/API/functionalities/asan/TestReportData.py b/lldb/test/API/functionalities/asan/TestReportData.py
index 5e4c179e2a481..29bdf1fac8e73 100644
--- a/lldb/test/API/functionalities/asan/TestReportData.py
+++ b/lldb/test/API/functionalities/asan/TestReportData.py
@@ -38,6 +38,9 @@ def setUp(self):
         self.col_crash = 16
 
     def asan_tests(self, libsanitizers=False):
+        if libsanitizers:
+            self.runCmd("log enable lldb expr")
+
         target = self.createTestTarget()
 
         if libsanitizers:


        


More information about the lldb-commits mailing list