[Lldb-commits] [lldb] b237179 - [lldb] Make that we can call HostInfo::Initialize and HostInfo::Terminate multiple times
Author: Raphael Isemann Date: 2019-12-20T12:52:06+01:00 New Revision: b2371791fc74b2ecad7f608ff8592ec512d098e6 URL: https://github.com/llvm/llvm-project/commit/b2371791fc74b2ecad7f608ff8592ec512d098e6 DIFF: https://github.com/llvm/llvm-project/commit/b2371791fc74b2ecad7f608ff8592ec512d098e6.diff LOG: [lldb] Make that we can call HostInfo::Initialize and HostInfo::Terminate multiple times Summary: HostInfo's state isn't actually fully rested after calling ::Terminate. Currently we only reset the values of all the `HostInfoBaseFields` but not all the variables with static storage that keep track of whether the fields need to be initialised. This breaks random unit tests as running them twice (or running multiple test instances in one run) will cause that the second time we ask HostInfo for any information we get the default value back for any field. This patch moves all the once_flag's into the `HostInfoBaseFields` so that they also get reseted by ::Terminate and removes all the `success` bools. We should also rewrite half this code but I would prefer if my tests aren't broken over the holidays so let's just put some duct tape on it for now. Reviewers: labath Reviewed By: labath Subscribers: abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71748 Added: Modified: lldb/source/Host/common/HostInfoBase.cpp Removed: diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index 3765f36fc79a..c69f705fa60a 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -47,18 +47,28 @@ struct HostInfoBaseFields { } } + llvm::once_flag m_host_triple_once; std::string m_host_triple; + llvm::once_flag m_host_arch_once; ArchSpec m_host_arch_32; ArchSpec m_host_arch_64; + llvm::once_flag m_lldb_so_dir_once; FileSpec m_lldb_so_dir; + llvm::once_flag m_lldb_support_exe_dir_once; FileSpec m_lldb_support_exe_dir; + llvm::once_flag m_lldb_headers_dir_once; FileSpec m_lldb_headers_dir; + llvm::once_flag m_lldb_clang_resource_dir_once; FileSpec m_lldb_clang_resource_dir; + llvm::once_flag m_lldb_system_plugin_dir_once; FileSpec m_lldb_system_plugin_dir; + llvm::once_flag m_lldb_user_plugin_dir_once; FileSpec m_lldb_user_plugin_dir; + llvm::once_flag m_lldb_process_tmp_dir_once; FileSpec m_lldb_process_tmp_dir; + llvm::once_flag m_lldb_global_tmp_dir_once; FileSpec m_lldb_global_tmp_dir; }; @@ -73,8 +83,7 @@ void HostInfoBase::Terminate() { } llvm::StringRef HostInfoBase::GetTargetTriple() { - static llvm::once_flag g_once_flag; - llvm::call_once(g_once_flag, []() { + llvm::call_once(g_fields->m_host_triple_once, []() { g_fields->m_host_triple = HostInfo::GetArchitecture().GetTriple().getTriple(); }); @@ -82,8 +91,7 @@ llvm::StringRef HostInfoBase::GetTargetTriple() { } const ArchSpec ::GetArchitecture(ArchitectureKind arch_kind) { - static llvm::once_flag g_once_flag; - llvm::call_once(g_once_flag, []() { + llvm::call_once(g_fields->m_host_arch_once, []() { HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32, g_fields->m_host_arch_64); }); @@ -108,87 +116,76 @@ llvm::Optional HostInfoBase::ParseArchitectureKi } FileSpec HostInfoBase::GetShlibDir() { - static llvm::once_flag g_once_flag; - static bool success = false; - llvm::call_once(g_once_flag, []() { -success = HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir); + llvm::call_once(g_fields->m_lldb_so_dir_once, []() { +if (!HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir)) + g_fields->m_lldb_so_dir = FileSpec(); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); LLDB_LOG(log, "shlib dir -> `{0}`", g_fields->m_lldb_so_dir); }); - return success ? g_fields->m_lldb_so_dir : FileSpec(); + return g_fields->m_lldb_so_dir; } FileSpec HostInfoBase::GetSupportExeDir() { - static llvm::once_flag g_once_flag; - static bool success = false; - llvm::call_once(g_once_flag, []() { -success = -HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir); + llvm::call_once(g_fields->m_lldb_support_exe_dir_once, []() { +if (!HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir)) + g_fields->m_lldb_support_exe_dir = FileSpec(); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); LLDB_LOG(log, "support exe dir -> `{0}`", g_fields->m_lldb_support_exe_dir); }); - return success ? g_fields->m_lldb_support_exe_dir : FileSpec(); + return g_fields->m_lldb_support_exe_dir; } FileSpec HostInfoBase::GetHeaderDir() { - static llvm::once_flag g_once_flag; - static bool success = false; - llvm::call_once(g_once_flag, []() {
[Lldb-commits] [lldb] 29bd219 - [lldb] Added test for objc_direct calls with categories
Author: Raphael Isemann Date: 2019-12-20T11:07:30+01:00 New Revision: 29bd2194979c50097edb39a4beb714bff8c153a1 URL: https://github.com/llvm/llvm-project/commit/29bd2194979c50097edb39a4beb714bff8c153a1 DIFF: https://github.com/llvm/llvm-project/commit/29bd2194979c50097edb39a4beb714bff8c153a1.diff LOG: [lldb] Added test for objc_direct calls with categories As pointed out in D71694 this wasn't tested before in LLDB. Added: Modified: lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m Removed: diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m index 1a199acdda45..6799f22500c9 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m @@ -24,6 +24,7 @@ -(int) entryPoint //%self.expect("expr [self directCallNSStringArg: str]", substrs=['@"some string"']) //%self.expect("expr [self directCallIdArg: (id)str]", substrs=['@"some string appendix"']) //%self.expect("expr [self directCallConflictingName]", substrs=["correct function"]) +//%self.expect("expr [self directCallWithCategory]", substrs=["called function with category"]) } // Declare several objc_direct functions we can test. @@ -61,6 +62,17 @@ -(const char *) directCallConflictingName __attribute__((objc_direct)) } @end + +@interface Foo (Cat) +@end + +@implementation Foo (Cat) +-(const char *) directCallWithCategory __attribute__((objc_direct)) +{ + return "called function with category"; +} +@end + int main() { Foo *foo = [[Foo alloc] init]; @@ -75,5 +87,6 @@ int main() //%self.expect("expr [foo directCallNSStringArg: str]", substrs=['@"some string"']) //%self.expect("expr [foo directCallIdArg: (id)str]", substrs=['@"some string appendix"']) //%self.expect("expr [foo directCallConflictingName]", substrs=["correct function"]) + //%self.expect("expr [foo directCallWithCategory]", substrs=["called function with category"]) return 0; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 200cce3 - [lldb][NFC] Change if statements in ClangASTImporter to follow LLVM code style
Author: Raphael Isemann Date: 2019-12-19T10:55:54+01:00 New Revision: 200cce345dcf114a1b1012bc9c68adef6c99a595 URL: https://github.com/llvm/llvm-project/commit/200cce345dcf114a1b1012bc9c68adef6c99a595 DIFF: https://github.com/llvm/llvm-project/commit/200cce345dcf114a1b1012bc9c68adef6c99a595.diff LOG: [lldb][NFC] Change if statements in ClangASTImporter to follow LLVM code style Added: Modified: lldb/include/lldb/Symbol/ClangASTImporter.h lldb/source/Symbol/ClangASTImporter.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index e0448249eba8..9c0a95beb1e8 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -287,9 +287,8 @@ class ClangASTImporter { ASTContextMetadataSP(new ASTContextMetadata(dst_ctx)); m_metadata_map[dst_ctx] = context_md; return context_md; -} else { - return context_md_iter->second; } +return context_md_iter->second; } ASTContextMetadataSP MaybeGetContextMetadata(clang::ASTContext *dst_ctx) { @@ -297,8 +296,7 @@ class ClangASTImporter { if (context_md_iter != m_metadata_map.end()) return context_md_iter->second; -else - return ASTContextMetadataSP(); +return ASTContextMetadataSP(); } ImporterDelegateSP GetDelegate(clang::ASTContext *dst_ctx, @@ -313,9 +311,8 @@ class ClangASTImporter { ImporterDelegateSP(new ASTImporterDelegate(*this, dst_ctx, src_ctx)); delegates[src_ctx] = delegate; return delegate; -} else { - return delegate_iter->second; } +return delegate_iter->second; } public: diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp index de5448d4317d..d856443b268a 100644 --- a/lldb/source/Symbol/ClangASTImporter.cpp +++ b/lldb/source/Symbol/ClangASTImporter.cpp @@ -674,9 +674,8 @@ bool ClangASTImporter::CompleteAndFetchChildren(clang::QualType type) { } } -if (RecordDecl *record_decl = dyn_cast(origin_tag_decl)) { +if (RecordDecl *record_decl = dyn_cast(origin_tag_decl)) record_decl->setHasLoadedFieldsFromExternalStorage(true); -} return true; } @@ -706,9 +705,8 @@ bool ClangASTImporter::CompleteAndFetchChildren(clang::QualType type) { } return true; -} else { - return false; } +return false; } return true; @@ -730,15 +728,12 @@ bool ClangASTImporter::RequireCompleteType(clang::QualType type) { if (ObjCInterfaceDecl *objc_interface_decl = objc_object_type->getInterface()) return CompleteObjCInterfaceDecl(objc_interface_decl); -else - return false; +return false; } - if (const ArrayType *array_type = type->getAsArrayTypeUnsafe()) { + if (const ArrayType *array_type = type->getAsArrayTypeUnsafe()) return RequireCompleteType(array_type->getElementType()); - } - if (const AtomicType *atomic_type = type->getAs()) { + if (const AtomicType *atomic_type = type->getAs()) return RequireCompleteType(atomic_type->getPointeeType()); - } return true; } @@ -748,8 +743,7 @@ ClangASTMetadata *ClangASTImporter::GetDeclMetadata(const clang::Decl *decl) { if (decl_origin.Valid()) return ClangASTContext::GetMetadata(decl_origin.ctx, decl_origin.decl); - else -return ClangASTContext::GetMetadata(>getASTContext(), decl); + return ClangASTContext::GetMetadata(>getASTContext(), decl); } ClangASTImporter::DeclOrigin @@ -762,8 +756,7 @@ ClangASTImporter::GetDeclOrigin(const clang::Decl *decl) { if (iter != origins.end()) return iter->second; - else -return DeclOrigin(); + return DeclOrigin(); } void ClangASTImporter::SetDeclOrigin(const clang::Decl *decl, @@ -777,9 +770,9 @@ void ClangASTImporter::SetDeclOrigin(const clang::Decl *decl, if (iter != origins.end()) { iter->second.decl = original_decl; iter->second.ctx = _decl->getASTContext(); - } else { -origins[decl] = DeclOrigin(_decl->getASTContext(), original_decl); +return; } + origins[decl] = DeclOrigin(_decl->getASTContext(), original_decl); } void ClangASTImporter::RegisterNamespaceMap(const clang::NamespaceDecl *decl, @@ -799,8 +792,7 @@ ClangASTImporter::GetNamespaceMap(const clang::NamespaceDecl *decl) { if (iter != namespace_maps.end()) return iter->second; - else -return NamespaceMapSP(); + return NamespaceMapSP(); } void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d8a3194 - [lldb][NFC] Add unit test for persistent variable lookup with ClangExpressionDeclMap
Author: Raphael Isemann Date: 2019-12-18T13:50:05+01:00 New Revision: d8a3194987301672fbd50f4e5703952381f0157c URL: https://github.com/llvm/llvm-project/commit/d8a3194987301672fbd50f4e5703952381f0157c DIFF: https://github.com/llvm/llvm-project/commit/d8a3194987301672fbd50f4e5703952381f0157c.diff LOG: [lldb][NFC] Add unit test for persistent variable lookup with ClangExpressionDeclMap This adds a unit test for looking up persistent declarations in the scratch AST context. Also adds the `GetPersistentDecl` hook to the ClangExpressionDeclMap that this unit test can emulate looking up persistent variables without having a lldb_private::Target. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 33867fb4d45a..232027668923 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -734,29 +734,33 @@ void ClangExpressionDeclMap::MaybeRegisterFunctionBody( } } -void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext , - const ConstString name, - unsigned int current_id) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); +clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) { if (!m_parser_vars) -return; +return nullptr; Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr(); if (!target) -return; +return nullptr; ClangASTContext *scratch_clang_ast_context = ClangASTContext::GetScratch(*target); if (!scratch_clang_ast_context) -return; +return nullptr; ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext(); if (!scratch_ast_context) -return; +return nullptr; + + return m_parser_vars->m_persistent_vars->GetPersistentDecl(name); +} + +void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext , + const ConstString name, + unsigned int current_id) { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - NamedDecl *persistent_decl = - m_parser_vars->m_persistent_vars->GetPersistentDecl(name); + NamedDecl *persistent_decl = GetPersistentDecl(name); if (!persistent_decl) return; @@ -1409,6 +1413,10 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( if (name.GetStringRef().startswith("$__lldb")) return; +// No ParserVars means we can't do register or variable lookup. +if (!m_parser_vars) + return; + ExpressionVariableSP pvar_sp( m_parser_vars->m_persistent_vars->GetVariable(name)); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h index 223fd3201097..41e41c1f1fef 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -283,6 +283,14 @@ class ClangExpressionDeclMap : public ClangASTSource { CompilerDeclContext _decl, unsigned int current_id); +protected: + /// Retrieves the declaration with the given name from the storage of + /// persistent declarations. + /// + /// \return + /// A persistent decl with the given name or a nullptr. + virtual clang::NamedDecl *GetPersistentDecl(ConstString name); + private: ExpressionVariableList m_found_entities; ///< All entities that were looked up for the parser. diff --git a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp index 2d93a6120dbd..6fac168462b3 100644 --- a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp +++ b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp @@ -11,12 +11,51 @@ #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangUtil.h" #include "lldb/lldb-defines.h" #include "gtest/gtest.h" using namespace lldb_private; using namespace lldb; +static std::unique_ptr createAST() { + return std::make_unique(HostInfo::GetTargetTriple()); +} + +namespace { +struct FakeClangExpressionDeclMap : public ClangExpressionDeclMap { + FakeClangExpressionDeclMap(const ClangASTImporterSP ) + :
[Lldb-commits] [lldb] 268f37d - [lldb][NFC] Use StringRef in CreateRecordType and CreateObjCClass
Author: Raphael Isemann Date: 2019-12-17T16:10:34+01:00 New Revision: 268f37df6e45c4b0603bd4d964483a0d84da44c1 URL: https://github.com/llvm/llvm-project/commit/268f37df6e45c4b0603bd4d964483a0d84da44c1 DIFF: https://github.com/llvm/llvm-project/commit/268f37df6e45c4b0603bd4d964483a0d84da44c1.diff LOG: [lldb][NFC] Use StringRef in CreateRecordType and CreateObjCClass Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Symbol/ClangASTContext.cpp lldb/unittests/Symbol/TestClangASTImporter.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 9c37b94219f0..6cebd6f3b62a 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -263,8 +263,9 @@ class ClangASTContext : public TypeSystem { bool omit_empty_base_classes); CompilerType CreateRecordType(clang::DeclContext *decl_ctx, -lldb::AccessType access_type, const char *name, -int kind, lldb::LanguageType language, +lldb::AccessType access_type, +llvm::StringRef name, int kind, +lldb::LanguageType language, ClangASTMetadata *metadata = nullptr, bool exports_symbols = false); @@ -322,8 +323,9 @@ class ClangASTContext : public TypeSystem { static bool RecordHasFields(const clang::RecordDecl *record_decl); - CompilerType CreateObjCClass(const char *name, clang::DeclContext *decl_ctx, - bool isForwardDecl, bool isInternal, + CompilerType CreateObjCClass(llvm::StringRef name, + clang::DeclContext *decl_ctx, bool isForwardDecl, + bool isInternal, ClangASTMetadata *metadata = nullptr); bool SetTagTypeKind(clang::QualType type, int kind) const; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index 6402e80d6f98..76375e22ad6a 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -128,7 +128,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate( if (!lldb_ctx) return clang::QualType(); CompilerType union_type(lldb_ctx->CreateRecordType( - nullptr, lldb::eAccessPublic, name.c_str(), kind, lldb::eLanguageTypeC)); + nullptr, lldb::eAccessPublic, name, kind, lldb::eLanguageTypeC)); if (union_type) { ClangASTContext::StartTagDeclarationDefinition(union_type); diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index 1f7366f5e184..b58550beb04a 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -778,9 +778,8 @@ clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id, metadata.SetUserID(toOpaqueUid(id)); metadata.SetIsDynamicCXXType(false); - CompilerType ct = - m_clang.CreateRecordType(context, access, uname.c_str(), ttk, - lldb::eLanguageTypeC_plus_plus, ); + CompilerType ct = m_clang.CreateRecordType( + context, access, uname, ttk, lldb::eLanguageTypeC_plus_plus, ); lldbassert(ct.IsValid()); diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index 7bf94c64aa4f..740b39016862 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -417,9 +417,9 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol ) { metadata.SetUserID(type.getSymIndexId()); metadata.SetIsDynamicCXXType(false); - clang_type = m_ast.CreateRecordType( - decl_context, access, name.c_str(), tag_type_kind, - lldb::eLanguageTypeC_plus_plus, ); + clang_type = + m_ast.CreateRecordType(decl_context, access, name, tag_type_kind, + lldb::eLanguageTypeC_plus_plus, ); assert(clang_type.IsValid()); auto record_decl = diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index
[Lldb-commits] [lldb] b852b3c - [lldb][NFC] Rename ClangASTImporter::InsertRecordDecl to SetRecordLayout and document it
Author: Raphael Isemann Date: 2019-12-17T15:56:07+01:00 New Revision: b852b3c982d2e8ad3f13c626b3e3655e5b3c399e URL: https://github.com/llvm/llvm-project/commit/b852b3c982d2e8ad3f13c626b3e3655e5b3c399e DIFF: https://github.com/llvm/llvm-project/commit/b852b3c982d2e8ad3f13c626b3e3655e5b3c399e.diff LOG: [lldb][NFC] Rename ClangASTImporter::InsertRecordDecl to SetRecordLayout and document it This function is just setting the layout for the given RecordDecl so the current name is not very descriptive. Also add some documentation for it. Added: Modified: lldb/include/lldb/Symbol/ClangASTImporter.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Symbol/ClangASTImporter.cpp lldb/unittests/Symbol/TestClangASTImporter.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index 58e068658ad8..e0448249eba8 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -58,7 +58,14 @@ class ClangASTImporter { clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx, clang::Decl *decl); - void InsertRecordDecl(clang::RecordDecl *decl, const LayoutInfo ); + /// Sets the layout for the given RecordDecl. The layout will later be + /// used by Clang's during code generation. Not calling this function for + /// a RecordDecl will cause that Clang's codegen tries to layout the + /// record by itself. + /// + /// \param decl The RecordDecl to set the layout for. + /// \param layout The layout for the record. + void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo ); bool LayoutRecordType( const clang::RecordDecl *record_decl, uint64_t _size, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index d7b216c99feb..136027ee4d55 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1720,7 +1720,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext , ClangASTContext::GetAsRecordDecl(clang_type); if (record_decl) { - GetClangASTImporter().InsertRecordDecl( + GetClangASTImporter().SetRecordLayout( record_decl, ClangASTImporter::LayoutInfo()); } } @@ -2134,7 +2134,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE , clang::CXXRecordDecl *record_decl = m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); if (record_decl) - GetClangASTImporter().InsertRecordDecl(record_decl, layout_info); + GetClangASTImporter().SetRecordLayout(record_decl, layout_info); } return (bool)clang_type; diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp index 3c494dc83986..7221144407c1 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp @@ -231,6 +231,6 @@ void UdtRecordCompleter::complete() { ClangASTContext::CompleteTagDeclarationDefinition(m_derived_ct); if (auto *record_decl = llvm::dyn_cast(_tag_decl)) { -m_ast_builder.importer().InsertRecordDecl(record_decl, m_layout); +m_ast_builder.importer().SetRecordLayout(record_decl, m_layout); } } diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index 245d99c8c05b..7bf94c64aa4f 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -1207,7 +1207,7 @@ bool PDBASTParser::CompleteTypeFromUDT( if (!record_decl) return static_cast(compiler_type); - GetClangASTImporter().InsertRecordDecl(record_decl, layout_info); + GetClangASTImporter().SetRecordLayout(record_decl, layout_info); return static_cast(compiler_type); } diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp index 3c11c3250af9..de5448d4317d 100644 --- a/lldb/source/Symbol/ClangASTImporter.cpp +++ b/lldb/source/Symbol/ClangASTImporter.cpp @@ -547,7 +547,7 @@ bool ClangASTImporter::LayoutRecordType( return success; } -void ClangASTImporter::InsertRecordDecl(clang::RecordDecl *decl, +void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo ) { m_record_decl_to_layout_map.insert(std::make_pair(decl, layout)); } diff --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp
[Lldb-commits] [lldb] 4aee81c - [lldb][NFC] Allow creating ClangExpressionDeclMap and ClangASTSource without a Target and add basic unit test
Author: Raphael Isemann Date: 2019-12-17T14:04:12+01:00 New Revision: 4aee81c4f73359230e358108bc428e3b0cc59566 URL: https://github.com/llvm/llvm-project/commit/4aee81c4f73359230e358108bc428e3b0cc59566 DIFF: https://github.com/llvm/llvm-project/commit/4aee81c4f73359230e358108bc428e3b0cc59566.diff LOG: [lldb][NFC] Allow creating ClangExpressionDeclMap and ClangASTSource without a Target and add basic unit test The ClangExpressionDeclMap should be testable from a unit test. This is currently impossible as they have both dependencies on Target/ExecutionContext from their constructor. This patch allows constructing these classes without an active Target and adds the missing tests for running without a target that we can do at least a basic lookup test without crashing. Added: lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp lldb/source/Symbol/ClangASTContext.cpp lldb/unittests/Expression/CMakeLists.txt Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 94a23c8069a1..f37fe21b5545 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -49,10 +49,11 @@ class ScopedLexicalDeclEraser { }; } -ClangASTSource::ClangASTSource(const lldb::TargetSP ) +ClangASTSource::ClangASTSource(const lldb::TargetSP , + const lldb::ClangASTImporterSP ) : m_import_in_progress(false), m_lookups_enabled(false), m_target(target), m_ast_context(nullptr), m_active_lexical_decls(), m_active_lookups() { - m_ast_importer_sp = m_target->GetClangASTImporter(); + m_ast_importer_sp = importer; } void ClangASTSource::InstallASTContext(ClangASTContext _ast_context, @@ -65,9 +66,13 @@ void ClangASTSource::InstallASTContext(ClangASTContext _ast_context, } ClangASTSource::~ClangASTSource() { - if (m_ast_importer_sp) -m_ast_importer_sp->ForgetDestination(m_ast_context); + if (!m_ast_importer_sp) +return; + + m_ast_importer_sp->ForgetDestination(m_ast_context); + if (!m_target) +return; // We are in the process of destruction, don't create clang ast context on // demand by passing false to // Target::GetScratchClangASTContext(create_on_demand). @@ -683,6 +688,9 @@ void ClangASTSource::FindExternalVisibleDecls( if (IgnoreName(name, true)) return; + if (!m_target) +return; + if (module_sp && namespace_decl) { CompilerDeclContext found_namespace_decl; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h index 0ae65e526e7e..e0442aeca326 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -38,7 +38,11 @@ class ClangASTSource : public ClangExternalASTSourceCommon, /// /// \param[in] target /// A reference to the target containing debug information to use. - ClangASTSource(const lldb::TargetSP ); + /// + /// \param[in] importer + /// The ClangASTImporter to use. + ClangASTSource(const lldb::TargetSP , + const lldb::ClangASTImporterSP ); /// Destructor ~ClangASTSource() override; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 3a6b7018e48f..33867fb4d45a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -65,9 +65,10 @@ const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars"; ClangExpressionDeclMap::ClangExpressionDeclMap( bool keep_result_in_memory, Materializer::PersistentVariableDelegate *result_delegate, -ExecutionContext _ctx, ValueObject *ctx_obj) -: ClangASTSource(exe_ctx.GetTargetSP()), m_found_entities(), - m_struct_members(), m_keep_result_in_memory(keep_result_in_memory), +const lldb::TargetSP , const lldb::ClangASTImporterSP , +ValueObject *ctx_obj) +: ClangASTSource(target, importer), m_found_entities(), m_struct_members(), + m_keep_result_in_memory(keep_result_in_memory), m_result_delegate(result_delegate), m_ctx_obj(ctx_obj), m_parser_vars(), m_struct_vars() { EnableStructVars(); @@ -737,6 +738,8
[Lldb-commits] [lldb] ff0102b - [lldb] Remove modern-type-lookup
Author: Raphael Isemann Date: 2019-12-17T12:24:31+01:00 New Revision: ff0102b32cfe506dfc16a86e38e70b0940697aa2 URL: https://github.com/llvm/llvm-project/commit/ff0102b32cfe506dfc16a86e38e70b0940697aa2 DIFF: https://github.com/llvm/llvm-project/commit/ff0102b32cfe506dfc16a86e38e70b0940697aa2.diff LOG: [lldb] Remove modern-type-lookup Summary: As discussed on the mailing list [1] we have to make a decision for how to proceed with the modern-type-lookup. This patch removes modern-type-lookup from LLDB. This just removes all the code behind the modern-type-lookup setting but it does *not* remove any code from Clang (i.e., the ExternalASTMerger and the clang-import-test stay around for now). The motivation for this is that I don't think that the current approach of implementing modern-type-lookup will work out. Especially creating a completely new lookup system behind some setting that is never turned on by anyone and then one day make one big switch to the new system seems wrong. It doesn't fit into the way LLVM is developed and has so far made the transition work much more complicated than it has to be. A lot of the benefits that were supposed to come with the modern-type-lookup are related to having a better organization in the way types move across LLDB and having less dependencies on unrelated LLDB code. By just looking at the current code (mostly the ClangASTImporter) I think we can reach the same goals by just incrementally cleaning up, documenting, refactoring and actually testing the existing code we have. [1] http://lists.llvm.org/pipermail/lldb-dev/2019-December/015831.html Reviewers: shafik, martong Subscribers: rnkovacs, christof, arphaman, JDevlieghere, usaxena95, lldb-commits, friss Tags: #lldb Differential Revision: https://reviews.llvm.org/D71562 Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/include/lldb/Target/Target.h lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h lldb/source/Symbol/ClangASTContext.cpp lldb/source/Target/Target.cpp lldb/source/Target/TargetProperties.td Removed: lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/Makefile lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/TestLibCxxModernTypeLookup.py lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/libcxx/main.cpp lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/Makefile lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/TestObjModulesModernTypeLookup.py lldb/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/objc-modules/main.m diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 5d228e7bdad7..9c37b94219f0 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -21,7 +21,6 @@ #include #include "clang/AST/ASTContext.h" -#include "clang/AST/ExternalASTMerger.h" #include "clang/AST/TemplateBase.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/SmallVector.h" @@ -965,10 +964,7 @@ class ClangASTContext : public TypeSystem { clang::DeclarationName GetDeclarationName(const char *name, const CompilerType _clang_type); - - virtual const clang::ExternalASTMerger::OriginMap () { -return m_origins; - } + protected: const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type); @@ -993,7 +989,6 @@ class ClangASTContext : public TypeSystem { CompleteTagDeclCallback m_callback_tag_decl = nullptr; CompleteObjCInterfaceDeclCallback m_callback_objc_decl = nullptr; void *m_callback_baton = nullptr; - clang::ExternalASTMerger::OriginMap m_origins; uint32_t
[Lldb-commits] [lldb] d9ca412 - [lldb][NFC] Remove all unnecessary includes for ClangASTSourceCommon.h
Author: Raphael Isemann Date: 2019-12-17T11:21:11+01:00 New Revision: d9ca412a8a75ab64af33a9e95d1319c4dd2004d2 URL: https://github.com/llvm/llvm-project/commit/d9ca412a8a75ab64af33a9e95d1319c4dd2004d2 DIFF: https://github.com/llvm/llvm-project/commit/d9ca412a8a75ab64af33a9e95d1319c4dd2004d2.diff LOG: [lldb][NFC] Remove all unnecessary includes for ClangASTSourceCommon.h These files only need the definition of ClangASTMetadata (which was previously in the ClangASTSourceCommon.h) or don't need the include at all. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index 0496e9e87b9f..6ef56ced21ce 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -38,7 +38,6 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index bd97c68bff79..d7b216c99feb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -22,7 +22,7 @@ #include "lldb/Core/Value.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ClangASTImporter.h" -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" +#include "lldb/Symbol/ClangASTMetadata.h" #include "lldb/Symbol/ClangUtil.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index 986b0b785d87..1f7366f5e184 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -17,7 +17,7 @@ #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" +#include "lldb/Symbol/ClangASTMetadata.h" #include "lldb/Symbol/ClangUtil.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/LLDBAssert.h" diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 22d1b08ea9e7..370c339fb74b 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -20,7 +20,6 @@ #include "lldb/Core/StreamBuffer.h" #include "lldb/Core/StreamFile.h" #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/ClangUtil.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineTable.h" diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index ccb5b6373ee4..245d99c8c05b 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -16,7 +16,7 @@ #include "lldb/Core/Module.h" #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" +#include "lldb/Symbol/ClangASTMetadata.h" #include "lldb/Symbol/ClangUtil.h" #include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/SymbolFile.h" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6e1fe49 - [lldb][NFC] Remove implementation of GetOriginalDecl and just call GetDeclOrigin instead
Author: Raphael Isemann Date: 2019-12-17T10:42:09+01:00 New Revision: 6e1fe4966c402d17a253b38192cfd5e8b919ab8e URL: https://github.com/llvm/llvm-project/commit/6e1fe4966c402d17a253b38192cfd5e8b919ab8e DIFF: https://github.com/llvm/llvm-project/commit/6e1fe4966c402d17a253b38192cfd5e8b919ab8e.diff LOG: [lldb][NFC] Remove implementation of GetOriginalDecl and just call GetDeclOrigin instead Those functions have the same semantics beside some small optimization of not creating a new empty ASTContextMetadataSP value in the metadata map. We never actually hit this optimization according to test coverage so let's just call GetDeclOrigin instead. Added: Modified: lldb/source/Symbol/ClangASTImporter.cpp Removed: diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp index 1cfec2531d8b..3c11c3250af9 100644 --- a/lldb/source/Symbol/ClangASTImporter.cpp +++ b/lldb/source/Symbol/ClangASTImporter.cpp @@ -1139,16 +1139,5 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from, clang::Decl * ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) { - ASTContextMetadataSP to_context_md = - m_master.GetContextMetadata(>getASTContext()); - - if (!to_context_md) -return nullptr; - - OriginMap::iterator iter = to_context_md->m_origins.find(To); - - if (iter == to_context_md->m_origins.end()) -return nullptr; - - return const_cast(iter->second.decl); + return m_master.GetDeclOrigin(To).decl; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d5b54bb - [lldb] Add support for calling objc_direct methods from LLDB's expression evaluator.
Author: Raphael Isemann Date: 2019-12-17T10:28:40+01:00 New Revision: d5b54bbfaf19a8527ebf70fbf23cb8d2937f15ef URL: https://github.com/llvm/llvm-project/commit/d5b54bbfaf19a8527ebf70fbf23cb8d2937f15ef DIFF: https://github.com/llvm/llvm-project/commit/d5b54bbfaf19a8527ebf70fbf23cb8d2937f15ef.diff LOG: [lldb] Add support for calling objc_direct methods from LLDB's expression evaluator. Summary: D69991 introduced `__attribute__((objc_direct))` that allows directly calling methods without message passing. This patch adds support for calling methods with this attribute to LLDB's expression evaluator. The patch can be summarised in that LLDB just adds the same attribute to our module AST when we find a method with `__attribute__((objc_direct))` in our debug information. Reviewers: aprantl, shafik Reviewed By: shafik Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71196 Added: lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/Makefile lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/TestObjCDirectMethods.py lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h lldb/source/Symbol/ClangASTContext.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 9537f33b3386..5d228e7bdad7 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -845,7 +845,7 @@ class ClangASTContext : public TypeSystem { // (lldb::opaque_compiler_type_t type, "-[NString // stringWithCString:]") const CompilerType _compiler_type, lldb::AccessType access, - bool is_artificial, bool is_variadic); + bool is_artificial, bool is_variadic, bool is_objc_direct_call); static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern); diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/Makefile b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/Makefile new file mode 100644 index ..afecbf969483 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/Makefile @@ -0,0 +1,4 @@ +OBJC_SOURCES := main.m +LD_EXTRAS := -lobjc -framework Foundation + +include Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/TestObjCDirectMethods.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/TestObjCDirectMethods.py new file mode 100644 index ..f0152de1ac33 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/TestObjCDirectMethods.py @@ -0,0 +1,5 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest( +__file__, globals(), [decorators.skipUnlessDarwin]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m new file mode 100644 index ..1a199acdda45 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m @@ -0,0 +1,79 @@ +#import + +int side_effect = 0; + +NSString *str = @"some string"; + +const char *directCallConflictingName() { + return "wrong function"; +} + +@interface Foo : NSObject { + int instance_var; +} +-(int) entryPoint; +@end + +@implementation Foo +-(int) entryPoint +{ + // Try calling directly with self. Same as in the main method otherwise. + return 0; //%self.expect("expr [self directCallNoArgs]", substrs=["called directCallNoArgs"]) +//%self.expect("expr [self directCallArgs: ]", substrs=["= 2345"]) +//%self.expect("expr side_effect = 0; [self directCallVoidReturn]; side_effect", substrs=["= 4321"]) +//%self.expect("expr [self directCallNSStringArg: str]", substrs=['@"some string"']) +//%self.expect("expr [self directCallIdArg: (id)str]", substrs=['@"some string appendix"']) +//%self.expect("expr [self directCallConflictingName]", substrs=["correct function"]) +} + +// Declare several objc_direct functions we can test. +-(const char *) directCallNoArgs __attribute__((objc_direct)) +{ + return "called directCallNoArgs"; +} + +-(void) directCallVoidReturn __attribute__((objc_direct)) +{ + side_effect = 4321; +} + +-(int) directCallArgs:(int)i __attribute__((objc_direct)) +{ + // Use the arg in some way to make sure that gets passed correctly. + return i + 1234; +} + +-(NSString *) directCallNSStringArg:(NSString
[Lldb-commits] [lldb] ba6f25d - [lldb][NFC] Make clang-format happy by removing trailing space in ArchSpec.cpp
Author: Raphael Isemann Date: 2019-12-17T09:13:48+01:00 New Revision: ba6f25d7d3671f8ff1d072a43a292950dbbf899e URL: https://github.com/llvm/llvm-project/commit/ba6f25d7d3671f8ff1d072a43a292950dbbf899e DIFF: https://github.com/llvm/llvm-project/commit/ba6f25d7d3671f8ff1d072a43a292950dbbf899e.diff LOG: [lldb][NFC] Make clang-format happy by removing trailing space in ArchSpec.cpp Added: Modified: lldb/source/Utility/ArchSpec.cpp Removed: diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index b638a6138cfe..3dae25ceacd6 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -444,7 +444,7 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = { {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON, LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON {ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE, - 0xu, 0xu }, // ARC + 0xu, 0xu}, // ARC }; static const ArchDefinition g_elf_arch_def = { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3c6554b - [lldb] Fix unused variable warning in ThreadPlanStepRange.cpp
Author: Raphael Isemann Date: 2019-12-17T08:53:06+01:00 New Revision: 3c6554be2e3c1500f825df5f7c186f2e58d6a33a URL: https://github.com/llvm/llvm-project/commit/3c6554be2e3c1500f825df5f7c186f2e58d6a33a DIFF: https://github.com/llvm/llvm-project/commit/3c6554be2e3c1500f825df5f7c186f2e58d6a33a.diff LOG: [lldb] Fix unused variable warning in ThreadPlanStepRange.cpp This was added in 434905b97d961531286d4b49c7ee1969f7cbea0e. Remove it to fix the compiler warnings for this. Added: Modified: lldb/source/Target/ThreadPlanStepRange.cpp Removed: diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp b/lldb/source/Target/ThreadPlanStepRange.cpp index a22337deaed5..1db29652aa8b 100644 --- a/lldb/source/Target/ThreadPlanStepRange.cpp +++ b/lldb/source/Target/ThreadPlanStepRange.cpp @@ -331,7 +331,6 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() { else { Target = GetThread().GetProcess()->GetTarget(); const bool ignore_calls = GetKind() == eKindStepOverRange; -bool found_calls; uint32_t branch_index = instructions->GetIndexOfNextBranchInstruction(pc_index, target, ignore_calls, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 22caa3c - [lldb] Add unit test for ClangASTImporter
Author: Raphael Isemann Date: 2019-12-16T12:43:55+01:00 New Revision: 22caa3cfbcf5762a47acc40c425d9fe0c40da621 URL: https://github.com/llvm/llvm-project/commit/22caa3cfbcf5762a47acc40c425d9fe0c40da621 DIFF: https://github.com/llvm/llvm-project/commit/22caa3cfbcf5762a47acc40c425d9fe0c40da621.diff LOG: [lldb] Add unit test for ClangASTImporter Added: lldb/unittests/Symbol/TestClangASTImporter.cpp Modified: lldb/unittests/Symbol/CMakeLists.txt Removed: diff --git a/lldb/unittests/Symbol/CMakeLists.txt b/lldb/unittests/Symbol/CMakeLists.txt index aa86986f4e0e..02875b8b53c1 100644 --- a/lldb/unittests/Symbol/CMakeLists.txt +++ b/lldb/unittests/Symbol/CMakeLists.txt @@ -2,6 +2,7 @@ add_lldb_unittest(SymbolTests LocateSymbolFileTest.cpp PostfixExpressionTest.cpp TestClangASTContext.cpp + TestClangASTImporter.cpp TestDWARFCallFrameInfo.cpp TestType.cpp TestLineEntry.cpp diff --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp b/lldb/unittests/Symbol/TestClangASTImporter.cpp new file mode 100644 index ..17a0dfb6a348 --- /dev/null +++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp @@ -0,0 +1,220 @@ +//===-- TestClangASTImporter.cpp *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "gtest/gtest.h" + +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangASTImporter.h" +#include "lldb/Symbol/ClangASTMetadata.h" +#include "lldb/Symbol/ClangUtil.h" +#include "lldb/Symbol/Declaration.h" +#include "clang/AST/DeclCXX.h" + +using namespace clang; +using namespace lldb; +using namespace lldb_private; + +class TestClangASTImporter : public testing::Test { +public: + static void SetUpTestCase() { +FileSystem::Initialize(); +HostInfo::Initialize(); + } + + static void TearDownTestCase() { +HostInfo::Terminate(); +FileSystem::Terminate(); + } + +protected: + std::unique_ptr createAST() { +return std::make_unique(HostInfo::GetTargetTriple()); + } + + CompilerType createRecord(ClangASTContext , const char *name) { +return ast.CreateRecordType(ast.getASTContext()->getTranslationUnitDecl(), +lldb::AccessType::eAccessPublic, name, 0, +lldb::LanguageType::eLanguageTypeC); + } +}; + +TEST_F(TestClangASTImporter, CanImportInvalidType) { + ClangASTImporter importer; + EXPECT_FALSE(importer.CanImport(CompilerType())); +} + +TEST_F(TestClangASTImporter, ImportInvalidType) { + ClangASTImporter importer; + EXPECT_FALSE(importer.Import(CompilerType())); +} + +TEST_F(TestClangASTImporter, CopyDeclTagDecl) { + // Tests that the ClangASTImporter::CopyDecl can copy TagDecls. + std::unique_ptr source_ast = createAST(); + CompilerType source_type = createRecord(*source_ast, "Source"); + clang::TagDecl *source = ClangUtil::GetAsTagDecl(source_type); + + std::unique_ptr target_ast = createAST(); + + ClangASTImporter importer; + clang::Decl *imported = importer.CopyDecl( + target_ast->getASTContext(), source_ast->getASTContext(), source); + ASSERT_NE(nullptr, imported); + + // Check that we got the correct decl by just comparing their qualified name. + clang::TagDecl *imported_tag_decl = llvm::cast(imported); + EXPECT_EQ(source->getQualifiedNameAsString(), +imported_tag_decl->getQualifiedNameAsString()); + + // Check that origin was set for the imported declaration. + ClangASTImporter::DeclOrigin origin = importer.GetDeclOrigin(imported); + EXPECT_TRUE(origin.Valid()); + EXPECT_EQ(origin.ctx, source_ast->getASTContext()); + EXPECT_EQ(origin.decl, source); +} + +TEST_F(TestClangASTImporter, CopyTypeTagDecl) { + // Tests that the ClangASTImporter::CopyType can copy TagDecls types. + std::unique_ptr source_ast = createAST(); + CompilerType source_type = createRecord(*source_ast, "Source"); + clang::TagDecl *source = ClangUtil::GetAsTagDecl(source_type); + + std::unique_ptr target_ast = createAST(); + + ClangASTImporter importer; + CompilerType imported = importer.CopyType(*target_ast, source_type); + ASSERT_TRUE(imported.IsValid()); + + // Check that we got the correct decl by just comparing their qualified name. + clang::TagDecl *imported_tag_decl = ClangUtil::GetAsTagDecl(imported); + EXPECT_EQ(source->getQualifiedNameAsString(), +imported_tag_decl->getQualifiedNameAsString()); + + // Check that origin was set for the imported declaration. + ClangASTImporter::DeclOrigin origin = + importer.GetDeclOrigin(imported_tag_decl); + EXPECT_TRUE(origin.Valid()); +
[Lldb-commits] [lldb] 75e8a91 - [lldb][NFC] Remove all overloads of Copy/DeportType in ClangASTImporter
Author: Raphael Isemann Date: 2019-12-16T12:09:05+01:00 New Revision: 75e8a91cf84fce2432f70949ab9e353ff2322a5f URL: https://github.com/llvm/llvm-project/commit/75e8a91cf84fce2432f70949ab9e353ff2322a5f DIFF: https://github.com/llvm/llvm-project/commit/75e8a91cf84fce2432f70949ab9e353ff2322a5f.diff LOG: [lldb][NFC] Remove all overloads of Copy/DeportType in ClangASTImporter The overloads that don't take a CompilerType serve no purpose as we always have a CompilerType in the scope where we call them. Instead just call the overload that takes a CompilerType and delete the now unused other overloaded methods. Added: Modified: lldb/include/lldb/Symbol/ClangASTImporter.h lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Symbol/ClangASTImporter.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index cd01bed624cc..58e068658ad8 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -48,21 +48,12 @@ class ClangASTImporter { : m_file_manager(clang::FileSystemOptions(), FileSystem::Instance().GetVirtualFileSystem()) {} - clang::QualType CopyType(clang::ASTContext *dst_ctx, - clang::ASTContext *src_ctx, clang::QualType type); - - lldb::opaque_compiler_type_t CopyType(clang::ASTContext *dst_ctx, -clang::ASTContext *src_ctx, -lldb::opaque_compiler_type_t type); - CompilerType CopyType(ClangASTContext , const CompilerType _type); clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx, clang::Decl *decl); - lldb::opaque_compiler_type_t DeportType(clang::ASTContext *dst_ctx, - clang::ASTContext *src_ctx, - lldb::opaque_compiler_type_t type); + CompilerType DeportType(ClangASTContext , const CompilerType _type); clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx, clang::Decl *decl); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 7a23606f57bc..58db9d4e7424 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -2022,9 +2022,8 @@ CompilerType ClangASTSource::GuardedCopyType(const CompilerType _type) { QualType copied_qual_type; if (m_ast_importer_sp) { -copied_qual_type = -m_ast_importer_sp->CopyType(m_ast_context, src_ast->getASTContext(), -ClangUtil::GetQualType(src_type)); +copied_qual_type = ClangUtil::GetQualType( +m_ast_importer_sp->CopyType(*m_clang_ast_context, src_type)); } else if (m_merger_up) { copied_qual_type = CopyTypeWithMerger(*src_ast->getASTContext(), *m_merger_up, diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index b16c1815caa1..192e43a46061 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -206,10 +206,7 @@ TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext , assert(source.getASTContext() == m_ast_context); if (m_ast_importer_sp) { -return TypeFromUser(m_ast_importer_sp->DeportType( -target.getASTContext(), source.getASTContext(), -parser_type.GetOpaqueQualType()), -); +return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type)); } else if (m_merger_up) { clang::FileID source_file = source.getASTContext()->getSourceManager().getFileID( diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp index a6125ce24f86..1cfec2531d8b 100644 --- a/lldb/source/Symbol/ClangASTImporter.cpp +++ b/lldb/source/Symbol/ClangASTImporter.cpp @@ -25,52 +25,42 @@ using namespace lldb_private; using namespace clang; -clang::QualType ClangASTImporter::CopyType(clang::ASTContext *dst_ast, - clang::ASTContext *src_ast, - clang::QualType type) { - ImporterDelegateSP delegate_sp(GetDelegate(dst_ast, src_ast)); +CompilerType ClangASTImporter::CopyType(ClangASTContext _ast, +const CompilerType _type) { + clang::ASTContext *dst_clang_ast = dst_ast.getASTContext(); + if
[Lldb-commits] [lldb] f49d15b - [lldb][NFC] Move definition of ClangASTMetadata out of ClangExternalASTSourceCommon.h
Author: Raphael Isemann Date: 2019-12-16T10:52:31+01:00 New Revision: f49d15b3f8ccd7737a62d40adfe5ff1e710788d4 URL: https://github.com/llvm/llvm-project/commit/f49d15b3f8ccd7737a62d40adfe5ff1e710788d4 DIFF: https://github.com/llvm/llvm-project/commit/f49d15b3f8ccd7737a62d40adfe5ff1e710788d4.diff LOG: [lldb][NFC] Move definition of ClangASTMetadata out of ClangExternalASTSourceCommon.h Changing metadata of a ClangASTContext currently requires to include the unrelated ClangExternalASTSourceCommon.h header because it actually defines the ClangASTMetadata class. This also removes the dependency from ClangASTImporter to ClangExternalASTSourceCommon. Added: lldb/include/lldb/Symbol/ClangASTMetadata.h lldb/source/Symbol/ClangASTMetadata.cpp Modified: lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h lldb/source/Symbol/CMakeLists.txt lldb/source/Symbol/ClangASTImporter.cpp lldb/source/Symbol/ClangExternalASTSourceCommon.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTMetadata.h b/lldb/include/lldb/Symbol/ClangASTMetadata.h new file mode 100644 index ..fdf4388f0847 --- /dev/null +++ b/lldb/include/lldb/Symbol/ClangASTMetadata.h @@ -0,0 +1,100 @@ +//===-- ClangASTMetadata.h --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef liblldb_ClangASTMetadata_h +#define liblldb_ClangASTMetadata_h + +#include "lldb/Core/dwarf.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" + +namespace lldb_private { + +class ClangASTMetadata { +public: + ClangASTMetadata() + : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false), +m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true) {} + + bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; } + + void SetIsDynamicCXXType(bool b) { m_is_dynamic_cxx = b; } + + void SetUserID(lldb::user_id_t user_id) { +m_user_id = user_id; +m_union_is_user_id = true; +m_union_is_isa_ptr = false; + } + + lldb::user_id_t GetUserID() const { +if (m_union_is_user_id) + return m_user_id; +else + return LLDB_INVALID_UID; + } + + void SetISAPtr(uint64_t isa_ptr) { +m_isa_ptr = isa_ptr; +m_union_is_user_id = false; +m_union_is_isa_ptr = true; + } + + uint64_t GetISAPtr() const { +if (m_union_is_isa_ptr) + return m_isa_ptr; +else + return 0; + } + + void SetObjectPtrName(const char *name) { +m_has_object_ptr = true; +if (strcmp(name, "self") == 0) + m_is_self = true; +else if (strcmp(name, "this") == 0) + m_is_self = false; +else + m_has_object_ptr = false; + } + + lldb::LanguageType GetObjectPtrLanguage() const { +if (m_has_object_ptr) { + if (m_is_self) +return lldb::eLanguageTypeObjC; + else +return lldb::eLanguageTypeC_plus_plus; +} +return lldb::eLanguageTypeUnknown; + } + + const char *GetObjectPtrName() const { +if (m_has_object_ptr) { + if (m_is_self) +return "self"; + else +return "this"; +} else + return nullptr; + } + + bool HasObjectPtr() const { return m_has_object_ptr; } + + void Dump(Stream *s); + +private: + union { +lldb::user_id_t m_user_id; +uint64_t m_isa_ptr; + }; + + bool m_union_is_user_id : 1, m_union_is_isa_ptr : 1, m_has_object_ptr : 1, + m_is_self : 1, m_is_dynamic_cxx : 1; +}; + +} // namespace lldb_private + +#endif // liblldb_ClangASTMetadata_h diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h index 5da486540bb9..dada61d7d026 100644 --- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h @@ -36,91 +36,12 @@ #include "clang/AST/ExternalASTSource.h" #include "lldb/Core/dwarf.h" +#include "lldb/Symbol/ClangASTMetadata.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" namespace lldb_private { -class ClangASTMetadata { -public: - ClangASTMetadata() - : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false), -m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true) {} - - bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; } - - void SetIsDynamicCXXType(bool b) { m_is_dynamic_cxx = b; } - - void SetUserID(lldb::user_id_t user_id) { -m_user_id = user_id; -m_union_is_user_id = true; -m_union_is_isa_ptr = false; - } - - lldb::user_id_t GetUserID() const { -if (m_union_is_user_id) - return m_user_id; -else - return
[Lldb-commits] [lldb] 959ed0e - [lldb][NFC] Fix file header of TestClangASTContext.cpp
Author: Raphael Isemann Date: 2019-12-16T09:34:16+01:00 New Revision: 959ed0e2944c454a3df3aa3bc8ab551c8b587e9b URL: https://github.com/llvm/llvm-project/commit/959ed0e2944c454a3df3aa3bc8ab551c8b587e9b DIFF: https://github.com/llvm/llvm-project/commit/959ed0e2944c454a3df3aa3bc8ab551c8b587e9b.diff LOG: [lldb][NFC] Fix file header of TestClangASTContext.cpp Added: Modified: lldb/unittests/Symbol/TestClangASTContext.cpp Removed: diff --git a/lldb/unittests/Symbol/TestClangASTContext.cpp b/lldb/unittests/Symbol/TestClangASTContext.cpp index 8fb24acc7a6a..b5c7542887e3 100644 --- a/lldb/unittests/Symbol/TestClangASTContext.cpp +++ b/lldb/unittests/Symbol/TestClangASTContext.cpp @@ -1,6 +1,4 @@ -//===-- TestClangASTContext.cpp ---*- C++ -//-*-===// - +//===-- TestClangASTContext.cpp -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 64678ef - [lldb][NFC] Remove ClangASTImporter::ResolveDeclOrigin
Author: Raphael Isemann Date: 2019-12-16T09:16:33+01:00 New Revision: 64678ef9f289e9c1951fee5dbcacde583f3d6576 URL: https://github.com/llvm/llvm-project/commit/64678ef9f289e9c1951fee5dbcacde583f3d6576 DIFF: https://github.com/llvm/llvm-project/commit/64678ef9f289e9c1951fee5dbcacde583f3d6576.diff LOG: [lldb][NFC] Remove ClangASTImporter::ResolveDeclOrigin ResolveDeclOrigin was just an inconvenience method around GetDeclOrigin. Added: Modified: lldb/include/lldb/Symbol/ClangASTImporter.h lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h lldb/source/Symbol/ClangASTImporter.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index 098091f7167f..cd01bed624cc 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -96,19 +96,6 @@ class ClangASTImporter { bool RequireCompleteType(clang::QualType type); - bool ResolveDeclOrigin(const clang::Decl *decl, clang::Decl **original_decl, - clang::ASTContext **original_ctx) { -DeclOrigin origin = GetDeclOrigin(decl); - -if (original_decl) - *original_decl = origin.decl; - -if (original_ctx) - *original_ctx = origin.ctx; - -return origin.Valid(); - } - void SetDeclOrigin(const clang::Decl *decl, clang::Decl *original_decl); ClangASTMetadata *GetDeclMetadata(const clang::Decl *decl); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index d05c074991ee..7a23606f57bc 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -438,13 +438,11 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) { return; } - Decl *original_decl = nullptr; - ASTContext *original_ctx = nullptr; + ClangASTImporter::DeclOrigin original = m_ast_importer_sp->GetDeclOrigin(interface_decl); - if (m_ast_importer_sp->ResolveDeclOrigin(interface_decl, _decl, - _ctx)) { + if (original.Valid()) { if (ObjCInterfaceDecl *original_iface_decl = -dyn_cast(original_decl)) { +dyn_cast(original.decl)) { ObjCInterfaceDecl *complete_iface_decl = GetCompleteObjCInterface(original_iface_decl); @@ -565,40 +563,38 @@ void ClangASTSource::FindExternalLexicalDecls( current_id, static_cast(m_ast_context)); } - Decl *original_decl = nullptr; - ASTContext *original_ctx = nullptr; + ClangASTImporter::DeclOrigin original = m_ast_importer_sp->GetDeclOrigin(context_decl); - if (!m_ast_importer_sp->ResolveDeclOrigin(context_decl, _decl, -_ctx)) + if (!original.Valid()) return; LLDB_LOG( log, " FELD[{0}] Original decl (ASTContext*){1:x} (Decl*){2:x}:\n{3}", - current_id, static_cast(original_ctx), - static_cast(original_decl), ClangUtil::DumpDecl(original_decl)); + current_id, static_cast(original.ctx), + static_cast(original.decl), ClangUtil::DumpDecl(original.decl)); if (ObjCInterfaceDecl *original_iface_decl = - dyn_cast(original_decl)) { + dyn_cast(original.decl)) { ObjCInterfaceDecl *complete_iface_decl = GetCompleteObjCInterface(original_iface_decl); if (complete_iface_decl && (complete_iface_decl != original_iface_decl)) { - original_decl = complete_iface_decl; - original_ctx = _iface_decl->getASTContext(); + original.decl = complete_iface_decl; + original.ctx = _iface_decl->getASTContext(); m_ast_importer_sp->SetDeclOrigin(context_decl, complete_iface_decl); } } - if (TagDecl *original_tag_decl = dyn_cast(original_decl)) { -ExternalASTSource *external_source = original_ctx->getExternalSource(); + if (TagDecl *original_tag_decl = dyn_cast(original.decl)) { +ExternalASTSource *external_source = original.ctx->getExternalSource(); if (external_source) external_source->CompleteType(original_tag_decl); } const DeclContext *original_decl_context = - dyn_cast(original_decl); + dyn_cast(original.decl); if (!original_decl_context) return; @@ -1036,11 +1032,10 @@ template class DeclFromUser : public TaggedASTDecl { template DeclFromUser DeclFromParser::GetOrigin(ClangASTSource ) { - DeclFromUser<> origin_decl; - source.ResolveDeclOrigin(this->decl, _decl.decl, nullptr); - if (origin_decl.IsInvalid()) + ClangASTImporter::DeclOrigin origin = source.GetDeclOrigin(this->decl); + if (!origin.Valid()) return DeclFromUser(); - return DeclFromUser(dyn_cast(origin_decl.decl)); + return
[Lldb-commits] [lldb] 0683250 - [lldb][NFC] Remove unnecessary includes in source/Commands
Author: Raphael Isemann Date: 2019-12-16T08:59:08+01:00 New Revision: 068325012796bf2da527612ea6fdc61531c8beb3 URL: https://github.com/llvm/llvm-project/commit/068325012796bf2da527612ea6fdc61531c8beb3 DIFF: https://github.com/llvm/llvm-project/commit/068325012796bf2da527612ea6fdc61531c8beb3.diff LOG: [lldb][NFC] Remove unnecessary includes in source/Commands Summary: This removes most of unnecessary includes in the `source/Commands` directory. This was generated by IWYU and a script that fixed all the bogus reports from IWYU. Patch is tested on Linux and macOS. Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71489 Added: Modified: lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectApropos.cpp lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/source/Commands/CommandObjectBreakpoint.h lldb/source/Commands/CommandObjectBreakpointCommand.cpp lldb/source/Commands/CommandObjectBreakpointCommand.h lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Commands/CommandObjectCommands.h lldb/source/Commands/CommandObjectDisassemble.cpp lldb/source/Commands/CommandObjectExpression.cpp lldb/source/Commands/CommandObjectExpression.h lldb/source/Commands/CommandObjectFrame.cpp lldb/source/Commands/CommandObjectFrame.h lldb/source/Commands/CommandObjectGUI.cpp lldb/source/Commands/CommandObjectHelp.cpp lldb/source/Commands/CommandObjectLanguage.cpp lldb/source/Commands/CommandObjectLanguage.h lldb/source/Commands/CommandObjectLog.cpp lldb/source/Commands/CommandObjectLog.h lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Commands/CommandObjectMultiword.cpp lldb/source/Commands/CommandObjectPlatform.cpp lldb/source/Commands/CommandObjectPlatform.h lldb/source/Commands/CommandObjectPlugin.cpp lldb/source/Commands/CommandObjectPlugin.h lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Commands/CommandObjectRegister.cpp lldb/source/Commands/CommandObjectReproducer.cpp lldb/source/Commands/CommandObjectReproducer.h lldb/source/Commands/CommandObjectSettings.h lldb/source/Commands/CommandObjectSource.cpp lldb/source/Commands/CommandObjectSource.h lldb/source/Commands/CommandObjectStats.cpp lldb/source/Commands/CommandObjectStats.h lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Commands/CommandObjectTarget.h lldb/source/Commands/CommandObjectThread.cpp lldb/source/Commands/CommandObjectType.cpp lldb/source/Commands/CommandObjectType.h lldb/source/Commands/CommandObjectVersion.cpp lldb/source/Commands/CommandObjectWatchpoint.cpp lldb/source/Commands/CommandObjectWatchpoint.h lldb/source/Commands/CommandObjectWatchpointCommand.cpp lldb/source/Commands/CommandObjectWatchpointCommand.h Removed: diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index b382e26e2b70..d9bee66b442a 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -6,11 +6,6 @@ // //===--===// -#include -#if defined(__APPLE__) || defined(__linux__) -#include -#endif - #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSet.h" @@ -23,13 +18,10 @@ #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Variable.h" -#include "lldb/Target/Target.h" -#include "lldb/Utility/Args.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/TildeExpressionResolver.h" -#include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" diff --git a/lldb/source/Commands/CommandObjectApropos.cpp b/lldb/source/Commands/CommandObjectApropos.cpp index 7ba0b250fbd5..15a20737273d 100644 --- a/lldb/source/Commands/CommandObjectApropos.cpp +++ b/lldb/source/Commands/CommandObjectApropos.cpp @@ -10,7 +10,6 @@ #include "CommandObjectApropos.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/Property.h" #include "lldb/Utility/Args.h" diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 380f753ea339..7c4c50ecf3f9 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -12,7 +12,6 @@ #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Host/OptionParser.h" -#include
[Lldb-commits] [lldb] e2d4761 - [lldb][NFC] Replace ClangASTImporter's use of map/set with SmallPtrSet and DenseMap
Author: Raphael Isemann Date: 2019-12-16T08:29:14+01:00 New Revision: e2d47614a81d0805a869e6141512e0136da9 URL: https://github.com/llvm/llvm-project/commit/e2d47614a81d0805a869e6141512e0136da9 DIFF: https://github.com/llvm/llvm-project/commit/e2d47614a81d0805a869e6141512e0136da9.diff LOG: [lldb][NFC] Replace ClangASTImporter's use of map/set with SmallPtrSet and DenseMap We have several pointer->pointer mappings in the ClangASTImporter implemented using STL data structures. This moves these variables to the appropriate LLVM data structures that are intended for mapping pointers. Added: Modified: lldb/include/lldb/Symbol/ClangASTImporter.h lldb/source/Symbol/ClangASTImporter.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index a67b698ef490..098091f7167f 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -182,7 +182,7 @@ class ClangASTImporter { clang::Decl *decl; }; - typedef std::map OriginMap; + typedef llvm::DenseMap OriginMap; /// Listener interface used by the ASTImporterDelegate to inform other code /// about decls that have been imported the first time. @@ -262,7 +262,7 @@ class ClangASTImporter { /// ASTContext. Used by the CxxModuleHandler to mark declarations that /// were created from the 'std' C++ module to prevent that the Importer /// tries to sync them with the broken equivalent in the debug info AST. -std::set m_decls_to_ignore; +llvm::SmallPtrSet m_decls_to_ignore; ClangASTImporter _master; clang::ASTContext *m_source_ctx; CxxModuleHandler *m_std_handler = nullptr; @@ -271,8 +271,8 @@ class ClangASTImporter { }; typedef std::shared_ptr ImporterDelegateSP; - typedef std::map DelegateMap; - typedef std::map + typedef llvm::DenseMap DelegateMap; + typedef llvm::DenseMap NamespaceMetaMap; struct ASTContextMetadata { @@ -289,7 +289,7 @@ class ClangASTImporter { }; typedef std::shared_ptr ASTContextMetadataSP; - typedef std::map + typedef llvm::DenseMap ContextMetadataMap; ContextMetadataMap m_metadata_map; diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp index 8b1c6c8f815e..80c5c4a6f345 100644 --- a/lldb/source/Symbol/ClangASTImporter.cpp +++ b/lldb/source/Symbol/ClangASTImporter.cpp @@ -121,7 +121,7 @@ class DeclContextOverride { clang::DeclContext *lexical_decl_context; }; - std::map m_backups; + llvm::DenseMap m_backups; void OverrideOne(clang::Decl *decl) { if (m_backups.find(decl) != m_backups.end()) { @@ -228,10 +228,8 @@ namespace { /// imported while completing the original Decls). class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener { ClangASTImporter::ImporterDelegateSP m_delegate; - // FIXME: Investigate how many decls we usually have in these sets and - // see if we can use SmallPtrSet instead here. - std::set m_decls_to_complete; - std::set m_decls_already_completed; + llvm::SmallPtrSet m_decls_to_complete; + llvm::SmallPtrSet m_decls_already_completed; clang::ASTContext *m_dst_ctx; clang::ASTContext *m_src_ctx; ClangASTImporter ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 8280896 - [lldb] Remove RTTI in ClangExternalASTSourceCommon based on a global map of known instances
Author: Raphael Isemann Date: 2019-12-15T22:39:50+01:00 New Revision: 8280896bd1b055a192d9e7d482b0ffa14ee88e3a URL: https://github.com/llvm/llvm-project/commit/8280896bd1b055a192d9e7d482b0ffa14ee88e3a DIFF: https://github.com/llvm/llvm-project/commit/8280896bd1b055a192d9e7d482b0ffa14ee88e3a.diff LOG: [lldb] Remove RTTI in ClangExternalASTSourceCommon based on a global map of known instances Summary: Currently we do our RTTI check for ClangExternalASTSourceCommon by using this global map of ClangExternalASTSourceCommon where every instance is registering and deregistering itself on creation/destruction. Then we can do the RTTI check by looking up in this map from ClangASTContext. This patch removes this whole thing and just adds LLVM-style RTTI support to ClangExternalASTSourceCommon which is possible with D71397. Reviewers: labath, aprantl Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71398 Added: Modified: lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h lldb/source/Symbol/ClangASTContext.cpp lldb/source/Symbol/ClangExternalASTSourceCommon.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h index e7dd94d28286..5da486540bb9 100644 --- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h @@ -122,8 +122,11 @@ class ClangASTMetadata { }; class ClangExternalASTSourceCommon : public clang::ExternalASTSource { + + /// LLVM-style RTTI. + static char ID; + public: - ClangExternalASTSourceCommon(); ~ClangExternalASTSourceCommon() override; ClangASTMetadata *GetMetadata(const clang::Decl *object); @@ -138,8 +141,13 @@ class ClangExternalASTSourceCommon : public clang::ExternalASTSource { m_type_metadata[object] = metadata; } - static ClangExternalASTSourceCommon *Lookup(clang::ExternalASTSource *source); - + /// LLVM-style RTTI. + /// \{ + bool isA(const void *ClassID) const override { +return ClassID == || ExternalASTSource::isA(ClassID); + } + static bool classof(const ExternalASTSource *S) { return S->isA(); } + /// \} private: typedef llvm::DenseMap DeclMetadataMap; typedef llvm::DenseMap TypeMetadataMap; diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 2576a372076c..ed613528a2f4 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -2414,41 +2414,31 @@ void ClangASTContext::SetMetadataAsUserID(const clang::Type *type, void ClangASTContext::SetMetadata(const clang::Decl *object, ClangASTMetadata ) { - ClangExternalASTSourceCommon *external_source = - ClangExternalASTSourceCommon::Lookup( - getASTContext()->getExternalSource()); - - if (external_source) -external_source->SetMetadata(object, metadata); + if (auto *A = llvm::dyn_cast_or_null( + getASTContext()->getExternalSource())) +A->SetMetadata(object, metadata); } void ClangASTContext::SetMetadata(const clang::Type *object, ClangASTMetadata ) { - ClangExternalASTSourceCommon *external_source = - ClangExternalASTSourceCommon::Lookup( - getASTContext()->getExternalSource()); - - if (external_source) -external_source->SetMetadata(object, metadata); + if (auto *A = llvm::dyn_cast_or_null( + getASTContext()->getExternalSource())) +A->SetMetadata(object, metadata); } ClangASTMetadata *ClangASTContext::GetMetadata(clang::ASTContext *ast, const clang::Decl *object) { - ClangExternalASTSourceCommon *external_source = - ClangExternalASTSourceCommon::Lookup(ast->getExternalSource()); - - if (external_source) -return external_source->GetMetadata(object); + if (auto *A = llvm::dyn_cast_or_null( + ast->getExternalSource())) +return A->GetMetadata(object); return nullptr; } ClangASTMetadata *ClangASTContext::GetMetadata(clang::ASTContext *ast, const clang::Type *object) { - ClangExternalASTSourceCommon *external_source = - ClangExternalASTSourceCommon::Lookup(ast->getExternalSource()); - - if (external_source) -return external_source->GetMetadata(object); + if (auto *A = llvm::dyn_cast_or_null( + ast->getExternalSource())) +return A->GetMetadata(object); return nullptr; } diff --git a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp index 66fb4f3b3f05..be015da872d0 100644 --- a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp +++ b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp @@ -13,43 +13,9 @@
[Lldb-commits] [lldb] 9bace26 - [lldb][NFC] Remove all `setUp` overrides that only call the parent implementation
Author: Raphael Isemann Date: 2019-12-13T12:34:49+01:00 New Revision: 9bace26a690a778ec0f09a9aae9537dfbdb6f42f URL: https://github.com/llvm/llvm-project/commit/9bace26a690a778ec0f09a9aae9537dfbdb6f42f DIFF: https://github.com/llvm/llvm-project/commit/9bace26a690a778ec0f09a9aae9537dfbdb6f42f.diff LOG: [lldb][NFC] Remove all `setUp` overrides that only call the parent implementation Summary: A lot of our tests copied the setUp code from our TestSampleTest.py: ``` def setUp(self): # Call super's setUp(). TestBase.setUp(self) ``` This code does nothing unless we actually do any setUp work in there, so let's remove all these method definitions. Reviewers: labath, JDevlieghere Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71454 Added: Modified: lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py lldb/packages/Python/lldbsuite/test/commands/apropos/basic/TestApropos.py lldb/packages/Python/lldbsuite/test/commands/command/script/import/TestImport.py lldb/packages/Python/lldbsuite/test/commands/command/script/import/rdar-12586188/TestRdar12586188.py lldb/packages/Python/lldbsuite/test/commands/disassemble/basic/TestFrameDisassemble.py lldb/packages/Python/lldbsuite/test/commands/expression/calculator_mode/TestCalculatorMode.py lldb/packages/Python/lldbsuite/test/commands/expression/dont_allow_jit/TestAllowJIT.py lldb/packages/Python/lldbsuite/test/commands/expression/entry-bp/TestExprEntryBP.py lldb/packages/Python/lldbsuite/test/commands/expression/persistent_ptr_update/TestPersistentPtrUpdate.py lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/TestWeakSymbols.py lldb/packages/Python/lldbsuite/test/commands/frame/diagnose/array/TestArray.py lldb/packages/Python/lldbsuite/test/commands/frame/language/TestGuessLanguage.py lldb/packages/Python/lldbsuite/test/commands/frame/var/TestFrameVar.py lldb/packages/Python/lldbsuite/test/commands/register/register/intel_xtended_registers/TestMPXRegisters.py lldb/packages/Python/lldbsuite/test/commands/register/register/intel_xtended_registers/mpx_offset_intersection/TestMPXOffsetIntersection.py lldb/packages/Python/lldbsuite/test/commands/target/stop-hooks/TestStopHooks.py lldb/packages/Python/lldbsuite/test/commands/version/TestVersion.py lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/TestDataFormatterCaching.py lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py lldb/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py lldb/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py lldb/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_limit/TestBacktraceLimit.py lldb/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py lldb/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py lldb/packages/Python/lldbsuite/test/functionalities/var_path/TestVarPath.py lldb/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py lldb/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/TestDynamicValueSameBase.py lldb/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py lldb/packages/Python/lldbsuite/test/lang/objc/modules-app-update/TestClangModulesAppUpdate.py
[Lldb-commits] [lldb] 3ca771b - [lldb][NFC] Remove unused includes in Utility's source files
Author: Raphael Isemann Date: 2019-12-13T12:33:47+01:00 New Revision: 3ca771ba594fbd40da7ef842c04b5842e7b2a83c URL: https://github.com/llvm/llvm-project/commit/3ca771ba594fbd40da7ef842c04b5842e7b2a83c DIFF: https://github.com/llvm/llvm-project/commit/3ca771ba594fbd40da7ef842c04b5842e7b2a83c.diff LOG: [lldb][NFC] Remove unused includes in Utility's source files Added: Modified: lldb/source/Utility/ArchSpec.cpp lldb/source/Utility/Broadcaster.cpp lldb/source/Utility/ConstString.cpp lldb/source/Utility/DataBufferLLVM.cpp lldb/source/Utility/DataEncoder.cpp lldb/source/Utility/StructuredData.cpp Removed: diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index bbfa5cf61d01..b638a6138cfe 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -9,17 +9,13 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/NameMatches.h" -#include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-defines.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/Twine.h" #include "llvm/BinaryFormat/COFF.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/BinaryFormat/MachO.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/Host.h" using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/Utility/Broadcaster.cpp b/lldb/source/Utility/Broadcaster.cpp index aeb72ce2685d..ee0c39f8fd42 100644 --- a/lldb/source/Utility/Broadcaster.cpp +++ b/lldb/source/Utility/Broadcaster.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp index 2516ecf6a989..e90bb929bb81 100644 --- a/lldb/source/Utility/ConstString.cpp +++ b/lldb/source/Utility/ConstString.cpp @@ -18,7 +18,6 @@ #include "llvm/Support/RWMutex.h" #include "llvm/Support/Threading.h" -#include #include #include diff --git a/lldb/source/Utility/DataBufferLLVM.cpp b/lldb/source/Utility/DataBufferLLVM.cpp index 4227e9b39960..c20e1b06f52e 100644 --- a/lldb/source/Utility/DataBufferLLVM.cpp +++ b/lldb/source/Utility/DataBufferLLVM.cpp @@ -8,12 +8,9 @@ #include "lldb/Utility/DataBufferLLVM.h" -#include "llvm/ADT/Twine.h" -#include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include -#include using namespace lldb_private; diff --git a/lldb/source/Utility/DataEncoder.cpp b/lldb/source/Utility/DataEncoder.cpp index 0b6456deec35..8a1036e26dce 100644 --- a/lldb/source/Utility/DataEncoder.cpp +++ b/lldb/source/Utility/DataEncoder.cpp @@ -13,9 +13,7 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/MathExtras.h" -#include #include #include diff --git a/lldb/source/Utility/StructuredData.cpp b/lldb/source/Utility/StructuredData.cpp index 783a08082174..22477bdbe6c8 100644 --- a/lldb/source/Utility/StructuredData.cpp +++ b/lldb/source/Utility/StructuredData.cpp @@ -7,16 +7,12 @@ //===--===// #include "lldb/Utility/StructuredData.h" -#include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" -#include "lldb/Utility/StreamString.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/Support/MemoryBuffer.h" #include #include #include -#include using namespace lldb_private; using namespace llvm; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4286aca - [lldb][NFC] Add reminder to TestSampleTest that setUp should be deleted if it not needed.
Author: Raphael Isemann Date: 2019-12-13T12:10:05+01:00 New Revision: 4286aca5d5adb2fd07fb07d0dbbc94e2ff16270d URL: https://github.com/llvm/llvm-project/commit/4286aca5d5adb2fd07fb07d0dbbc94e2ff16270d DIFF: https://github.com/llvm/llvm-project/commit/4286aca5d5adb2fd07fb07d0dbbc94e2ff16270d.diff LOG: [lldb][NFC] Add reminder to TestSampleTest that setUp should be deleted if it not needed. Added: Modified: lldb/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py b/lldb/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py index a22670a72a1a..3577723084a8 100644 --- a/lldb/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py +++ b/lldb/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py @@ -28,6 +28,8 @@ def test_sample_rename_this(self): def setUp(self): # Call super's setUp(). TestBase.setUp(self) +# Set up your test case here. If your test doesn't need any set up then +# remove this method from your TestCase class. def sample_test(self): """You might use the test implementation in several ways, say so here.""" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5ab9fa4 - [lldb][NFC] Make metadata tracking type safe
Author: Raphael Isemann Date: 2019-12-13T12:04:42+01:00 New Revision: 5ab9fa44cd60d5bca7b6d809a86bf10be416eb5d URL: https://github.com/llvm/llvm-project/commit/5ab9fa44cd60d5bca7b6d809a86bf10be416eb5d DIFF: https://github.com/llvm/llvm-project/commit/5ab9fa44cd60d5bca7b6d809a86bf10be416eb5d.diff LOG: [lldb][NFC] Make metadata tracking type safe Summary: LLDB associates additional information with Types and Declarations which it calls ClangASTMetadata. ClangASTMetadata is stored by the ClangASTSourceCommon which is implemented by having a large map of `void *` keys to associated `ClangASTMetadata` values. To make this whole mechanism even unsafer we also decided to use `clang::Decl *` as one of pointers we throw in there (beside `clang::Type *`). The Decl class hierarchy uses multiple inheritance which means that not all pointers have the same address when they are implicitly converted to pointers of their parent classes. For example `clang::Decl *` and `clang::DeclContext *` won't end up being the same address when they are implicitly converted from one of the many Decl-subclasses that inherit from both. As we use the addresses as the keys in our Metadata map, this means that any implicit type conversions to parent classes (or anything else that changes the addresses) will break our metadata tracking in obscure ways. Just to illustrate how broken this whole mechanism currently is: ```lang=cpp // m_ast is our ClangASTContext. Let's double check that from GetTranslationUnitDecl // in ClangASTContext and ASTContext return the same thing (one method just calls the other). assert(m_ast->GetTranslationUnitDecl() == m_ast->getASTContext()->getTranslationUnitDecl()); // Ok, both methods have the same TU*. Let's store metadata with the result of one method call. m_ast->SetMetadataAsUserID(m_ast->GetTranslationUnitDecl(), 1234U); // Retrieve the same Metadata for the TU by using the TU* from the other method... which fails? EXPECT_EQ(m_ast->GetMetadata(m_ast->getASTContext()->getTranslationUnitDecl())->GetUserID(), 1234U); // Turns out that getTranslationUnitDecl one time returns a TranslationUnitDecl* but the other time // we return one of the parent classes of TranslationUnitDecl (DeclContext). ``` This patch splits up the `void *` API into two where one does the `clang::Type *` tracking and one the `clang::Decl *` mapping. Type and Decl are disjoint class hierarchies so there is no implicit conversion possible that could influence the address values. I had to change the storing of `clang::QualType` opaque pointers to their `clang::Type *` equivalents as opaque pointers are already `void *` pointers to begin with. We don't seem to ever set any qualifier in any of these QualTypes to this conversion should be NFC. Reviewers: labath, shafik, aprantl Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71409 Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Symbol/ClangASTContext.cpp lldb/source/Symbol/ClangExternalASTSourceCommon.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 43d42105c936..9537f33b3386 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -145,16 +145,24 @@ class ClangASTContext : public TypeSystem { static bool GetCompleteDecl(clang::ASTContext *ast, clang::Decl *decl); - void SetMetadataAsUserID(const void *object, lldb::user_id_t user_id); + void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id); + void SetMetadataAsUserID(const clang::Type *type, lldb::user_id_t user_id); - void SetMetadata(const void *object, ClangASTMetadata _data); + void SetMetadata(const clang::Decl *object, ClangASTMetadata _data); + void SetMetadata(const clang::Type *object, ClangASTMetadata _data); + ClangASTMetadata *GetMetadata(const clang::Decl *object) { +return GetMetadata(getASTContext(), object); + } + + static ClangASTMetadata *GetMetadata(clang::ASTContext *ast, + const clang::Decl *object); - ClangASTMetadata *GetMetadata(const void *object) { + ClangASTMetadata *GetMetadata(const clang::Type *object) { return GetMetadata(getASTContext(), object); } static ClangASTMetadata *GetMetadata(clang::ASTContext *ast, - const void *object); + const clang::Type *object); // Basic Types CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, @@ -487,7 +495,7 @@ class ClangASTContext : public TypeSystem {
[Lldb-commits] [lldb] e39cb48 - [lldb] Remove ClangASTMetrics
Author: Raphael Isemann Date: 2019-12-12T11:46:25+01:00 New Revision: e39cb48cd0bdf9157b57c4616c821488f7b6d7c4 URL: https://github.com/llvm/llvm-project/commit/e39cb48cd0bdf9157b57c4616c821488f7b6d7c4 DIFF: https://github.com/llvm/llvm-project/commit/e39cb48cd0bdf9157b57c4616c821488f7b6d7c4.diff LOG: [lldb] Remove ClangASTMetrics Summary: Not once have I looked at these numbers in a log and considered them useful. Also this should not have been implemented via an unguarded list of globals. Reviewers: martong, shafik Reviewed By: shafik Subscribers: rnkovacs, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71336 Added: Modified: lldb/include/lldb/Symbol/ClangASTImporter.h lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Symbol/ClangASTImporter.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index f963f9b2b1dc..a67b698ef490 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -30,57 +30,6 @@ namespace lldb_private { -class ClangASTMetrics { -public: - static void DumpCounters(Log *log); - static void ClearLocalCounters() { local_counters = {0, 0, 0, 0, 0, 0}; } - - static void RegisterVisibleQuery() { -++global_counters.m_visible_query_count; -++local_counters.m_visible_query_count; - } - - static void RegisterLexicalQuery() { -++global_counters.m_lexical_query_count; -++local_counters.m_lexical_query_count; - } - - static void RegisterLLDBImport() { -++global_counters.m_lldb_import_count; -++local_counters.m_lldb_import_count; - } - - static void RegisterClangImport() { -++global_counters.m_clang_import_count; -++local_counters.m_clang_import_count; - } - - static void RegisterDeclCompletion() { -++global_counters.m_decls_completed_count; -++local_counters.m_decls_completed_count; - } - - static void RegisterRecordLayout() { -++global_counters.m_record_layout_count; -++local_counters.m_record_layout_count; - } - -private: - struct Counters { -uint64_t m_visible_query_count; -uint64_t m_lexical_query_count; -uint64_t m_lldb_import_count; -uint64_t m_clang_import_count; -uint64_t m_decls_completed_count; -uint64_t m_record_layout_count; - }; - - static Counters global_counters; - static Counters local_counters; - - static void DumpCounters(Log *log, Counters ); -}; - class ClangASTImporter { public: struct LayoutInfo { diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 51540902e2dc..0fef262b1aba 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -524,8 +524,6 @@ void ClangASTSource::FindExternalLexicalDecls( } else if (!m_ast_importer_sp) return; - ClangASTMetrics::RegisterLexicalQuery(); - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); const Decl *context_decl = dyn_cast(decl_context); @@ -671,8 +669,6 @@ void ClangASTSource::FindExternalLexicalDecls( void ClangASTSource::FindExternalVisibleDecls(NameSearchContext ) { assert(m_ast_context); - ClangASTMetrics::RegisterVisibleQuery(); - const ConstString name(context.m_decl_name.getAsString().c_str()); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); @@ -1714,8 +1710,6 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t , FieldOffsetMap _offsets, BaseOffsetMap _offsets, BaseOffsetMap _base_offsets) { - ClangASTMetrics::RegisterRecordLayout(); - static unsigned int invocation_id = 0; unsigned int current_id = invocation_id++; @@ -2032,8 +2026,6 @@ CompilerType ClangASTSource::GuardedCopyType(const CompilerType _type) { if (src_ast == nullptr) return CompilerType(); - ClangASTMetrics::RegisterLLDBImport(); - SetImportInProgress(true); QualType copied_qual_type; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index fc25a2e72e3b..7a2dbbd16b2d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -84,8 +84,6 @@ ClangExpressionDeclMap::~ClangExpressionDeclMap() { bool ClangExpressionDeclMap::WillParse(ExecutionContext _ctx, Materializer *materializer) { -
[Lldb-commits] [lldb] 2aec4b4 - [lldb][NFC] Don't implement ClangASTContext::SetMetadata again as a static method
Author: Raphael Isemann Date: 2019-12-12T11:14:26+01:00 New Revision: 2aec4b4863f883e1e9e8e0362b85d37fc5fc0545 URL: https://github.com/llvm/llvm-project/commit/2aec4b4863f883e1e9e8e0362b85d37fc5fc0545 DIFF: https://github.com/llvm/llvm-project/commit/2aec4b4863f883e1e9e8e0362b85d37fc5fc0545.diff LOG: [lldb][NFC] Don't implement ClangASTContext::SetMetadata again as a static method We always have an ClangASTContext when we call this method so we might as well always call the non-static version. Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/source/Symbol/ClangASTContext.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index f13567e0583c..97b151c14b91 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -132,12 +132,7 @@ class ClangASTContext : public TypeSystem { void SetMetadataAsUserID(const void *object, lldb::user_id_t user_id); - void SetMetadata(const void *object, ClangASTMetadata _data) { -SetMetadata(getASTContext(), object, meta_data); - } - - static void SetMetadata(clang::ASTContext *ast, const void *object, - ClangASTMetadata _data); + void SetMetadata(const void *object, ClangASTMetadata _data); ClangASTMetadata *GetMetadata(const void *object) { return GetMetadata(getASTContext(), object); diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index e7237a39a9c2..d49c29c0a495 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -1344,7 +1344,7 @@ CompilerType ClangASTContext::CreateRecordType( if (decl) { if (metadata) - SetMetadata(ast, decl, *metadata); + SetMetadata(decl, *metadata); if (access_type != eAccessNone) decl->setAccess(ConvertAccessTypeToAccessSpecifier(access_type)); @@ -1701,7 +1701,7 @@ CompilerType ClangASTContext::CreateObjCClass(const char *name, isInternal); if (decl && metadata) -SetMetadata(ast, decl, *metadata); +SetMetadata(decl, *metadata); return CompilerType(this, ast->getObjCInterfaceType(decl).getAsOpaquePtr()); } @@ -2405,10 +2405,11 @@ void ClangASTContext::SetMetadataAsUserID(const void *object, SetMetadata(object, meta_data); } -void ClangASTContext::SetMetadata(clang::ASTContext *ast, const void *object, +void ClangASTContext::SetMetadata(const void *object, ClangASTMetadata ) { ClangExternalASTSourceCommon *external_source = - ClangExternalASTSourceCommon::Lookup(ast->getExternalSource()); + ClangExternalASTSourceCommon::Lookup( + getASTContext()->getExternalSource()); if (external_source) external_source->SetMetadata(object, metadata); @@ -7662,7 +7663,7 @@ bool ClangASTContext::AddObjCClassProperty( return false; if (metadata) -ClangASTContext::SetMetadata(clang_ast, property_decl, *metadata); +ast->SetMetadata(property_decl, *metadata); class_interface_decl->addDecl(property_decl); @@ -7745,7 +7746,7 @@ bool ClangASTContext::AddObjCClassProperty( if (getter) { if (metadata) -ClangASTContext::SetMetadata(clang_ast, getter, *metadata); +ast->SetMetadata(getter, *metadata); getter->setMethodParams(*clang_ast, llvm::ArrayRef(), @@ -7780,7 +7781,7 @@ bool ClangASTContext::AddObjCClassProperty( if (setter) { if (metadata) -ClangASTContext::SetMetadata(clang_ast, setter, *metadata); +ast->SetMetadata(setter, *metadata); llvm::SmallVector params; params.push_back(clang::ParmVarDecl::Create( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c7738cc - [lldb] Don't search the metadata map three times when retrieving metadata
Author: Raphael Isemann Date: 2019-12-11T15:08:10+01:00 New Revision: c7738cca7efda9d1a78569b69ba4ac735c0f2212 URL: https://github.com/llvm/llvm-project/commit/c7738cca7efda9d1a78569b69ba4ac735c0f2212 DIFF: https://github.com/llvm/llvm-project/commit/c7738cca7efda9d1a78569b69ba4ac735c0f2212.diff LOG: [lldb] Don't search the metadata map three times when retrieving metadata HasMetadata checks if our metadata map knows the given object. GetMetadata also does this check and then does another search to actually retrieve the value. This can all just be one lookup. Added: Modified: lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h lldb/source/Symbol/ClangASTContext.cpp lldb/source/Symbol/ClangExternalASTSourceCommon.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h index 8e69f6d3e4eb..1d40080033a1 100644 --- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h @@ -128,7 +128,6 @@ class ClangExternalASTSourceCommon : public clang::ExternalASTSource { ClangASTMetadata *GetMetadata(const void *object); void SetMetadata(const void *object, ClangASTMetadata ); - bool HasMetadata(const void *object); static ClangExternalASTSourceCommon *Lookup(clang::ExternalASTSource *source); diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 8c5b0cae34b7..e7237a39a9c2 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -2419,7 +2419,7 @@ ClangASTMetadata *ClangASTContext::GetMetadata(clang::ASTContext *ast, ClangExternalASTSourceCommon *external_source = ClangExternalASTSourceCommon::Lookup(ast->getExternalSource()); - if (external_source && external_source->HasMetadata(object)) + if (external_source) return external_source->GetMetadata(object); else return nullptr; diff --git a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp index 9c58969dc46e..b60b3791aae1 100644 --- a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp +++ b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp @@ -53,8 +53,9 @@ ClangExternalASTSourceCommon::~ClangExternalASTSourceCommon() { ClangASTMetadata * ClangExternalASTSourceCommon::GetMetadata(const void *object) { - if (HasMetadata(object)) -return _metadata[object]; + auto It = m_metadata.find(object); + if (It != m_metadata.end()) +return >second; else return nullptr; } @@ -64,10 +65,6 @@ void ClangExternalASTSourceCommon::SetMetadata(const void *object, m_metadata[object] = metadata; } -bool ClangExternalASTSourceCommon::HasMetadata(const void *object) { - return m_metadata.find(object) != m_metadata.end(); -} - void ClangASTMetadata::Dump(Stream *s) { lldb::user_id_t uid = GetUserID(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f95ef6a - [lldb][NFC] Remove dead metadata code in ClangASTSourceProxy
Author: Raphael Isemann Date: 2019-12-11T14:38:12+01:00 New Revision: f95ef6a548211ffa6723e4ec923d37359a3bb9e1 URL: https://github.com/llvm/llvm-project/commit/f95ef6a548211ffa6723e4ec923d37359a3bb9e1 DIFF: https://github.com/llvm/llvm-project/commit/f95ef6a548211ffa6723e4ec923d37359a3bb9e1.diff LOG: [lldb][NFC] Remove dead metadata code in ClangASTSourceProxy Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h index 194233e4a028..83a7ae2893c3 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -249,18 +249,6 @@ class ClangASTSource : public ClangExternalASTSourceCommon, return m_original.StartTranslationUnit(Consumer); } -ClangASTMetadata *GetMetadata(const void *object) { - return m_original.GetMetadata(object); -} - -void SetMetadata(const void *object, ClangASTMetadata ) { - return m_original.SetMetadata(object, metadata); -} - -bool HasMetadata(const void *object) { - return m_original.HasMetadata(object); -} - private: ClangASTSource _original; }; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3bf8558 - [lldb][NFC] Remove ClangExternalASTSourceCommon::g_TotalSizeOfMetadata
Author: Raphael Isemann Date: 2019-12-11T14:05:43+01:00 New Revision: 3bf8558fbb2f3e9348bf1f5aafb64d8095ad6420 URL: https://github.com/llvm/llvm-project/commit/3bf8558fbb2f3e9348bf1f5aafb64d8095ad6420 DIFF: https://github.com/llvm/llvm-project/commit/3bf8558fbb2f3e9348bf1f5aafb64d8095ad6420.diff LOG: [lldb][NFC] Remove ClangExternalASTSourceCommon::g_TotalSizeOfMetadata Turns out this counter is doing literally nothing beside counting. Added: Modified: lldb/source/Symbol/ClangExternalASTSourceCommon.cpp Removed: diff --git a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp index 2309bc60d617..9c58969dc46e 100644 --- a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp +++ b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp @@ -13,8 +13,6 @@ using namespace lldb_private; -static uint64_t g_TotalSizeOfMetadata = 0; - typedef llvm::DenseMap ASTSourceMap; @@ -44,7 +42,6 @@ ClangExternalASTSourceCommon::Lookup(clang::ExternalASTSource *source) { ClangExternalASTSourceCommon::ClangExternalASTSourceCommon() : clang::ExternalASTSource() { - g_TotalSizeOfMetadata += m_metadata.size(); std::unique_lock guard; GetSourceMap(guard)[this] = this; } @@ -52,7 +49,6 @@ ClangExternalASTSourceCommon::ClangExternalASTSourceCommon() ClangExternalASTSourceCommon::~ClangExternalASTSourceCommon() { std::unique_lock guard; GetSourceMap(guard).erase(this); - g_TotalSizeOfMetadata -= m_metadata.size(); } ClangASTMetadata * @@ -65,10 +61,7 @@ ClangExternalASTSourceCommon::GetMetadata(const void *object) { void ClangExternalASTSourceCommon::SetMetadata(const void *object, ClangASTMetadata ) { - uint64_t orig_size = m_metadata.size(); m_metadata[object] = metadata; - uint64_t new_size = m_metadata.size(); - g_TotalSizeOfMetadata += (new_size - orig_size); } bool ClangExternalASTSourceCommon::HasMetadata(const void *object) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 987e732 - [lldb][NFC] Cleanup includes in FormatManagerTests.cpp
Author: Raphael Isemann Date: 2019-12-11T11:33:19+01:00 New Revision: 987e7323fb53f968d5878483610fcf2319cdde86 URL: https://github.com/llvm/llvm-project/commit/987e7323fb53f968d5878483610fcf2319cdde86 DIFF: https://github.com/llvm/llvm-project/commit/987e7323fb53f968d5878483610fcf2319cdde86.diff LOG: [lldb][NFC] Cleanup includes in FormatManagerTests.cpp Added: Modified: lldb/unittests/DataFormatter/FormatManagerTests.cpp Removed: diff --git a/lldb/unittests/DataFormatter/FormatManagerTests.cpp b/lldb/unittests/DataFormatter/FormatManagerTests.cpp index d57454b3f9d1..acfafdbd293c 100644 --- a/lldb/unittests/DataFormatter/FormatManagerTests.cpp +++ b/lldb/unittests/DataFormatter/FormatManagerTests.cpp @@ -6,20 +6,7 @@ // //===--===// -#include "TestingSupport/TestUtilities.h" - -#include "lldb/Core/Mangled.h" -#include "lldb/Core/Module.h" -#include "lldb/Core/ModuleSpec.h" #include "lldb/DataFormatters/FormatManager.h" -#include "lldb/Host/FileSystem.h" -#include "lldb/Host/HostInfo.h" -#include "lldb/Symbol/SymbolContext.h" - -#include "llvm/Support/FileUtilities.h" -#include "llvm/Support/Path.h" -#include "llvm/Support/Program.h" -#include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 14f3d13 - [lldb] Actually enable wchar support in Editline when it is defined in the host config
Author: Raphael Isemann Date: 2019-12-10T14:30:41+01:00 New Revision: 14f3d13412cb2eac87f1c0ae74ed2af7ace1580f URL: https://github.com/llvm/llvm-project/commit/14f3d13412cb2eac87f1c0ae74ed2af7ace1580f DIFF: https://github.com/llvm/llvm-project/commit/14f3d13412cb2eac87f1c0ae74ed2af7ace1580f.diff LOG: [lldb] Actually enable wchar support in Editline when it is defined in the host config Summary: Our Editline implementation in LLDB supports using the wchar interface of Editline which should improve handling of unicode input when using Editline. At the moment we essentially just ignore unicode input and echo the escaped unicode code point (`\U1234`) to the command line (which we then also incorrectly treat as multiple characters, so console navigation is also broken afterwards). This patch just adds the include to the host config file which already contains the LLDB_EDITLINE_USE_WCHAR define to enable the Editline support (we just never included it in the file before). With this we now actually echo back unicode characters on macOS and we no longer ignore unicode input. On Linux this doesn't seem to improve the echoing back of characters but at least it fixes that we ignore unicode input. Reviewers: labath Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71251 Added: lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py Modified: lldb/include/lldb/Host/Editline.h Removed: diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h index 0cb2c6c5b6a1..db3d9e48cfbb 100644 --- a/lldb/include/lldb/Host/Editline.h +++ b/lldb/include/lldb/Host/Editline.h @@ -32,6 +32,8 @@ #define liblldb_Editline_h_ #if defined(__cplusplus) +#include "lldb/Host/Config.h" + #if LLDB_EDITLINE_USE_WCHAR #include #endif diff --git a/lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py b/lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py new file mode 100644 index ..c8ff9a6ab32d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/iohandler/unicode/TestUnicode.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +""" +Test unicode handling in LLDB. +""" + +import os + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test.lldbpexpect import PExpectTest + +class TestCase(PExpectTest): + +mydir = TestBase.compute_mydir(__file__) + +# PExpect uses many timeouts internally and doesn't play well +# under ASAN on a loaded machine.. +@skipIfAsan +def test_unicode_input(self): +self.launch() + +# Send some unicode input to LLDB. +# We should get back that this is an invalid command with our character as UTF-8. +self.expect(u'\u1234', substrs=[u"error: '\u1234' is not a valid command.".encode('utf-8')]) + +self.quit() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e9895c6 - [lldb][NFC] Make g_TotalSizeOfMetadata in ClangExternalASTSourceCommon.cpp static
Author: Raphael Isemann Date: 2019-12-10T13:46:12+01:00 New Revision: e9895c612a5a331660020172affa927664e138ad URL: https://github.com/llvm/llvm-project/commit/e9895c612a5a331660020172affa927664e138ad DIFF: https://github.com/llvm/llvm-project/commit/e9895c612a5a331660020172affa927664e138ad.diff LOG: [lldb][NFC] Make g_TotalSizeOfMetadata in ClangExternalASTSourceCommon.cpp static Clang was warning that this global should be static (which makes sense). Added: Modified: lldb/source/Symbol/ClangExternalASTSourceCommon.cpp Removed: diff --git a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp index 3dcf9051d0a4..2309bc60d617 100644 --- a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp +++ b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp @@ -13,7 +13,7 @@ using namespace lldb_private; -uint64_t g_TotalSizeOfMetadata = 0; +static uint64_t g_TotalSizeOfMetadata = 0; typedef llvm::DenseMap ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d0fb7a4 - [lldb] Support for DWARF-5 atomic types
Author: Raphael Isemann Date: 2019-12-09T10:46:26+01:00 New Revision: d0fb7a478df19b78b58bf8778e9f046903115035 URL: https://github.com/llvm/llvm-project/commit/d0fb7a478df19b78b58bf8778e9f046903115035 DIFF: https://github.com/llvm/llvm-project/commit/d0fb7a478df19b78b58bf8778e9f046903115035.diff LOG: [lldb] Support for DWARF-5 atomic types Summary: This patch adds support for atomic types (DW_TAG_atomic_type) to LLDB. It's mostly just filling out all the switch-statements that didn't implement Atomic case with the usual boilerplate. Thanks Pavel for writing the test case. Reviewers: labath, aprantl, shafik Reviewed By: labath Subscribers: jfb, abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71183 Added: lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/include/lldb/Symbol/CompilerType.h lldb/include/lldb/Symbol/Type.h lldb/include/lldb/Symbol/TypeSystem.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Symbol/ClangASTContext.cpp lldb/source/Symbol/CompilerType.cpp lldb/source/Symbol/Type.cpp lldb/source/Symbol/TypeSystem.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index b2c284282f11..f13567e0583c 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -644,6 +644,8 @@ class ClangASTContext : public TypeSystem { CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type) override; + CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override; + CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override; CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override; diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 91d9c5e48d20..ee87b53942b7 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -218,6 +218,11 @@ class CompilerType { // an invalid type. CompilerType AddVolatileModifier() const; + // Return a new CompilerType that is the atomic type of this type. If this + // type is not valid or the type system doesn't support atomic types, this + // returns an invalid type. + CompilerType GetAtomicType() const; + // Return a new CompilerType adds a restrict modifier to this type if this // type is valid and the type system supports restrict modifiers, else return // an invalid type. diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index ae61f99b4a4b..95a3bc497517 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -80,7 +80,9 @@ class Type : public std::enable_shared_from_this, public UserID { eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type /// whose UID is m_encoding_uid eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type - /// whose UID is m_encoding_uid + /// whose UID is m_encoding_uid, +eEncodingIsAtomicUID, ///< This type is the type whose UID is + /// m_encoding_uid as an atomic type. eEncodingIsSyntheticUID }; diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index ea860647fdb1..5143a53674ab 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -228,6 +228,8 @@ class TypeSystem : public PluginInterface { virtual CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type); + virtual CompilerType GetAtomicType(lldb::opaque_compiler_type_t type); + virtual CompilerType AddConstModifier(lldb::opaque_compiler_type_t type); virtual CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 09f5b28449cb..002d373a5d99 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -474,6 +474,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , case DW_TAG_const_type: case DW_TAG_restrict_type: case DW_TAG_volatile_type: + case DW_TAG_atomic_type: case DW_TAG_unspecified_type: { type_sp = ParseTypeModifier(sc, die, attrs); break; @@ -618,6 +619,9 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext , case DW_TAG_volatile_type: encoding_data_type = Type::eEncodingIsVolatileUID; break; + case DW_TAG_atomic_type: +
[Lldb-commits] [lldb] f6e0567 - [lldb] Add a test for how we lazily create Clang AST nodes
Author: Raphael Isemann Date: 2019-12-09T09:59:40+01:00 New Revision: f6e05672f6566a8d7efc4aed6473319e7115f979 URL: https://github.com/llvm/llvm-project/commit/f6e05672f6566a8d7efc4aed6473319e7115f979 DIFF: https://github.com/llvm/llvm-project/commit/f6e05672f6566a8d7efc4aed6473319e7115f979.diff LOG: [lldb] Add a test for how we lazily create Clang AST nodes Summary: One of the ways we try to make LLDB faster is by only creating the Clang declarations (and loading the associated types) when we actually need them for something. For example an evaluated expression might need to load types to type check and codegen the expression. Currently this mechanism isn't really tested, so we currently have no way to know how many Clang nodes we load and when we load them. In general there seems to be some confusion when and why certain Clang nodes are created. As we are about to make some changes to the code which is creating Clang AST nodes we probably should have a test that at least checks that the current behaviour doesn't change. It also serves as some kind of documentation on the current behaviour. The test in this patch is just evaluating some expressions and checks which Clang nodes are created due to this in the module AST. The check happens by looking at the AST dump of the current module and then scanning it for the declarations we are looking for. I'm aware that there are things missing in this test (inheritance, template parameters, non-expression evaluation commands) but I'll expand it in follow up patches. Also this test found two potential bugs in LLDB which are documented near the respective asserts in the test: 1. LLDB seems to always load all types of local variables even when we don't reference them in the expression. We had patches that tried to prevent this but it seems that didn't work as well as it should have (even though we don't complete these types). 2. We always seem to complete the first field of any record we run into. This has the funny side effect that LLDB is faster when all classes in a project have an arbitrary `char unused;` as their first member. We probably want to fix this. Reviewers: shafik Subscribers: abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71056 Added: lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/Makefile lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/TestLazyLoading.py lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/main.cpp Modified: Removed: diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/Makefile new file mode 100644 index ..3d0b98f13f3d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/Makefile @@ -0,0 +1,2 @@ +CXX_SOURCES := main.cpp +include Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/TestLazyLoading.py b/lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/TestLazyLoading.py new file mode 100644 index ..4dceb371 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/lazy-loading/TestLazyLoading.py @@ -0,0 +1,236 @@ +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +""" +This test ensures that we only create Clang AST nodes in our module AST +when we actually need them. + +All tests in this file behave like this: + 1. Use LLDB to do something (expression evaluation, breakpoint setting, etc.). + 2. Check that certain Clang AST nodes were not loaded during the previous + step. +""" + +class TestCase(TestBase): + +NO_DEBUG_INFO_TESTCASE = True +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): + TestBase.setUp(self) + # Only build this test once. + self.build() + +# Clang declaration kind we are looking for. +class_decl_kind = "CXXRecordDecl" +# FIXME: This shouldn't be a CXXRecordDecl, but that's how we model +# structs in Clang. +struct_decl_kind = "CXXRecordDecl" + +# The decls we use in this program in the format that +# decl_in_line and decl_completed_in_line expect (which is a pair of +# node type and the unqualified declaration name. +struct_first_member_decl = [struct_decl_kind, "StructFirstMember"] +struct_behind_ptr_decl = [struct_decl_kind, "StructBehindPointer"] +struct_behind_ref_decl = [struct_decl_kind, "StructBehindRef"] +struct_member_decl = [struct_decl_kind, "StructMember"] +some_struct_decl = [struct_decl_kind, "SomeStruct"] +other_struct_decl = [struct_decl_kind, "OtherStruct"] +class_in_namespace_decl = [class_decl_kind, "ClassInNamespace"] +class_we_enter_decl =
[Lldb-commits] [lldb] fc39b94 - [lldb][NFC] Move [SU]Int64ValueIsValidForByteSize to RegisterValue
Author: Raphael Isemann Date: 2019-12-06T11:16:39+01:00 New Revision: fc39b94849c89843aebb210c5d9be9c48e2b43a6 URL: https://github.com/llvm/llvm-project/commit/fc39b94849c89843aebb210c5d9be9c48e2b43a6 DIFF: https://github.com/llvm/llvm-project/commit/fc39b94849c89843aebb210c5d9be9c48e2b43a6.diff LOG: [lldb][NFC] Move [SU]Int64ValueIsValidForByteSize to RegisterValue These functions are an implementation detail of RegisterValue, so it doesn't make a lot of sense to implement them in a totally unrelated class. Added: Modified: lldb/include/lldb/Utility/Args.h lldb/source/Utility/RegisterValue.cpp Removed: diff --git a/lldb/include/lldb/Utility/Args.h b/lldb/include/lldb/Utility/Args.h index 7987787e7af5..1308f4038dbd 100644 --- a/lldb/include/lldb/Utility/Args.h +++ b/lldb/include/lldb/Utility/Args.h @@ -252,35 +252,6 @@ class Args { // For re-setting or blanking out the list of arguments. void Clear(); - static bool UInt64ValueIsValidForByteSize(uint64_t uval64, -size_t total_byte_size) { -if (total_byte_size > 8) - return false; - -if (total_byte_size == 8) - return true; - -const uint64_t max = (static_cast(1) - << static_cast(total_byte_size * 8)) - - 1; -return uval64 <= max; - } - - static bool SInt64ValueIsValidForByteSize(int64_t sval64, -size_t total_byte_size) { -if (total_byte_size > 8) - return false; - -if (total_byte_size == 8) - return true; - -const int64_t max = (static_cast(1) - << static_cast(total_byte_size * 8 - 1)) - -1; -const int64_t min = ~(max); -return min <= sval64 && sval64 <= max; - } - static lldb::Encoding StringToEncoding(llvm::StringRef s, lldb::Encoding fail_value = lldb::eEncodingInvalid); diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp index a01c35a2818e..36790f5d8efa 100644 --- a/lldb/source/Utility/RegisterValue.cpp +++ b/lldb/source/Utility/RegisterValue.cpp @@ -8,7 +8,6 @@ #include "lldb/Utility/RegisterValue.h" -#include "lldb/Utility/Args.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" @@ -330,6 +329,35 @@ static bool ParseVectorEncoding(const RegisterInfo *reg_info, return true; } +static bool UInt64ValueIsValidForByteSize(uint64_t uval64, + size_t total_byte_size) { + if (total_byte_size > 8) +return false; + + if (total_byte_size == 8) +return true; + + const uint64_t max = + (static_cast(1) << static_cast(total_byte_size * 8)) - + 1; + return uval64 <= max; +} + +static bool SInt64ValueIsValidForByteSize(int64_t sval64, + size_t total_byte_size) { + if (total_byte_size > 8) +return false; + + if (total_byte_size == 8) +return true; + + const int64_t max = (static_cast(1) + << static_cast(total_byte_size * 8 - 1)) - + 1; + const int64_t min = ~(max); + return min <= sval64 && sval64 <= max; +} + Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info, llvm::StringRef value_str) { Status error; @@ -368,7 +396,7 @@ Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info, break; } -if (!Args::UInt64ValueIsValidForByteSize(uval64, byte_size)) { +if (!UInt64ValueIsValidForByteSize(uval64, byte_size)) { error.SetErrorStringWithFormat( "value 0x%" PRIx64 " is too large to fit in a %u byte unsigned integer value", @@ -397,7 +425,7 @@ Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info, break; } -if (!Args::SInt64ValueIsValidForByteSize(ival64, byte_size)) { +if (!SInt64ValueIsValidForByteSize(ival64, byte_size)) { error.SetErrorStringWithFormat( "value 0x%" PRIx64 " is too large to fit in a %u byte signed integer value", ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b6e2cf3 - [lldb][NFC] Remove ability to pass a custom printf format to DataExtractor::PutToLog
Author: Raphael Isemann Date: 2019-12-06T10:27:45+01:00 New Revision: b6e2cf3270dab43dbc6ffad4695c5c14789bc5e5 URL: https://github.com/llvm/llvm-project/commit/b6e2cf3270dab43dbc6ffad4695c5c14789bc5e5 DIFF: https://github.com/llvm/llvm-project/commit/b6e2cf3270dab43dbc6ffad4695c5c14789bc5e5.diff LOG: [lldb][NFC] Remove ability to pass a custom printf format to DataExtractor::PutToLog This is luckily not used anywhere. Added: Modified: lldb/include/lldb/Utility/DataExtractor.h lldb/source/Utility/DataExtractor.cpp Removed: diff --git a/lldb/include/lldb/Utility/DataExtractor.h b/lldb/include/lldb/Utility/DataExtractor.h index 333baf9fd349..bf0d1055cf43 100644 --- a/lldb/include/lldb/Utility/DataExtractor.h +++ b/lldb/include/lldb/Utility/DataExtractor.h @@ -188,16 +188,11 @@ class DataExtractor { /// The type of objects to use when dumping data from this /// object. See DataExtractor::Type. /// - /// \param[in] type_format - /// The optional format to use for the \a type objects. If this - /// is nullptr, the default format for the \a type will be used. - /// /// \return /// The offset at which dumping ended. lldb::offset_t PutToLog(Log *log, lldb::offset_t offset, lldb::offset_t length, uint64_t base_addr, - uint32_t num_per_line, Type type, - const char *type_format = nullptr) const; + uint32_t num_per_line, Type type) const; /// Extract an arbitrary number of bytes in the specified byte order. /// diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp index 4e45baf3aa41..ea4fb09bdaab 100644 --- a/lldb/source/Utility/DataExtractor.cpp +++ b/lldb/source/Utility/DataExtractor.cpp @@ -985,8 +985,7 @@ uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) const { lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset, offset_t length, uint64_t base_addr, uint32_t num_per_line, - DataExtractor::Type type, - const char *format) const { + DataExtractor::Type type) const { if (log == nullptr) return start_offset; @@ -1010,29 +1009,29 @@ lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset, switch (type) { case TypeUInt8: - sstr.Printf(format ? format : " %2.2x", GetU8()); + sstr.Printf(" %2.2x", GetU8()); break; case TypeChar: { char ch = GetU8(); - sstr.Printf(format ? format : " %c", isprint(ch) ? ch : ' '); + sstr.Printf(" %c", isprint(ch) ? ch : ' '); } break; case TypeUInt16: - sstr.Printf(format ? format : " %4.4x", GetU16()); + sstr.Printf(" %4.4x", GetU16()); break; case TypeUInt32: - sstr.Printf(format ? format : " %8.8x", GetU32()); + sstr.Printf(" %8.8x", GetU32()); break; case TypeUInt64: - sstr.Printf(format ? format : " %16.16" PRIx64, GetU64()); + sstr.Printf(" %16.16" PRIx64, GetU64()); break; case TypePointer: - sstr.Printf(format ? format : " 0x%" PRIx64, GetAddress()); + sstr.Printf(" 0x%" PRIx64, GetAddress()); break; case TypeULEB128: - sstr.Printf(format ? format : " 0x%" PRIx64, GetULEB128()); + sstr.Printf(" 0x%" PRIx64, GetULEB128()); break; case TypeSLEB128: - sstr.Printf(format ? format : " %" PRId64, GetSLEB128()); + sstr.Printf(" %" PRId64, GetSLEB128()); break; } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 777d1f7 - [lldb] Migrate VMRange::Dump to raw_ostream
Author: Raphael Isemann Date: 2019-12-06T10:19:20+01:00 New Revision: 777d1f7272b52cbe372e7234a7247b189e416062 URL: https://github.com/llvm/llvm-project/commit/777d1f7272b52cbe372e7234a7247b189e416062 DIFF: https://github.com/llvm/llvm-project/commit/777d1f7272b52cbe372e7234a7247b189e416062.diff LOG: [lldb] Migrate VMRange::Dump to raw_ostream Added: Modified: lldb/include/lldb/Utility/VMRange.h lldb/source/Core/Section.cpp lldb/source/Expression/DWARFExpression.cpp lldb/source/Utility/VMRange.cpp Removed: diff --git a/lldb/include/lldb/Utility/VMRange.h b/lldb/include/lldb/Utility/VMRange.h index 9c2f9d090919..72f859b67582 100644 --- a/lldb/include/lldb/Utility/VMRange.h +++ b/lldb/include/lldb/Utility/VMRange.h @@ -10,15 +10,12 @@ #define liblldb_VMRange_h_ #include "lldb/lldb-types.h" +#include "llvm/Support/raw_ostream.h" #include #include #include -namespace lldb_private { -class Stream; -} - namespace lldb_private { // A vm address range. These can represent offsets ranges or actual @@ -81,7 +78,7 @@ class VMRange { return false; } - void Dump(Stream *s, lldb::addr_t base_addr = 0, + void Dump(llvm::raw_ostream , lldb::addr_t base_addr = 0, uint32_t addr_width = 8) const; static bool ContainsValue(const VMRange::collection , diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp index e8fcca4603df..4a9acab2e27c 100644 --- a/lldb/source/Core/Section.cpp +++ b/lldb/source/Core/Section.cpp @@ -323,7 +323,7 @@ void Section::Dump(Stream *s, Target *target, uint32_t depth) const { } VMRange range(addr, addr + m_byte_size); -range.Dump(s, 0); +range.Dump(s->AsRawOstream(), 0); } s->Printf("%c %c%c%c 0x%8.8" PRIx64 " 0x%8.8" PRIx64 " 0x%8.8x ", diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index df31d15e7d59..1297255a38be 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -131,7 +131,7 @@ void DWARFExpression::GetDescription(Stream *s, lldb::DescriptionLevel level, s->PutCString(", "); VMRange addr_range(curr_base_addr + begin_addr_offset, curr_base_addr + end_addr_offset); -addr_range.Dump(s, 0, 8); +addr_range.Dump(s->AsRawOstream(), 0, 8); s->PutChar('{'); lldb::offset_t location_length = m_data.GetU16(); DumpLocation(s, offset, location_length, level, abi); diff --git a/lldb/source/Utility/VMRange.cpp b/lldb/source/Utility/VMRange.cpp index e7c6b0bcccbb..c8c3334138d3 100644 --- a/lldb/source/Utility/VMRange.cpp +++ b/lldb/source/Utility/VMRange.cpp @@ -35,9 +35,10 @@ bool VMRange::ContainsRange(const VMRange::collection , }) != coll.end(); } -void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const { - DumpAddressRange(s->AsRawOstream(), offset + GetBaseAddress(), - offset + GetEndAddress(), addr_width); +void VMRange::Dump(llvm::raw_ostream , lldb::addr_t offset, + uint32_t addr_width) const { + DumpAddressRange(s, offset + GetBaseAddress(), offset + GetEndAddress(), + addr_width); } bool lldb_private::operator==(const VMRange , const VMRange ) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4dac97e - [lldb][NFC] Migrate FileSpec::Dump to raw_ostream
Author: Raphael Isemann Date: 2019-12-06T09:40:42+01:00 New Revision: 4dac97eb1e6563750e682e482e68f29ac076a4f7 URL: https://github.com/llvm/llvm-project/commit/4dac97eb1e6563750e682e482e68f29ac076a4f7 DIFF: https://github.com/llvm/llvm-project/commit/4dac97eb1e6563750e682e482e68f29ac076a4f7.diff LOG: [lldb][NFC] Migrate FileSpec::Dump to raw_ostream Added: Modified: lldb/include/lldb/Utility/FileSpec.h lldb/source/Breakpoint/BreakpointLocation.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/FileSpecList.cpp lldb/source/Core/FormatEntity.cpp lldb/source/Core/Module.cpp lldb/source/Interpreter/OptionValueFileSpecList.cpp lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp lldb/source/Symbol/LineEntry.cpp lldb/source/Symbol/SymbolContext.cpp lldb/source/Utility/FileSpec.cpp lldb/source/Utility/ProcessInfo.cpp Removed: diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h index 61b6209bb3c0..533426671cc6 100644 --- a/lldb/include/lldb/Utility/FileSpec.h +++ b/lldb/include/lldb/Utility/FileSpec.h @@ -211,7 +211,7 @@ class FileSpec { /// /// \param[in] s /// The stream to which to dump the object description. - void Dump(Stream *s) const; + void Dump(llvm::raw_ostream ) const; Style GetPathStyle() const; diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index e6d7d85f9060..7f08b08c6055 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -519,7 +519,7 @@ void BreakpointLocation::GetDescription(Stream *s, if (sc.module_sp) { s->EOL(); s->Indent("module = "); -sc.module_sp->GetFileSpec().Dump(s); +sc.module_sp->GetFileSpec().Dump(s->AsRawOstream()); } if (sc.comp_unit != nullptr) { diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index ac3188740234..345c325563f0 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1349,7 +1349,7 @@ static void DumpFullpath(Stream , const FileSpec *file_spec_ptr, strm.Printf("%-*s", width, fullpath.c_str()); return; } else { - file_spec_ptr->Dump(); + file_spec_ptr->Dump(strm.AsRawOstream()); return; } } diff --git a/lldb/source/Core/FileSpecList.cpp b/lldb/source/Core/FileSpecList.cpp index 95133faf7502..6651324fa362 100644 --- a/lldb/source/Core/FileSpecList.cpp +++ b/lldb/source/Core/FileSpecList.cpp @@ -47,7 +47,7 @@ void FileSpecList::Clear() { m_files.clear(); } void FileSpecList::Dump(Stream *s, const char *separator_cstr) const { collection::const_iterator pos, end = m_files.end(); for (pos = m_files.begin(); pos != end; ++pos) { -pos->Dump(s); +pos->Dump(s->AsRawOstream()); if (separator_cstr && ((pos + 1) != end)) s->PutCString(separator_cstr); } diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 81ad6d127f04..beab026e67aa 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -2310,7 +2310,7 @@ bool FormatEntity::FormatFileSpec(const FileSpec _spec, Stream , llvm::StringRef variable_name, llvm::StringRef variable_format) { if (variable_name.empty() || variable_name.equals(".fullpath")) { -file_spec.Dump(); +file_spec.Dump(s.AsRawOstream()); return true; } else if (variable_name.equals(".basename")) { s.PutCString(file_spec.GetFilename().AsCString("")); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index cc4eea674170..5bb6a55457dd 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1511,7 +1511,7 @@ bool Module::LoadScriptingResourceInTarget(Target *target, Status , return false; } StreamString scripting_stream; -scripting_fspec.Dump(_stream); +scripting_fspec.Dump(scripting_stream.AsRawOstream()); const bool can_reload = true; const bool init_lldb_globals = false; bool did_load = script_interpreter->LoadScriptingModule( diff --git a/lldb/source/Interpreter/OptionValueFileSpecList.cpp b/lldb/source/Interpreter/OptionValueFileSpecList.cpp index 1a9d3c9ecb87..f2367b1941c9 100644 --- a/lldb/source/Interpreter/OptionValueFileSpecList.cpp +++ b/lldb/source/Interpreter/OptionValueFileSpecList.cpp @@ -33,7 +33,7 @@ void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx, strm.Indent(); strm.Printf("[%u]: ", i);
[Lldb-commits] [lldb] 1462f5a - [lldb][NFC] Move Address and AddressRange functions out of Stream and let them take raw_ostream
Author: Raphael Isemann Date: 2019-12-05T14:41:33+01:00 New Revision: 1462f5a4c138bb20f38a579a29d12ab4e5fb6191 URL: https://github.com/llvm/llvm-project/commit/1462f5a4c138bb20f38a579a29d12ab4e5fb6191 DIFF: https://github.com/llvm/llvm-project/commit/1462f5a4c138bb20f38a579a29d12ab4e5fb6191.diff LOG: [lldb][NFC] Move Address and AddressRange functions out of Stream and let them take raw_ostream Summary: Yet another step on the long road towards getting rid of lldb's Stream class. We probably should just make this some kind of member of Address/AddressRange, but it seems quite often we just push in random integers in there and this is just about getting rid of Stream and not improving arbitrary APIs. I had to rename another `DumpAddress` function in FormatEntity that is dumping the content of an address to make Clang happy. Reviewers: labath Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71052 Added: Modified: lldb/include/lldb/Utility/Stream.h lldb/source/Core/Address.cpp lldb/source/Core/AddressRange.cpp lldb/source/Core/DumpDataExtractor.cpp lldb/source/Core/FormatEntity.cpp lldb/source/Expression/DWARFExpression.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp lldb/source/Symbol/Block.cpp lldb/source/Target/ThreadPlanRunToAddress.cpp lldb/source/Target/ThreadPlanStepInRange.cpp lldb/source/Target/ThreadPlanStepInstruction.cpp lldb/source/Target/ThreadPlanStepOverRange.cpp lldb/source/Target/ThreadPlanStepThrough.cpp lldb/source/Utility/Stream.cpp lldb/source/Utility/VMRange.cpp lldb/unittests/Utility/StreamTest.cpp Removed: diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h index a3a33178086e..18a16a3461c1 100644 --- a/lldb/include/lldb/Utility/Stream.h +++ b/lldb/include/lldb/Utility/Stream.h @@ -222,47 +222,6 @@ class Stream { Stream <<(int32_t sval) = delete; Stream <<(int64_t sval) = delete; - /// Output an address value to this stream. - /// - /// Put an address \a addr out to the stream with optional \a prefix and \a - /// suffix strings. - /// - /// \param[in] addr - /// An address value. - /// - /// \param[in] addr_size - /// Size in bytes of the address, used for formatting. - /// - /// \param[in] prefix - /// A prefix C string. If nullptr, no prefix will be output. - /// - /// \param[in] suffix - /// A suffix C string. If nullptr, no suffix will be output. - void Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, - const char *suffix = nullptr); - - /// Output an address range to this stream. - /// - /// Put an address range \a lo_addr - \a hi_addr out to the stream with - /// optional \a prefix and \a suffix strings. - /// - /// \param[in] lo_addr - /// The start address of the address range. - /// - /// \param[in] hi_addr - /// The end address of the address range. - /// - /// \param[in] addr_size - /// Size in bytes of the address, used for formatting. - /// - /// \param[in] prefix - /// A prefix C string. If nullptr, no prefix will be output. - /// - /// \param[in] suffix - /// A suffix C string. If nullptr, no suffix will be output. - void AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, -const char *prefix = nullptr, const char *suffix = nullptr); - /// Output a C string to the stream. /// /// Print a C string \a cstr to the stream. @@ -452,6 +411,54 @@ class Stream { RawOstreamForward m_forwarder; }; +/// Output an address value to this stream. +/// +/// Put an address \a addr out to the stream with optional \a prefix and \a +/// suffix strings. +/// +/// \param[in] s +/// The output stream. +/// +/// \param[in] addr +/// An address value. +/// +/// \param[in] addr_size +/// Size in bytes of the address, used for formatting. +/// +/// \param[in] prefix +/// A prefix C string. If nullptr, no prefix will be output. +/// +/// \param[in] suffix +/// A suffix C string. If nullptr, no suffix will be output. +void DumpAddress(llvm::raw_ostream , uint64_t addr, uint32_t addr_size, + const char *prefix = nullptr, const char *suffix = nullptr); + +/// Output an address range to this stream. +/// +/// Put an address range \a lo_addr - \a hi_addr out to the stream with +/// optional \a prefix and \a suffix strings. +/// +/// \param[in] s +/// The output stream. +/// +/// \param[in] lo_addr +/// The start address of the address range. +/// +/// \param[in] hi_addr +/// The end address of the address range. +/// +/// \param[in] addr_size +/// Size in bytes of the address, used for formatting. +/// +/// \param[in] prefix
[Lldb-commits] [lldb] 5e71356 - [lldb] Fix macOS build by replacing nullptr with FileSpec()
Author: Raphael Isemann Date: 2019-12-04T14:37:10+01:00 New Revision: 5e713563934eadb48b4830ad019bdb91f1d89150 URL: https://github.com/llvm/llvm-project/commit/5e713563934eadb48b4830ad019bdb91f1d89150 DIFF: https://github.com/llvm/llvm-project/commit/5e713563934eadb48b4830ad019bdb91f1d89150.diff LOG: [lldb] Fix macOS build by replacing nullptr with FileSpec() Before we had a implicit conversion from nullptr to FileSpec which was thankfully removed. Added: Modified: lldb/source/Host/macosx/objcxx/Host.mm lldb/source/Symbol/LocateSymbolFileMacOSX.cpp Removed: diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm index 8c7393739bc6..03880ff433bd 100644 --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -1130,7 +1130,7 @@ static Status LaunchProcessPosixSpawn(const char *exe_path, // --arch as part of the shell invocation // to do that job on OSX. - if (launch_info.GetShell() == nullptr) { + if (launch_info.GetShell() == FileSpec()) { // We don't need to do this for ARM, and we really shouldn't now that we // have multiple CPU subtypes and no posix_spawnattr call that allows us // to set which CPU subtype to launch... diff --git a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp index 74718a8c5e30..5ee632ec2077 100644 --- a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp +++ b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp @@ -595,7 +595,7 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec _spec, } Status error = Host::RunShellCommand( command.GetData(), -NULL,// current working directory +FileSpec(), // current working directory _status,// Exit status , // Signal int * _output, // Command output ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4d37f18 - [lldb][NFC] Extract single member parsing out of DWARFASTParserClang::ParseChildMembers
Author: Raphael Isemann Date: 2019-12-04T10:05:40+01:00 New Revision: 4d37f18b29cc3fd1abd336ec10baca17694d035f URL: https://github.com/llvm/llvm-project/commit/4d37f18b29cc3fd1abd336ec10baca17694d035f DIFF: https://github.com/llvm/llvm-project/commit/4d37f18b29cc3fd1abd336ec10baca17694d035f.diff LOG: [lldb][NFC] Extract single member parsing out of DWARFASTParserClang::ParseChildMembers ParseChildMembers does a few things, only one part is actually parsing a single member. This extracts the member parsing logic into its own function. This commit just moves the code as-is into its own function and forwards the parameters/ local variables to it, which means it should be NFC. The only actual changes to the code are replacing 'break's (and one very curious 'continue' that behaves like a 'break') with 'return's. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index ca1db03b02fa..09f5b28449cb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2448,493 +2448,500 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit _unit, return nullptr; } -bool DWARFASTParserClang::ParseChildMembers( -const DWARFDIE _die, CompilerType _clang_type, -const LanguageType class_language, -std::vector> _classes, +void DWARFASTParserClang::ParseSingleMember( +const DWARFDIE , const DWARFDIE _die, +lldb_private::CompilerType _clang_type, +const lldb::LanguageType class_language, std::vector _accessibilities, -std::vector _function_dies, -DelayedPropertyList _properties, AccessType _accessibility, -bool _a_class, ClangASTImporter::LayoutInfo _info) { - if (!parent_die) -return false; - +lldb::AccessType _accessibility, +DelayedPropertyList _properties, +lldb_private::ClangASTImporter::LayoutInfo _info, +BitfieldInfo _field_info) { + ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule(); + const dw_tag_t tag = die.Tag(); // Get the parent byte size so we can verify any members will fit const uint64_t parent_byte_size = parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX); const uint64_t parent_bit_size = parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8; - BitfieldInfo last_field_info; - - ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule(); - ClangASTContext *ast = - llvm::dyn_cast_or_null(class_clang_type.GetTypeSystem()); - if (ast == nullptr) -return false; - - for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); - die = die.GetSibling()) { -dw_tag_t tag = die.Tag(); - -switch (tag) { -case DW_TAG_member: -case DW_TAG_APPLE_property: { - DWARFAttributes attributes; - const size_t num_attributes = die.GetAttributes(attributes); - if (num_attributes > 0) { -const char *name = nullptr; -const char *prop_name = nullptr; -const char *prop_getter_name = nullptr; -const char *prop_setter_name = nullptr; -uint32_t prop_attributes = 0; - -bool is_artificial = false; -DWARFFormValue encoding_form; -AccessType accessibility = eAccessNone; -uint32_t member_byte_offset = -(parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX; -llvm::Optional byte_size; -int64_t bit_offset = 0; -uint64_t data_bit_offset = UINT64_MAX; -size_t bit_size = 0; -bool is_external = -false; // On DW_TAG_members, this means the member is static -uint32_t i; -for (i = 0; i < num_attributes && !is_artificial; ++i) { - const dw_attr_t attr = attributes.AttributeAtIndex(i); - DWARFFormValue form_value; - if (attributes.ExtractFormValueAtIndex(i, form_value)) { -switch (attr) { -case DW_AT_name: - name = form_value.AsCString(); - break; -case DW_AT_type: - encoding_form = form_value; - break; -case DW_AT_bit_offset: - bit_offset = form_value.Signed(); - break; -case DW_AT_bit_size: - bit_size = form_value.Unsigned(); - break; -case DW_AT_byte_size: - byte_size = form_value.Unsigned(); - break; -case DW_AT_data_bit_offset: - data_bit_offset = form_value.Unsigned(); - break; -case DW_AT_data_member_location: - if (form_value.BlockData()) { -
[Lldb-commits] [lldb] c4c464f - [lldb][NFC] Migrate to raw_ostream in Module::GetDescription
Author: Raphael Isemann Date: 2019-12-04T09:35:50+01:00 New Revision: c4c464f8a5025ad59733723e1ba1900837760078 URL: https://github.com/llvm/llvm-project/commit/c4c464f8a5025ad59733723e1ba1900837760078 DIFF: https://github.com/llvm/llvm-project/commit/c4c464f8a5025ad59733723e1ba1900837760078.diff LOG: [lldb][NFC] Migrate to raw_ostream in Module::GetDescription Added: Modified: lldb/include/lldb/Core/Module.h lldb/source/API/SBModule.cpp lldb/source/Core/Module.cpp lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/source/Target/Target.cpp Removed: diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index bb6c9bdad760..2af18c83f23a 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -190,7 +190,7 @@ class Module : public std::enable_shared_from_this, lldb::ModuleSP CalculateSymbolContextModule() override; void - GetDescription(Stream *s, + GetDescription(llvm::raw_ostream , lldb::DescriptionLevel level = lldb::eDescriptionLevelFull); /// Get the module path and object name. diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 7ac189bb4273..4e9dfb0c1e62 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -245,7 +245,7 @@ bool SBModule::GetDescription(SBStream ) { ModuleSP module_sp(GetSP()); if (module_sp) { -module_sp->GetDescription(); +module_sp->GetDescription(strm.AsRawOstream()); } else strm.PutCString("No value"); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 360c8c134546..a8a92bb5b1fa 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1061,34 +1061,35 @@ std::string Module::GetSpecificationDescription() const { return spec; } -void Module::GetDescription(Stream *s, lldb::DescriptionLevel level) { +void Module::GetDescription(llvm::raw_ostream , +lldb::DescriptionLevel level) { std::lock_guard guard(m_mutex); if (level >= eDescriptionLevelFull) { if (m_arch.IsValid()) - s->Printf("(%s) ", m_arch.GetArchitectureName()); + s << llvm::formatv("({0}) ", m_arch.GetArchitectureName()); } if (level == eDescriptionLevelBrief) { const char *filename = m_file.GetFilename().GetCString(); if (filename) - s->PutCString(filename); + s << filename; } else { char path[PATH_MAX]; if (m_file.GetPath(path, sizeof(path))) - s->PutCString(path); + s << path; } const char *object_name = m_object_name.GetCString(); if (object_name) -s->Printf("(%s)", object_name); +s << llvm::formatv("({0})", object_name); } void Module::ReportError(const char *format, ...) { if (format && format[0]) { StreamString strm; strm.PutCString("error: "); -GetDescription(, lldb::eDescriptionLevelBrief); +GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief); strm.PutChar(' '); va_list args; va_start(args, format); @@ -1119,7 +1120,7 @@ void Module::ReportErrorIfModifyDetected(const char *format, ...) { if (format) { StreamString strm; strm.PutCString("error: the object file "); -GetDescription(, lldb::eDescriptionLevelFull); +GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull); strm.PutCString(" has been modified\n"); va_list args; @@ -1145,7 +1146,7 @@ void Module::ReportWarning(const char *format, ...) { if (format && format[0]) { StreamString strm; strm.PutCString("warning: "); -GetDescription(, lldb::eDescriptionLevelFull); +GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull); strm.PutChar(' '); va_list args; @@ -1166,7 +1167,7 @@ void Module::ReportWarning(const char *format, ...) { void Module::LogMessage(Log *log, const char *format, ...) { if (log != nullptr) { StreamString log_message; -GetDescription(_message, lldb::eDescriptionLevelFull); +GetDescription(log_message.AsRawOstream(), lldb::eDescriptionLevelFull); log_message.PutCString(": "); va_list args; va_start(args, format); @@ -1179,7 +1180,7 @@ void Module::LogMessage(Log *log, const char *format, ...) { void Module::LogMessageVerboseBacktrace(Log *log, const char *format, ...) { if (log != nullptr) { StreamString log_message; -GetDescription(_message, lldb::eDescriptionLevelFull); +GetDescription(log_message.AsRawOstream(), lldb::eDescriptionLevelFull); log_message.PutCString(": "); va_list args; va_start(args, format); diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index 654585cb35eb..fb8b48cc108b 100644 ---
[Lldb-commits] [lldb] 2f1e7b3 - [lldb][NFC] Migrate to raw_ostream in ArchSpec::DumpTriple
Author: Raphael Isemann Date: 2019-12-04T08:28:52+01:00 New Revision: 2f1e7b3d01e176e912477d52847c19d3847a43a0 URL: https://github.com/llvm/llvm-project/commit/2f1e7b3d01e176e912477d52847c19d3847a43a0 DIFF: https://github.com/llvm/llvm-project/commit/2f1e7b3d01e176e912477d52847c19d3847a43a0.diff LOG: [lldb][NFC] Migrate to raw_ostream in ArchSpec::DumpTriple Reviewers: labath, davide Reviewed By: davide Subscribers: clayborg, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70979 Added: Modified: lldb/include/lldb/Core/ModuleSpec.h lldb/include/lldb/Utility/ArchSpec.h lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Target/Platform.cpp lldb/source/Target/TargetList.cpp lldb/source/Utility/ArchSpec.cpp lldb/source/Utility/ProcessInfo.cpp Removed: diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h index 651d0dc869bc..26be59e3f4ae 100644 --- a/lldb/include/lldb/Core/ModuleSpec.h +++ b/lldb/include/lldb/Core/ModuleSpec.h @@ -207,7 +207,7 @@ class ModuleSpec { if (dumped_something) strm.PutCString(", "); strm.Printf("arch = "); - m_arch.DumpTriple(strm); + m_arch.DumpTriple(strm.AsRawOstream()); dumped_something = true; } if (m_uuid.IsValid()) { diff --git a/lldb/include/lldb/Utility/ArchSpec.h b/lldb/include/lldb/Utility/ArchSpec.h index ae7958376832..15e2fdb10c32 100644 --- a/lldb/include/lldb/Utility/ArchSpec.h +++ b/lldb/include/lldb/Utility/ArchSpec.h @@ -433,7 +433,7 @@ class ArchSpec { /// \return A triple describing this ArchSpec. const llvm::Triple () const { return m_triple; } - void DumpTriple(Stream ) const; + void DumpTriple(llvm::raw_ostream ) const; /// Architecture triple setter. /// diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 9f4e58e55e5d..ac3188740234 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -78,7 +78,7 @@ static void DumpTargetInfo(uint32_t target_idx, Target *target, uint32_t properties = 0; if (target_arch.IsValid()) { strm.Printf("%sarch=", properties++ > 0 ? ", " : " ( "); -target_arch.DumpTriple(strm); +target_arch.DumpTriple(strm.AsRawOstream()); properties++; } PlatformSP platform_sp(target->GetPlatform()); @@ -1291,7 +1291,7 @@ static void DumpModuleArchitecture(Stream , Module *module, StreamString arch_strm; if (full_triple) - module->GetArchitecture().DumpTriple(arch_strm); + module->GetArchitecture().DumpTriple(arch_strm.AsRawOstream()); else arch_strm.PutCString(module->GetArchitecture().GetArchitectureName()); std::string arch_str = arch_strm.GetString(); diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index c9849a9e5f09..aaf48f35f921 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -406,7 +406,7 @@ void Platform::GetStatus(Stream ) { if (arch.IsValid()) { if (!arch.GetTriple().str().empty()) { strm.Printf("Triple: "); - arch.DumpTriple(strm); + arch.DumpTriple(strm.AsRawOstream()); strm.EOL(); } } diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index 7c7a36e97bbf..ebd02a504d09 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -144,9 +144,9 @@ Status TargetList::CreateTargetInternal( StreamString platform_arch_strm; StreamString module_arch_strm; - platform_arch.DumpTriple(platform_arch_strm); + platform_arch.DumpTriple(platform_arch_strm.AsRawOstream()); matching_module_spec.GetArchitecture().DumpTriple( - module_arch_strm); + module_arch_strm.AsRawOstream()); error.SetErrorStringWithFormat( "the specified architecture '%s' is not compatible with '%s' " "in '%s'", diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index 38f6752b0348..2bebecb2c677 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -1450,17 +1450,17 @@ bool ArchSpec::IsAlwaysThumbInstructions() const { return false; } -void ArchSpec::DumpTriple(Stream ) const { +void ArchSpec::DumpTriple(llvm::raw_ostream ) const { const llvm::Triple = GetTriple(); llvm::StringRef arch_str = triple.getArchName(); llvm::StringRef vendor_str = triple.getVendorName(); llvm::StringRef os_str = triple.getOSName(); llvm::StringRef environ_str = triple.getEnvironmentName(); - s.Printf("%s-%s-%s", arch_str.empty() ? "*" : arch_str.str().c_str(), - vendor_str.empty() ? "*" :
[Lldb-commits] [lldb] 16c0653 - [lldb][NFC] Extract searching for function SymbolContexts out of ClangExpressionDeclMap::LookupFunction
Author: Raphael Isemann Date: 2019-12-03T12:33:24+01:00 New Revision: 16c0653db1150c849bb25f0547abb64349234394 URL: https://github.com/llvm/llvm-project/commit/16c0653db1150c849bb25f0547abb64349234394 DIFF: https://github.com/llvm/llvm-project/commit/16c0653db1150c849bb25f0547abb64349234394.diff LOG: [lldb][NFC] Extract searching for function SymbolContexts out of ClangExpressionDeclMap::LookupFunction This code was just creating a new SymbolContextList with any found functions in the front and orders them by how close they are to the current frame. This refactors this code into its own function to make this more obvious. Doesn't do any other changes to the code, so this is NFC. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 22966e8023d6..fc25a2e72e3b 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1177,6 +1177,104 @@ bool ClangExpressionDeclMap::LookupLocalVariable( return variable_found; } +/// Structure to hold the info needed when comparing function +/// declarations. +namespace { +struct FuncDeclInfo { + ConstString m_name; + CompilerType m_copied_type; + uint32_t m_decl_lvl; + SymbolContext m_sym_ctx; +}; +} // namespace + +SymbolContextList ClangExpressionDeclMap::SearchFunctionsInSymbolContexts( +const SymbolContextList _list, +const CompilerDeclContext _decl_context) { + // First, symplify things by looping through the symbol contexts to + // remove unwanted functions and separate out the functions we want to + // compare and prune into a separate list. Cache the info needed about + // the function declarations in a vector for efficiency. + uint32_t num_indices = sc_list.GetSize(); + SymbolContextList sc_sym_list; + std::vector decl_infos; + decl_infos.reserve(num_indices); + clang::DeclContext *frame_decl_ctx = + (clang::DeclContext *)frame_decl_context.GetOpaqueDeclContext(); + ClangASTContext *ast = llvm::dyn_cast_or_null( + frame_decl_context.GetTypeSystem()); + + for (uint32_t index = 0; index < num_indices; ++index) { +FuncDeclInfo fdi; +SymbolContext sym_ctx; +sc_list.GetContextAtIndex(index, sym_ctx); + +// We don't know enough about symbols to compare them, but we should +// keep them in the list. +Function *function = sym_ctx.function; +if (!function) { + sc_sym_list.Append(sym_ctx); + continue; +} +// Filter out functions without declaration contexts, as well as +// class/instance methods, since they'll be skipped in the code that +// follows anyway. +CompilerDeclContext func_decl_context = function->GetDeclContext(); +if (!func_decl_context || +func_decl_context.IsClassMethod(nullptr, nullptr, nullptr)) + continue; +// We can only prune functions for which we can copy the type. +CompilerType func_clang_type = function->GetType()->GetFullCompilerType(); +CompilerType copied_func_type = GuardedCopyType(func_clang_type); +if (!copied_func_type) { + sc_sym_list.Append(sym_ctx); + continue; +} + +fdi.m_sym_ctx = sym_ctx; +fdi.m_name = function->GetName(); +fdi.m_copied_type = copied_func_type; +fdi.m_decl_lvl = LLDB_INVALID_DECL_LEVEL; +if (fdi.m_copied_type && func_decl_context) { + // Call CountDeclLevels to get the number of parent scopes we have + // to look through before we find the function declaration. When + // comparing functions of the same type, the one with a lower count + // will be closer to us in the lookup scope and shadows the other. + clang::DeclContext *func_decl_ctx = + (clang::DeclContext *)func_decl_context.GetOpaqueDeclContext(); + fdi.m_decl_lvl = ast->CountDeclLevels(frame_decl_ctx, func_decl_ctx, +_name, _copied_type); +} +decl_infos.emplace_back(fdi); + } + + // Loop through the functions in our cache looking for matching types, + // then compare their scope levels to see which is closer. + std::multimap matches; + for (const FuncDeclInfo : decl_infos) { +const CompilerType t = fdi.m_copied_type; +auto q = matches.find(t); +if (q != matches.end()) { + if (q->second->m_decl_lvl > fdi.m_decl_lvl) +// This function is closer; remove the old set. +matches.erase(t); + else if (q->second->m_decl_lvl < fdi.m_decl_lvl) +// The functions in our set are closer - skip this one. +continue; +} +matches.insert(std::make_pair(t, )); + } + + // Loop through
[Lldb-commits] [lldb] b37a43d - [lldb] Remove all remaining tabs from TestReturnValue.py
Author: Raphael Isemann Date: 2019-12-03T12:14:40+01:00 New Revision: b37a43d93db8c5afb3b95d803638f0536608779d URL: https://github.com/llvm/llvm-project/commit/b37a43d93db8c5afb3b95d803638f0536608779d DIFF: https://github.com/llvm/llvm-project/commit/b37a43d93db8c5afb3b95d803638f0536608779d.diff LOG: [lldb] Remove all remaining tabs from TestReturnValue.py I assumed this was just a single typo, but it seems we actually have a whole bunch of tabs in this file which cause Python to complain about mixing tabs and spaces. Added: Modified: lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py b/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py index a0f434aad654..e84bbc3c245d 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py @@ -127,7 +127,7 @@ def test_with_python(self): #self.assertTrue(in_float == return_float) if not self.affected_by_radar_34562999() and not self.affected_by_pr44132(): - self.return_and_test_struct_value("return_one_int") +self.return_and_test_struct_value("return_one_int") self.return_and_test_struct_value("return_two_int") self.return_and_test_struct_value("return_three_int") self.return_and_test_struct_value("return_four_int") @@ -185,12 +185,12 @@ def test_vector_values(self): self.return_and_test_struct_value("return_vector_size_float32_8") self.return_and_test_struct_value("return_vector_size_float32_16") - if not self.affected_by_pr44132(): - self.return_and_test_struct_value("return_vector_size_float32_32") +if not self.affected_by_pr44132(): +self.return_and_test_struct_value("return_vector_size_float32_32") self.return_and_test_struct_value("return_ext_vector_size_float32_2") self.return_and_test_struct_value("return_ext_vector_size_float32_4") - if not self.affected_by_pr44132(): - self.return_and_test_struct_value("return_ext_vector_size_float32_8") +if not self.affected_by_pr44132(): + self.return_and_test_struct_value("return_ext_vector_size_float32_8") # limit the nested struct and class tests to only x86_64 @skipIf(archs=no_match(['x86_64'])) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4821d2a - [lldb][NFC] Test going up/down one line in the multiline expression editor
Author: Raphael Isemann Date: 2019-12-03T12:06:40+01:00 New Revision: 4821d2a014e02b14223676c98b2ef5244eb91da8 URL: https://github.com/llvm/llvm-project/commit/4821d2a014e02b14223676c98b2ef5244eb91da8 DIFF: https://github.com/llvm/llvm-project/commit/4821d2a014e02b14223676c98b2ef5244eb91da8.diff LOG: [lldb][NFC] Test going up/down one line in the multiline expression editor Added: lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py Modified: Removed: diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py new file mode 100644 index ..712111209215 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py @@ -0,0 +1,67 @@ +""" +Tests navigating in the multiline expression editor. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test.lldbpexpect import PExpectTest + +class TestCase(PExpectTest): + +mydir = TestBase.compute_mydir(__file__) + +arrow_up = "\033[A" +arrow_down = "\033[B" + +# PExpect uses many timeouts internally and doesn't play well +# under ASAN on a loaded machine.. +@skipIfAsan +def test_nav_arrow_up(self): +"""Tests that we can navigate back to the previous line with the up arrow""" +self.launch() + +# Start multiline expression mode by just running 'expr' +self.child.sendline("expr") +self.child.expect_exact("terminate with an empty line to evaluate") +# Create a simple integer expression '123' and press enter. +self.child.send("123\n") +# We should see the prompt for the second line of our expression. +self.child.expect_exact("2: ") +# Go back to the first line and change 123 to 124. +# Then press enter twice to evaluate our expression. +self.child.send(self.arrow_up + "\b4\n\n") +# The result of our expression should be 124 (our edited expression) +# and not 123 (the one we initially typed). +self.child.expect_exact("(int) $0 = 124") + +self.quit() + +@skipIfAsan +def test_nav_arrow_down(self): +"""Tests that we can navigate to the next line with the down arrow""" +self.launch() + +# Start multiline expression mode by just running 'expr' +self.child.sendline("expr") +self.child.expect_exact("terminate with an empty line to evaluate") +# Create a simple integer expression '111' and press enter. +self.child.send("111\n") +# We should see the prompt for the second line of our expression. +self.child.expect_exact("2: ") +# Create another simple integer expression '222'. +self.child.send("222") +# Go back to the first line and change '111' to '111+' to make +# an addition operation that spans two lines. We need to go up to +# test that we can go back down again. +self.child.send(self.arrow_up + "+") +# Go back down to our second line and change '222' to '223' +# so that the full expression is now '111+\n223'. +# Then press enter twice to evaluate the expression. +self.child.send(self.arrow_down + "\b3\n\n") +# The result of our expression '111 + 223' should be '334'. +# If the expression is '333' then arrow down failed to get +# us back to the second line. +self.child.expect_exact("(int) $0 = 334") + +self.quit() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 46d0ec3 - [lldb] Remove tab from TestReturnValue.py
Author: Raphael Isemann Date: 2019-12-03T11:44:24+01:00 New Revision: 46d0ec3a803021281c8d868b1487d2d5cd06f274 URL: https://github.com/llvm/llvm-project/commit/46d0ec3a803021281c8d868b1487d2d5cd06f274 DIFF: https://github.com/llvm/llvm-project/commit/46d0ec3a803021281c8d868b1487d2d5cd06f274.diff LOG: [lldb] Remove tab from TestReturnValue.py Mixing tabs and spaces makes Python exit with this error: File "llvm/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py", line 23 return (self.getArchitecture() == "aarch64" and self.getPlatform() == "linux") ^ TabError: inconsistent use of tabs and spaces in indentation Added: Modified: lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py b/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py index b326c96325fa..a0f434aad654 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py @@ -20,7 +20,7 @@ def affected_by_pr33042(self): "aarch64" and self.getPlatform() == "linux") def affected_by_pr44132(self): - return (self.getArchitecture() == "aarch64" and self.getPlatform() == "linux") +return (self.getArchitecture() == "aarch64" and self.getPlatform() == "linux") # ABIMacOSX_arm can't fetch simple values inside a structure def affected_by_radar_34562999(self): ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 315600f - [lldb][NFC] Remove ThreadSafeSTLVector and ThreadSafeSTLMap and their use in ValueObjectSynthetic
Author: Raphael Isemann Date: 2019-12-03T09:18:44+01:00 New Revision: 315600f480055f5143aaa245f25bd25221edfa91 URL: https://github.com/llvm/llvm-project/commit/315600f480055f5143aaa245f25bd25221edfa91 DIFF: https://github.com/llvm/llvm-project/commit/315600f480055f5143aaa245f25bd25221edfa91.diff LOG: [lldb][NFC] Remove ThreadSafeSTLVector and ThreadSafeSTLMap and their use in ValueObjectSynthetic Summary: ThreadSafeSTLVector and ThreadSafeSTLMap are not useful for achieving any degree of thread safety in LLDB and should be removed before they are used in more places. They are only used (unsurprisingly incorrectly) in `ValueObjectSynthetic::GetChildAtIndex`, so this patch replaces their use there with a simple mutex with which we guard the related data structures. This doesn't make ValueObjectSynthetic::GetChildAtIndex any more thread-safe, but on the other hand it at least allows us to get rid of the ThreadSafeSTL* data structures without changing the observable behaviour of ValueObjectSynthetic (beside that it is now a few bytes smaller). Reviewers: labath, JDevlieghere, jingham Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70845 Added: Modified: lldb/include/lldb/Core/ValueObjectSyntheticFilter.h lldb/source/Core/ValueObjectSyntheticFilter.cpp Removed: lldb/include/lldb/Core/ThreadSafeSTLMap.h lldb/include/lldb/Core/ThreadSafeSTLVector.h diff --git a/lldb/include/lldb/Core/ThreadSafeSTLMap.h b/lldb/include/lldb/Core/ThreadSafeSTLMap.h deleted file mode 100644 index df0208cd49b3.. --- a/lldb/include/lldb/Core/ThreadSafeSTLMap.h +++ /dev/null @@ -1,128 +0,0 @@ -//===-- ThreadSafeSTLMap.h --*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -#ifndef liblldb_ThreadSafeSTLMap_h_ -#define liblldb_ThreadSafeSTLMap_h_ - -#include -#include - -#include "lldb/lldb-defines.h" - -namespace lldb_private { - -template class ThreadSafeSTLMap { -public: - typedef std::map<_Key, _Tp> collection; - typedef typename collection::iterator iterator; - typedef typename collection::const_iterator const_iterator; - // Constructors and Destructors - ThreadSafeSTLMap() : m_collection(), m_mutex() {} - - ~ThreadSafeSTLMap() {} - - bool IsEmpty() const { -std::lock_guard guard(m_mutex); -return m_collection.empty(); - } - - void Clear() { -std::lock_guard guard(m_mutex); -return m_collection.clear(); - } - - size_t Erase(const _Key ) { -std::lock_guard guard(m_mutex); -return EraseNoLock(key); - } - - size_t EraseNoLock(const _Key ) { return m_collection.erase(key); } - - bool GetValueForKey(const _Key , _Tp ) const { -std::lock_guard guard(m_mutex); -return GetValueForKeyNoLock(key, value); - } - - // Call this if you have already manually locked the mutex using the - // GetMutex() accessor - bool GetValueForKeyNoLock(const _Key , _Tp ) const { -const_iterator pos = m_collection.find(key); -if (pos != m_collection.end()) { - value = pos->second; - return true; -} -return false; - } - - bool GetFirstKeyForValue(const _Tp , _Key ) const { -std::lock_guard guard(m_mutex); -return GetFirstKeyForValueNoLock(value, key); - } - - bool GetFirstKeyForValueNoLock(const _Tp , _Key ) const { -const_iterator pos, end = m_collection.end(); -for (pos = m_collection.begin(); pos != end; ++pos) { - if (pos->second == value) { -key = pos->first; -return true; - } -} -return false; - } - - bool LowerBound(const _Key , _Key _key, _Tp _value, - bool decrement_if_not_equal) const { -std::lock_guard guard(m_mutex); -return LowerBoundNoLock(key, match_key, match_value, -decrement_if_not_equal); - } - - bool LowerBoundNoLock(const _Key , _Key _key, _Tp _value, -bool decrement_if_not_equal) const { -const_iterator pos = m_collection.lower_bound(key); -if (pos != m_collection.end()) { - match_key = pos->first; - if (decrement_if_not_equal && key != match_key && - pos != m_collection.begin()) { ---pos; -match_key = pos->first; - } - match_value = pos->second; - return true; -} -return false; - } - - iterator lower_bound_unsafe(const _Key ) { -return m_collection.lower_bound(key); - } - - void SetValueForKey(const _Key , const _Tp ) { -std::lock_guard guard(m_mutex); -SetValueForKeyNoLock(key, value); - } - - // Call this if you have already manually locked the mutex using
[Lldb-commits] [lldb] d62026e - [lldb][NFC] Don't calculate member indices in DWARFASTParserClang::ParseChildMembers
Author: Raphael Isemann Date: 2019-12-02T14:43:40+01:00 New Revision: d62026e2dde1d27c7d1c702f11b0464e1d470d4f URL: https://github.com/llvm/llvm-project/commit/d62026e2dde1d27c7d1c702f11b0464e1d470d4f DIFF: https://github.com/llvm/llvm-project/commit/d62026e2dde1d27c7d1c702f11b0464e1d470d4f.diff LOG: [lldb][NFC] Don't calculate member indices in DWARFASTParserClang::ParseChildMembers We keep counting members and then don't do anything with the computed result. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 43030c62cb40..ca1db03b02fa 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2465,7 +2465,6 @@ bool DWARFASTParserClang::ParseChildMembers( const uint64_t parent_bit_size = parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8; - uint32_t member_idx = 0; BitfieldInfo last_field_info; ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule(); @@ -2935,7 +2934,6 @@ bool DWARFASTParserClang::ParseChildMembers( } } } - ++member_idx; } break; case DW_TAG_subprogram: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4f728bf - [lldb][NFC] Use raw_ostream instead of Stream in Baton::GetDescription
Author: Raphael Isemann Date: 2019-12-02T13:27:21+01:00 New Revision: 4f728bfc13c45bc744bfdbfc3086bed74a8cbb4c URL: https://github.com/llvm/llvm-project/commit/4f728bfc13c45bc744bfdbfc3086bed74a8cbb4c DIFF: https://github.com/llvm/llvm-project/commit/4f728bfc13c45bc744bfdbfc3086bed74a8cbb4c.diff LOG: [lldb][NFC] Use raw_ostream instead of Stream in Baton::GetDescription Removing raw_ostream here is getting us closer to removing LLDB's Stream class. Added: Modified: lldb/include/lldb/Breakpoint/BreakpointOptions.h lldb/include/lldb/Breakpoint/WatchpointOptions.h lldb/include/lldb/Utility/Baton.h lldb/source/Breakpoint/BreakpointOptions.cpp lldb/source/Breakpoint/WatchpointOptions.cpp lldb/source/Commands/CommandObjectBreakpointCommand.cpp lldb/source/Commands/CommandObjectWatchpointCommand.cpp lldb/source/Utility/Baton.cpp Removed: diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h b/lldb/include/lldb/Breakpoint/BreakpointOptions.h index 9e02afff5227..2c52170eb9f6 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h +++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h @@ -88,7 +88,8 @@ friend class Breakpoint; explicit CommandBaton(std::unique_ptr Data) : TypedBaton(std::move(Data)) {} -void GetDescription(Stream *s, lldb::DescriptionLevel level) const override; +void GetDescription(llvm::raw_ostream , lldb::DescriptionLevel level, +unsigned indentation) const override; }; typedef std::shared_ptr CommandBatonSP; diff --git a/lldb/include/lldb/Breakpoint/WatchpointOptions.h b/lldb/include/lldb/Breakpoint/WatchpointOptions.h index b395dde21901..0dc34d4ebef7 100644 --- a/lldb/include/lldb/Breakpoint/WatchpointOptions.h +++ b/lldb/include/lldb/Breakpoint/WatchpointOptions.h @@ -180,7 +180,8 @@ class WatchpointOptions { CommandBaton(std::unique_ptr Data) : TypedBaton(std::move(Data)) {} -void GetDescription(Stream *s, lldb::DescriptionLevel level) const override; +void GetDescription(llvm::raw_ostream , lldb::DescriptionLevel level, +unsigned indentation) const override; }; protected: diff --git a/lldb/include/lldb/Utility/Baton.h b/lldb/include/lldb/Utility/Baton.h index 4050f2af2bf0..c42867489c65 100644 --- a/lldb/include/lldb/Utility/Baton.h +++ b/lldb/include/lldb/Utility/Baton.h @@ -12,6 +12,8 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" +#include "llvm/Support/raw_ostream.h" + #include namespace lldb_private { @@ -37,8 +39,9 @@ class Baton { virtual void *data() = 0; - virtual void GetDescription(Stream *s, - lldb::DescriptionLevel level) const = 0; + virtual void GetDescription(llvm::raw_ostream , + lldb::DescriptionLevel level, + unsigned indentation) const = 0; }; class UntypedBaton : public Baton { @@ -50,7 +53,8 @@ class UntypedBaton : public Baton { } void *data() override { return m_data; } - void GetDescription(Stream *s, lldb::DescriptionLevel level) const override; + void GetDescription(llvm::raw_ostream , lldb::DescriptionLevel level, + unsigned indentation) const override; void *m_data; // Leave baton public for easy access }; @@ -63,7 +67,8 @@ template class TypedBaton : public Baton { const T *getItem() const { return Item.get(); } void *data() override { return Item.get(); } - void GetDescription(Stream *s, lldb::DescriptionLevel level) const override {} + void GetDescription(llvm::raw_ostream , lldb::DescriptionLevel level, + unsigned indentation) const override {} protected: std::unique_ptr Item; diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp index 0d4c6173c3c5..8fd16f420c04 100644 --- a/lldb/source/Breakpoint/BreakpointOptions.cpp +++ b/lldb/source/Breakpoint/BreakpointOptions.cpp @@ -566,7 +566,8 @@ void BreakpointOptions::GetDescription(Stream *s, if (m_callback_baton_sp.get()) { if (level != eDescriptionLevelBrief) { s->EOL(); - m_callback_baton_sp->GetDescription(s, level); + m_callback_baton_sp->GetDescription(s->AsRawOstream(), level, + s->GetIndentLevel()); } } if (!m_condition_text.empty()) { @@ -578,35 +579,33 @@ void BreakpointOptions::GetDescription(Stream *s, } void BreakpointOptions::CommandBaton::GetDescription( -Stream *s, lldb::DescriptionLevel level) const { +llvm::raw_ostream , lldb::DescriptionLevel level, +unsigned indentation) const { const CommandData *data = getItem(); if (level == eDescriptionLevelBrief) { -s->Printf(", commands = %s", - (data && data->user_source.GetSize() > 0) ? "yes" : "no"); +s << ",
[Lldb-commits] [lldb] f8fb372 - [lldb][NFC] Make Stream's IndentLevel an unsigned integers.
Author: Raphael Isemann Date: 2019-12-02T13:01:26+01:00 New Revision: f8fb3729e9d794f174aa737351235f76e6ac46db URL: https://github.com/llvm/llvm-project/commit/f8fb3729e9d794f174aa737351235f76e6ac46db DIFF: https://github.com/llvm/llvm-project/commit/f8fb3729e9d794f174aa737351235f76e6ac46db.diff LOG: [lldb][NFC] Make Stream's IndentLevel an unsigned integers. We expect it to be always positive values and LLVM/Clang's IndentLevel values are already unsigned integers, so we should do the same. Added: Modified: lldb/include/lldb/Utility/Stream.h lldb/source/Target/Target.cpp lldb/source/Utility/Stream.cpp Removed: diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h index 88cdb88d77ad..9982d8236a65 100644 --- a/lldb/include/lldb/Utility/Stream.h +++ b/lldb/include/lldb/Utility/Stream.h @@ -338,8 +338,8 @@ class Stream { /// Get the current indentation level. /// /// \return - /// The current indentation level as an integer. - int GetIndentLevel() const; + /// The current indentation level. + unsigned GetIndentLevel() const; /// Indent the current line in the stream. /// @@ -353,10 +353,10 @@ class Stream { size_t Indent(llvm::StringRef s); /// Decrement the current indentation level. - void IndentLess(int amount = 2); + void IndentLess(unsigned amount = 2); /// Increment the current indentation level. - void IndentMore(int amount = 2); + void IndentMore(unsigned amount = 2); /// Output an offset value. /// @@ -411,7 +411,7 @@ class Stream { /// /// \param[in] level /// The new indentation level. - void SetIndentLevel(int level); + void SetIndentLevel(unsigned level); /// Output a SLEB128 number to the stream. /// @@ -442,7 +442,7 @@ class Stream { uint32_t m_addr_size; ///< Size of an address in bytes. lldb::ByteOrder m_byte_order; ///< Byte order to use when encoding scalar types. - int m_indent_level; ///< Indention level. + unsigned m_indent_level; ///< Indention level. std::size_t m_bytes_written = 0; ///< Number of bytes written so far. void _PutHex8(uint8_t uvalue, bool add_prefix); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 4b9a1b77ad16..aeb77b7cf676 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3177,7 +3177,7 @@ void Target::StopHook::SetThreadSpecifier(ThreadSpec *specifier) { void Target::StopHook::GetDescription(Stream *s, lldb::DescriptionLevel level) const { - int indent_level = s->GetIndentLevel(); + unsigned indent_level = s->GetIndentLevel(); s->SetIndentLevel(indent_level + 2); diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index 991f7e924d8d..119d1e0f7964 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -185,16 +185,18 @@ Stream ::operator<<(int64_t sval) { } // Get the current indentation level -int Stream::GetIndentLevel() const { return m_indent_level; } +unsigned Stream::GetIndentLevel() const { return m_indent_level; } // Set the current indentation level -void Stream::SetIndentLevel(int indent_level) { m_indent_level = indent_level; } +void Stream::SetIndentLevel(unsigned indent_level) { + m_indent_level = indent_level; +} // Increment the current indentation level -void Stream::IndentMore(int amount) { m_indent_level += amount; } +void Stream::IndentMore(unsigned amount) { m_indent_level += amount; } // Decrement the current indentation level -void Stream::IndentLess(int amount) { +void Stream::IndentLess(unsigned amount) { if (m_indent_level >= amount) m_indent_level -= amount; else ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 160a504 - [lldb][NFC] Add 'breakpoint command list' test
Author: Raphael Isemann Date: 2019-12-02T11:57:55+01:00 New Revision: 160a5045c699ac523eac3c7a1984705c3e86720e URL: https://github.com/llvm/llvm-project/commit/160a5045c699ac523eac3c7a1984705c3e86720e DIFF: https://github.com/llvm/llvm-project/commit/160a5045c699ac523eac3c7a1984705c3e86720e.diff LOG: [lldb][NFC] Add 'breakpoint command list' test The command has zero test coverage and I'll have to touch the code formatting the output commands, so let's start by adding a test for it. Added: lldb/packages/Python/lldbsuite/test/commands/breakpoint/command/list/TestBreakpointCommandList.py lldb/packages/Python/lldbsuite/test/commands/breakpoint/command/list/a.yaml Modified: Removed: diff --git a/lldb/packages/Python/lldbsuite/test/commands/breakpoint/command/list/TestBreakpointCommandList.py b/lldb/packages/Python/lldbsuite/test/commands/breakpoint/command/list/TestBreakpointCommandList.py new file mode 100644 index ..f1a8656a73b5 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/breakpoint/command/list/TestBreakpointCommandList.py @@ -0,0 +1,44 @@ +""" +Test 'breakpoint command list'. +""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +@no_debug_info_test +def test_list_commands(self): +src_dir = self.getSourceDir() +yaml_path = os.path.join(src_dir, "a.yaml") +yaml_base, ext = os.path.splitext(yaml_path) +obj_path = self.getBuildArtifact("main.o") +self.yaml2obj(yaml_path, obj_path) + +# Create a target with the object file we just created from YAML +target = self.dbg.CreateTarget(obj_path) +self.assertTrue(target, VALID_TARGET) + +# Test without any breakpoints. +self.expect("breakpoint command list 1", error=True, substrs=["error: No breakpoints exist for which to list commands"]) + +# Set a breakpoint +self.runCmd("b foo") + +# Check list breakpoint commands for breakpoints that have no commands. +self.expect("breakpoint command list 1", startstr="Breakpoint 1 does not have an associated command.") + +# Add a breakpoint command. +self.runCmd("breakpoint command add -o 'source list' 1") + +# List breakpoint command that we just created. +self.expect("breakpoint command list 1", startstr="""Breakpoint 1: +Breakpoint commands: + source list +""") + +# List breakpoint command with invalid breakpoint ID. +self.expect("breakpoint command list 2", error=True, startstr="error: '2' is not a currently valid breakpoint ID.") diff --git a/lldb/packages/Python/lldbsuite/test/commands/breakpoint/command/list/a.yaml b/lldb/packages/Python/lldbsuite/test/commands/breakpoint/command/list/a.yaml new file mode 100644 index ..1007f60c19ee --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/breakpoint/command/list/a.yaml @@ -0,0 +1,18 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_REL + Machine: EM_X86_64 +Sections: + - Name:.text +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +AddressAlign:0x0010 +Content: 554889E5897DFC5DC3 +Symbols: + - Name:foo +Type:STT_FUNC +Section: .text +Size:0x0009 +... ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 8059188 - [lldb][NFC] Remove unused ClangASTContext::GetBasicType(ConstString)
Author: Raphael Isemann Date: 2019-11-29T14:11:25+01:00 New Revision: 8059188c45f049b52b779d6684ea78b6ef8b168c URL: https://github.com/llvm/llvm-project/commit/8059188c45f049b52b779d6684ea78b6ef8b168c DIFF: https://github.com/llvm/llvm-project/commit/8059188c45f049b52b779d6684ea78b6ef8b168c.diff LOG: [lldb][NFC] Remove unused ClangASTContext::GetBasicType(ConstString) Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/source/Symbol/ClangASTContext.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index a55307ef632d..b2c284282f11 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -152,8 +152,6 @@ class ClangASTContext : public TypeSystem { CompilerType GetBasicType(lldb::BasicType type); - CompilerType GetBasicType(ConstString name); - static lldb::BasicType GetBasicTypeEnumeration(ConstString name); CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(const char *type_name, diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 8428dfe8c4fa..e683a0a9f4be 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -971,11 +971,6 @@ ClangASTContext::GetBasicTypeEnumeration(ConstString name) { return eBasicTypeInvalid; } -CompilerType ClangASTContext::GetBasicType(ConstString name) { - lldb::BasicType basic_type = ClangASTContext::GetBasicTypeEnumeration(name); - return GetBasicType(basic_type); -} - uint32_t ClangASTContext::GetPointerByteSize() { if (m_pointer_byte_size == 0) if (auto size = GetBasicType(lldb::eBasicTypeVoid) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c214c92 - [lldb][NFC] Remove ClangASTContext::GetBuiltinTypeForEncodingAndBitSize overload
Author: Raphael Isemann Date: 2019-11-29T13:57:02+01:00 New Revision: c214c92f3be7c15abc458f23c7be05a5790e6aed URL: https://github.com/llvm/llvm-project/commit/c214c92f3be7c15abc458f23c7be05a5790e6aed DIFF: https://github.com/llvm/llvm-project/commit/c214c92f3be7c15abc458f23c7be05a5790e6aed.diff LOG: [lldb][NFC] Remove ClangASTContext::GetBuiltinTypeForEncodingAndBitSize overload Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Symbol/ClangASTContext.cpp lldb/unittests/Symbol/TestClangASTContext.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 7018f3b71b4f..a55307ef632d 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -150,9 +150,6 @@ class ClangASTContext : public TypeSystem { CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override; - static CompilerType GetBuiltinTypeForEncodingAndBitSize( - clang::ASTContext *ast, lldb::Encoding encoding, uint32_t bit_size); - CompilerType GetBasicType(lldb::BasicType type); CompilerType GetBasicType(ConstString name); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index b33547529deb..22966e8023d6 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1762,8 +1762,8 @@ void ClangExpressionDeclMap::AddOneRegister(NameSearchContext , Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); CompilerType clang_type = - ClangASTContext::GetBuiltinTypeForEncodingAndBitSize( - m_ast_context, reg_info->encoding, reg_info->byte_size * 8); + m_clang_ast_context->GetBuiltinTypeForEncodingAndBitSize( + reg_info->encoding, reg_info->byte_size * 8); if (!clang_type) { LLDB_LOGF(log, " Tried to add a type for %s, but couldn't get one", diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 9988f0615651..8428dfe8c4fa 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -843,77 +843,62 @@ static inline bool QualTypeMatchesBitSize(const uint64_t bit_size, CompilerType ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding, size_t bit_size) { - return ClangASTContext::GetBuiltinTypeForEncodingAndBitSize( - getASTContext(), encoding, bit_size); -} - -CompilerType ClangASTContext::GetBuiltinTypeForEncodingAndBitSize( -ASTContext *ast, Encoding encoding, uint32_t bit_size) { - auto *clang_ast_context = ClangASTContext::GetASTContext(ast); + ASTContext *ast = this->getASTContext(); if (!ast) return CompilerType(); switch (encoding) { case eEncodingInvalid: if (QualTypeMatchesBitSize(bit_size, ast, ast->VoidPtrTy)) - return CompilerType(clang_ast_context, ast->VoidPtrTy.getAsOpaquePtr()); + return CompilerType(this, ast->VoidPtrTy.getAsOpaquePtr()); break; case eEncodingUint: if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy)) - return CompilerType(clang_ast_context, - ast->UnsignedCharTy.getAsOpaquePtr()); + return CompilerType(this, ast->UnsignedCharTy.getAsOpaquePtr()); if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy)) - return CompilerType(clang_ast_context, - ast->UnsignedShortTy.getAsOpaquePtr()); + return CompilerType(this, ast->UnsignedShortTy.getAsOpaquePtr()); if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy)) - return CompilerType(clang_ast_context, - ast->UnsignedIntTy.getAsOpaquePtr()); + return CompilerType(this, ast->UnsignedIntTy.getAsOpaquePtr()); if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongTy)) - return CompilerType(clang_ast_context, - ast->UnsignedLongTy.getAsOpaquePtr()); + return CompilerType(this, ast->UnsignedLongTy.getAsOpaquePtr()); if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongLongTy)) - return CompilerType(clang_ast_context, - ast->UnsignedLongLongTy.getAsOpaquePtr()); + return CompilerType(this, ast->UnsignedLongLongTy.getAsOpaquePtr()); if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedInt128Ty)) - return CompilerType(clang_ast_context, - ast->UnsignedInt128Ty.getAsOpaquePtr()); + return CompilerType(this,
[Lldb-commits] [lldb] bc7f1df - [lldb][NFC] Explicitly ask for a ClangASTContext in ClangASTSource
Author: Raphael Isemann Date: 2019-11-29T13:28:55+01:00 New Revision: bc7f1df6b61a3c8f88f2541ef9ba73f4ee0ee4fe URL: https://github.com/llvm/llvm-project/commit/bc7f1df6b61a3c8f88f2541ef9ba73f4ee0ee4fe DIFF: https://github.com/llvm/llvm-project/commit/bc7f1df6b61a3c8f88f2541ef9ba73f4ee0ee4fe.diff LOG: [lldb][NFC] Explicitly ask for a ClangASTContext in ClangASTSource ClangASTSource currently takes a clang::ASTContext and keeps that around, but a lot of LLDB's functionality for doing operations on a clang::ASTContext is in its ClangASTContext twin class. We currently constantly recompute the respective ClangASTContext from the clang::ASTContext while we instead could just pass and store a ClangASTContext in the ClangASTSource. This also allows us to get rid of a bunch of unreachable error checking for cases where recomputation fails for some reason. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Symbol/ClangASTContext.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 2b484db3a188..51540902e2dc 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -57,10 +57,11 @@ ClangASTSource::ClangASTSource(const lldb::TargetSP ) } } -void ClangASTSource::InstallASTContext(clang::ASTContext _context, +void ClangASTSource::InstallASTContext(ClangASTContext _ast_context, clang::FileManager _manager, bool is_shared_context) { - m_ast_context = _context; + m_ast_context = clang_ast_context.getASTContext(); + m_clang_ast_context = _ast_context; m_file_manager = _manager; if (m_target->GetUseModernTypeLookup()) { // Configure the ExternalASTMerger. The merger needs to be able to import @@ -69,7 +70,7 @@ void ClangASTSource::InstallASTContext(clang::ASTContext _context, // AST contexts. lldbassert(!m_merger_up); -clang::ExternalASTMerger::ImporterTarget target = {ast_context, +clang::ExternalASTMerger::ImporterTarget target = {*m_ast_context, file_manager}; std::vector sources; for (lldb::ModuleSP module_sp : m_target->GetImages().Modules()) { @@ -132,7 +133,7 @@ void ClangASTSource::InstallASTContext(clang::ASTContext _context, m_merger_up = std::make_unique(target, sources); } else { -m_ast_importer_sp->InstallMapCompleter(_context, *this); +m_ast_importer_sp->InstallMapCompleter(m_ast_context, *this); } } @@ -775,7 +776,7 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext ) { } clang::Sema *ClangASTSource::getSema() { - return ClangASTContext::GetASTContext(m_ast_context)->getSema(); + return m_clang_ast_context->getSema(); } bool ClangASTSource::IgnoreName(const ConstString name, @@ -2058,8 +2059,7 @@ CompilerType ClangASTSource::GuardedCopyType(const CompilerType _type) { // seems to be generating bad types on occasion. return CompilerType(); - return CompilerType(ClangASTContext::GetASTContext(m_ast_context), - copied_qual_type.getAsOpaquePtr()); + return CompilerType(m_clang_ast_context, copied_qual_type.getAsOpaquePtr()); } clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType ) { @@ -2186,10 +2186,9 @@ clang::NamedDecl *NameSearchContext::AddGenericFunDecl() { ArrayRef(), // argument types proto_info)); - return AddFunDecl( - CompilerType(ClangASTContext::GetASTContext(m_ast_source.m_ast_context), - generic_function_type.getAsOpaquePtr()), - true); + return AddFunDecl(CompilerType(m_ast_source.m_clang_ast_context, + generic_function_type.getAsOpaquePtr()), +true); } clang::NamedDecl * diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h index d8e784f49b10..194233e4a028 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -57,7 +57,7 @@ class ClangASTSource : public ClangExternalASTSourceCommon, } void MaterializeVisibleDecls(const clang::DeclContext *DC) { return; } - void InstallASTContext(clang::ASTContext _context, + void InstallASTContext(ClangASTContext _context, clang::FileManager _manager, bool
[Lldb-commits] [lldb] 76016f9 - [lldb][NFC] Early exit in ClangASTContext::CreateInstance
Author: Raphael Isemann Date: 2019-11-29T12:49:33+01:00 New Revision: 76016f9b3a9acdba7728561a7ddfb48b1245dfa7 URL: https://github.com/llvm/llvm-project/commit/76016f9b3a9acdba7728561a7ddfb48b1245dfa7 DIFF: https://github.com/llvm/llvm-project/commit/76016f9b3a9acdba7728561a7ddfb48b1245dfa7.diff LOG: [lldb][NFC] Early exit in ClangASTContext::CreateInstance Added: Modified: lldb/source/Symbol/ClangASTContext.cpp Removed: diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index e70b005550d1..adb8d57a74f6 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -562,47 +562,47 @@ uint32_t ClangASTContext::GetPluginVersion() { return 1; } lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language, lldb_private::Module *module, Target *target) { - if (ClangASTContextSupportsLanguage(language)) { -ArchSpec arch; -if (module) - arch = module->GetArchitecture(); -else if (target) - arch = target->GetArchitecture(); - -if (arch.IsValid()) { - ArchSpec fixed_arch = arch; - // LLVM wants this to be set to iOS or MacOSX; if we're working on - // a bare-boards type image, change the triple for llvm's benefit. - if (fixed_arch.GetTriple().getVendor() == llvm::Triple::Apple && - fixed_arch.GetTriple().getOS() == llvm::Triple::UnknownOS) { -if (fixed_arch.GetTriple().getArch() == llvm::Triple::arm || -fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64 || -fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64_32 || -fixed_arch.GetTriple().getArch() == llvm::Triple::thumb) { - fixed_arch.GetTriple().setOS(llvm::Triple::IOS); -} else { - fixed_arch.GetTriple().setOS(llvm::Triple::MacOSX); -} - } - - if (module) { -std::shared_ptr ast_sp( -new ClangASTContext(fixed_arch)); -return ast_sp; - } else if (target && target->IsValid()) { -std::shared_ptr ast_sp( -new ClangASTContextForExpressions(*target, fixed_arch)); -ast_sp->m_scratch_ast_source_up.reset( -new ClangASTSource(target->shared_from_this())); -lldbassert(ast_sp->getFileManager()); -ast_sp->m_scratch_ast_source_up->InstallASTContext( -*ast_sp->getASTContext(), *ast_sp->getFileManager(), true); -llvm::IntrusiveRefCntPtr proxy_ast_source( -ast_sp->m_scratch_ast_source_up->CreateProxy()); -ast_sp->SetExternalSource(proxy_ast_source); -return ast_sp; - } -} + if (!ClangASTContextSupportsLanguage(language)) +return lldb::TypeSystemSP(); + ArchSpec arch; + if (module) +arch = module->GetArchitecture(); + else if (target) +arch = target->GetArchitecture(); + + if (!arch.IsValid()) +return lldb::TypeSystemSP(); + + ArchSpec fixed_arch = arch; + // LLVM wants this to be set to iOS or MacOSX; if we're working on + // a bare-boards type image, change the triple for llvm's benefit. + if (fixed_arch.GetTriple().getVendor() == llvm::Triple::Apple && + fixed_arch.GetTriple().getOS() == llvm::Triple::UnknownOS) { +if (fixed_arch.GetTriple().getArch() == llvm::Triple::arm || +fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64 || +fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64_32 || +fixed_arch.GetTriple().getArch() == llvm::Triple::thumb) { + fixed_arch.GetTriple().setOS(llvm::Triple::IOS); +} else { + fixed_arch.GetTriple().setOS(llvm::Triple::MacOSX); +} + } + + if (module) { +std::shared_ptr ast_sp(new ClangASTContext(fixed_arch)); +return ast_sp; + } else if (target && target->IsValid()) { +std::shared_ptr ast_sp( +new ClangASTContextForExpressions(*target, fixed_arch)); +ast_sp->m_scratch_ast_source_up.reset( +new ClangASTSource(target->shared_from_this())); +lldbassert(ast_sp->getFileManager()); +ast_sp->m_scratch_ast_source_up->InstallASTContext( +*ast_sp->getASTContext(), *ast_sp->getFileManager(), true); +llvm::IntrusiveRefCntPtr proxy_ast_source( +ast_sp->m_scratch_ast_source_up->CreateProxy()); +ast_sp->SetExternalSource(proxy_ast_source); +return ast_sp; } return lldb::TypeSystemSP(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d752b75 - [lldb][NFC] Simplify regex_chars in CommandCompletions
Author: Raphael Isemann Date: 2019-11-29T12:34:23+01:00 New Revision: d752b75d7fce2a77bb7656d33d2aa062372dc014 URL: https://github.com/llvm/llvm-project/commit/d752b75d7fce2a77bb7656d33d2aa062372dc014 DIFF: https://github.com/llvm/llvm-project/commit/d752b75d7fce2a77bb7656d33d2aa062372dc014.diff LOG: [lldb][NFC] Simplify regex_chars in CommandCompletions Added: Modified: lldb/source/Commands/CommandCompletions.cpp Removed: diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index d325b724a38f..b382e26e2b70 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -413,10 +413,7 @@ void CommandCompletions::SourceFileCompleter::DoCompletion( // SymbolCompleter static bool regex_chars(const char comp) { - return (comp == '[' || comp == ']' || comp == '(' || comp == ')' || - comp == '{' || comp == '}' || comp == '+' || comp == '.' || - comp == '*' || comp == '|' || comp == '^' || comp == '$' || - comp == '\\' || comp == '?'); + return llvm::StringRef("[](){}+.*|^$\\?").contains(comp); } CommandCompletions::SymbolCompleter::SymbolCompleter( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d1d6049 - [lldb][NFC] Remove dead logging code from DWARFASTParserClang::CompleteRecordType
Author: Raphael Isemann Date: 2019-11-29T12:13:34+01:00 New Revision: d1d6049e9d6600f28746379290705b02ffb52d4b URL: https://github.com/llvm/llvm-project/commit/d1d6049e9d6600f28746379290705b02ffb52d4b DIFF: https://github.com/llvm/llvm-project/commit/d1d6049e9d6600f28746379290705b02ffb52d4b.diff LOG: [lldb][NFC] Remove dead logging code from DWARFASTParserClang::CompleteRecordType This code is behind a `if (log)` that is always a nullptr as the initializer was commented out. One could uncomment the initializer code, but then this logging code just leads to a deadlock as it tries to aquire the module lock. This removes the logging code until I get this working again. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index ba17469ea998..43030c62cb40 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1974,8 +1974,6 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE , CompilerType _type) { const dw_tag_t tag = die.Tag(); SymbolFileDWARF *dwarf = die.GetDWARF(); - Log *log = - nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION)); ClangASTImporter::LayoutInfo layout_info; @@ -2125,75 +2123,8 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE , clang::CXXRecordDecl *record_decl = m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); -if (record_decl) { - if (log) { -ModuleSP module_sp = dwarf->GetObjectFile()->GetModule(); - -if (module_sp) { - module_sp->LogMessage( - log, - "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) " - "caching layout info for record_decl = %p, bit_size = %" PRIu64 - ", alignment = %" PRIu64 - ", field_offsets[%u], base_offsets[%u], vbase_offsets[%u])", - static_cast(clang_type.GetOpaqueQualType()), - static_cast(record_decl), layout_info.bit_size, - layout_info.alignment, - static_cast(layout_info.field_offsets.size()), - static_cast(layout_info.base_offsets.size()), - static_cast(layout_info.vbase_offsets.size())); - - uint32_t idx; - { -llvm::DenseMap::const_iterator -pos, -end = layout_info.field_offsets.end(); -for (idx = 0, pos = layout_info.field_offsets.begin(); pos != end; - ++pos, ++idx) { - module_sp->LogMessage( - log, - "ClangASTContext::CompleteTypeFromDWARF (clang_type = " - "%p) field[%u] = { bit_offset=%u, name='%s' }", - static_cast(clang_type.GetOpaqueQualType()), idx, - static_cast(pos->second), - pos->first->getNameAsString().c_str()); -} - } - - { -llvm::DenseMap::const_iterator base_pos, -base_end = layout_info.base_offsets.end(); -for (idx = 0, base_pos = layout_info.base_offsets.begin(); - base_pos != base_end; ++base_pos, ++idx) { - module_sp->LogMessage( - log, - "ClangASTContext::CompleteTypeFromDWARF (clang_type = " - "%p) base[%u] = { byte_offset=%u, name='%s' }", - clang_type.GetOpaqueQualType(), idx, - (uint32_t)base_pos->second.getQuantity(), - base_pos->first->getNameAsString().c_str()); -} - } - { -llvm::DenseMap::const_iterator vbase_pos, -vbase_end = layout_info.vbase_offsets.end(); -for (idx = 0, vbase_pos = layout_info.vbase_offsets.begin(); - vbase_pos != vbase_end; ++vbase_pos, ++idx) { - module_sp->LogMessage( - log, - "ClangASTContext::CompleteTypeFromDWARF (clang_type = " - "%p) vbase[%u] = { byte_offset=%u, name='%s' }", - static_cast(clang_type.GetOpaqueQualType()), idx, - static_cast(vbase_pos->second.getQuantity()), - vbase_pos->first->getNameAsString().c_str()); -} - } -} - } +if (record_decl) GetClangASTImporter().InsertRecordDecl(record_decl, layout_info); -} } return (bool)clang_type; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a48b5e2 - [lldb][NFC] Fix header guard comment in ThreadSafeDenseMap.h
Author: Raphael Isemann Date: 2019-11-29T11:34:18+01:00 New Revision: a48b5e24747ca83f9f18dff62a4bacb2f7dfd773 URL: https://github.com/llvm/llvm-project/commit/a48b5e24747ca83f9f18dff62a4bacb2f7dfd773 DIFF: https://github.com/llvm/llvm-project/commit/a48b5e24747ca83f9f18dff62a4bacb2f7dfd773.diff LOG: [lldb][NFC] Fix header guard comment in ThreadSafeDenseMap.h Added: Modified: lldb/include/lldb/Core/ThreadSafeDenseMap.h Removed: diff --git a/lldb/include/lldb/Core/ThreadSafeDenseMap.h b/lldb/include/lldb/Core/ThreadSafeDenseMap.h index c485b91acb47..420cb5763586 100644 --- a/lldb/include/lldb/Core/ThreadSafeDenseMap.h +++ b/lldb/include/lldb/Core/ThreadSafeDenseMap.h @@ -62,4 +62,4 @@ class ThreadSafeDenseMap { } // namespace lldb_private -#endif // liblldb_ThreadSafeSTLMap_h_ +#endif // liblldb_ThreadSafeDenseMap_h_ ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c2dd84e - [lldb][NFC] Remove CompilerDeclContext::IsClang
Author: Raphael Isemann Date: 2019-11-28T15:54:11+01:00 New Revision: c2dd84e396d091ca61b06b59c622b444ffc17234 URL: https://github.com/llvm/llvm-project/commit/c2dd84e396d091ca61b06b59c622b444ffc17234 DIFF: https://github.com/llvm/llvm-project/commit/c2dd84e396d091ca61b06b59c622b444ffc17234.diff LOG: [lldb][NFC] Remove CompilerDeclContext::IsClang This method is only used in ClangASTContext. Also removes the includes we only needed for the ClangASTContext RTTI check in the CompilerDecl[Context].cpp files. Added: Modified: lldb/include/lldb/Symbol/CompilerDeclContext.h lldb/source/Symbol/ClangASTContext.cpp lldb/source/Symbol/CompilerDecl.cpp lldb/source/Symbol/CompilerDeclContext.cpp Removed: diff --git a/lldb/include/lldb/Symbol/CompilerDeclContext.h b/lldb/include/lldb/Symbol/CompilerDeclContext.h index c140a3df13d0..fe8539ab30e6 100644 --- a/lldb/include/lldb/Symbol/CompilerDeclContext.h +++ b/lldb/include/lldb/Symbol/CompilerDeclContext.h @@ -38,8 +38,6 @@ class CompilerDeclContext { return m_type_system != nullptr && m_opaque_decl_ctx != nullptr; } - bool IsClang() const; - std::vector FindDeclByName(ConstString name, const bool ignore_using_decls); diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index e413029f0300..e70b005550d1 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -10199,16 +10199,20 @@ bool ClangASTContext::DeclContextIsContainedInLookup( return false; } +static bool IsClangDeclContext(const CompilerDeclContext ) { + return dc.IsValid() && isa(dc.GetTypeSystem()); +} + clang::DeclContext * ClangASTContext::DeclContextGetAsDeclContext(const CompilerDeclContext ) { - if (dc.IsClang()) + if (IsClangDeclContext(dc)) return (clang::DeclContext *)dc.GetOpaqueDeclContext(); return nullptr; } ObjCMethodDecl * ClangASTContext::DeclContextGetAsObjCMethodDecl(const CompilerDeclContext ) { - if (dc.IsClang()) + if (IsClangDeclContext(dc)) return llvm::dyn_cast( (clang::DeclContext *)dc.GetOpaqueDeclContext()); return nullptr; @@ -10216,7 +10220,7 @@ ClangASTContext::DeclContextGetAsObjCMethodDecl(const CompilerDeclContext ) { CXXMethodDecl * ClangASTContext::DeclContextGetAsCXXMethodDecl(const CompilerDeclContext ) { - if (dc.IsClang()) + if (IsClangDeclContext(dc)) return llvm::dyn_cast( (clang::DeclContext *)dc.GetOpaqueDeclContext()); return nullptr; @@ -10224,7 +10228,7 @@ ClangASTContext::DeclContextGetAsCXXMethodDecl(const CompilerDeclContext ) { clang::FunctionDecl * ClangASTContext::DeclContextGetAsFunctionDecl(const CompilerDeclContext ) { - if (dc.IsClang()) + if (IsClangDeclContext(dc)) return llvm::dyn_cast( (clang::DeclContext *)dc.GetOpaqueDeclContext()); return nullptr; @@ -10232,7 +10236,7 @@ ClangASTContext::DeclContextGetAsFunctionDecl(const CompilerDeclContext ) { clang::NamespaceDecl * ClangASTContext::DeclContextGetAsNamespaceDecl(const CompilerDeclContext ) { - if (dc.IsClang()) + if (IsClangDeclContext(dc)) return llvm::dyn_cast( (clang::DeclContext *)dc.GetOpaqueDeclContext()); return nullptr; diff --git a/lldb/source/Symbol/CompilerDecl.cpp b/lldb/source/Symbol/CompilerDecl.cpp index 017e541bd203..48d9169c1a7a 100644 --- a/lldb/source/Symbol/CompilerDecl.cpp +++ b/lldb/source/Symbol/CompilerDecl.cpp @@ -7,7 +7,6 @@ //===--===// #include "lldb/Symbol/CompilerDecl.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/Symbol/TypeSystem.h" diff --git a/lldb/source/Symbol/CompilerDeclContext.cpp b/lldb/source/Symbol/CompilerDeclContext.cpp index 7d45f47ad133..672de6ec34d1 100644 --- a/lldb/source/Symbol/CompilerDeclContext.cpp +++ b/lldb/source/Symbol/CompilerDeclContext.cpp @@ -7,7 +7,6 @@ //===--===// #include "lldb/Symbol/CompilerDeclContext.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompilerDecl.h" #include "lldb/Symbol/TypeSystem.h" #include @@ -24,10 +23,6 @@ CompilerDeclContext::FindDeclByName(ConstString name, return std::vector(); } -bool CompilerDeclContext::IsClang() const { - return IsValid() && llvm::isa(m_type_system); -} - ConstString CompilerDeclContext::GetName() const { if (IsValid()) return m_type_system->DeclContextGetName(m_opaque_decl_ctx); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f39277c - [lldb][NFC] Remove unused variable in ClangASTSource::CompleteType
Author: Raphael Isemann Date: 2019-11-28T15:32:56+01:00 New Revision: f39277c1d370ccbbec2e20a20375ee6fb7281ae4 URL: https://github.com/llvm/llvm-project/commit/f39277c1d370ccbbec2e20a20375ee6fb7281ae4 DIFF: https://github.com/llvm/llvm-project/commit/f39277c1d370ccbbec2e20a20375ee6fb7281ae4.diff LOG: [lldb][NFC] Remove unused variable in ClangASTSource::CompleteType Now that CompilerDeclContext is a trivial class, Clang started warning that this unused variable is in fact unused. Let's remove it. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 7440f6a0c363..2b484db3a188 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -363,7 +363,6 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) { TypeList types; ConstString name(tag_decl->getName().str().c_str()); - CompilerDeclContext namespace_decl; const ModuleList _list = m_target->GetImages(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e0203b2 - [lldb][NFC] Simplify CompilerDecl and CompilerDeclContext initialization
Author: Raphael Isemann Date: 2019-11-28T15:27:54+01:00 New Revision: e0203b25af92a3388580d6ef4eb386058720449e URL: https://github.com/llvm/llvm-project/commit/e0203b25af92a3388580d6ef4eb386058720449e DIFF: https://github.com/llvm/llvm-project/commit/e0203b25af92a3388580d6ef4eb386058720449e.diff LOG: [lldb][NFC] Simplify CompilerDecl and CompilerDeclContext initialization Added: Modified: lldb/include/lldb/Symbol/CompilerDecl.h lldb/include/lldb/Symbol/CompilerDeclContext.h Removed: diff --git a/lldb/include/lldb/Symbol/CompilerDecl.h b/lldb/include/lldb/Symbol/CompilerDecl.h index 7e4755a58c59..e4687ffb3853 100644 --- a/lldb/include/lldb/Symbol/CompilerDecl.h +++ b/lldb/include/lldb/Symbol/CompilerDecl.h @@ -18,13 +18,11 @@ namespace lldb_private { class CompilerDecl { public: // Constructors and Destructors - CompilerDecl() : m_type_system(nullptr), m_opaque_decl(nullptr) {} + CompilerDecl() = default; CompilerDecl(TypeSystem *type_system, void *decl) : m_type_system(type_system), m_opaque_decl(decl) {} - ~CompilerDecl() {} - // Tests explicit operator bool() const { return IsValid(); } @@ -73,8 +71,8 @@ class CompilerDecl { CompilerType GetFunctionArgumentType(size_t arg_idx) const; private: - TypeSystem *m_type_system; - void *m_opaque_decl; + TypeSystem *m_type_system = nullptr; + void *m_opaque_decl = nullptr; }; bool operator==(const CompilerDecl , const CompilerDecl ); diff --git a/lldb/include/lldb/Symbol/CompilerDeclContext.h b/lldb/include/lldb/Symbol/CompilerDeclContext.h index e7958c08d833..c140a3df13d0 100644 --- a/lldb/include/lldb/Symbol/CompilerDeclContext.h +++ b/lldb/include/lldb/Symbol/CompilerDeclContext.h @@ -19,13 +19,11 @@ namespace lldb_private { class CompilerDeclContext { public: // Constructors and Destructors - CompilerDeclContext() : m_type_system(nullptr), m_opaque_decl_ctx(nullptr) {} + CompilerDeclContext() = default; CompilerDeclContext(TypeSystem *type_system, void *decl_ctx) : m_type_system(type_system), m_opaque_decl_ctx(decl_ctx) {} - ~CompilerDeclContext() {} - // Tests explicit operator bool() const { return IsValid(); } @@ -105,8 +103,8 @@ class CompilerDeclContext { bool IsStructUnionOrClass() const; private: - TypeSystem *m_type_system; - void *m_opaque_decl_ctx; + TypeSystem *m_type_system = nullptr; + void *m_opaque_decl_ctx = nullptr; }; bool operator==(const CompilerDeclContext , const CompilerDeclContext ); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3cd8ba0 - [lldb][NFC] Remove unused CompilerDecl::IsClang
Author: Raphael Isemann Date: 2019-11-28T15:11:37+01:00 New Revision: 3cd8ba0e37a035a134dc01ce260040f1d57f4d40 URL: https://github.com/llvm/llvm-project/commit/3cd8ba0e37a035a134dc01ce260040f1d57f4d40 DIFF: https://github.com/llvm/llvm-project/commit/3cd8ba0e37a035a134dc01ce260040f1d57f4d40.diff LOG: [lldb][NFC] Remove unused CompilerDecl::IsClang Added: Modified: lldb/include/lldb/Symbol/CompilerDecl.h lldb/source/Symbol/CompilerDecl.cpp Removed: diff --git a/lldb/include/lldb/Symbol/CompilerDecl.h b/lldb/include/lldb/Symbol/CompilerDecl.h index 4817ec4b2267..7e4755a58c59 100644 --- a/lldb/include/lldb/Symbol/CompilerDecl.h +++ b/lldb/include/lldb/Symbol/CompilerDecl.h @@ -39,8 +39,6 @@ class CompilerDecl { return m_type_system != nullptr && m_opaque_decl != nullptr; } - bool IsClang() const; - // Accessors TypeSystem *GetTypeSystem() const { return m_type_system; } diff --git a/lldb/source/Symbol/CompilerDecl.cpp b/lldb/source/Symbol/CompilerDecl.cpp index 3d17d802dd04..017e541bd203 100644 --- a/lldb/source/Symbol/CompilerDecl.cpp +++ b/lldb/source/Symbol/CompilerDecl.cpp @@ -13,10 +13,6 @@ using namespace lldb_private; -bool CompilerDecl::IsClang() const { - return IsValid() && llvm::isa(m_type_system); -} - ConstString CompilerDecl::GetName() const { return m_type_system->DeclGetName(m_opaque_decl); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 50e2ffa - Revert "[lldb] NFC: refactor CompileUnit::ResolveSymbolContext"
Author: Raphael Isemann Date: 2019-11-28T14:25:46+01:00 New Revision: 50e2ffa18da4247e4d45f421c3271b58b936c869 URL: https://github.com/llvm/llvm-project/commit/50e2ffa18da4247e4d45f421c3271b58b936c869 DIFF: https://github.com/llvm/llvm-project/commit/50e2ffa18da4247e4d45f421c3271b58b936c869.diff LOG: Revert "[lldb] NFC: refactor CompileUnit::ResolveSymbolContext" This reverts commit 373e2a4f69d623e59329ff801f261d8b299e12d2. This broke breakpoint setting. Added: Modified: lldb/include/lldb/Symbol/CompileUnit.h lldb/source/API/SBThread.cpp lldb/source/Core/AddressResolverFileLine.cpp lldb/source/Symbol/CompileUnit.cpp Removed: diff --git a/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h index b5f37f678900..7efbf792b1a9 100644 --- a/lldb/include/lldb/Symbol/CompileUnit.h +++ b/lldb/include/lldb/Symbol/CompileUnit.h @@ -381,11 +381,14 @@ class CompileUnit : public std::enable_shared_from_this, /// A SymbolContext list class that will get any matching /// entries appended to. /// + /// \return + /// The number of new matches that were added to \a sc_list. + /// /// \see enum SymbolContext::Scope - void ResolveSymbolContext(const FileSpec _spec, uint32_t line, -bool check_inlines, bool exact, -lldb::SymbolContextItem resolve_scope, -SymbolContextList _list); + uint32_t ResolveSymbolContext(const FileSpec _spec, uint32_t line, +bool check_inlines, bool exact, +lldb::SymbolContextItem resolve_scope, +SymbolContextList _list); /// Get whether compiler optimizations were enabled for this compile unit /// diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 2dada9a6118d..8d4930bf6edb 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -914,10 +914,9 @@ SBError SBThread::StepOverUntil(lldb::SBFrame _frame, const bool exact = false; SymbolContextList sc_list; -frame_sc.comp_unit->ResolveSymbolContext(step_file_spec, line, - check_inlines, exact, - eSymbolContextLineEntry, sc_list); -const uint32_t num_matches = sc_list.GetSize(); +const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext( +step_file_spec, line, check_inlines, exact, eSymbolContextLineEntry, +sc_list); if (num_matches > 0) { SymbolContext sc; for (uint32_t i = 0; i < num_matches; ++i) { diff --git a/lldb/source/Core/AddressResolverFileLine.cpp b/lldb/source/Core/AddressResolverFileLine.cpp index 4122b5d3b747..4a14260c6c72 100644 --- a/lldb/source/Core/AddressResolverFileLine.cpp +++ b/lldb/source/Core/AddressResolverFileLine.cpp @@ -40,13 +40,14 @@ Searcher::CallbackReturn AddressResolverFileLine::SearchCallback(SearchFilter , SymbolContext , Address *addr) { SymbolContextList sc_list; + uint32_t sc_list_size; CompileUnit *cu = context.comp_unit; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - cu->ResolveSymbolContext(m_file_spec, m_line_number, m_inlines, false, - eSymbolContextEverything, sc_list); - uint32_t sc_list_size = sc_list.GetSize(); + sc_list_size = + cu->ResolveSymbolContext(m_file_spec, m_line_number, m_inlines, false, + eSymbolContextEverything, sc_list); for (uint32_t i = 0; i < sc_list_size; i++) { SymbolContext sc; if (sc_list.GetContextAtIndex(i, sc)) { diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp index 62a1d690da42..b37636c3bafc 100644 --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -244,11 +244,11 @@ uint32_t CompileUnit::FindLineEntry(uint32_t start_idx, uint32_t line, return UINT32_MAX; } -void CompileUnit::ResolveSymbolContext(const FileSpec _spec, - uint32_t line, bool check_inlines, - bool exact, - SymbolContextItem resolve_scope, - SymbolContextList _list) { +uint32_t CompileUnit::ResolveSymbolContext(const FileSpec _spec, + uint32_t line, bool check_inlines, + bool exact, + SymbolContextItem resolve_scope, + SymbolContextList _list) { // First find all of the file indexes that match our "file_spec". If // "file_spec" has an empty directory, then only compare the basenames when
[Lldb-commits] [lldb] 42c857a - [lldb][NFC] Remove unused STLUtil include and STLUtil.h header
Author: Raphael Isemann Date: 2019-11-28T14:11:35+01:00 New Revision: 42c857aa4783824183d55e8a6ede488d69349806 URL: https://github.com/llvm/llvm-project/commit/42c857aa4783824183d55e8a6ede488d69349806 DIFF: https://github.com/llvm/llvm-project/commit/42c857aa4783824183d55e8a6ede488d69349806.diff LOG: [lldb][NFC] Remove unused STLUtil include and STLUtil.h header Added: Modified: lldb/include/lldb/Interpreter/CommandReturnObject.h Removed: lldb/include/lldb/Core/STLUtils.h diff --git a/lldb/include/lldb/Core/STLUtils.h b/lldb/include/lldb/Core/STLUtils.h deleted file mode 100644 index f9500aa5594e.. --- a/lldb/include/lldb/Core/STLUtils.h +++ /dev/null @@ -1,26 +0,0 @@ -//===-- STLUtils.h --*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -#ifndef liblldb_STLUtils_h_ -#define liblldb_STLUtils_h_ - -#include - -#include -#include -#include - - -// C string less than compare function object -struct CStringCompareFunctionObject { - bool operator()(const char *s1, const char *s2) const { -return strcmp(s1, s2) < 0; - } -}; - -#endif // liblldb_STLUtils_h_ diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h index 61e57fb798a1..8af76e07e5ae 100644 --- a/lldb/include/lldb/Interpreter/CommandReturnObject.h +++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -9,7 +9,6 @@ #ifndef liblldb_CommandReturnObject_h_ #define liblldb_CommandReturnObject_h_ -#include "lldb/Core/STLUtils.h" #include "lldb/Core/StreamFile.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StreamTee.h" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a54ef8a - [lldb][NFC] Use llvm::StringRef instead of C-strings as multimap key
Author: Raphael Isemann Date: 2019-11-28T14:05:47+01:00 New Revision: a54ef8af89c78f7296bea6ffabb7728ef563bec1 URL: https://github.com/llvm/llvm-project/commit/a54ef8af89c78f7296bea6ffabb7728ef563bec1 DIFF: https://github.com/llvm/llvm-project/commit/a54ef8af89c78f7296bea6ffabb7728ef563bec1.diff LOG: [lldb][NFC] Use llvm::StringRef instead of C-strings as multimap key Added: Modified: lldb/source/Symbol/Symtab.cpp Removed: diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 9a2b5cddd73b..c7a6bf214526 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -13,7 +13,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/RichManglingContext.h" -#include "lldb/Core/STLUtils.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symbol.h" @@ -107,10 +106,8 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, // sorted by name. So we must make the ordered symbol list up ourselves. s->PutCString(" (sorted by name):\n"); DumpSymbolHeader(s); - typedef std::multimap - CStringToSymbol; - CStringToSymbol name_map; + + std::multimap name_map; for (const_iterator pos = m_symbols.begin(), end = m_symbols.end(); pos != end; ++pos) { const char *name = pos->GetName().AsCString(); @@ -118,12 +115,10 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, name_map.insert(std::make_pair(name, &(*pos))); } - for (CStringToSymbol::const_iterator pos = name_map.begin(), - end = name_map.end(); - pos != end; ++pos) { + for (const auto _to_symbol : name_map) { +const Symbol *symbol = name_to_symbol.second; s->Indent(); -pos->second->Dump(s, target, pos->second - _symbols[0], - name_preference); +symbol->Dump(s, target, symbol - _symbols[0], name_preference); } } break; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2e3c040 - [lldb][NFC] Remove unused CStringToDIEMap typedef
Author: Raphael Isemann Date: 2019-11-28T13:33:19+01:00 New Revision: 2e3c040ee062741472233c1de2dbf135bcee5c7a URL: https://github.com/llvm/llvm-project/commit/2e3c040ee062741472233c1de2dbf135bcee5c7a DIFF: https://github.com/llvm/llvm-project/commit/2e3c040ee062741472233c1de2dbf135bcee5c7a.diff LOG: [lldb][NFC] Remove unused CStringToDIEMap typedef Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index d1b066ffe80c..056cf33a202f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -16,7 +16,6 @@ #include "DWARFTypeUnit.h" #include "DWARFUnit.h" #include "SymbolFileDWARF.h" -#include "lldb/Core/STLUtils.h" #include "lldb/lldb-private.h" #include "llvm/Support/Error.h" @@ -24,11 +23,6 @@ namespace lldb_private { class DWARFContext; } -typedef std::multimap -CStringToDIEMap; -typedef CStringToDIEMap::iterator CStringToDIEMapIter; -typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter; - class DWARFDebugInfo { public: typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ee79fea - [lldb][NFC] Remove forward declaration of PrivateAutoCompleteMembers
Author: Raphael Isemann Date: 2019-11-28T12:45:48+01:00 New Revision: ee79feaec3ed44b21654936baf44561f5f726dfc URL: https://github.com/llvm/llvm-project/commit/ee79feaec3ed44b21654936baf44561f5f726dfc DIFF: https://github.com/llvm/llvm-project/commit/ee79feaec3ed44b21654936baf44561f5f726dfc.diff LOG: [lldb][NFC] Remove forward declaration of PrivateAutoCompleteMembers That's declared directly above the actual definition, so it serves no use. Added: Modified: lldb/source/Symbol/Variable.cpp Removed: diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index a2eeaa1d2a5b..6e4b87c47700 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -487,13 +487,6 @@ static void PrivateAutoComplete( _path, // Anything that has been resolved already will be in here const CompilerType _type, CompletionRequest ); -static void PrivateAutoCompleteMembers( -StackFrame *frame, const std::string _member_name, -llvm::StringRef partial_path, -const llvm::Twine -_path, // Anything that has been resolved already will be in here -const CompilerType _type, CompletionRequest ); - static void PrivateAutoCompleteMembers( StackFrame *frame, const std::string _member_name, llvm::StringRef partial_path, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9d26791 - [lldb][NFC] Make GetAsCXXRecordDecl static
Author: Raphael Isemann Date: 2019-11-28T12:24:41+01:00 New Revision: 9d2679152a4bbe892f72802427657bfdca85a63b URL: https://github.com/llvm/llvm-project/commit/9d2679152a4bbe892f72802427657bfdca85a63b DIFF: https://github.com/llvm/llvm-project/commit/9d2679152a4bbe892f72802427657bfdca85a63b.diff LOG: [lldb][NFC] Make GetAsCXXRecordDecl static All other casting functions there are static, so this should be too. Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 20421bca305e..7018f3b71b4f 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -908,7 +908,8 @@ class ClangASTContext : public TypeSystem { static clang::TypedefNameDecl *GetAsTypedefDecl(const CompilerType ); - clang::CXXRecordDecl *GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type); + static clang::CXXRecordDecl * + GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type); static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType ); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f7e31e0 - [lldb][NFC] Split up DWARFASTParserClang::CompleteTypeFromDWARF
Author: Raphael Isemann Date: 2019-11-28T10:45:29+01:00 New Revision: f7e31e0cfd3b467a21c2ac9a94f5c828f88a9b72 URL: https://github.com/llvm/llvm-project/commit/f7e31e0cfd3b467a21c2ac9a94f5c828f88a9b72 DIFF: https://github.com/llvm/llvm-project/commit/f7e31e0cfd3b467a21c2ac9a94f5c828f88a9b72.diff LOG: [lldb][NFC] Split up DWARFASTParserClang::CompleteTypeFromDWARF Moving the different parts into their own functions without any additional cleanup/refactoring, so this is NFC. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 51fa90322cf0..ba17469ea998 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1969,267 +1969,283 @@ bool DWARFASTParserClang::ParseTemplateParameterInfos( return template_param_infos.args.size() == template_param_infos.names.size(); } -bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE , -lldb_private::Type *type, -CompilerType _type) { - SymbolFileDWARF *dwarf = die.GetDWARF(); - - std::lock_guard guard( - dwarf->GetObjectFile()->GetModule()->GetMutex()); - - // Disable external storage for this type so we don't get anymore - // clang::ExternalASTSource queries for this type. - m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), false); - - if (!die) -return false; - +bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE , + lldb_private::Type *type, + CompilerType _type) { const dw_tag_t tag = die.Tag(); - + SymbolFileDWARF *dwarf = die.GetDWARF(); Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION)); - if (log) -dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace( -log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", -die.GetID(), die.GetTagAsCString(), type->GetName().AsCString()); - assert(clang_type); - DWARFAttributes attributes; - switch (tag) { - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_class_type: { -ClangASTImporter::LayoutInfo layout_info; - -{ - if (die.HasChildren()) { -LanguageType class_language = eLanguageTypeUnknown; -if (ClangASTContext::IsObjCObjectOrInterfaceType(clang_type)) { - class_language = eLanguageTypeObjC; - // For objective C we don't start the definition when the class is - // created. - ClangASTContext::StartTagDeclarationDefinition(clang_type); -} -int tag_decl_kind = -1; -AccessType default_accessibility = eAccessNone; -if (tag == DW_TAG_structure_type) { - tag_decl_kind = clang::TTK_Struct; - default_accessibility = eAccessPublic; -} else if (tag == DW_TAG_union_type) { - tag_decl_kind = clang::TTK_Union; - default_accessibility = eAccessPublic; -} else if (tag == DW_TAG_class_type) { - tag_decl_kind = clang::TTK_Class; - default_accessibility = eAccessPrivate; -} + ClangASTImporter::LayoutInfo layout_info; -std::vector> bases; -std::vector member_accessibilities; -bool is_a_class = false; -// Parse members and base classes first -std::vector member_function_dies; + { +if (die.HasChildren()) { + LanguageType class_language = eLanguageTypeUnknown; + if (ClangASTContext::IsObjCObjectOrInterfaceType(clang_type)) { +class_language = eLanguageTypeObjC; +// For objective C we don't start the definition when the class is +// created. +ClangASTContext::StartTagDeclarationDefinition(clang_type); + } -DelayedPropertyList delayed_properties; -ParseChildMembers(die, clang_type, class_language, bases, - member_accessibilities, member_function_dies, - delayed_properties, default_accessibility, is_a_class, - layout_info); + int tag_decl_kind = -1; + AccessType default_accessibility = eAccessNone; + if (tag == DW_TAG_structure_type) { +tag_decl_kind = clang::TTK_Struct; +default_accessibility = eAccessPublic; + } else if (tag == DW_TAG_union_type) { +tag_decl_kind = clang::TTK_Union; +default_accessibility = eAccessPublic; + } else if (tag == DW_TAG_class_type) { +tag_decl_kind = clang::TTK_Class; +default_accessibility =
[Lldb-commits] [lldb] b44e91a - [lldb] Remove debugging code used for LLDB_DWARF_DONT_COMPLETE_TYPENAMES
Author: Raphael Isemann Date: 2019-11-28T10:21:58+01:00 New Revision: b44e91a472526f01d67ee9ce5de2561216782330 URL: https://github.com/llvm/llvm-project/commit/b44e91a472526f01d67ee9ce5de2561216782330 DIFF: https://github.com/llvm/llvm-project/commit/b44e91a472526f01d67ee9ce5de2561216782330.diff LOG: [lldb] Remove debugging code used for LLDB_DWARF_DONT_COMPLETE_TYPENAMES Reviewers: labath, clayborg, shafik Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70802 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index df5c81f2e830..51fa90322cf0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1984,39 +1984,6 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE , if (!die) return false; -#if defined LLDB_CONFIGURATION_DEBUG - // For debugging purposes, the LLDB_DWARF_DONT_COMPLETE_TYPENAMES environment - // variable can be set with one or more typenames separated by ';' - // characters. This will cause this function to not complete any types whose - // names match. - // - // Examples of setting this environment variable: - // - // LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo - // LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo;Bar;Baz - const char *dont_complete_typenames_cstr = - getenv("LLDB_DWARF_DONT_COMPLETE_TYPENAMES"); - if (dont_complete_typenames_cstr && dont_complete_typenames_cstr[0]) { -const char *die_name = die.GetName(); -if (die_name && die_name[0]) { - const char *match = strstr(dont_complete_typenames_cstr, die_name); - if (match) { -size_t die_name_length = strlen(die_name); -while (match) { - const char separator_char = ';'; - const char next_char = match[die_name_length]; - if (next_char == '\0' || next_char == separator_char) { -if (match == dont_complete_typenames_cstr || -match[-1] == separator_char) - return false; - } - match = strstr(match + 1, die_name); -} - } -} - } -#endif - const dw_tag_t tag = die.Tag(); Log *log = ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 92d5ea5 - [lldb][NFC] Move TypeSystem RTTI to static variable to remove swift reference
Author: Raphael Isemann Date: 2019-11-27T10:28:02+01:00 New Revision: 92d5ea5d1674c38e03d130c6b04afa118e94ef4a URL: https://github.com/llvm/llvm-project/commit/92d5ea5d1674c38e03d130c6b04afa118e94ef4a DIFF: https://github.com/llvm/llvm-project/commit/92d5ea5d1674c38e03d130c6b04afa118e94ef4a.diff LOG: [lldb][NFC] Move TypeSystem RTTI to static variable to remove swift reference Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/include/lldb/Symbol/TypeSystem.h lldb/source/Symbol/ClangASTContext.cpp lldb/source/Symbol/CompilerDecl.cpp lldb/source/Symbol/CompilerDeclContext.cpp lldb/source/Symbol/TypeSystem.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index f4428c682182..20421bca305e 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -41,15 +41,17 @@ namespace lldb_private { class Declaration; class ClangASTContext : public TypeSystem { + // LLVM RTTI support + static char ID; + public: typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *); typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *); // llvm casting support - static bool classof(const TypeSystem *ts) { -return ts->getKind() == TypeSystem::eKindClang; - } + bool isA(const void *ClassID) const override { return ClassID == } + static bool classof(const TypeSystem *ts) { return ts->isA(); } // Constructors and Destructors explicit ClangASTContext(llvm::StringRef triple = ""); diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index 6283d67baba5..ea860647fdb1 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -52,47 +52,11 @@ struct LanguageSet { /// Interface for representing the Type Systems in diff erent languages. class TypeSystem : public PluginInterface { public: - // Intrusive type system that allows us to use llvm casting. - // - // To add a new type system: - // - // 1 - Add a new enumeration for llvm casting below for your TypeSystem - // subclass, here we will use eKindFoo - // - // 2 - Your TypeSystem subclass will inherit from TypeSystem and needs - // to implement a static classof() function that returns your - // enumeration: - // - //class Foo : public lldb_private::TypeSystem - //{ - //static bool classof(const TypeSystem *ts) - //{ - //return ts->getKind() == TypeSystem::eKindFoo; - //} - //}; - // - // 3 - Contruct your TypeSystem subclass with the enumeration from below - // - //Foo() : - //TypeSystem(TypeSystem::eKindFoo), - //... - //{ - //} - // - // Then you can use the llvm casting on any "TypeSystem *" to get an instance - // of your subclass. - enum LLVMCastKind { -eKindClang, -eKindSwift, -kNumKinds - }; - // Constructors and Destructors - TypeSystem(LLVMCastKind kind); - ~TypeSystem() override; - LLVMCastKind getKind() const { return m_kind; } + // LLVM RTTI support + virtual bool isA(const void *ClassID) const = 0; static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module); @@ -493,8 +457,7 @@ class TypeSystem : public PluginInterface { virtual bool IsMeaninglessWithoutDynamicResolution(void *type); protected: - const LLVMCastKind m_kind; // Support for llvm casting - SymbolFile *m_sym_file; + SymbolFile *m_sym_file = nullptr; }; class TypeSystemMap { diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 244ac8ce5ff8..e413029f0300 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -337,6 +337,8 @@ static ClangASTMap () { return *g_map_ptr; } +char ClangASTContext::ID; + bool ClangASTContext::IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind _kind) { // All operators have to start with "operator". @@ -522,8 +524,7 @@ static void ParseLangArgs(LangOptions , InputKind IK, const char *triple) { Opts.NoInlineDefine = !Opt; } -ClangASTContext::ClangASTContext(llvm::StringRef target_triple) -: TypeSystem(TypeSystem::eKindClang) { +ClangASTContext::ClangASTContext(llvm::StringRef target_triple) { if (!target_triple.empty()) SetTargetTriple(target_triple); // The caller didn't pass an ASTContext so create a new one for this @@ -531,16 +532,14 @@ ClangASTContext::ClangASTContext(llvm::StringRef target_triple) CreateASTContext(); } -ClangASTContext::ClangASTContext(ArchSpec arch) -: TypeSystem(TypeSystem::eKindClang) {
[Lldb-commits] [lldb] f1b1173 - [lldb][NFC] Remove unused CompilerType memory functions
Author: Raphael Isemann Date: 2019-11-27T09:51:50+01:00 New Revision: f1b117394d7f9ae6decf9730ed9d443ca1b54769 URL: https://github.com/llvm/llvm-project/commit/f1b117394d7f9ae6decf9730ed9d443ca1b54769 DIFF: https://github.com/llvm/llvm-project/commit/f1b117394d7f9ae6decf9730ed9d443ca1b54769.diff LOG: [lldb][NFC] Remove unused CompilerType memory functions Summary: All these functions are unused from what I can see. Unless I'm missing something here, this code can go the way of the Dodo. Reviewers: labath Reviewed By: labath Subscribers: abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70770 Added: Modified: lldb/include/lldb/Symbol/CompilerType.h lldb/source/Symbol/CompilerType.cpp Removed: diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index cedd2523a5a8..91d9c5e48d20 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -357,14 +357,6 @@ class CompilerType { bool GetValueAsScalar(const DataExtractor , lldb::offset_t data_offset, size_t data_byte_size, Scalar ) const; - bool SetValueFromScalar(const Scalar , Stream ); - - bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr, - AddressType address_type, DataExtractor ); - - bool WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t addr, - AddressType address_type, StreamString _value); - void Clear() { m_type = nullptr; m_type_system = nullptr; diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 571a8570a43b..d35213120b4d 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -874,173 +874,6 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor , return false; } -bool CompilerType::SetValueFromScalar(const Scalar , Stream ) { - if (!IsValid()) -return false; - - // Aggregate types don't have scalar values - if (!IsAggregateType()) { -strm.GetFlags().Set(Stream::eBinary); -uint64_t count = 0; -lldb::Encoding encoding = GetEncoding(count); - -if (encoding == lldb::eEncodingInvalid || count != 1) - return false; - -llvm::Optional bit_width = GetBitSize(nullptr); -if (!bit_width) - return false; - -// This function doesn't currently handle non-byte aligned assignments -if ((*bit_width % 8) != 0) - return false; - -const uint64_t byte_size = (*bit_width + 7) / 8; -switch (encoding) { -case lldb::eEncodingInvalid: - break; -case lldb::eEncodingVector: - break; -case lldb::eEncodingUint: - switch (byte_size) { - case 1: -strm.PutHex8(value.UInt()); -return true; - case 2: -strm.PutHex16(value.UInt()); -return true; - case 4: -strm.PutHex32(value.UInt()); -return true; - case 8: -strm.PutHex64(value.ULongLong()); -return true; - default: -break; - } - break; - -case lldb::eEncodingSint: - switch (byte_size) { - case 1: -strm.PutHex8(value.SInt()); -return true; - case 2: -strm.PutHex16(value.SInt()); -return true; - case 4: -strm.PutHex32(value.SInt()); -return true; - case 8: -strm.PutHex64(value.SLongLong()); -return true; - default: -break; - } - break; - -case lldb::eEncodingIEEE754: - if (byte_size <= sizeof(long double)) { -if (byte_size == sizeof(float)) { - strm.PutFloat(value.Float()); - return true; -} else if (byte_size == sizeof(double)) { - strm.PutDouble(value.Double()); - return true; -} else if (byte_size == sizeof(long double)) { - strm.PutDouble(value.LongDouble()); - return true; -} - } - break; -} - } - return false; -} - -bool CompilerType::ReadFromMemory(lldb_private::ExecutionContext *exe_ctx, - lldb::addr_t addr, AddressType address_type, - lldb_private::DataExtractor ) { - if (!IsValid()) -return false; - - // Can't convert a file address to anything valid without more context (which - // Module it came from) - if (address_type == eAddressTypeFile) -return false; - - if (!GetCompleteType()) -return false; - - auto byte_size = - GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr); - if (!byte_size) -return false; - - if (data.GetByteSize() < *byte_size) { -lldb::DataBufferSP data_sp(new DataBufferHeap(*byte_size, '\0')); -data.SetData(data_sp); - } - - uint8_t *dst = const_cast(data.PeekData(0, *byte_size)); - if (dst != nullptr) { -
[Lldb-commits] [lldb] 3a28042 - [lldb][NFC] Early exit in DWARFASTParserClang::ParseArrayType
Author: Raphael Isemann Date: 2019-11-27T09:28:01+01:00 New Revision: 3a280422b66a31af694782746ec0b5b7552a82a1 URL: https://github.com/llvm/llvm-project/commit/3a280422b66a31af694782746ec0b5b7552a82a1 DIFF: https://github.com/llvm/llvm-project/commit/3a280422b66a31af694782746ec0b5b7552a82a1.diff LOG: [lldb][NFC] Early exit in DWARFASTParserClang::ParseArrayType Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index fe6ab3064447..df5c81f2e830 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1257,83 +1257,83 @@ TypeSP DWARFASTParserClang::ParseArrayType(const DWARFDIE , DWARFDIE type_die = attrs.type.Reference(); Type *element_type = dwarf->ResolveTypeUID(type_die, true); - if (element_type) { -auto array_info = ParseChildArrayInfo(die); -if (array_info) { - attrs.byte_stride = array_info->byte_stride; - attrs.bit_stride = array_info->bit_stride; -} -if (attrs.byte_stride == 0 && attrs.bit_stride == 0) - attrs.byte_stride = element_type->GetByteSize().getValueOr(0); -CompilerType array_element_type = element_type->GetForwardCompilerType(); - -if (ClangASTContext::IsCXXClassType(array_element_type) && -!array_element_type.GetCompleteType()) { - ModuleSP module_sp = die.GetModule(); - if (module_sp) { -if (die.GetCU()->GetProducer() == eProducerClang) - module_sp->ReportError( - "DWARF DW_TAG_array_type DIE at 0x%8.8x has a " - "class/union/struct element type DIE 0x%8.8x that is a " - "forward declaration, not a complete definition.\nTry " - "compiling the source file with -fstandalone-debug or " - "disable -gmodules", - die.GetOffset(), type_die.GetOffset()); -else - module_sp->ReportError( - "DWARF DW_TAG_array_type DIE at 0x%8.8x has a " - "class/union/struct element type DIE 0x%8.8x that is a " - "forward declaration, not a complete definition.\nPlease " - "file a bug against the compiler and include the " - "preprocessed output for %s", - die.GetOffset(), type_die.GetOffset(), GetUnitName(die).c_str()); - } - - // We have no choice other than to pretend that the element class - // type is complete. If we don't do this, clang will crash when - // trying to layout the class. Since we provide layout - // assistance, all ivars in this class and other classes will be - // fine, this is the best we can do short of crashing. - if (ClangASTContext::StartTagDeclarationDefinition(array_element_type)) { -ClangASTContext::CompleteTagDeclarationDefinition(array_element_type); - } else { -module_sp->ReportError("DWARF DIE at 0x%8.8x was not able to " - "start its definition.\nPlease file a " - "bug and attach the file at the start " - "of this error message", - type_die.GetOffset()); - } -} + if (!element_type) +return nullptr; -uint64_t array_element_bit_stride = -attrs.byte_stride * 8 + attrs.bit_stride; -CompilerType clang_type; -if (array_info && array_info->element_orders.size() > 0) { - uint64_t num_elements = 0; - auto end = array_info->element_orders.rend(); - for (auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) { -num_elements = *pos; -clang_type = m_ast.CreateArrayType(array_element_type, num_elements, - attrs.is_vector); -array_element_type = clang_type; -array_element_bit_stride = num_elements - ? array_element_bit_stride * num_elements - : array_element_bit_stride; - } + llvm::Optional array_info = ParseChildArrayInfo(die); + if (array_info) { +attrs.byte_stride = array_info->byte_stride; +attrs.bit_stride = array_info->bit_stride; + } + if (attrs.byte_stride == 0 && attrs.bit_stride == 0) +attrs.byte_stride = element_type->GetByteSize().getValueOr(0); + CompilerType array_element_type = element_type->GetForwardCompilerType(); + + if (ClangASTContext::IsCXXClassType(array_element_type) && + !array_element_type.GetCompleteType()) { +ModuleSP module_sp = die.GetModule(); +if (module_sp) { + if (die.GetCU()->GetProducer() == eProducerClang) +module_sp->ReportError( +"DWARF DW_TAG_array_type DIE at 0x%8.8x has a " +
[Lldb-commits] [lldb] 16144d2 - [lldb][NFC] Modernize string handling in DWARFASTParserClang::ParseTypeModifier
Author: Raphael Isemann Date: 2019-11-26T15:04:54+01:00 New Revision: 16144d2b21d90a0515be2fc9158cbaf828abd980 URL: https://github.com/llvm/llvm-project/commit/16144d2b21d90a0515be2fc9158cbaf828abd980 DIFF: https://github.com/llvm/llvm-project/commit/16144d2b21d90a0515be2fc9158cbaf828abd980.diff LOG: [lldb][NFC] Modernize string handling in DWARFASTParserClang::ParseTypeModifier Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 89331f7aca6c..fe6ab3064447 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -662,11 +662,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext , if (cu_language == eLanguageTypeObjC || cu_language == eLanguageTypeObjC_plus_plus) { if (attrs.name) { -static ConstString g_objc_type_name_id("id"); -static ConstString g_objc_type_name_Class("Class"); -static ConstString g_objc_type_name_selector("SEL"); - -if (attrs.name == g_objc_type_name_id) { +if (attrs.name == "id") { if (log) dwarf->GetObjectFile()->GetModule()->LogMessage( log, @@ -677,8 +673,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext , encoding_data_type = Type::eEncodingIsUID; attrs.type.Clear(); resolve_state = Type::ResolveState::Full; - -} else if (attrs.name == g_objc_type_name_Class) { +} else if (attrs.name == "Class") { if (log) dwarf->GetObjectFile()->GetModule()->LogMessage( log, @@ -689,7 +684,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext , encoding_data_type = Type::eEncodingIsUID; attrs.type.Clear(); resolve_state = Type::ResolveState::Full; -} else if (attrs.name == g_objc_type_name_selector) { +} else if (attrs.name == "SEL") { if (log) dwarf->GetObjectFile()->GetModule()->LogMessage( log, @@ -709,20 +704,19 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext , const DWARFDIE encoding_die = attrs.type.Reference(); if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type) { - if (const char *struct_name = encoding_die.GetName()) { -if (!strcmp(struct_name, "objc_object")) { - if (log) -dwarf->GetObjectFile()->GetModule()->LogMessage( -log, -"SymbolFileDWARF::ParseType (die = 0x%8.8x) %s " -"'%s' is 'objc_object*', which we overrode to " -"'id'.", -die.GetOffset(), die.GetTagAsCString(), die.GetName()); - clang_type = m_ast.GetBasicType(eBasicTypeObjCID); - encoding_data_type = Type::eEncodingIsUID; - attrs.type.Clear(); - resolve_state = Type::ResolveState::Full; -} + llvm::StringRef struct_name = encoding_die.GetName(); + if (struct_name == "objc_object") { +if (log) + dwarf->GetObjectFile()->GetModule()->LogMessage( + log, + "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s " + "'%s' is 'objc_object*', which we overrode to " + "'id'.", + die.GetOffset(), die.GetTagAsCString(), die.GetName()); +clang_type = m_ast.GetBasicType(eBasicTypeObjCID); +encoding_data_type = Type::eEncodingIsUID; +attrs.type.Clear(); +resolve_state = Type::ResolveState::Full; } } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cdfecb8 - [lldb][NFC] Remove no longer unused variable in DWARFASTParserClang::ParseTypeFromDWARF
Author: Raphael Isemann Date: 2019-11-26T14:17:06+01:00 New Revision: cdfecb82ee27fabf927102a356acd298ddca8703 URL: https://github.com/llvm/llvm-project/commit/cdfecb82ee27fabf927102a356acd298ddca8703 DIFF: https://github.com/llvm/llvm-project/commit/cdfecb82ee27fabf927102a356acd298ddca8703.diff LOG: [lldb][NFC] Remove no longer unused variable in DWARFASTParserClang::ParseTypeFromDWARF Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 78c5af482191..89331f7aca6c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -463,7 +463,6 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , const dw_tag_t tag = die.Tag(); - CompilerType clang_type; TypeSP type_sp; switch (tag) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0181338 - [lldb][NFC] Simplify structure parsing code in DWARFASTParserClang::ParseTypeFromDWARF
Author: Raphael Isemann Date: 2019-11-26T14:01:12+01:00 New Revision: 0181338ddae26230d4067fdc00c2f7218f1d64d7 URL: https://github.com/llvm/llvm-project/commit/0181338ddae26230d4067fdc00c2f7218f1d64d7 DIFF: https://github.com/llvm/llvm-project/commit/0181338ddae26230d4067fdc00c2f7218f1d64d7.diff LOG: [lldb][NFC] Simplify structure parsing code in DWARFASTParserClang::ParseTypeFromDWARF This way it looks more like the code around it. The assert is also gone as it just checks that the variables we declare directly above were not initialized by anyone. That made more sense when this was one large function. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 8ead4ea4f519..78c5af482191 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -483,10 +483,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_class_type: { -assert((!type_sp && !clang_type) && - "Did not expect partially computed structure-like type"); -TypeSP struct_like_type_sp = ParseStructureLikeDIE(sc, die, attrs); -return UpdateSymbolContextScopeForType(sc, die, struct_like_type_sp); +type_sp = ParseStructureLikeDIE(sc, die, attrs); +break; } case DW_TAG_enumeration_type: { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 30fc94b - [lldb][NFC] Extract type modifier parsing from DWARFASTParserClang::ParseTypeFromDWARF
Author: Raphael Isemann Date: 2019-11-26T13:53:06+01:00 New Revision: 30fc94be237f26d3127d8bbc872d9e3b82f03590 URL: https://github.com/llvm/llvm-project/commit/30fc94be237f26d3127d8bbc872d9e3b82f03590 DIFF: https://github.com/llvm/llvm-project/commit/30fc94be237f26d3127d8bbc872d9e3b82f03590.diff LOG: [lldb][NFC] Extract type modifier parsing from DWARFASTParserClang::ParseTypeFromDWARF Part of the work to split up this monolithic parsing function. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 17e0924e3e58..8ead4ea4f519 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -463,13 +463,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , const dw_tag_t tag = die.Tag(); - Type::ResolveState resolve_state = Type::ResolveState::Unresolved; - - Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID; CompilerType clang_type; - TypeSP type_sp; - LanguageType cu_language = die.GetLanguage(); + switch (tag) { case DW_TAG_typedef: case DW_TAG_base_type: @@ -480,209 +476,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , case DW_TAG_restrict_type: case DW_TAG_volatile_type: case DW_TAG_unspecified_type: { -if (tag == DW_TAG_typedef && attrs.type.IsValid()) { - // Try to parse a typedef from the (DWARF embedded in the) Clang - // module file first as modules can contain typedef'ed - // structures that have no names like: - // - // typedef struct { int a; } Foo; - // - // In this case we will have a structure with no name and a - // typedef named "Foo" that points to this unnamed - // structure. The name in the typedef is the only identifier for - // the struct, so always try to get typedefs from Clang modules - // if possible. - // - // The type_sp returned will be empty if the typedef doesn't - // exist in a module file, so it is cheap to call this function - // just to check. - // - // If we don't do this we end up creating a TypeSP that says - // this is a typedef to type 0x123 (the DW_AT_type value would - // be 0x123 in the DW_TAG_typedef), and this is the unnamed - // structure type. We will have a hard time tracking down an - // unnammed structure type in the module debug info, so we make - // sure we don't get into this situation by always resolving - // typedefs from the module. - const DWARFDIE encoding_die = attrs.type.Reference(); - - // First make sure that the die that this is typedef'ed to _is_ - // just a declaration (DW_AT_declaration == 1), not a full - // definition since template types can't be represented in - // modules since only concrete instances of templates are ever - // emitted and modules won't contain those - if (encoding_die && - encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) { -type_sp = ParseTypeFromClangModule(sc, die, log); -if (type_sp) - return type_sp; - } -} - -DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", - die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr, - encoding_uid.Reference()); - -switch (tag) { -default: - break; - -case DW_TAG_unspecified_type: - if (attrs.name == "nullptr_t" || attrs.name == "decltype(nullptr)") { -resolve_state = Type::ResolveState::Full; -clang_type = m_ast.GetBasicType(eBasicTypeNullPtr); -break; - } - // Fall through to base type below in case we can handle the type - // there... - LLVM_FALLTHROUGH; - -case DW_TAG_base_type: - resolve_state = Type::ResolveState::Full; - clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize( - attrs.name.GetCString(), attrs.encoding, - attrs.byte_size.getValueOr(0) * 8); - break; - -case DW_TAG_pointer_type: - encoding_data_type = Type::eEncodingIsPointerUID; - break; -case DW_TAG_reference_type: - encoding_data_type = Type::eEncodingIsLValueReferenceUID; - break; -case DW_TAG_rvalue_reference_type: - encoding_data_type = Type::eEncodingIsRValueReferenceUID; - break; -case DW_TAG_typedef: - encoding_data_type = Type::eEncodingIsTypedefUID; - break; -case DW_TAG_const_type: - encoding_data_type = Type::eEncodingIsConstUID; - break; -case DW_TAG_restrict_type: - encoding_data_type = Type::eEncodingIsRestrictUID; - break; -
[Lldb-commits] [lldb] 8f2b57d - [lldb][NFC] Extract enum parsing from DWARFASTParserClang::ParseTypeFromDWARF
Author: Raphael Isemann Date: 2019-11-26T12:30:06+01:00 New Revision: 8f2b57d257e87b0244f9883cd8075898005ba757 URL: https://github.com/llvm/llvm-project/commit/8f2b57d257e87b0244f9883cd8075898005ba757 DIFF: https://github.com/llvm/llvm-project/commit/8f2b57d257e87b0244f9883cd8075898005ba757.diff LOG: [lldb][NFC] Extract enum parsing from DWARFASTParserClang::ParseTypeFromDWARF Part of the work to split up this monolithic parsing function. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index aca87b3a5b1c..17e0924e3e58 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -694,106 +694,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , } case DW_TAG_enumeration_type: { -if (attrs.is_forward_declaration) { - type_sp = ParseTypeFromClangModule(sc, die, log); - if (type_sp) -return type_sp; - - DWARFDeclContext die_decl_ctx; - die.GetDWARFDeclContext(die_decl_ctx); - - type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx); - - if (!type_sp) { -SymbolFileDWARFDebugMap *debug_map_symfile = -dwarf->GetDebugMapSymfile(); -if (debug_map_symfile) { - // We weren't able to find a full declaration in this DWARF, - // see if we have a declaration anywhere else... - type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext( - die_decl_ctx); -} - } - - if (type_sp) { -if (log) { - dwarf->GetObjectFile()->GetModule()->LogMessage( - log, - "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a " - "forward declaration, complete type is 0x%8.8" PRIx64, - static_cast(this), die.GetOffset(), - DW_TAG_value_to_name(tag), attrs.name.GetCString(), - type_sp->GetID()); -} - -// We found a real definition for this type elsewhere so lets use -// it and cache the fact that we found a complete type for this -// die -dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); -clang::DeclContext *defn_decl_ctx = -GetCachedClangDeclContextForDIE(dwarf->GetDIE(type_sp->GetID())); -if (defn_decl_ctx) - LinkDeclContextToDIE(defn_decl_ctx, die); -return type_sp; - } -} -DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), - DW_TAG_value_to_name(tag), type_name_cstr); - -CompilerType enumerator_clang_type; -clang_type.SetCompilerType( -_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE())); -if (!clang_type) { - if (attrs.type.IsValid()) { -Type *enumerator_type = -dwarf->ResolveTypeUID(attrs.type.Reference(), true); -if (enumerator_type) - enumerator_clang_type = enumerator_type->GetFullCompilerType(); - } - - if (!enumerator_clang_type) { -if (attrs.byte_size) { - enumerator_clang_type = - m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize( - NULL, DW_ATE_signed, *attrs.byte_size * 8); -} else { - enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt); -} - } - - clang_type = m_ast.CreateEnumerationType( - attrs.name.GetCString(), - GetClangDeclContextContainingDIE(die, nullptr), attrs.decl, - enumerator_clang_type, attrs.is_scoped_enum); -} else { - enumerator_clang_type = - m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType()); -} - -LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), - die); - -type_sp = std::make_shared( -die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr, -dwarf->GetUID(attrs.type.Reference()), Type::eEncodingIsUID, -, clang_type, Type::ResolveState::Forward); - -if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) { - if (die.HasChildren()) { -bool is_signed = false; -enumerator_clang_type.IsIntegerType(is_signed); -ParseChildEnumerators(clang_type, is_signed, - type_sp->GetByteSize().getValueOr(0), die); - } - ClangASTContext::CompleteTagDeclarationDefinition(clang_type); -} else { - dwarf->GetObjectFile()->GetModule()->ReportError( - "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its " - "definition.\nPlease file a bug and attach the file at the " - "start of this error
[Lldb-commits] [lldb] 9493965 - [lldb][NFCI] Extract subroutine parsing from DWARFASTParserClang::ParseTypeFromDWARF
Author: Raphael Isemann Date: 2019-11-26T12:14:40+01:00 New Revision: 94939650b632cd44e518a9adeb16ab829375 URL: https://github.com/llvm/llvm-project/commit/94939650b632cd44e518a9adeb16ab829375 DIFF: https://github.com/llvm/llvm-project/commit/94939650b632cd44e518a9adeb16ab829375.diff LOG: [lldb][NFCI] Extract subroutine parsing from DWARFASTParserClang::ParseTypeFromDWARF Part of the work to split up this monolithic parsing function. Should be NFC but due to the kafkaesque control flow in this case statement this might have some unintended side effects. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index ea0f02778941..aca87b3a5b1c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -798,428 +798,436 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , case DW_TAG_inlined_subroutine: case DW_TAG_subprogram: case DW_TAG_subroutine_type: { -bool is_variadic = false; -bool is_static = false; -bool has_template_params = false; +type_sp = ParseSubroutine(die, attrs); +break; + } + case DW_TAG_array_type: { +type_sp = ParseArrayType(die, attrs); +break; + } + case DW_TAG_ptr_to_member_type: { +type_sp = ParsePointerToMemberType(die, attrs); +break; + } + default: +dwarf->GetObjectFile()->GetModule()->ReportError( +"{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and " +"attach the file at the start of this error message", +die.GetOffset(), tag, DW_TAG_value_to_name(tag)); +break; + } -unsigned type_quals = 0; + // TODO: We should consider making the switch above exhaustive to simplify + // control flow in ParseTypeFromDWARF. Then, we could simply replace this + // return statement with a call to llvm_unreachable. + return UpdateSymbolContextScopeForType(sc, die, type_sp); +} -std::string object_pointer_name; -if (attrs.object_pointer) { - const char *object_pointer_name_cstr = attrs.object_pointer.GetName(); - if (object_pointer_name_cstr) -object_pointer_name = object_pointer_name_cstr; -} +TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE , + ParsedDWARFTypeAttributes ) { + Log *log(LogChannelDWARF::GetLogIfAny(DWARF_LOG_TYPE_COMPLETION | +DWARF_LOG_LOOKUPS)); -DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), - DW_TAG_value_to_name(tag), type_name_cstr); + SymbolFileDWARF *dwarf = die.GetDWARF(); + const dw_tag_t tag = die.Tag(); -CompilerType return_clang_type; -Type *func_type = NULL; - -if (attrs.type.IsValid()) - func_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true); - -if (func_type) - return_clang_type = func_type->GetForwardCompilerType(); -else - return_clang_type = m_ast.GetBasicType(eBasicTypeVoid); - -std::vector function_param_types; -std::vector function_param_decls; - -// Parse the function children for the parameters - -DWARFDIE decl_ctx_die; -clang::DeclContext *containing_decl_ctx = -GetClangDeclContextContainingDIE(die, _ctx_die); -const clang::Decl::Kind containing_decl_kind = -containing_decl_ctx->getDeclKind(); - -bool is_cxx_method = DeclKindIsCXXClass(containing_decl_kind); -// Start off static. This will be set to false in -// ParseChildParameters(...) if we find a "this" parameters as the -// first parameter -if (is_cxx_method) { - is_static = true; -} - -if (die.HasChildren()) { - bool skip_artificial = true; - ParseChildParameters(containing_decl_ctx, die, skip_artificial, is_static, - is_variadic, has_template_params, - function_param_types, function_param_decls, - type_quals); -} - -bool ignore_containing_context = false; -// Check for templatized class member functions. If we had any -// DW_TAG_template_type_parameter or DW_TAG_template_value_parameter -// the DW_TAG_subprogram DIE, then we can't let this become a method in -// a class. Why? Because templatized functions are only emitted if one -// of the templatized methods is used in the current compile unit and -// we will end up with classes that may or may not include these member -// functions and this means one class won't match another class -// definition and it affects our ability to use a class in the clang -// expression parser. So for the greater good,
[Lldb-commits] [lldb] e8013ef - [lldb][NFC] Extract array type parsing from DWARFASTParserClang::ParseTypeFromDWARF
Author: Raphael Isemann Date: 2019-11-26T11:46:25+01:00 New Revision: e8013ef53ac0cd82f9c921abd0b2fa1aa8b2f20c URL: https://github.com/llvm/llvm-project/commit/e8013ef53ac0cd82f9c921abd0b2fa1aa8b2f20c DIFF: https://github.com/llvm/llvm-project/commit/e8013ef53ac0cd82f9c921abd0b2fa1aa8b2f20c.diff LOG: [lldb][NFC] Extract array type parsing from DWARFASTParserClang::ParseTypeFromDWARF Part of the work to split up this monolithic parsing function. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 6d02f1b5ee83..ea0f02778941 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1201,90 +1201,9 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , } break; case DW_TAG_array_type: { -DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), - DW_TAG_value_to_name(tag), type_name_cstr); - -DWARFDIE type_die = attrs.type.Reference(); -Type *element_type = dwarf->ResolveTypeUID(type_die, true); - -if (element_type) { - auto array_info = ParseChildArrayInfo(die); - if (array_info) { -attrs.byte_stride = array_info->byte_stride; -attrs.bit_stride = array_info->bit_stride; - } - if (attrs.byte_stride == 0 && attrs.bit_stride == 0) -attrs.byte_stride = element_type->GetByteSize().getValueOr(0); - CompilerType array_element_type = element_type->GetForwardCompilerType(); - - if (ClangASTContext::IsCXXClassType(array_element_type) && - !array_element_type.GetCompleteType()) { -ModuleSP module_sp = die.GetModule(); -if (module_sp) { - if (die.GetCU()->GetProducer() == eProducerClang) -module_sp->ReportError( -"DWARF DW_TAG_array_type DIE at 0x%8.8x has a " -"class/union/struct element type DIE 0x%8.8x that is a " -"forward declaration, not a complete definition.\nTry " -"compiling the source file with -fstandalone-debug or " -"disable -gmodules", -die.GetOffset(), type_die.GetOffset()); - else -module_sp->ReportError( -"DWARF DW_TAG_array_type DIE at 0x%8.8x has a " -"class/union/struct element type DIE 0x%8.8x that is a " -"forward declaration, not a complete definition.\nPlease " -"file a bug against the compiler and include the " -"preprocessed output for %s", -die.GetOffset(), type_die.GetOffset(), -GetUnitName(die).c_str()); -} - -// We have no choice other than to pretend that the element class -// type is complete. If we don't do this, clang will crash when -// trying to layout the class. Since we provide layout -// assistance, all ivars in this class and other classes will be -// fine, this is the best we can do short of crashing. -if (ClangASTContext::StartTagDeclarationDefinition( -array_element_type)) { - ClangASTContext::CompleteTagDeclarationDefinition(array_element_type); -} else { - module_sp->ReportError("DWARF DIE at 0x%8.8x was not able to " - "start its definition.\nPlease file a " - "bug and attach the file at the start " - "of this error message", - type_die.GetOffset()); -} - } - - uint64_t array_element_bit_stride = - attrs.byte_stride * 8 + attrs.bit_stride; - if (array_info && array_info->element_orders.size() > 0) { -uint64_t num_elements = 0; -auto end = array_info->element_orders.rend(); -for (auto pos = array_info->element_orders.rbegin(); pos != end; - ++pos) { - num_elements = *pos; - clang_type = m_ast.CreateArrayType(array_element_type, num_elements, - attrs.is_vector); - array_element_type = clang_type; - array_element_bit_stride = - num_elements ? array_element_bit_stride * num_elements - : array_element_bit_stride; -} - } else { -clang_type = m_ast.CreateArrayType(array_element_type, 0, attrs.is_vector); - } - ConstString empty_name; - type_sp = std::make_shared( - die.GetID(), dwarf, empty_name, array_element_bit_stride / 8, nullptr, - dwarf->GetUID(type_die), Type::eEncodingIsUID, , -
[Lldb-commits] [lldb] 7047a3a - [lldb][NFC] Extract pointer to member type parsing from DWARFASTParserClang::ParseTypeFromDWARF
Author: Raphael Isemann Date: 2019-11-26T11:07:59+01:00 New Revision: 7047a3a729c6b2779b512269ff3eba88d8976d63 URL: https://github.com/llvm/llvm-project/commit/7047a3a729c6b2779b512269ff3eba88d8976d63 DIFF: https://github.com/llvm/llvm-project/commit/7047a3a729c6b2779b512269ff3eba88d8976d63.diff LOG: [lldb][NFC] Extract pointer to member type parsing from DWARFASTParserClang::ParseTypeFromDWARF Part of the work to split up this monolithic parsing function. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 3a712fc7e76b..6d02f1b5ee83 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1286,24 +1286,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , } break; case DW_TAG_ptr_to_member_type: { -Type *pointee_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true); -Type *class_type = -dwarf->ResolveTypeUID(attrs.containing_type.Reference(), true); - -CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType(); -CompilerType class_clang_type = class_type->GetLayoutCompilerType(); - -clang_type = ClangASTContext::CreateMemberPointerType(class_clang_type, - pointee_clang_type); - -if (llvm::Optional clang_type_size = -clang_type.GetByteSize(nullptr)) { - type_sp = std::make_shared( - die.GetID(), dwarf, attrs.name, *clang_type_size, nullptr, - LLDB_INVALID_UID, Type::eEncodingIsUID, nullptr, clang_type, - Type::ResolveState::Forward); -} - +type_sp = ParsePointerToMemberType(die, attrs); break; } default: @@ -1320,6 +1303,29 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext , return UpdateSymbolContextScopeForType(sc, die, type_sp); } +TypeSP DWARFASTParserClang::ParsePointerToMemberType( +const DWARFDIE , const ParsedDWARFTypeAttributes ) { + SymbolFileDWARF *dwarf = die.GetDWARF(); + Type *pointee_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true); + Type *class_type = + dwarf->ResolveTypeUID(attrs.containing_type.Reference(), true); + + CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType(); + CompilerType class_clang_type = class_type->GetLayoutCompilerType(); + + CompilerType clang_type = ClangASTContext::CreateMemberPointerType( + class_clang_type, pointee_clang_type); + + if (llvm::Optional clang_type_size = + clang_type.GetByteSize(nullptr)) { +return std::make_shared(die.GetID(), dwarf, attrs.name, + *clang_type_size, nullptr, LLDB_INVALID_UID, + Type::eEncodingIsUID, nullptr, clang_type, + Type::ResolveState::Forward); + } + return nullptr; +} + TypeSP DWARFASTParserClang::UpdateSymbolContextScopeForType( const SymbolContext , const DWARFDIE , TypeSP type_sp) { if (!type_sp) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 982a089981d4..b92c39739454 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -168,6 +168,10 @@ class DWARFASTParserClang : public DWARFASTParser { // Return true if this type is a declaration to a type in an external // module. lldb::ModuleSP GetModuleForType(const DWARFDIE ); + +private: + lldb::TypeSP ParsePointerToMemberType(const DWARFDIE , +const ParsedDWARFTypeAttributes ); }; /// Parsed form of all attributes that are relevant for type reconstruction. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cfd9d39 - [lldb][NFC] NULL -> nullptr in DWARFASTParserClang::UpdateSymbolContextScopeForType
Author: Raphael Isemann Date: 2019-11-26T10:35:30+01:00 New Revision: cfd9d395674030d549de286d26c0f52020de26e6 URL: https://github.com/llvm/llvm-project/commit/cfd9d395674030d549de286d26c0f52020de26e6 DIFF: https://github.com/llvm/llvm-project/commit/cfd9d395674030d549de286d26c0f52020de26e6.diff LOG: [lldb][NFC] NULL -> nullptr in DWARFASTParserClang::UpdateSymbolContextScopeForType Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 01655f04c422..3a712fc7e76b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1330,20 +1330,20 @@ TypeSP DWARFASTParserClang::UpdateSymbolContextScopeForType( DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die); dw_tag_t sc_parent_tag = sc_parent_die.Tag(); - SymbolContextScope *symbol_context_scope = NULL; + SymbolContextScope *symbol_context_scope = nullptr; if (sc_parent_tag == DW_TAG_compile_unit || sc_parent_tag == DW_TAG_partial_unit) { symbol_context_scope = sc.comp_unit; - } else if (sc.function != NULL && sc_parent_die) { + } else if (sc.function != nullptr && sc_parent_die) { symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID()); -if (symbol_context_scope == NULL) +if (symbol_context_scope == nullptr) symbol_context_scope = sc.function; } else { symbol_context_scope = sc.module_sp.get(); } - if (symbol_context_scope != NULL) + if (symbol_context_scope != nullptr) type_sp->SetSymbolContextScope(symbol_context_scope); // We are ready to put this type into the uniqued list up at the module ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d178213 - [lldb][NFC] Allow range-based for-loops on VariableList
Author: Raphael Isemann Date: 2019-11-25T15:03:46+01:00 New Revision: d1782133d96d316c3bc98e33a191994794a26851 URL: https://github.com/llvm/llvm-project/commit/d1782133d96d316c3bc98e33a191994794a26851 DIFF: https://github.com/llvm/llvm-project/commit/d1782133d96d316c3bc98e33a191994794a26851.diff LOG: [lldb][NFC] Allow range-based for-loops on VariableList Summary: Adds support for doing range-based for-loops on LLDB's VariableList and modernises all the index-based for-loops in LLDB where possible. Reviewers: labath, jdoerfert Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70668 Added: Modified: lldb/include/lldb/Symbol/VariableList.h lldb/source/API/SBFrame.cpp lldb/source/API/SBModule.cpp lldb/source/API/SBTarget.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/Address.cpp lldb/source/Core/IOHandler.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp lldb/source/Symbol/Block.cpp lldb/source/Symbol/Variable.cpp lldb/source/Target/StackFrame.cpp Removed: diff --git a/lldb/include/lldb/Symbol/VariableList.h b/lldb/include/lldb/Symbol/VariableList.h index 54d27583cd7b..87f98668a8a8 100644 --- a/lldb/include/lldb/Symbol/VariableList.h +++ b/lldb/include/lldb/Symbol/VariableList.h @@ -16,6 +16,8 @@ namespace lldb_private { class VariableList { + typedef std::vector collection; + public: // Constructors and Destructors // VariableList(const SymbolContext _context); @@ -65,11 +67,15 @@ class VariableList { size_t GetSize() const; bool Empty() const { return m_variables.empty(); } -protected: - typedef std::vector collection; typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; + iterator begin() { return m_variables.begin(); } + iterator end() { return m_variables.end(); } + const_iterator begin() const { return m_variables.begin(); } + const_iterator end() const { return m_variables.end(); } + +protected: collection m_variables; private: diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index c0e272e1bcd4..af42be9ac75e 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -831,14 +831,12 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions ) { if (stop_locker.TryLock(>GetRunLock())) { frame = exe_ctx.GetFramePtr(); if (frame) { -size_t i; VariableList *variable_list = nullptr; variable_list = frame->GetVariableList(true); if (variable_list) { const size_t num_variables = variable_list->GetSize(); if (num_variables) { -for (i = 0; i < num_variables; ++i) { - VariableSP variable_sp(variable_list->GetVariableAtIndex(i)); +for (const VariableSP _sp : *variable_list) { if (variable_sp) { bool add_variable = false; switch (variable_sp->GetScope()) { diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 6cc6d2628ace..7ac189bb4273 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -419,16 +419,12 @@ SBValueList SBModule::FindGlobalVariables(SBTarget , const char *name, VariableList variable_list; module_sp->FindGlobalVariables(ConstString(name), nullptr, max_matches, variable_list); -const uint32_t match_count = variable_list.GetSize(); -if (match_count > 0) { - for (uint32_t i = 0; i < match_count; ++i) { -lldb::ValueObjectSP valobj_sp; -TargetSP target_sp(target.GetSP()); -valobj_sp = ValueObjectVariable::Create( -target_sp.get(), variable_list.GetVariableAtIndex(i)); -if (valobj_sp) - sb_value_list.Append(SBValue(valobj_sp)); - } +for (const VariableSP _sp : variable_list) { + lldb::ValueObjectSP valobj_sp; + TargetSP target_sp(target.GetSP()); + valobj_sp = ValueObjectVariable::Create(target_sp.get(), var_sp); + if (valobj_sp) +sb_value_list.Append(SBValue(valobj_sp)); } } diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index bf444a72278a..7013e2b45e5f 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1929,14 +1929,13 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, VariableList variable_list; target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches, variable_list); -const uint32_t match_count = variable_list.GetSize(); -if (match_count > 0) { +if (!variable_list.Empty()) {
[Lldb-commits] [lldb] 7a6588a - [lldb] Remove lldb's own ASTDumper
Author: Raphael Isemann Date: 2019-11-25T13:27:51+01:00 New Revision: 7a6588abf8bac99d716188608adfbfb4928714db URL: https://github.com/llvm/llvm-project/commit/7a6588abf8bac99d716188608adfbfb4928714db DIFF: https://github.com/llvm/llvm-project/commit/7a6588abf8bac99d716188608adfbfb4928714db.diff LOG: [lldb] Remove lldb's own ASTDumper Summary: LLDB's ASTDumper is just a clone of Clang's ASTDumper but with some scary code and some unrelated functionality (like dumping name/attributes of types). This removes LLDB's ASTDumper and replaces its uses with the `ClangUtils::DumpDecl` method that just calls Clang's ASTDumper and returns the result as a string. The few uses where we just want a textual representation of a type (which will print their name/attributes but not dump any AST) are now also in ClangUtil under a `ToString` name until we find a better home for them. Reviewers: labath Reviewed By: labath Subscribers: mgorny, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70663 Added: Modified: lldb/include/lldb/Symbol/ClangUtil.h lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp lldb/source/Symbol/ClangUtil.cpp Removed: lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.h diff --git a/lldb/include/lldb/Symbol/ClangUtil.h b/lldb/include/lldb/Symbol/ClangUtil.h index d6106032190c..5ffbce340e59 100644 --- a/lldb/include/lldb/Symbol/ClangUtil.h +++ b/lldb/include/lldb/Symbol/ClangUtil.h @@ -11,6 +11,7 @@ #ifndef LLDB_SYMBOL_CLANGUTIL_H #define LLDB_SYMBOL_CLANGUTIL_H +#include "clang/AST/DeclBase.h" #include "clang/AST/Type.h" #include "lldb/Symbol/CompilerType.h" @@ -30,6 +31,15 @@ struct ClangUtil { static CompilerType RemoveFastQualifiers(const CompilerType ); static clang::TagDecl *GetAsTagDecl(const CompilerType ); + + /// Returns a textual representation of the given Decl's AST. Does not + /// deserialize any child nodes. + static std::string DumpDecl(const clang::Decl *d); + /// Returns a textual representation of the given type. + static std::string ToString(const clang::Type *t); + /// Returns a textual representation of the given CompilerType (assuming + /// its underlying type is a Clang type). + static std::string ToString(const CompilerType ); }; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp deleted file mode 100644 index f33a713cc0b2.. --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//===-- ASTDumper.cpp ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -#include "ASTDumper.h" - -#include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangUtil.h" -#include "lldb/Symbol/CompilerType.h" -#include "lldb/Utility/Log.h" - -#include "llvm/Support/raw_ostream.h" - -using namespace lldb_private; - -ASTDumper::ASTDumper(clang::Decl *decl) { - clang::DeclContext *decl_ctx = llvm::dyn_cast(decl); - - bool has_external_lexical_storage; - bool has_external_visible_storage; - - if (decl_ctx) { -has_external_lexical_storage = decl_ctx->hasExternalLexicalStorage(); -has_external_visible_storage = decl_ctx->hasExternalVisibleStorage(); -decl_ctx->setHasExternalLexicalStorage(false); -decl_ctx->setHasExternalVisibleStorage(false); - } - - llvm::raw_string_ostream os(m_dump); - decl->print(os); - os.flush(); - - if (decl_ctx) { -decl_ctx->setHasExternalLexicalStorage(has_external_lexical_storage); -decl_ctx->setHasExternalVisibleStorage(has_external_visible_storage); - } -} - -ASTDumper::ASTDumper(clang::DeclContext *decl_ctx) { - bool has_external_lexical_storage = decl_ctx->hasExternalLexicalStorage(); - bool has_external_visible_storage = decl_ctx->hasExternalVisibleStorage(); - - decl_ctx->setHasExternalLexicalStorage(false); - decl_ctx->setHasExternalVisibleStorage(false); - - if (clang::Decl *decl = llvm::dyn_cast(decl_ctx)) { -llvm::raw_string_ostream os(m_dump); -decl->print(os); -os.flush(); - } else { -m_dump.assign(""); - } - - decl_ctx->setHasExternalLexicalStorage(has_external_lexical_storage); - decl_ctx->setHasExternalVisibleStorage(has_external_visible_storage); -} - -ASTDumper::ASTDumper(const
[Lldb-commits] [lldb] 1e0d395 - [lldb][NFC] Do an early exit in LookupLocalVarNamespace and LookUpLldbObjCClass
Author: Raphael Isemann Date: 2019-11-23T22:48:09+01:00 New Revision: 1e0d395480b3cc4d1364aab74a81ce5ba29a470c URL: https://github.com/llvm/llvm-project/commit/1e0d395480b3cc4d1364aab74a81ce5ba29a470c DIFF: https://github.com/llvm/llvm-project/commit/1e0d395480b3cc4d1364aab74a81ce5ba29a470c.diff LOG: [lldb][NFC] Do an early exit in LookupLocalVarNamespace and LookUpLldbObjCClass Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 60759be0eb0f..30c0ddd3f2a0 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1039,64 +1039,72 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext , lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); - if (self_var && self_var->IsInScope(frame) && - self_var->LocationIsValidForFrame(frame)) { -Type *self_type = self_var->GetType(); + if (!self_var) +return; + if (!self_var->IsInScope(frame)) +return; + if (!self_var->LocationIsValidForFrame(frame)) +return; -if (!self_type) - return; + Type *self_type = self_var->GetType(); -CompilerType self_clang_type = self_type->GetFullCompilerType(); + if (!self_type) +return; -if (ClangASTContext::IsObjCClassType(self_clang_type)) { - return; -} else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type)) { - self_clang_type = self_clang_type.GetPointeeType(); + CompilerType self_clang_type = self_type->GetFullCompilerType(); - if (!self_clang_type) -return; + if (ClangASTContext::IsObjCClassType(self_clang_type)) { +return; + } + if (!ClangASTContext::IsObjCObjectPointerType(self_clang_type)) +return; + self_clang_type = self_clang_type.GetPointeeType(); - if (log) { -ASTDumper ast_dumper(self_type->GetFullCompilerType()); -LLDB_LOGF(log, " FEVD[%u] Adding type for $__lldb_objc_class: %s", - current_id, ast_dumper.GetCString()); - } + if (!self_clang_type) +return; - TypeFromUser class_user_type(self_clang_type); + if (log) { +ASTDumper ast_dumper(self_type->GetFullCompilerType()); +LLDB_LOGF(log, " FEVD[%u] Adding type for $__lldb_objc_class: %s", + current_id, ast_dumper.GetCString()); + } - AddOneType(context, class_user_type, current_id); + TypeFromUser class_user_type(self_clang_type); - TypeFromUser self_user_type(self_type->GetFullCompilerType()); + AddOneType(context, class_user_type, current_id); - m_struct_vars->m_object_pointer_type = self_user_type; -} - } + TypeFromUser self_user_type(self_type->GetFullCompilerType()); + + m_struct_vars->m_object_pointer_type = self_user_type; } void ClangExpressionDeclMap::LookupLocalVarNamespace( -SymbolContext _ctx, NameSearchContext ) { - CompilerDeclContext frame_decl_context = sym_ctx.block != nullptr - ? sym_ctx.block->GetDeclContext() - : CompilerDeclContext(); - - if (frame_decl_context) { -ClangASTContext *frame_ast = llvm::dyn_cast_or_null( -frame_decl_context.GetTypeSystem()); - -ClangASTContext *map_ast = ClangASTContext::GetASTContext(m_ast_context); -if (frame_ast && map_ast) { - clang::NamespaceDecl *namespace_decl = - map_ast->GetUniqueNamespaceDeclaration( - g_lldb_local_vars_namespace_cstr, nullptr); - if (namespace_decl) { -context.AddNamedDecl(namespace_decl); -clang::DeclContext *clang_decl_ctx = -clang::Decl::castToDeclContext(namespace_decl); -clang_decl_ctx->setHasExternalVisibleStorage(true); -context.m_found.local_vars_nsp = true; - } -} - } +SymbolContext _ctx, NameSearchContext _context) { + if (sym_ctx.block == nullptr) +return; + + CompilerDeclContext frame_decl_context = sym_ctx.block->GetDeclContext(); + if (!frame_decl_context) +return; + + ClangASTContext *frame_ast = llvm::dyn_cast_or_null( + frame_decl_context.GetTypeSystem()); + if (!frame_ast) +return; + + ClangASTContext *map_ast = ClangASTContext::GetASTContext(m_ast_context); + if (!map_ast) +return; + + clang::NamespaceDecl *namespace_decl = map_ast->GetUniqueNamespaceDeclaration( + g_lldb_local_vars_namespace_cstr, nullptr); + if (!namespace_decl) +return; + + name_context.AddNamedDecl(namespace_decl); + clang::DeclContext *ctxt = clang::Decl::castToDeclContext(namespace_decl); +
[Lldb-commits] [lldb] 46883f4 - [lldb][NFC] NFC refactoring for ClangExpressionDeclMap::LookupInModulesDeclVendor
Author: Raphael Isemann Date: 2019-11-23T20:31:13+01:00 New Revision: 46883f46dc4f0ec3eb5cf2a6c5492bbd2c57c8c2 URL: https://github.com/llvm/llvm-project/commit/46883f46dc4f0ec3eb5cf2a6c5492bbd2c57c8c2 DIFF: https://github.com/llvm/llvm-project/commit/46883f46dc4f0ec3eb5cf2a6c5492bbd2c57c8c2.diff LOG: [lldb][NFC] NFC refactoring for ClangExpressionDeclMap::LookupInModulesDeclVendor Early exiting and deduplicating copy-pasted code. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 53bcde940e9a..60759be0eb0f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1103,69 +1103,44 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor( NameSearchContext , ConstString name, unsigned current_id) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - if (ClangModulesDeclVendor *modules_decl_vendor = - m_target->GetClangModulesDeclVendor()) { -bool append = false; -uint32_t max_matches = 1; -std::vector decls; - -if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls)) - return; - -clang::NamedDecl *const decl_from_modules = decls[0]; - -if (llvm::isa(decl_from_modules)) { - if (log) { -LLDB_LOGF(log, - " CAS::FEVD[%u] Matching function found for " - "\"%s\" in the modules", - current_id, name.GetCString()); - } - - clang::Decl *copied_decl = CopyDecl(decl_from_modules); - clang::FunctionDecl *copied_function_decl = - copied_decl ? dyn_cast(copied_decl) : nullptr; - - if (!copied_function_decl) { -LLDB_LOGF(log, - " CAS::FEVD[%u] - Couldn't export a function " - "declaration from the modules", - current_id); - -return; - } + auto *modules_decl_vendor = m_target->GetClangModulesDeclVendor(); + if (!modules_decl_vendor) +return; - MaybeRegisterFunctionBody(copied_function_decl); + bool append = false; + uint32_t max_matches = 1; + std::vector decls; - context.AddNamedDecl(copied_function_decl); + if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls)) +return; - context.m_found.function_with_type_info = true; - context.m_found.function = true; -} else if (llvm::isa(decl_from_modules)) { - if (log) { -LLDB_LOGF(log, - " CAS::FEVD[%u] Matching variable found for " - "\"%s\" in the modules", - current_id, name.GetCString()); - } + assert(!decls.empty() && "FindDecls returned true but no decls?"); + clang::NamedDecl *const decl_from_modules = decls[0]; - clang::Decl *copied_decl = CopyDecl(decl_from_modules); - clang::VarDecl *copied_var_decl = - copied_decl ? dyn_cast_or_null(copied_decl) : nullptr; + LLDB_LOG(log, + " CAS::FEVD[{0}] Matching decl found for " + "\"{1}\" in the modules", + current_id, name); - if (!copied_var_decl) { -LLDB_LOGF(log, - " CAS::FEVD[%u] - Couldn't export a variable " - "declaration from the modules", - current_id); + clang::Decl *copied_decl = CopyDecl(decl_from_modules); + if (!copied_decl) { +LLDB_LOG(log, + " CAS::FEVD[{0}] - Couldn't export a " + "declaration from the modules", + current_id); +return; + } -return; - } + if (auto copied_function = dyn_cast(copied_decl)) { +MaybeRegisterFunctionBody(copied_function); - context.AddNamedDecl(copied_var_decl); +context.AddNamedDecl(copied_function); - context.m_found.variable = true; -} +context.m_found.function_with_type_info = true; +context.m_found.function = true; + } else if (auto copied_var = dyn_cast(copied_decl)) { +context.AddNamedDecl(copied_var); +context.m_found.variable = true; } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7a0c548 - [lldb][NFC] NFC refactoring ClangExpressionDeclMap::LookupLocalVariable
Author: Raphael Isemann Date: 2019-11-23T18:41:23+01:00 New Revision: 7a0c54844474ca110a2ca5316d86ec08417c1730 URL: https://github.com/llvm/llvm-project/commit/7a0c54844474ca110a2ca5316d86ec08417c1730 DIFF: https://github.com/llvm/llvm-project/commit/7a0c54844474ca110a2ca5316d86ec08417c1730.diff LOG: [lldb][NFC] NFC refactoring ClangExpressionDeclMap::LookupLocalVariable Adding an early exits and moving variable declarations closer to their actual use. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 418a90614cd1..53bcde940e9a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1172,48 +1172,45 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor( bool ClangExpressionDeclMap::LookupLocalVariable( NameSearchContext , ConstString name, unsigned current_id, SymbolContext _ctx, CompilerDeclContext _decl) { - ValueObjectSP valobj; - VariableSP var; + if (sym_ctx.block == nullptr) +return false; + CompilerDeclContext decl_context = sym_ctx.block->GetDeclContext(); + if (!decl_context) +return false; + + // Make sure that the variables are parsed so that we have the + // declarations. StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr(); - CompilerDeclContext compiler_decl_context = - sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext() - : CompilerDeclContext(); - - if (compiler_decl_context) { -// Make sure that the variables are parsed so that we have the -// declarations. -VariableListSP vars = frame->GetInScopeVariableList(true); -for (size_t i = 0; i < vars->GetSize(); i++) - vars->GetVariableAtIndex(i)->GetDecl(); - -// Search for declarations matching the name. Do not include imported -// decls in the search if we are looking for decls in the artificial -// namespace $__lldb_local_vars. -std::vector found_decls = -compiler_decl_context.FindDeclByName(name, namespace_decl.IsValid()); - -bool variable_found = false; -for (CompilerDecl decl : found_decls) { - for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) { -VariableSP candidate_var = vars->GetVariableAtIndex(vi); -if (candidate_var->GetDecl() == decl) { - var = candidate_var; - break; -} - } + VariableListSP vars = frame->GetInScopeVariableList(true); + for (size_t i = 0; i < vars->GetSize(); i++) +vars->GetVariableAtIndex(i)->GetDecl(); - if (var && !variable_found) { -variable_found = true; -valobj = ValueObjectVariable::Create(frame, var); -AddOneVariable(context, var, valobj, current_id); -context.m_found.variable = true; + // Search for declarations matching the name. Do not include imported + // decls in the search if we are looking for decls in the artificial + // namespace $__lldb_local_vars. + std::vector found_decls = + decl_context.FindDeclByName(name, namespace_decl.IsValid()); + + VariableSP var; + bool variable_found = false; + for (CompilerDecl decl : found_decls) { +for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) { + VariableSP candidate_var = vars->GetVariableAtIndex(vi); + if (candidate_var->GetDecl() == decl) { +var = candidate_var; +break; } } -if (variable_found) - return true; + +if (var && !variable_found) { + variable_found = true; + ValueObjectSP valobj = ValueObjectVariable::Create(frame, var); + AddOneVariable(context, var, valobj, current_id); + context.m_found.variable = true; +} } - return false; + return variable_found; } void ClangExpressionDeclMap::LookupFunction(NameSearchContext , ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7af53d7 - [lldb][NFC] Fix LLDB build after ModuleManager->ASTReader rename
Author: Raphael Isemann Date: 2019-11-23T17:56:23+01:00 New Revision: 7af53d75c60bf5c09157daeebff86b9e594bf1ee URL: https://github.com/llvm/llvm-project/commit/7af53d75c60bf5c09157daeebff86b9e594bf1ee DIFF: https://github.com/llvm/llvm-project/commit/7af53d75c60bf5c09157daeebff86b9e594bf1ee.diff LOG: [lldb][NFC] Fix LLDB build after ModuleManager->ASTReader rename That happened in 20d51b2f14ac4488f684f8f but LLDB wasn't updated. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 664938c9613e..a0f966ddd511 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -974,7 +974,7 @@ ClangExpressionParser::ParseInternal(DiagnosticManager _manager, m_compiler->setASTConsumer(std::move(Consumer)); if (ast_context.getLangOpts().Modules) { -m_compiler->createModuleManager(); +m_compiler->createASTReader(); m_ast_context->setSema(_compiler->getSema()); } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index f3df589d7311..f3bb24ee79da 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -704,7 +704,7 @@ ClangModulesDeclVendor::Create(Target ) { instance->getPreprocessor().enableIncrementalProcessing(); - instance->createModuleManager(); + instance->createASTReader(); instance->createSema(action->getTranslationUnitKind(), nullptr); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0b0dca9 - [lldb] Fix exception breakpoint not being resolved when set on dummy target
Author: Martin Svensson Date: 2019-11-22T11:20:09+01:00 New Revision: 0b0dca9f6fe34333abdb437bd1d3d92c8362a2e6 URL: https://github.com/llvm/llvm-project/commit/0b0dca9f6fe34333abdb437bd1d3d92c8362a2e6 DIFF: https://github.com/llvm/llvm-project/commit/0b0dca9f6fe34333abdb437bd1d3d92c8362a2e6.diff LOG: [lldb] Fix exception breakpoint not being resolved when set on dummy target Summary: Ensure that breakpoint ivar is properly set in exception breakpoint resolver so that exception breakpoints set on dummy targets are resolved once real targets are created and run. Reviewers: jingham Reviewed By: jingham Subscribers: teemperor, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D69880 Added: Modified: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py lldb/source/Target/LanguageRuntime.cpp Removed: diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py index e8a1b81a8394..839a47041ae8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py @@ -24,6 +24,14 @@ def test_cpp_exception_breakpoint(self): self.build() self.do_cpp_exception_bkpt() +@add_test_categories(['pyapi']) +@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24538") +@expectedFailureNetBSD +def test_dummy_target_cpp_exception_breakpoint(self): +"""Test setting and hitting the C++ exception breakpoint from dummy target.""" +self.build() +self.do_dummy_target_cpp_exception_bkpt() + def setUp(self): TestBase.setUp(self) self.main_source = "main.c" @@ -50,3 +58,30 @@ def do_cpp_exception_bkpt(self): process, exception_bkpt) self.assertTrue(len(thread_list) == 1, "One thread stopped at the exception breakpoint.") + +def do_dummy_target_cpp_exception_bkpt(self): +exe = self.getBuildArtifact("a.out") +error = lldb.SBError() + +dummy_exception_bkpt = self.dbg.GetDummyTarget().BreakpointCreateForException( +lldb.eLanguageTypeC_plus_plus, False, True) +self.assertTrue( +dummy_exception_bkpt.IsValid(), +"Created exception breakpoint in dummy target.") + +self.target = self.dbg.CreateTarget(exe) +self.assertTrue(self.target, VALID_TARGET) + +exception_bkpt = self.target.GetBreakpointAtIndex(0) +self.assertTrue( +exception_bkpt.IsValid(), +"Target primed with exception breakpoint from dummy target.") + +process = self.target.LaunchSimple( +None, None, self.get_process_working_directory()) +self.assertTrue(process, PROCESS_IS_VALID) + +thread_list = lldbutil.get_threads_stopped_at_breakpoint( + process, exception_bkpt) +self.assertTrue(len(thread_list) == 1, + "One thread stopped at the exception breakpoint.") diff --git a/lldb/source/Target/LanguageRuntime.cpp b/lldb/source/Target/LanguageRuntime.cpp index 999ac99e93c3..32dd805a00b1 100644 --- a/lldb/source/Target/LanguageRuntime.cpp +++ b/lldb/source/Target/LanguageRuntime.cpp @@ -155,8 +155,10 @@ class ExceptionBreakpointResolver : public BreakpointResolver { protected: BreakpointResolverSP CopyForBreakpoint(Breakpoint ) override { -return BreakpointResolverSP( +BreakpointResolverSP ret_sp( new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp)); +ret_sp->SetBreakpoint(); +return ret_sp; } bool SetActualResolver() { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b30dabf - [lldb] Don't enable expression log in TestEmptyStdModule.py
Author: Raphael Isemann Date: 2019-11-22T08:34:08+01:00 New Revision: b30dabfe905b714b9161422b58199e2aa8938481 URL: https://github.com/llvm/llvm-project/commit/b30dabfe905b714b9161422b58199e2aa8938481 DIFF: https://github.com/llvm/llvm-project/commit/b30dabfe905b714b9161422b58199e2aa8938481.diff LOG: [lldb] Don't enable expression log in TestEmptyStdModule.py Thanks for pointing this out Jason! Added: Modified: lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py index 7df275d5badd..76e79df5cd1c 100644 --- a/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py @@ -28,7 +28,6 @@ def test(self): "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) self.runCmd("settings set target.import-std-module true") -self.runCmd("log enable lldb expr") # Use the typedef that is only defined in our 'empty' module. If this fails, then LLDB # somehow figured out the correct define for the header and compiled the right ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 8cf8ec4 - [lldb][NFC] Modernize string handling in ClangExpressionDeclMap::FindExternalVisibleDecl
Author: Raphael Isemann Date: 2019-11-21T14:59:47+01:00 New Revision: 8cf8ec40a1fee9706237d30385e78e1de214d8f7 URL: https://github.com/llvm/llvm-project/commit/8cf8ec40a1fee9706237d30385e78e1de214d8f7 DIFF: https://github.com/llvm/llvm-project/commit/8cf8ec40a1fee9706237d30385e78e1de214d8f7.diff LOG: [lldb][NFC] Modernize string handling in ClangExpressionDeclMap::FindExternalVisibleDecl Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index c6cb63407f70..418a90614cd1 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1453,20 +1453,17 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( if (!namespace_decl) SearchPersistenDecls(context, name, current_id); - if (name.GetCString()[0] == '$' && !namespace_decl) { -static ConstString g_lldb_class_name("$__lldb_class"); - -if (name == g_lldb_class_name) { + if (name.GetStringRef().startswith("$") && !namespace_decl) { +if (name == "$__lldb_class") { LookUpLldbClass(context, current_id); return; } -static ConstString g_lldb_objc_class_name("$__lldb_objc_class"); -if (name == g_lldb_objc_class_name) { +if (name == "$__lldb_objc_class") { LookUpLldbObjCClass(context, current_id); return; } -if (name == ConstString(g_lldb_local_vars_namespace_cstr)) { +if (name == g_lldb_local_vars_namespace_cstr) { LookupLocalVarNamespace(sym_ctx, context); return; } @@ -1483,7 +1480,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( return; } -const char *reg_name(()[1]); +assert(name.GetStringRef().startswith("$")); +llvm::StringRef reg_name = name.GetStringRef().substr(1); if (m_parser_vars->m_exe_ctx.GetRegisterContext()) { const RegisterInfo *reg_info( @@ -1500,9 +1498,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( return; } - bool local_var_lookup = - !namespace_decl || (namespace_decl.GetName() == - ConstString(g_lldb_local_vars_namespace_cstr)); + bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() == + g_lldb_local_vars_namespace_cstr); if (frame && local_var_lookup) if (LookupLocalVariable(context, name, current_id, sym_ctx, namespace_decl)) return; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5fb7dd8 - [lldb][NFC] Move searching functions in ClangExpressionDeclMap to own function
Author: Raphael Isemann Date: 2019-11-21T14:31:31+01:00 New Revision: 5fb7dd8a40d2f35eea47b9c280722bd735e387a0 URL: https://github.com/llvm/llvm-project/commit/5fb7dd8a40d2f35eea47b9c280722bd735e387a0 DIFF: https://github.com/llvm/llvm-project/commit/5fb7dd8a40d2f35eea47b9c280722bd735e387a0.diff LOG: [lldb][NFC] Move searching functions in ClangExpressionDeclMap to own function Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 0fdc5e266a0f..c6cb63407f70 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1216,97 +1216,13 @@ bool ClangExpressionDeclMap::LookupLocalVariable( return false; } -void ClangExpressionDeclMap::FindExternalVisibleDecls( -NameSearchContext , lldb::ModuleSP module_sp, -CompilerDeclContext _decl, unsigned int current_id) { - assert(m_ast_context); - - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); +void ClangExpressionDeclMap::LookupFunction(NameSearchContext , +lldb::ModuleSP module_sp, +ConstString name, +CompilerDeclContext _decl, +unsigned current_id) { - const ConstString name(context.m_decl_name.getAsString().c_str()); - if (IgnoreName(name, false)) -return; - - // Only look for functions by name out in our symbols if the function doesn't - // start with our phony prefix of '$' Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr(); - StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr(); - SymbolContext sym_ctx; - if (frame != nullptr) -sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction | - lldb::eSymbolContextBlock); - - // Try the persistent decls, which take precedence over all else. - if (!namespace_decl) -SearchPersistenDecls(context, name, current_id); - - if (name.GetCString()[0] == '$' && !namespace_decl) { -static ConstString g_lldb_class_name("$__lldb_class"); - -if (name == g_lldb_class_name) { - LookUpLldbClass(context, current_id); - return; -} - -static ConstString g_lldb_objc_class_name("$__lldb_objc_class"); -if (name == g_lldb_objc_class_name) { - LookUpLldbObjCClass(context, current_id); - return; -} -if (name == ConstString(g_lldb_local_vars_namespace_cstr)) { - LookupLocalVarNamespace(sym_ctx, context); - return; -} - -// any other $__lldb names should be weeded out now -if (name.GetStringRef().startswith("$__lldb")) - return; - -ExpressionVariableSP pvar_sp( -m_parser_vars->m_persistent_vars->GetVariable(name)); - -if (pvar_sp) { - AddOneVariable(context, pvar_sp, current_id); - return; -} - -const char *reg_name(()[1]); - -if (m_parser_vars->m_exe_ctx.GetRegisterContext()) { - const RegisterInfo *reg_info( - m_parser_vars->m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName( - reg_name)); - - if (reg_info) { -LLDB_LOGF(log, " CEDM::FEVD[%u] Found register %s", current_id, - reg_info->name); - -AddOneRegister(context, reg_info, current_id); - } -} -return; - } - - bool local_var_lookup = - !namespace_decl || (namespace_decl.GetName() == - ConstString(g_lldb_local_vars_namespace_cstr)); - if (frame && local_var_lookup) -if (LookupLocalVariable(context, name, current_id, sym_ctx, namespace_decl)) - return; - - if (target) { -ValueObjectSP valobj; -VariableSP var; -var = FindGlobalVariable(*target, module_sp, name, _decl, - nullptr); - -if (var) { - valobj = ValueObjectVariable::Create(target, var); - AddOneVariable(context, var, valobj, current_id); - context.m_found.variable = true; - return; -} - } std::vector decls_from_modules; @@ -1511,6 +1427,101 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( } } } +} + +void ClangExpressionDeclMap::FindExternalVisibleDecls( +NameSearchContext , lldb::ModuleSP module_sp, +CompilerDeclContext _decl, unsigned int current_id) { + assert(m_ast_context); + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); + + const ConstString name(context.m_decl_name.getAsString().c_str()); + if (IgnoreName(name, false)) +return; + + // Only look for functions by name out
[Lldb-commits] [lldb] 24e9886 - [lldb][NFC] Reduce scope of some variables in ClangExpressionDeclMap::FindExternalVisibleDecls
Author: Raphael Isemann Date: 2019-11-21T13:43:48+01:00 New Revision: 24e98867937d5bb89605fd7be7e9ebdd3d5fb935 URL: https://github.com/llvm/llvm-project/commit/24e98867937d5bb89605fd7be7e9ebdd3d5fb935 DIFF: https://github.com/llvm/llvm-project/commit/24e98867937d5bb89605fd7be7e9ebdd3d5fb935.diff LOG: [lldb][NFC] Reduce scope of some variables in ClangExpressionDeclMap::FindExternalVisibleDecls Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 50e76be8f31b..0fdc5e266a0f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1223,8 +1223,6 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - SymbolContextList sc_list; - const ConstString name(context.m_decl_name.getAsString().c_str()); if (IgnoreName(name, false)) return; @@ -1288,8 +1286,6 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( } return; } - ValueObjectSP valobj; - VariableSP var; bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() == @@ -1299,6 +1295,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( return; if (target) { +ValueObjectSP valobj; +VariableSP var; var = FindGlobalVariable(*target, module_sp, name, _decl, nullptr); @@ -1320,7 +1318,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( } const bool include_inlines = false; - sc_list.Clear(); + SymbolContextList sc_list; if (namespace_decl && module_sp) { const bool include_symbols = false; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7fa976d - [lldb][NFC] Move searching local variables into own function
Author: Raphael Isemann Date: 2019-11-21T12:45:38+01:00 New Revision: 7fa976d57a1e2ab735212e5d9fc13cc38c4c81e9 URL: https://github.com/llvm/llvm-project/commit/7fa976d57a1e2ab735212e5d9fc13cc38c4c81e9 DIFF: https://github.com/llvm/llvm-project/commit/7fa976d57a1e2ab735212e5d9fc13cc38c4c81e9.diff LOG: [lldb][NFC] Move searching local variables into own function Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index a4ca7cb6cc7b..50e76be8f31b 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1169,6 +1169,53 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor( } } +bool ClangExpressionDeclMap::LookupLocalVariable( +NameSearchContext , ConstString name, unsigned current_id, +SymbolContext _ctx, CompilerDeclContext _decl) { + ValueObjectSP valobj; + VariableSP var; + + StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr(); + CompilerDeclContext compiler_decl_context = + sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext() + : CompilerDeclContext(); + + if (compiler_decl_context) { +// Make sure that the variables are parsed so that we have the +// declarations. +VariableListSP vars = frame->GetInScopeVariableList(true); +for (size_t i = 0; i < vars->GetSize(); i++) + vars->GetVariableAtIndex(i)->GetDecl(); + +// Search for declarations matching the name. Do not include imported +// decls in the search if we are looking for decls in the artificial +// namespace $__lldb_local_vars. +std::vector found_decls = +compiler_decl_context.FindDeclByName(name, namespace_decl.IsValid()); + +bool variable_found = false; +for (CompilerDecl decl : found_decls) { + for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) { +VariableSP candidate_var = vars->GetVariableAtIndex(vi); +if (candidate_var->GetDecl() == decl) { + var = candidate_var; + break; +} + } + + if (var && !variable_found) { +variable_found = true; +valobj = ValueObjectVariable::Create(frame, var); +AddOneVariable(context, var, valobj, current_id); +context.m_found.variable = true; + } +} +if (variable_found) + return true; + } + return false; +} + void ClangExpressionDeclMap::FindExternalVisibleDecls( NameSearchContext , lldb::ModuleSP module_sp, CompilerDeclContext _decl, unsigned int current_id) { @@ -1247,46 +1294,10 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() == ConstString(g_lldb_local_vars_namespace_cstr)); - if (frame && local_var_lookup) { -CompilerDeclContext compiler_decl_context = -sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext() - : CompilerDeclContext(); - -if (compiler_decl_context) { - // Make sure that the variables are parsed so that we have the - // declarations. - VariableListSP vars = frame->GetInScopeVariableList(true); - for (size_t i = 0; i < vars->GetSize(); i++) -vars->GetVariableAtIndex(i)->GetDecl(); - - // Search for declarations matching the name. Do not include imported - // decls in the search if we are looking for decls in the artificial - // namespace $__lldb_local_vars. - std::vector found_decls = - compiler_decl_context.FindDeclByName(name, - namespace_decl.IsValid()); - - bool variable_found = false; - for (CompilerDecl decl : found_decls) { -for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) { - VariableSP candidate_var = vars->GetVariableAtIndex(vi); - if (candidate_var->GetDecl() == decl) { -var = candidate_var; -break; - } -} + if (frame && local_var_lookup) +if (LookupLocalVariable(context, name, current_id, sym_ctx, namespace_decl)) + return; -if (var && !variable_found) { - variable_found = true; - valobj = ValueObjectVariable::Create(frame, var); - AddOneVariable(context, var, valobj, current_id); - context.m_found.variable = true; -} - } - if (variable_found) -return; -} - } if (target) { var = FindGlobalVariable(*target, module_sp, name, _decl, nullptr); diff --git
[Lldb-commits] [lldb] a0408ab - [lldb][NFC] Move searching the ClangModulesDeclVendor into own function
Author: Raphael Isemann Date: 2019-11-21T12:04:43+01:00 New Revision: a0408ab7f9863954b9d978d78761ed7b893f13b1 URL: https://github.com/llvm/llvm-project/commit/a0408ab7f9863954b9d978d78761ed7b893f13b1 DIFF: https://github.com/llvm/llvm-project/commit/a0408ab7f9863954b9d978d78761ed7b893f13b1.diff LOG: [lldb][NFC] Move searching the ClangModulesDeclVendor into own function Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index f2d5ded7d98f..a4ca7cb6cc7b 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1099,6 +1099,76 @@ void ClangExpressionDeclMap::LookupLocalVarNamespace( } } +void ClangExpressionDeclMap::LookupInModulesDeclVendor( +NameSearchContext , ConstString name, unsigned current_id) { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); + + if (ClangModulesDeclVendor *modules_decl_vendor = + m_target->GetClangModulesDeclVendor()) { +bool append = false; +uint32_t max_matches = 1; +std::vector decls; + +if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls)) + return; + +clang::NamedDecl *const decl_from_modules = decls[0]; + +if (llvm::isa(decl_from_modules)) { + if (log) { +LLDB_LOGF(log, + " CAS::FEVD[%u] Matching function found for " + "\"%s\" in the modules", + current_id, name.GetCString()); + } + + clang::Decl *copied_decl = CopyDecl(decl_from_modules); + clang::FunctionDecl *copied_function_decl = + copied_decl ? dyn_cast(copied_decl) : nullptr; + + if (!copied_function_decl) { +LLDB_LOGF(log, + " CAS::FEVD[%u] - Couldn't export a function " + "declaration from the modules", + current_id); + +return; + } + + MaybeRegisterFunctionBody(copied_function_decl); + + context.AddNamedDecl(copied_function_decl); + + context.m_found.function_with_type_info = true; + context.m_found.function = true; +} else if (llvm::isa(decl_from_modules)) { + if (log) { +LLDB_LOGF(log, + " CAS::FEVD[%u] Matching variable found for " + "\"%s\" in the modules", + current_id, name.GetCString()); + } + + clang::Decl *copied_decl = CopyDecl(decl_from_modules); + clang::VarDecl *copied_var_decl = + copied_decl ? dyn_cast_or_null(copied_decl) : nullptr; + + if (!copied_var_decl) { +LLDB_LOGF(log, + " CAS::FEVD[%u] - Couldn't export a variable " + "declaration from the modules", + current_id); + +return; + } + + context.AddNamedDecl(copied_var_decl); + + context.m_found.variable = true; +} + } +} + void ClangExpressionDeclMap::FindExternalVisibleDecls( NameSearchContext , lldb::ModuleSP module_sp, CompilerDeclContext _decl, unsigned int current_id) { @@ -1433,78 +1503,9 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( } } - if (!context.m_found.function_with_type_info) { -// Try the modules next. - -do { - if (ClangModulesDeclVendor *modules_decl_vendor = - m_target->GetClangModulesDeclVendor()) { -bool append = false; -uint32_t max_matches = 1; -std::vector decls; - -if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls)) - break; - -clang::NamedDecl *const decl_from_modules = decls[0]; - -if (llvm::isa(decl_from_modules)) { - if (log) { -LLDB_LOGF(log, - " CAS::FEVD[%u] Matching function found for " - "\"%s\" in the modules", - current_id, name.GetCString()); - } - - clang::Decl *copied_decl = CopyDecl(decl_from_modules); - clang::FunctionDecl *copied_function_decl = - copied_decl ? dyn_cast(copied_decl) - : nullptr; - - if (!copied_function_decl) { -LLDB_LOGF(log, - " CAS::FEVD[%u] - Couldn't export a function " - "declaration from the modules", - current_id); - -break; - } - - MaybeRegisterFunctionBody(copied_function_decl); - - context.AddNamedDecl(copied_function_decl); - - context.m_found.function_with_type_info = true; - context.m_found.function = true; -
[Lldb-commits] [lldb] 337151f - [lldb][NFC] Move searching for the local variable namespace into own function
Author: Raphael Isemann Date: 2019-11-21T11:03:24+01:00 New Revision: 337151f41e78f42df1eedbb86479888a2c5d0a04 URL: https://github.com/llvm/llvm-project/commit/337151f41e78f42df1eedbb86479888a2c5d0a04 DIFF: https://github.com/llvm/llvm-project/commit/337151f41e78f42df1eedbb86479888a2c5d0a04.diff LOG: [lldb][NFC] Move searching for the local variable namespace into own function Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 31bf55ca4af4..f2d5ded7d98f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1073,6 +1073,32 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext , } } +void ClangExpressionDeclMap::LookupLocalVarNamespace( +SymbolContext _ctx, NameSearchContext ) { + CompilerDeclContext frame_decl_context = sym_ctx.block != nullptr + ? sym_ctx.block->GetDeclContext() + : CompilerDeclContext(); + + if (frame_decl_context) { +ClangASTContext *frame_ast = llvm::dyn_cast_or_null( +frame_decl_context.GetTypeSystem()); + +ClangASTContext *map_ast = ClangASTContext::GetASTContext(m_ast_context); +if (frame_ast && map_ast) { + clang::NamespaceDecl *namespace_decl = + map_ast->GetUniqueNamespaceDeclaration( + g_lldb_local_vars_namespace_cstr, nullptr); + if (namespace_decl) { +context.AddNamedDecl(namespace_decl); +clang::DeclContext *clang_decl_ctx = +clang::Decl::castToDeclContext(namespace_decl); +clang_decl_ctx->setHasExternalVisibleStorage(true); +context.m_found.local_vars_nsp = true; + } +} + } +} + void ClangExpressionDeclMap::FindExternalVisibleDecls( NameSearchContext , lldb::ModuleSP module_sp, CompilerDeclContext _decl, unsigned int current_id) { @@ -1113,30 +1139,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( return; } if (name == ConstString(g_lldb_local_vars_namespace_cstr)) { - CompilerDeclContext frame_decl_context = - sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext() - : CompilerDeclContext(); - - if (frame_decl_context) { -ClangASTContext *frame_ast = llvm::dyn_cast_or_null( -frame_decl_context.GetTypeSystem()); - -ClangASTContext *map_ast = -ClangASTContext::GetASTContext(m_ast_context); -if (frame_ast && map_ast) { - clang::NamespaceDecl *namespace_decl = - map_ast->GetUniqueNamespaceDeclaration(name.GetCString(), - nullptr); - if (namespace_decl) { -context.AddNamedDecl(namespace_decl); -clang::DeclContext *clang_decl_ctx = -clang::Decl::castToDeclContext(namespace_decl); -clang_decl_ctx->setHasExternalVisibleStorage(true); -context.m_found.local_vars_nsp = true; - } -} - } - + LookupLocalVarNamespace(sym_ctx, context); return; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h index 93342dace77e..b599e2802d14 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -410,6 +410,17 @@ class ClangExpressionDeclMap : public ClangASTSource { /// for logging purposes. void LookUpLldbObjCClass(NameSearchContext , unsigned int current_id); + /// Handles looking up the synthetic namespace that contains our local + /// variables for the current frame. + /// + /// \param[in] sym_ctx + /// The current SymbolContext of this frame. + /// + /// \param[in] context + /// The NameSearchContext that can construct Decls for this name. + void LookupLocalVarNamespace(SymbolContext _ctx, + NameSearchContext ); + /// Given a target, find a variable that matches the given name and type. /// /// \param[in] target ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2cada1e - [lldb][NFC] Early exit in ClangExpressionDeclMap::FindExternalVisibleDecls
Author: Raphael Isemann Date: 2019-11-21T10:29:50+01:00 New Revision: 2cada1e4da9d55b54a06b240cc061605729d50f4 URL: https://github.com/llvm/llvm-project/commit/2cada1e4da9d55b54a06b240cc061605729d50f4 DIFF: https://github.com/llvm/llvm-project/commit/2cada1e4da9d55b54a06b240cc061605729d50f4.diff LOG: [lldb][NFC] Early exit in ClangExpressionDeclMap::FindExternalVisibleDecls Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 7b8456257c62..31bf55ca4af4 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1166,367 +1166,367 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( AddOneRegister(context, reg_info, current_id); } } - } else { -ValueObjectSP valobj; -VariableSP var; - -bool local_var_lookup = -!namespace_decl || (namespace_decl.GetName() == -ConstString(g_lldb_local_vars_namespace_cstr)); -if (frame && local_var_lookup) { - CompilerDeclContext compiler_decl_context = - sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext() - : CompilerDeclContext(); - - if (compiler_decl_context) { -// Make sure that the variables are parsed so that we have the -// declarations. -VariableListSP vars = frame->GetInScopeVariableList(true); -for (size_t i = 0; i < vars->GetSize(); i++) - vars->GetVariableAtIndex(i)->GetDecl(); - -// Search for declarations matching the name. Do not include imported -// decls in the search if we are looking for decls in the artificial -// namespace $__lldb_local_vars. -std::vector found_decls = -compiler_decl_context.FindDeclByName(name, - namespace_decl.IsValid()); - -bool variable_found = false; -for (CompilerDecl decl : found_decls) { - for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) { -VariableSP candidate_var = vars->GetVariableAtIndex(vi); -if (candidate_var->GetDecl() == decl) { - var = candidate_var; - break; -} +return; + } + ValueObjectSP valobj; + VariableSP var; + + bool local_var_lookup = + !namespace_decl || (namespace_decl.GetName() == + ConstString(g_lldb_local_vars_namespace_cstr)); + if (frame && local_var_lookup) { +CompilerDeclContext compiler_decl_context = +sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext() + : CompilerDeclContext(); + +if (compiler_decl_context) { + // Make sure that the variables are parsed so that we have the + // declarations. + VariableListSP vars = frame->GetInScopeVariableList(true); + for (size_t i = 0; i < vars->GetSize(); i++) +vars->GetVariableAtIndex(i)->GetDecl(); + + // Search for declarations matching the name. Do not include imported + // decls in the search if we are looking for decls in the artificial + // namespace $__lldb_local_vars. + std::vector found_decls = + compiler_decl_context.FindDeclByName(name, + namespace_decl.IsValid()); + + bool variable_found = false; + for (CompilerDecl decl : found_decls) { +for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) { + VariableSP candidate_var = vars->GetVariableAtIndex(vi); + if (candidate_var->GetDecl() == decl) { +var = candidate_var; +break; } +} - if (var && !variable_found) { -variable_found = true; -valobj = ValueObjectVariable::Create(frame, var); -AddOneVariable(context, var, valobj, current_id); -context.m_found.variable = true; - } +if (var && !variable_found) { + variable_found = true; + valobj = ValueObjectVariable::Create(frame, var); + AddOneVariable(context, var, valobj, current_id); + context.m_found.variable = true; } -if (variable_found) - return; } + if (variable_found) +return; } -if (target) { - var = FindGlobalVariable(*target, module_sp, name, _decl, - nullptr); + } + if (target) { +var = FindGlobalVariable(*target, module_sp, name, _decl, + nullptr); - if (var) { -valobj = ValueObjectVariable::Create(target, var); -AddOneVariable(context, var,
[Lldb-commits] [lldb] c502bae - [lldb][NFC] Simplify ClangASTContext::GetBasicTypes
Author: Raphael Isemann Date: 2019-11-20T12:47:14+01:00 New Revision: c502bae52410c83947e5ad7184dff810083afe75 URL: https://github.com/llvm/llvm-project/commit/c502bae52410c83947e5ad7184dff810083afe75 DIFF: https://github.com/llvm/llvm-project/commit/c502bae52410c83947e5ad7184dff810083afe75.diff LOG: [lldb][NFC] Simplify ClangASTContext::GetBasicTypes static convenience methods that do the clang::ASTContext -> ClangASTContext conversion and handle errors by simply ignoring them are not a good idea. Added: Modified: lldb/include/lldb/Symbol/ClangASTContext.h lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Symbol/ClangASTContext.cpp lldb/unittests/Symbol/TestClangASTContext.cpp Removed: diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index e68df0a4868a..c279bdb82c46 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -153,11 +153,7 @@ class ClangASTContext : public TypeSystem { CompilerType GetBasicType(lldb::BasicType type); - static CompilerType GetBasicType(clang::ASTContext *ast, - lldb::BasicType type); - - static CompilerType GetBasicType(clang::ASTContext *ast, - ConstString name); + CompilerType GetBasicType(ConstString name); static lldb::BasicType GetBasicTypeEnumeration(ConstString name); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index bbc03126ea24..f8e448ffcb6f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1724,17 +1724,15 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext , if (target == nullptr) return; - ASTContext *scratch_ast_context = - target->GetScratchClangASTContext()->getASTContext(); - - TypeFromUser user_type( - ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid) - .GetPointerType() - .GetLValueReferenceType()); - TypeFromParser parser_type( - ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid) - .GetPointerType() - .GetLValueReferenceType()); + ClangASTContext *scratch_ast_context = target->GetScratchClangASTContext(); + + TypeFromUser user_type(scratch_ast_context->GetBasicType(eBasicTypeVoid) + .GetPointerType() + .GetLValueReferenceType()); + ClangASTContext *own_context = ClangASTContext::GetASTContext(m_ast_context); + TypeFromParser parser_type(own_context->GetBasicType(eBasicTypeVoid) + .GetPointerType() + .GetLValueReferenceType()); NamedDecl *var_decl = context.AddVarDecl(parser_type); std::string decl_name(context.m_decl_name.getAsString()); @@ -2024,8 +2022,9 @@ void ClangExpressionDeclMap::AddThisType(NameSearchContext , if (copied_clang_type.IsAggregateType() && copied_clang_type.GetCompleteType()) { -CompilerType void_clang_type = -ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid); +ClangASTContext *own_context = +ClangASTContext::GetASTContext(m_ast_context); +CompilerType void_clang_type = own_context->GetBasicType(eBasicTypeVoid); CompilerType void_ptr_clang_type = void_clang_type.GetPointerType(); CompilerType method_type = ClangASTContext::CreateFunctionType( diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index fbf5bd4cf406..bee72b219b5e 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -987,13 +987,9 @@ ClangASTContext::GetBasicTypeEnumeration(ConstString name) { return eBasicTypeInvalid; } -CompilerType ClangASTContext::GetBasicType(ASTContext *ast, - ConstString name) { - if (ast) { -lldb::BasicType basic_type = ClangASTContext::GetBasicTypeEnumeration(name); -return ClangASTContext::GetBasicType(ast, basic_type); - } - return CompilerType(); +CompilerType ClangASTContext::GetBasicType(ConstString name) { + lldb::BasicType basic_type = ClangASTContext::GetBasicTypeEnumeration(name); + return GetBasicType(basic_type); } uint32_t ClangASTContext::GetPointerByteSize() { @@ -1006,13 +1002,8 @@ uint32_t ClangASTContext::GetPointerByteSize() { } CompilerType ClangASTContext::GetBasicType(lldb::BasicType basic_type) { - return GetBasicType(getASTContext(), basic_type); -} + clang::ASTContext *ast = getASTContext(); -CompilerType ClangASTContext::GetBasicType(ASTContext *ast, -