[Lldb-commits] [lldb] 8f6ee17 - [lldb] Warn when we fail to find dwo/dwp files

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 9 05:31:24 PST 2022


Author: Pavel Labath
Date: 2022-03-09T14:31:17+01:00
New Revision: 8f6ee17f22a7575671ad1581231f29947a6a280a

URL: https://github.com/llvm/llvm-project/commit/8f6ee17f22a7575671ad1581231f29947a6a280a
DIFF: https://github.com/llvm/llvm-project/commit/8f6ee17f22a7575671ad1581231f29947a6a280a.diff

LOG: [lldb] Warn when we fail to find dwo/dwp files

This ensures that the user is aware that many commands will not work
correctly.

We print the warning only once (per module) to avoid spamming the user
with potentially thousands of error messages.

Differential Revision: https://reviews.llvm.org/D120892

Added: 
    lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 0a5f76995129c..d0f5bc5f05de1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1746,8 +1746,14 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
     dwo_file.AppendPathComponent(dwo_name);
   }
 
-  if (!FileSystem::Instance().Exists(dwo_file))
+  if (!FileSystem::Instance().Exists(dwo_file)) {
+    if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) {
+      GetObjectFile()->GetModule()->ReportWarning(
+          "unable to locate separate debug file (dwo, dwp). Debugging will be "
+          "degraded.");
+    }
     return nullptr;
+  }
 
   const lldb::offset_t file_offset = 0;
   DataBufferSP dwo_file_data_sp;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index f84a78620e17e..86338ccdf68cc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -560,6 +560,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
   /// address in the module.
   lldb::addr_t m_first_code_address = LLDB_INVALID_ADDRESS;
   lldb_private::StatsDuration m_parse_time;
+  std::atomic_flag m_dwo_warning_issued = ATOMIC_FLAG_INIT;
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARF_H

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
new file mode 100644
index 0000000000000..929e11f80e34e
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang --target=x86_64-pc-linux -g -gsplit-dwarf -c %s -o %t.o
+// RUN: rm %t.dwo
+// RUN: %lldb %t.o -o "br set -n main" -o exit 2>&1 | FileCheck %s
+
+// CHECK: warning: {{.*}} unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+
+int main() { return 47; }


        


More information about the lldb-commits mailing list