[Lldb-commits] [lldb] r168655 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: DWARFCompileUnit.cpp DWARFCompileUnit.h SymbolFileDWARF.cpp
Greg Clayton
gclayton at apple.com
Mon Nov 26 16:59:26 PST 2012
Author: gclayton
Date: Mon Nov 26 18:59:26 2012
New Revision: 168655
URL: http://llvm.org/viewvc/llvm-project?rev=168655&view=rev
Log:
<rdar://problem/12636970>
Detect the new fixed clang that properly supports bitfields in objc classes.
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=168655&r1=168654&r2=168655&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Mon Nov 26 18:59:26 2012
@@ -43,7 +43,10 @@
m_length (0),
m_version (0),
m_addr_size (DWARFCompileUnit::GetDefaultAddressSize()),
- m_producer (eProducerInvalid)
+ m_producer (eProducerInvalid),
+ m_producer_version_major (0),
+ m_producer_version_minor (0),
+ m_producer_version_update (0)
{
}
@@ -883,9 +886,22 @@
}
bool
+DWARFCompileUnit::Supports_unnamed_objc_bitfields ()
+{
+ if (GetProducer() == eProducerClang)
+ {
+ if (GetProducerVersionMajor() >= 425 && GetProducerVersionUpdate() >= 13)
+ return true;
+ else
+ return false;
+ }
+ return true; // Assume all other compilers didn't have incorrect ObjC bitfield info
+}
+
+bool
DWARFCompileUnit::Supports_DW_AT_APPLE_objc_complete_type ()
{
- if (GetProducer() == eProcucerLLVMGCC)
+ if (GetProducer() == eProducerLLVMGCC)
return false;
return true;
}
@@ -895,34 +911,81 @@
{
// llvm-gcc makes completely invalid decl file attributes and won't ever
// be fixed, so we need to know to ignore these.
- return GetProducer() == eProcucerLLVMGCC;
+ return GetProducer() == eProducerLLVMGCC;
}
-DWARFCompileUnit::Producer
-DWARFCompileUnit::GetProducer ()
+void
+DWARFCompileUnit::ParseProducerInfo ()
{
- if (m_producer == eProducerInvalid)
+ m_producer_version_major = UINT32_MAX;
+ m_producer_version_minor = UINT32_MAX;
+ m_producer_version_update = UINT32_MAX;
+
+ const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
+ if (die)
{
- const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
- if (die)
+
+ const char *producer_cstr = die->GetAttributeValueAsString(m_dwarf2Data, this, DW_AT_producer, NULL);
+ if (producer_cstr)
{
- const char *producer_cstr = die->GetAttributeValueAsString(m_dwarf2Data, this, DW_AT_producer, NULL);
- if (producer_cstr)
+ RegularExpression llvm_gcc_regex("^4\\.[012]\\.[01] \\(Based on Apple Inc\\. build [0-9]+\\) \\(LLVM build [\\.0-9]+\\)$");
+ if (llvm_gcc_regex.Execute (producer_cstr))
{
- RegularExpression g_llvm_gcc_regex("^4\\.[012]\\.[01] \\(Based on Apple Inc\\. build [0-9]+\\) \\(LLVM build [\\.0-9]+\\)$");
- if (g_llvm_gcc_regex.Execute (producer_cstr))
- m_producer = eProcucerLLVMGCC;
- else if (strstr(producer_cstr, "clang"))
- m_producer = eProducerClang;
- else if (strstr(producer_cstr, "GNU"))
- m_producer = eProducerGCC;
+ m_producer = eProducerLLVMGCC;
}
+ else if (strstr(producer_cstr, "clang"))
+ {
+ RegularExpression clang_regex("clang-([0-9]+)\\.([0-9]+)\\.([0-9]+)");
+ if (clang_regex.Execute (producer_cstr, 3))
+ {
+ std::string str;
+ if (clang_regex.GetMatchAtIndex (producer_cstr, 1, str))
+ m_producer_version_major = Args::StringToUInt32(str.c_str(), UINT32_MAX, 10);
+ if (clang_regex.GetMatchAtIndex (producer_cstr, 2, str))
+ m_producer_version_minor = Args::StringToUInt32(str.c_str(), UINT32_MAX, 10);
+ if (clang_regex.GetMatchAtIndex (producer_cstr, 3, str))
+ m_producer_version_update = Args::StringToUInt32(str.c_str(), UINT32_MAX, 10);
+ }
+ m_producer = eProducerClang;
+ }
+ else if (strstr(producer_cstr, "GNU"))
+ m_producer = eProducerGCC;
}
- if (m_producer == eProducerInvalid)
- m_producer = eProcucerOther;
}
+ if (m_producer == eProducerInvalid)
+ m_producer = eProcucerOther;
+}
+
+DWARFCompileUnit::Producer
+DWARFCompileUnit::GetProducer ()
+{
+ if (m_producer == eProducerInvalid)
+ ParseProducerInfo ();
return m_producer;
}
+uint32_t
+DWARFCompileUnit::GetProducerVersionMajor()
+{
+ if (m_producer_version_major == 0)
+ ParseProducerInfo ();
+ return m_producer_version_major;
+}
+
+uint32_t
+DWARFCompileUnit::GetProducerVersionMinor()
+{
+ if (m_producer_version_minor == 0)
+ ParseProducerInfo ();
+ return m_producer_version_minor;
+}
+
+uint32_t
+DWARFCompileUnit::GetProducerVersionUpdate()
+{
+ if (m_producer_version_update == 0)
+ ParseProducerInfo ();
+ return m_producer_version_update;
+}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=168655&r1=168654&r2=168655&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Mon Nov 26 18:59:26 2012
@@ -23,7 +23,7 @@
eProducerInvalid = 0,
eProducerClang,
eProducerGCC,
- eProcucerLLVMGCC,
+ eProducerLLVMGCC,
eProcucerOther
};
@@ -144,6 +144,9 @@
bool
DW_AT_decl_file_attributes_are_invalid();
+ bool
+ Supports_unnamed_objc_bitfields ();
+
// void
// AddGlobalDIEByIndex (uint32_t die_idx);
//
@@ -173,6 +176,14 @@
Producer
GetProducer ();
+ uint32_t
+ GetProducerVersionMajor();
+
+ uint32_t
+ GetProducerVersionMinor();
+
+ uint32_t
+ GetProducerVersionUpdate();
protected:
SymbolFileDWARF* m_dwarf2Data;
@@ -186,6 +197,12 @@
uint16_t m_version;
uint8_t m_addr_size;
Producer m_producer;
+ uint32_t m_producer_version_major;
+ uint32_t m_producer_version_minor;
+ uint32_t m_producer_version_update;
+
+ void
+ ParseProducerInfo ();
private:
DISALLOW_COPY_AND_ASSIGN (DWARFCompileUnit);
};
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=168655&r1=168654&r2=168655&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Nov 26 18:59:26 2012
@@ -1768,11 +1768,15 @@
// Code to detect unnamed bitifields
if (bit_size > 0 && member_byte_offset != UINT32_MAX)
{
- // Objective C has invalid DW_AT_bit_offset values so we can't use them to detect
- // unnamed bitfields. Once clang is fixed we will enable unnamed bitfields
- // in ObjC classes (<rdar://problem/12636970>)
+ // Objective C has invalid DW_AT_bit_offset values in older versions
+ // of clang, so we have to be careful and only detect unnammed bitfields
+ // if we have a new enough clang.
+ bool detect_unnamed_bitfields = true;
- if (!(class_language == eLanguageTypeObjC || class_language == eLanguageTypeObjC_plus_plus))
+ if (class_language == eLanguageTypeObjC || class_language == eLanguageTypeObjC_plus_plus)
+ detect_unnamed_bitfields = dwarf_cu->Supports_unnamed_objc_bitfields ();
+
+ if (detect_unnamed_bitfields)
{
// We have a bitfield, we need to watch out for
// unnamed bitfields that we need to insert if
More information about the lldb-commits
mailing list