Skip to content

[LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings #106609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

walter-erquinigo
Copy link
Member

My build of LLDB is all the time loading targets with a version of libc++ that was built with gcc that uses the DW_FORM 0x1e that is not implemented by LLVM, and I doubt it'll ever implement it. It's used for some 128 bit encoding of numbers, which is just very weird. Because of this, LLDB is showing some warnings all the time for my users, so I'm adding a flag to control the enablement of this warning.

My build of LLDB is all the time loading targets with a version of
libc++ that was built with gcc that uses the DW_FORM 0x1e that is not
implemented by LLVM, and I doubt it'll ever implement it. It's used for
some 128 bit encoding of numbers, which is just very weird.
Because of this, LLDB is showing some warnings all the time for my
users, so I'm adding a flag to control the enablement of this warning.
@llvmbot
Copy link
Member

llvmbot commented Aug 29, 2024

@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)

Changes

My build of LLDB is all the time loading targets with a version of libc++ that was built with gcc that uses the DW_FORM 0x1e that is not implemented by LLVM, and I doubt it'll ever implement it. It's used for some 128 bit encoding of numbers, which is just very weird. Because of this, LLDB is showing some warnings all the time for my users, so I'm adding a flag to control the enablement of this warning.


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

2 Files Affected:

  • (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+19-11)
  • (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td (+4)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 7e0cf36d0de1b8..cb2625a2928701 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -87,7 +87,7 @@
 #include <cctype>
 #include <cstring>
 
-//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
+// #define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
 
 #ifdef ENABLE_DEBUG_PRINTF
 #include <cstdio>
@@ -129,6 +129,11 @@ class PluginProperties : public Properties {
   bool IgnoreFileIndexes() const {
     return GetPropertyAtIndexAs<bool>(ePropertyIgnoreIndexes, false);
   }
+
+  bool EmitUnsupportedDWFormValueWarning() const {
+    return GetPropertyAtIndexAs<bool>(
+        ePropertyEmitUnsupportedDWFormValueWarning, true);
+  }
 };
 
 } // namespace
@@ -624,12 +629,14 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
       llvm::DWARFDebugAbbrev *abbrev = DebugAbbrev();
       std::set<dw_form_t> unsupported_forms = GetUnsupportedForms(abbrev);
       if (!unsupported_forms.empty()) {
-        StreamString error;
-        error.Printf("unsupported DW_FORM value%s:",
-                     unsupported_forms.size() > 1 ? "s" : "");
-        for (auto form : unsupported_forms)
-          error.Printf(" %#x", form);
-        m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
+        if (GetGlobalPluginProperties().EmitUnsupportedDWFormValueWarning()) {
+          StreamString error;
+          error.Printf("unsupported DW_FORM value%s:",
+                       unsupported_forms.size() > 1 ? "s" : "");
+          for (auto form : unsupported_forms)
+            error.Printf(" %#x", form);
+          m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
+        }
         return 0;
       }
 
@@ -1770,16 +1777,17 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) {
     return this;
 
   if (file_index) {
-      // We have a SymbolFileDWARFDebugMap, so let it find the right file
+    // We have a SymbolFileDWARFDebugMap, so let it find the right file
     if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile())
       return debug_map->GetSymbolFileByOSOIndex(*file_index);
-    
+
     // Handle the .dwp file case correctly
     if (*file_index == DIERef::k_file_index_mask)
       return GetDwpSymbolFile().get(); // DWP case
 
     // Handle the .dwo file case correctly
-    return DebugInfo().GetUnitAtIndex(*die_ref.file_index())
+    return DebugInfo()
+        .GetUnitAtIndex(*die_ref.file_index())
         ->GetDwoSymbolFile(); // DWO case
   }
   return this;
@@ -3594,7 +3602,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
     lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS;
     if (!location_is_const_value_data) {
       bool op_error = false;
-      const DWARFExpression* location = location_list.GetAlwaysValidExpr();
+      const DWARFExpression *location = location_list.GetAlwaysValidExpr();
       if (location)
         location_DW_OP_addr =
             location->GetLocation_DW_OP_addr(location_form.GetUnit(), op_error);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
index 2f1ce88808b763..0f980a514b6720 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
@@ -5,4 +5,8 @@ let Definition = "symbolfiledwarf" in {
     Global,
     DefaultFalse,
     Desc<"Ignore indexes present in the object files and always index DWARF manually.">;
+  def EmitUnsupportedDWFormValueWarning: Property<"emit-unsupported-dwform-value", "Boolean">,
+    Global,
+    DefaultTrue,
+    Desc<"Emit warnings about unsupported DW_Form values.">;
 }

@walter-erquinigo
Copy link
Member Author

Merging because of time constraints, but happy to get follow up feedback.

@walter-erquinigo walter-erquinigo merged commit 9aa25b8 into llvm:main Aug 30, 2024
9 checks passed
Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

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

Please fix and revert this, we do not want this in open source. Very easy to fix and the warning does nothing to improve the situation and actually will be bad for the product. Happy to discuss over VC and get a real fix in quickly

@walter-erquinigo
Copy link
Member Author

@clayborg , sure!

@walter-erquinigo
Copy link
Member Author

Revert commit: #106765

@walter-erquinigo walter-erquinigo deleted the modular/walter/fix branch August 30, 2024 21:21
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.

3 participants