diff options
author | Aaron Smith <aaron.smith@microsoft.com> | 2018-01-23 20:35:19 +0000 |
---|---|---|
committer | Aaron Smith <aaron.smith@microsoft.com> | 2018-01-23 20:35:19 +0000 |
commit | ec40f818c630156db9318e0aa8206acb334b9ac8 (patch) | |
tree | 235657b8c1f2984f010f41a660fe01a9c0d4bbdd /lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | |
parent | a9ae2fe782c5d80d1c4f8443a13bf12b33add32f (diff) | |
download | bcm5719-llvm-ec40f818c630156db9318e0aa8206acb334b9ac8.tar.gz bcm5719-llvm-ec40f818c630156db9318e0aa8206acb334b9ac8.zip |
[SymbolFilePDB] Fix null array access when parsing the type of a function without any arguments, i.e. 'int main()' and add support to test it
Summary:
- Fix a null array access bug. This happens when creating the lldb type for a function that has no argument.
- Implement SymbolFilePDB::ParseTypes method. Using `lldb-test symbols` will show all supported types in the target.
- Create lldb types for variadic function, PDBSymbolTypePointer, PDBSymbolTypeBuiltin
- The underlying builtin type for PDBSymbolTypeEnum is always `Int`, correct it with the very first enumerator's encoding if any. This is more accurate when the underlying type is not signed or another integer type.
- Fix a bug when the compiler type is not created based on PDB_BuiltinType. For example, basic type `long` is of same width as `int` in a 32-bit target, and the compiler type of former one will be represented by the one generated for latter if using the default method. Introduce a static function GetBuiltinTypeForPDBEncodingAndBitSize to correct this issue.
- Basic type `long double` and `double` have the same bit size in MSVC and there is no information in a PDB to distinguish them. The compiler type of the former one is represented by the latter's.
- There is no line information about typedef, enum etc in a PDB and the source and line information for them are not shown.
- There is no information about scoped enumeration. The compiler type is represented as an unscoped one.
Reviewers: zturner, lldb-commits
Reviewed By: zturner
Subscribers: majnemer, llvm-commits
Differential Revision: https://reviews.llvm.org/D42434
llvm-svn: 323255
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp')
-rw-r--r-- | lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 7b7c237fdd2..d0082925a3c 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -20,6 +20,7 @@ #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/TypeMap.h" +#include "lldb/Symbol/TypeList.h" #include "lldb/Utility/RegularExpression.h" #include "llvm/DebugInfo/PDB/GenericError.h" @@ -318,8 +319,33 @@ SymbolFilePDB::ParseFunctionBlocks(const lldb_private::SymbolContext &sc) { } size_t SymbolFilePDB::ParseTypes(const lldb_private::SymbolContext &sc) { - // TODO: Implement this - return size_t(); + lldbassert(sc.module_sp.get()); + size_t num_added = 0; + auto results_up = m_session_up->getGlobalScope()->findAllChildren(); + if (!results_up) + return 0; + while (auto symbol_up = results_up->getNext()) { + switch (symbol_up->getSymTag()) { + case PDB_SymType::Enum: + case PDB_SymType::UDT: + case PDB_SymType::Typedef: + break; + default: + continue; + } + + auto type_uid = symbol_up->getSymIndexId(); + if (m_types.find(type_uid) != m_types.end()) + continue; + + // This should cause the type to get cached and stored in the `m_types` + // lookup. + if (!ResolveTypeUID(symbol_up->getSymIndexId())) + continue; + + ++num_added; + } + return num_added; } size_t @@ -349,8 +375,11 @@ lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) { return nullptr; lldb::TypeSP result = pdb->CreateLLDBTypeFromPDBType(*pdb_type); - if (result.get()) + if (result.get()) { m_types.insert(std::make_pair(type_uid, result)); + auto type_list = GetTypeList(); + type_list->Insert(result); + } return result.get(); } @@ -649,7 +678,9 @@ size_t SymbolFilePDB::FindTypes( return 0; } -lldb_private::TypeList *SymbolFilePDB::GetTypeList() { return nullptr; } +lldb_private::TypeList *SymbolFilePDB::GetTypeList() { + return m_obj_file->GetModule()->GetTypeList(); +} size_t SymbolFilePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope, uint32_t type_mask, |