[Lldb-commits] [lldb] r239963 - Fix enum LanguageType values and language string table lookups.
Dawn Perchik
dawn at burble.org
Wed Jun 17 15:30:24 PDT 2015
Author: dperchik
Date: Wed Jun 17 17:30:24 2015
New Revision: 239963
URL: http://llvm.org/viewvc/llvm-project?rev=239963&view=rev
Log:
Fix enum LanguageType values and language string table lookups.
Summary:
* Fix enum LanguageType values so that they can be used as indexes
into array language_names and g_languages as assumed by
LanguageRuntime::GetNameForLanguageType,
Language::SetLanguageFromCString and Language::AsCString.
* Add DWARFCompileUnit::LanguageTypeFromDWARF to convert from DWARF
DW_LANG_* values to enum LanguageType values.
Reviewed By: clayborg, abidh
Differential Revision: http://reviews.llvm.org/D10484
Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/Language.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Target/LanguageRuntime.cpp
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=239963&r1=239962&r2=239963&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Jun 17 17:30:24 2015
@@ -421,7 +421,12 @@ namespace lldb {
eLanguageTypeFortran03 = 0x0022, ///< ISO Fortran 2003.
eLanguageTypeFortran08 = 0x0023, ///< ISO Fortran 2008.
// Vendor Extensions
- eLanguageTypeExtRenderScript = 0x8e57, ///< RenderScript
+ // Note: LanguageRuntime::GetNameForLanguageType
+ // assumes these can be used as indexes into array language_names, and
+ // Language::SetLanguageFromCString and Language::AsCString
+ // assume these can be used as indexes into array g_languages.
+ eLanguageTypeMipsAssembler = 0x0024, ///< Mips_Assembler.
+ eLanguageTypeExtRenderScript = 0x0025, ///< RenderScript.
eNumLanguageTypes
};
Modified: lldb/trunk/source/Core/Language.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Language.cpp?rev=239963&r1=239962&r2=239963&view=diff
==============================================================================
--- lldb/trunk/source/Core/Language.cpp (original)
+++ lldb/trunk/source/Core/Language.cpp Wed Jun 17 17:30:24 2015
@@ -46,7 +46,25 @@ g_languages[] =
{ { "objc++" , NULL , "Objective-C++" } },
{ { "upc" , NULL , "Unified Parallel C" } },
{ { "d" , NULL , "D" } },
- { { "python" , NULL , "Python" } }
+ { { "python" , NULL , "Python" } },
+ { { "opencl" , "OpenCL" , "OpenCL" } },
+ { { "go" , "Go" , "Go" } },
+ { { "modula3" , "Modula3" , "Modula 3" } },
+ { { "haskell" , "Haskell" , "Haskell" } },
+ { { "c++03" , "C_plus_plus_03" , "ISO C++:2003" } },
+ { { "c++11" , "C_plus_plus_11" , "ISO C++:2011" } },
+ { { "ocaml" , "OCaml" , "OCaml" } },
+ { { "rust" , "Rust" , "Rust" } },
+ { { "c11" , "C11" , "ISO C:2011" } },
+ { { "swift" , "Swift" , "Swift" } },
+ { { "julia" , "Julia" , "Julia" } },
+ { { "dylan" , "Dylan" , "Dylan" } },
+ { { "c++14" , "C_plus_plus_14" , "ISO C++:2014" } },
+ { { "f03" , "Fortran03" , "ISO Fortran 2003" } },
+ { { "f08" , "Fortran08" , "ISO Fortran 2008" } },
+ // Vendor Extensions
+ { { "mipsassem" , "Mips_Assembler" , "Mips Assembler" } },
+ { { "renderscript" , "RenderScript" , "RenderScript" } }
};
static const size_t g_num_languages = llvm::array_lengthof(g_languages);
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=239963&r1=239962&r2=239963&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Wed Jun 17 17:30:24 2015
@@ -1070,6 +1070,22 @@ DWARFCompileUnit::GetProducerVersionUpda
}
LanguageType
+DWARFCompileUnit::LanguageTypeFromDWARF(uint64_t val)
+{
+ // Note: user languages between lo_user and hi_user
+ // must be handled explicitly here.
+ switch (val)
+ {
+ case DW_LANG_Mips_Assembler:
+ return eLanguageTypeMipsAssembler;
+ case 0x8e57: // FIXME: needs to be added to llvm
+ return eLanguageTypeExtRenderScript;
+ default:
+ return static_cast<LanguageType>(val);
+ }
+}
+
+LanguageType
DWARFCompileUnit::GetLanguageType()
{
if (m_language_type != eLanguageTypeUnknown)
@@ -1077,8 +1093,8 @@ DWARFCompileUnit::GetLanguageType()
const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
if (die)
- m_language_type = static_cast<LanguageType>(
- die->GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_language, eLanguageTypeUnknown));
+ m_language_type = LanguageTypeFromDWARF(
+ die->GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_language, 0));
return m_language_type;
}
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=239963&r1=239962&r2=239963&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Wed Jun 17 17:30:24 2015
@@ -187,6 +187,9 @@ public:
uint32_t
GetProducerVersionUpdate();
+ static lldb::LanguageType
+ LanguageTypeFromDWARF(uint64_t val);
+
lldb::LanguageType
GetLanguageType();
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=239963&r1=239962&r2=239963&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Jun 17 17:30:24 2015
@@ -989,7 +989,7 @@ SymbolFileDWARF::ParseCompileUnit (DWARF
if (module_sp->RemapSourceFile(cu_file_spec.GetCString(), remapped_file))
cu_file_spec.SetFile(remapped_file, false);
- LanguageType cu_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0);
+ LanguageType cu_language = DWARFCompileUnit::LanguageTypeFromDWARF(cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0));
cu_sp.reset(new CompileUnit (module_sp,
dwarf_cu,
@@ -1192,11 +1192,7 @@ SymbolFileDWARF::ParseCompileUnitLanguag
{
const DWARFDebugInfoEntry *die = dwarf_cu->GetCompileUnitDIEOnly();
if (die)
- {
- const uint32_t language = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0);
- if (language)
- return (lldb::LanguageType)language;
- }
+ return DWARFCompileUnit::LanguageTypeFromDWARF(die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0));
}
return eLanguageTypeUnknown;
}
Modified: lldb/trunk/source/Target/LanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=239963&r1=239962&r2=239963&view=diff
==============================================================================
--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/LanguageRuntime.cpp Wed Jun 17 17:30:24 2015
@@ -367,6 +367,7 @@ struct language_name_pair language_names
{ "fortran03", eLanguageTypeFortran03 },
{ "fortran08", eLanguageTypeFortran08 },
// Vendor Extensions
+ { "mipsassem", eLanguageTypeMipsAssembler },
{ "renderscript", eLanguageTypeExtRenderScript},
// Now synonyms, in arbitrary order
{ "objc", eLanguageTypeObjC },
More information about the lldb-commits
mailing list