augusto2112 updated this revision to Diff 344151.
augusto2112 added a comment.
Add GetExeModuleWhenMissingSymbolFile tesst.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101539/new/
https://reviews.llvm.org/D101539
Files:
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Symbol/Type.cpp
lldb/unittests/Symbol/TestTypeSystemClang.cpp
Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp
===================================================================
--- lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/Declaration.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/lldb-enumerations.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/ExprCXX.h"
@@ -741,3 +742,14 @@
ScratchTypeSystemClang::IsolatedASTKind::CppModules,
ScratchTypeSystemClang::InferIsolatedASTKindFromLangOpts(lang_opts));
}
+
+TEST_F(TestTypeSystemClang, GetExeModuleWhenMissingSymbolFile) {
+ auto compiler_type = m_ast->GetBasicTypeFromAST(lldb::eBasicTypeInt);
+ lldb_private::Type t(0, nullptr, ConstString("MyType"), llvm::None, nullptr,
+ 0, {}, {}, compiler_type,
+ lldb_private::Type::ResolveState::Full);
+ // Test that getting the execution module when no type system is present
+ // is handled gracefully.
+ auto module = t.GetExeModule();
+}
+
Index: lldb/source/Symbol/Type.cpp
===================================================================
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -730,7 +730,8 @@
ModuleSP Type::GetExeModule() {
if (m_compiler_type) {
SymbolFile *symbol_file = m_compiler_type.GetTypeSystem()->GetSymbolFile();
- return symbol_file->GetObjectFile()->GetModule();
+ if (symbol_file)
+ return symbol_file->GetObjectFile()->GetModule();
}
return ModuleSP();
}
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===================================================================
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9306,11 +9306,11 @@
std::vector<CompilerDecl> TypeSystemClang::DeclContextFindDeclByName(
void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) {
std::vector<CompilerDecl> found_decls;
- if (opaque_decl_ctx) {
+ SymbolFile *symbol_file = GetSymbolFile();
+ if (opaque_decl_ctx && symbol_file) {
DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
std::set<DeclContext *> searched;
std::multimap<DeclContext *, DeclContext *> search_queue;
- SymbolFile *symbol_file = GetSymbolFile();
for (clang::DeclContext *decl_context = root_decl_ctx;
decl_context != nullptr && found_decls.empty();
@@ -9404,10 +9404,10 @@
clang::DeclContext *child_decl_ctx,
ConstString *child_name,
CompilerType *child_type) {
- if (frame_decl_ctx) {
+ SymbolFile *symbol_file = GetSymbolFile();
+ if (frame_decl_ctx && symbol_file) {
std::set<DeclContext *> searched;
std::multimap<DeclContext *, DeclContext *> search_queue;
- SymbolFile *symbol_file = GetSymbolFile();
// Get the lookup scope for the decl we're trying to find.
clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -534,8 +534,12 @@
auto type_def = llvm::dyn_cast<PDBSymbolTypeTypedef>(&type);
assert(type_def);
+ SymbolFile *symbol_file = m_ast.GetSymbolFile();
+ if (!symbol_file)
+ return nullptr;
+
lldb_private::Type *target_type =
- m_ast.GetSymbolFile()->ResolveTypeUID(type_def->getTypeId());
+ symbol_file->ResolveTypeUID(type_def->getTypeId());
if (!target_type)
return nullptr;
@@ -609,8 +613,13 @@
auto arg = arg_enum->getChildAtIndex(arg_idx);
if (!arg)
break;
+
+ SymbolFile *symbol_file = m_ast.GetSymbolFile();
+ if (!symbol_file)
+ return nullptr;
+
lldb_private::Type *arg_type =
- m_ast.GetSymbolFile()->ResolveTypeUID(arg->getSymIndexId());
+ symbol_file->ResolveTypeUID(arg->getSymIndexId());
// If there's some error looking up one of the dependent types of this
// function signature, bail.
if (!arg_type)
@@ -621,8 +630,12 @@
lldbassert(arg_list.size() <= num_args);
auto pdb_return_type = func_sig->getReturnType();
+ SymbolFile *symbol_file = m_ast.GetSymbolFile();
+ if (!symbol_file)
+ return nullptr;
+
lldb_private::Type *return_type =
- m_ast.GetSymbolFile()->ResolveTypeUID(pdb_return_type->getSymIndexId());
+ symbol_file->ResolveTypeUID(pdb_return_type->getSymIndexId());
// If there's some error looking up one of the dependent types of this
// function signature, bail.
if (!return_type)
@@ -654,10 +667,13 @@
if (uint64_t size = array_type->getLength())
bytes = size;
+ SymbolFile *symbol_file = m_ast.GetSymbolFile();
+ if (!symbol_file)
+ return nullptr;
+
// If array rank > 0, PDB gives the element type at N=0. So element type
// will parsed in the order N=0, N=1,..., N=rank sequentially.
- lldb_private::Type *element_type =
- m_ast.GetSymbolFile()->ResolveTypeUID(element_uid);
+ lldb_private::Type *element_type = symbol_file->ResolveTypeUID(element_uid);
if (!element_type)
return nullptr;
@@ -711,7 +727,12 @@
case PDB_SymType::PointerType: {
auto *pointer_type = llvm::dyn_cast<PDBSymbolTypePointer>(&type);
assert(pointer_type);
- Type *pointee_type = m_ast.GetSymbolFile()->ResolveTypeUID(
+
+ SymbolFile *symbol_file = m_ast.GetSymbolFile();
+ if (!symbol_file)
+ return nullptr;
+
+ Type *pointee_type = symbol_file->ResolveTypeUID(
pointer_type->getPointeeType()->getSymIndexId());
if (!pointee_type)
return nullptr;
@@ -719,8 +740,7 @@
if (pointer_type->isPointerToDataMember() ||
pointer_type->isPointerToMemberFunction()) {
auto class_parent_uid = pointer_type->getRawSymbol().getClassParentId();
- auto class_parent_type =
- m_ast.GetSymbolFile()->ResolveTypeUID(class_parent_uid);
+ auto class_parent_type = symbol_file->ResolveTypeUID(class_parent_uid);
assert(class_parent_type);
CompilerType pointer_ast_type;
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits