Skip to content

Commit 9aa25b8

Browse files
[LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings (#106609)
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.
1 parent 5b3ba43 commit 9aa25b8

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
#include <cctype>
8888
#include <cstring>
8989

90-
//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
90+
// #define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
9191

9292
#ifdef ENABLE_DEBUG_PRINTF
9393
#include <cstdio>
@@ -129,6 +129,11 @@ class PluginProperties : public Properties {
129129
bool IgnoreFileIndexes() const {
130130
return GetPropertyAtIndexAs<bool>(ePropertyIgnoreIndexes, false);
131131
}
132+
133+
bool EmitUnsupportedDWFormValueWarning() const {
134+
return GetPropertyAtIndexAs<bool>(
135+
ePropertyEmitUnsupportedDWFormValueWarning, true);
136+
}
132137
};
133138

134139
} // namespace
@@ -624,12 +629,14 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
624629
llvm::DWARFDebugAbbrev *abbrev = DebugAbbrev();
625630
std::set<dw_form_t> unsupported_forms = GetUnsupportedForms(abbrev);
626631
if (!unsupported_forms.empty()) {
627-
StreamString error;
628-
error.Printf("unsupported DW_FORM value%s:",
629-
unsupported_forms.size() > 1 ? "s" : "");
630-
for (auto form : unsupported_forms)
631-
error.Printf(" %#x", form);
632-
m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
632+
if (GetGlobalPluginProperties().EmitUnsupportedDWFormValueWarning()) {
633+
StreamString error;
634+
error.Printf("unsupported DW_FORM value%s:",
635+
unsupported_forms.size() > 1 ? "s" : "");
636+
for (auto form : unsupported_forms)
637+
error.Printf(" %#x", form);
638+
m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
639+
}
633640
return 0;
634641
}
635642

@@ -1770,16 +1777,17 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) {
17701777
return this;
17711778

17721779
if (file_index) {
1773-
// We have a SymbolFileDWARFDebugMap, so let it find the right file
1780+
// We have a SymbolFileDWARFDebugMap, so let it find the right file
17741781
if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile())
17751782
return debug_map->GetSymbolFileByOSOIndex(*file_index);
1776-
1783+
17771784
// Handle the .dwp file case correctly
17781785
if (*file_index == DIERef::k_file_index_mask)
17791786
return GetDwpSymbolFile().get(); // DWP case
17801787

17811788
// Handle the .dwo file case correctly
1782-
return DebugInfo().GetUnitAtIndex(*die_ref.file_index())
1789+
return DebugInfo()
1790+
.GetUnitAtIndex(*die_ref.file_index())
17831791
->GetDwoSymbolFile(); // DWO case
17841792
}
17851793
return this;
@@ -3621,7 +3629,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
36213629
lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS;
36223630
if (!location_is_const_value_data) {
36233631
bool op_error = false;
3624-
const DWARFExpression* location = location_list.GetAlwaysValidExpr();
3632+
const DWARFExpression *location = location_list.GetAlwaysValidExpr();
36253633
if (location)
36263634
location_DW_OP_addr =
36273635
location->GetLocation_DW_OP_addr(location_form.GetUnit(), op_error);

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ let Definition = "symbolfiledwarf" in {
55
Global,
66
DefaultFalse,
77
Desc<"Ignore indexes present in the object files and always index DWARF manually.">;
8+
def EmitUnsupportedDWFormValueWarning: Property<"emit-unsupported-dwform-value", "Boolean">,
9+
Global,
10+
DefaultTrue,
11+
Desc<"Emit warnings about unsupported DW_Form values.">;
812
}

0 commit comments

Comments
 (0)