diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py index e81571a7f1f0c3..3c9b3cd6f552c4 100644 --- a/libcxx/utils/libcxx/test/config.py +++ b/libcxx/utils/libcxx/test/config.py @@ -194,7 +194,7 @@ def configure_executor(self): # ValgrindExecutor is supposed to go. It is likely # that the user wants it at the end, but we have no # way of getting at that easily. - selt.lit_config.fatal("Cannot infer how to create a Valgrind " + self.lit_config.fatal("Cannot infer how to create a Valgrind " " executor.") else: te = LocalExecutor() diff --git a/lldb/include/lldb/Symbol/DebugMacros.h b/lldb/include/lldb/Symbol/DebugMacros.h index d364299ef49025..55e6519612578e 100644 --- a/lldb/include/lldb/Symbol/DebugMacros.h +++ b/lldb/include/lldb/Symbol/DebugMacros.h @@ -23,7 +23,9 @@ typedef std::shared_ptr DebugMacrosSP; class DebugMacroEntry { public: - enum EntryType { INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT }; + enum EntryType : uint32_t { + INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT + }; public: static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str); diff --git a/lldb/packages/Python/lldbsuite/test/api/command-return-object/main.cpp b/lldb/packages/Python/lldbsuite/test/api/command-return-object/main.cpp index 4aeaf3fd5fdccc..c1d4d246a43c8c 100644 --- a/lldb/packages/Python/lldbsuite/test/api/command-return-object/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/api/command-return-object/main.cpp @@ -18,9 +18,7 @@ class CommandCrasher : public SBCommandPluginInterface { result = subcommand(dbg, "help"); // Test also whether self-assignment is handled correctly. result = result; - if (!result.Succeeded()) - return false; - return true; + return result.Succeeded(); } }; diff --git a/lldb/packages/Python/lldbsuite/test/commands/expression/macros/Makefile b/lldb/packages/Python/lldbsuite/test/commands/expression/macros/Makefile index a7549f24ea7ab0..a2af5c4ce70fb8 100644 --- a/lldb/packages/Python/lldbsuite/test/commands/expression/macros/Makefile +++ b/lldb/packages/Python/lldbsuite/test/commands/expression/macros/Makefile @@ -2,5 +2,8 @@ CXX_SOURCES := main.cpp DEBUG_INFO_FLAG = -g3 -gdwarf-5 +# GCC produces incorrect .debug_macro section when "-include" option is used: +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93075. +NO_TEST_COMMON_H := 1 include Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/exec/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/exec/main.cpp index 4475bbe4452f38..bec470fd13ef1a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/exec/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/exec/main.cpp @@ -1,3 +1,5 @@ +#define _POSIX_C_SOURCE 200809L + #include #include #include diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index 3515bc812ac5c9..02946f0398b470 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -129,7 +129,12 @@ def getDarwinOSTriples(): def getPlatform(): """Returns the target platform which the tests are running on.""" - platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] + triple = lldb.DBG.GetSelectedPlatform().GetTriple() + if triple is None: + # It might be an unconnected remote platform. + return '' + + platform = triple.split('-')[2] if platform.startswith('freebsd'): platform = 'freebsd' elif platform.startswith('netbsd'): diff --git a/lldb/packages/Python/lldbsuite/test/test_categories.py b/lldb/packages/Python/lldbsuite/test/test_categories.py index 07f6e335edeee7..05ce2a15d844a3 100644 --- a/lldb/packages/Python/lldbsuite/test/test_categories.py +++ b/lldb/packages/Python/lldbsuite/test/test_categories.py @@ -36,6 +36,7 @@ 'flakey': 'Flakey test cases, i.e. tests that do not reliably pass at each execution', 'darwin-log': 'Darwin log tests', 'watchpoint': 'Watchpoint-related tests', + 'lldb-vscode': 'Visual Studio Code debug adaptor tests', } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp index 063b995ff79a21..54f8397e1dad31 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -311,7 +311,8 @@ class ObjCRuntimeMethodType { } clang::ObjCMethodDecl * - BuildMethod(clang::ObjCInterfaceDecl *interface_decl, const char *name, + BuildMethod(ClangASTContext &clang_ast_ctxt, + clang::ObjCInterfaceDecl *interface_decl, const char *name, bool instance, ObjCLanguageRuntime::EncodingToTypeSP type_realizer_sp) { if (!m_is_valid || m_type_vector.size() < 3) @@ -360,8 +361,7 @@ class ObjCRuntimeMethodType { clang::QualType ret_type = ClangUtil::GetQualType(type_realizer_sp->RealizeType( - interface_decl->getASTContext(), m_type_vector[0].c_str(), - for_expression)); + clang_ast_ctxt, m_type_vector[0].c_str(), for_expression)); if (ret_type.isNull()) return nullptr; @@ -378,7 +378,7 @@ class ObjCRuntimeMethodType { const bool for_expression = true; clang::QualType arg_type = ClangUtil::GetQualType(type_realizer_sp->RealizeType( - ast_ctx, m_type_vector[ai].c_str(), for_expression)); + clang_ast_ctxt, m_type_vector[ai].c_str(), for_expression)); if (arg_type.isNull()) return nullptr; // well, we just wasted a bunch of time. Wish we could @@ -455,8 +455,8 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { ObjCRuntimeMethodType method_type(types); - clang::ObjCMethodDecl *method_decl = - method_type.BuildMethod(interface_decl, name, true, m_type_realizer_sp); + clang::ObjCMethodDecl *method_decl = method_type.BuildMethod( + m_ast_ctx, interface_decl, name, true, m_type_realizer_sp); LLDB_LOGF(log, "[ AOTV::FD] Instance method [%s] [%s]", name, types); @@ -474,7 +474,7 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { ObjCRuntimeMethodType method_type(types); clang::ObjCMethodDecl *method_decl = method_type.BuildMethod( - interface_decl, name, false, m_type_realizer_sp); + m_ast_ctx, interface_decl, name, false, m_type_realizer_sp); LLDB_LOGF(log, "[ AOTV::FD] Class method [%s] [%s]", name, types); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index 76375e22ad6a5f..5fa4073f40b127 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -63,7 +63,7 @@ AppleObjCTypeEncodingParser::StructElement::StructElement() : name(""), type(clang::QualType()), bitfield(0) {} AppleObjCTypeEncodingParser::StructElement -AppleObjCTypeEncodingParser::ReadStructElement(clang::ASTContext &ast_ctx, +AppleObjCTypeEncodingParser::ReadStructElement(ClangASTContext &ast_ctx, StringLexer &type, bool for_expression) { StructElement retval; @@ -78,19 +78,19 @@ AppleObjCTypeEncodingParser::ReadStructElement(clang::ASTContext &ast_ctx, } clang::QualType AppleObjCTypeEncodingParser::BuildStruct( - clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression) { + ClangASTContext &ast_ctx, StringLexer &type, bool for_expression) { return BuildAggregate(ast_ctx, type, for_expression, '{', '}', clang::TTK_Struct); } clang::QualType AppleObjCTypeEncodingParser::BuildUnion( - clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression) { + ClangASTContext &ast_ctx, StringLexer &type, bool for_expression) { return BuildAggregate(ast_ctx, type, for_expression, '(', ')', clang::TTK_Union); } clang::QualType AppleObjCTypeEncodingParser::BuildAggregate( - clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression, + ClangASTContext &ast_ctx, StringLexer &type, bool for_expression, char opener, char closer, uint32_t kind) { if (!type.NextIf(opener)) return clang::QualType(); @@ -124,10 +124,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate( if (is_templated) return clang::QualType(); // This is where we bail out. Sorry! - ClangASTContext *lldb_ctx = ClangASTContext::GetASTContext(&ast_ctx); - if (!lldb_ctx) - return clang::QualType(); - CompilerType union_type(lldb_ctx->CreateRecordType( + CompilerType union_type(ast_ctx.CreateRecordType( nullptr, lldb::eAccessPublic, name, kind, lldb::eLanguageTypeC)); if (union_type) { ClangASTContext::StartTagDeclarationDefinition(union_type); @@ -141,8 +138,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate( } ClangASTContext::AddFieldToRecordType( union_type, element.name.c_str(), - CompilerType(ClangASTContext::GetASTContext(&ast_ctx), - element.type.getAsOpaquePtr()), + CompilerType(&ast_ctx, element.type.getAsOpaquePtr()), lldb::eAccessPublic, element.bitfield); ++count; } @@ -152,20 +148,15 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate( } clang::QualType AppleObjCTypeEncodingParser::BuildArray( - clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression) { + ClangASTContext &ast_ctx, StringLexer &type, bool for_expression) { if (!type.NextIf('[')) return clang::QualType(); uint32_t size = ReadNumber(type); clang::QualType element_type(BuildType(ast_ctx, type, for_expression)); if (!type.NextIf(']')) return clang::QualType(); - ClangASTContext *lldb_ctx = ClangASTContext::GetASTContext(&ast_ctx); - if (!lldb_ctx) - return clang::QualType(); - CompilerType array_type(lldb_ctx->CreateArrayType( - CompilerType(ClangASTContext::GetASTContext(&ast_ctx), - element_type.getAsOpaquePtr()), - size, false)); + CompilerType array_type(ast_ctx.CreateArrayType( + CompilerType(&ast_ctx, element_type.getAsOpaquePtr()), size, false)); return ClangUtil::GetQualType(array_type); } @@ -175,10 +166,12 @@ clang::QualType AppleObjCTypeEncodingParser::BuildArray( // consume but ignore the type info and always return an 'id'; if anything, // dynamic typing will resolve things for us anyway clang::QualType AppleObjCTypeEncodingParser::BuildObjCObjectPointerType( - clang::ASTContext &ast_ctx, StringLexer &type, bool for_expression) { + ClangASTContext &clang_ast_ctx, StringLexer &type, bool for_expression) { if (!type.NextIf('@')) return clang::QualType(); + clang::ASTContext &ast_ctx = clang_ast_ctx.getASTContext(); + std::string name; if (type.NextIf('"')) { @@ -257,23 +250,25 @@ clang::QualType AppleObjCTypeEncodingParser::BuildObjCObjectPointerType( } clang::QualType -AppleObjCTypeEncodingParser::BuildType(clang::ASTContext &ast_ctx, +AppleObjCTypeEncodingParser::BuildType(ClangASTContext &clang_ast_ctx, StringLexer &type, bool for_expression, uint32_t *bitfield_bit_size) { if (!type.HasAtLeast(1)) return clang::QualType(); + clang::ASTContext &ast_ctx = clang_ast_ctx.getASTContext(); + switch (type.Peek()) { default: break; case '{': - return BuildStruct(ast_ctx, type, for_expression); + return BuildStruct(clang_ast_ctx, type, for_expression); case '[': - return BuildArray(ast_ctx, type, for_expression); + return BuildArray(clang_ast_ctx, type, for_expression); case '(': - return BuildUnion(ast_ctx, type, for_expression); + return BuildUnion(clang_ast_ctx, type, for_expression); case '@': - return BuildObjCObjectPointerType(ast_ctx, type, for_expression); + return BuildObjCObjectPointerType(clang_ast_ctx, type, for_expression); } switch (type.Next()) { @@ -289,10 +284,7 @@ AppleObjCTypeEncodingParser::BuildType(clang::ASTContext &ast_ctx, case 'l': return ast_ctx.getIntTypeForBitwidth(32, true); // this used to be done like this: - // ClangASTContext *lldb_ctx = ClangASTContext::GetASTContext(&ast_ctx); - // if (!lldb_ctx) - // return clang::QualType(); - // return lldb_ctx->GetIntTypeFromBitSize(32, true).GetQualType(); + // return clang_ast_ctx->GetIntTypeFromBitSize(32, true).GetQualType(); // which uses one of the constants if one is available, but we don't think // all this work is necessary. case 'q': @@ -331,7 +323,8 @@ AppleObjCTypeEncodingParser::BuildType(clang::ASTContext &ast_ctx, return clang::QualType(); } case 'r': { - clang::QualType target_type = BuildType(ast_ctx, type, for_expression); + clang::QualType target_type = + BuildType(clang_ast_ctx, type, for_expression); if (target_type.isNull()) return clang::QualType(); else if (target_type == ast_ctx.UnknownAnyTy) @@ -348,7 +341,8 @@ AppleObjCTypeEncodingParser::BuildType(clang::ASTContext &ast_ctx, // practical cases return ast_ctx.VoidPtrTy; } else { - clang::QualType target_type = BuildType(ast_ctx, type, for_expression); + clang::QualType target_type = + BuildType(clang_ast_ctx, type, for_expression); if (target_type.isNull()) return clang::QualType(); else if (target_type == ast_ctx.UnknownAnyTy) @@ -362,13 +356,13 @@ AppleObjCTypeEncodingParser::BuildType(clang::ASTContext &ast_ctx, } } -CompilerType AppleObjCTypeEncodingParser::RealizeType( - clang::ASTContext &ast_ctx, const char *name, bool for_expression) { +CompilerType AppleObjCTypeEncodingParser::RealizeType(ClangASTContext &ast_ctx, + const char *name, + bool for_expression) { if (name && name[0]) { StringLexer lexer(name); clang::QualType qual_type = BuildType(ast_ctx, lexer, for_expression); - return CompilerType(ClangASTContext::GetASTContext(&ast_ctx), - qual_type.getAsOpaquePtr()); + return CompilerType(&ast_ctx, qual_type.getAsOpaquePtr()); } return CompilerType(); } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h index 590bc4ba9eaebb..e43711bf4ee428 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h @@ -22,7 +22,7 @@ class AppleObjCTypeEncodingParser : public ObjCLanguageRuntime::EncodingToType { AppleObjCTypeEncodingParser(ObjCLanguageRuntime &runtime); ~AppleObjCTypeEncodingParser() override = default; - CompilerType RealizeType(clang::ASTContext &ast_ctx, const char *name, + CompilerType RealizeType(ClangASTContext &ast_ctx, const char *name, bool for_expression) override; private: @@ -35,29 +35,29 @@ class AppleObjCTypeEncodingParser : public ObjCLanguageRuntime::EncodingToType { ~StructElement() = default; }; - clang::QualType BuildType(clang::ASTContext &ast_ctx, StringLexer &type, + clang::QualType BuildType(ClangASTContext &clang_ast_ctx, StringLexer &type, bool for_expression, uint32_t *bitfield_bit_size = nullptr); - clang::QualType BuildStruct(clang::ASTContext &ast_ctx, StringLexer &type, + clang::QualType BuildStruct(ClangASTContext &ast_ctx, StringLexer &type, bool for_expression); - clang::QualType BuildAggregate(clang::ASTContext &ast_ctx, StringLexer &type, - bool for_expression, char opener, char closer, - uint32_t kind); + clang::QualType BuildAggregate(ClangASTContext &clang_ast_ctx, + StringLexer &type, bool for_expression, + char opener, char closer, uint32_t kind); - clang::QualType BuildUnion(clang::ASTContext &ast_ctx, StringLexer &type, + clang::QualType BuildUnion(ClangASTContext &ast_ctx, StringLexer &type, bool for_expression); - clang::QualType BuildArray(clang::ASTContext &ast_ctx, StringLexer &type, + clang::QualType BuildArray(ClangASTContext &ast_ctx, StringLexer &type, bool for_expression); std::string ReadStructName(StringLexer &type); - StructElement ReadStructElement(clang::ASTContext &ast_ctx, StringLexer &type, + StructElement ReadStructElement(ClangASTContext &ast_ctx, StringLexer &type, bool for_expression); - clang::QualType BuildObjCObjectPointerType(clang::ASTContext &ast_ctx, + clang::QualType BuildObjCObjectPointerType(ClangASTContext &clang_ast_ctx, StringLexer &type, bool for_expression); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp index 399bb120d7a333..335ef996419c61 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp @@ -313,12 +313,6 @@ ObjCLanguageRuntime::EncodingToType::RealizeType(const char *name, return CompilerType(); } -CompilerType ObjCLanguageRuntime::EncodingToType::RealizeType( - ClangASTContext &ast_ctx, const char *name, bool for_expression) { - clang::ASTContext &clang_ast = ast_ctx.getASTContext(); - return RealizeType(clang_ast, name, for_expression); -} - ObjCLanguageRuntime::EncodingToType::~EncodingToType() {} ObjCLanguageRuntime::EncodingToTypeSP ObjCLanguageRuntime::GetEncodingToType() { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h index 39acd6e9f26884..069ce7facf5213 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h @@ -145,12 +145,9 @@ class ObjCLanguageRuntime : public LanguageRuntime { virtual ~EncodingToType(); virtual CompilerType RealizeType(ClangASTContext &ast_ctx, const char *name, - bool for_expression); + bool for_expression) = 0; virtual CompilerType RealizeType(const char *name, bool for_expression); - virtual CompilerType RealizeType(clang::ASTContext &ast_ctx, - const char *name, bool for_expression) = 0; - protected: std::unique_ptr m_scratch_ast_ctx_up; }; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 028171e337dfc5..a49db5d9a93441 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2349,21 +2349,22 @@ void ProcessGDBRemote::RefreshStateAfterStop() { m_thread_ids.clear(); m_thread_pcs.clear(); + // Set the thread stop info. It might have a "threads" key whose value is a // list of all thread IDs in the current process, so m_thread_ids might get // set. + // Check to see if SetThreadStopInfo() filled in m_thread_ids? + if (m_thread_ids.empty()) { + // No, we need to fetch the thread list manually + UpdateThreadIDList(); + } + + // We might set some stop info's so make sure the thread list is up to + // date before we do that or we might overwrite what was computed here. + UpdateThreadListIfNeeded(); // Scope for the lock { - // Check to see if SetThreadStopInfo() filled in m_thread_ids? - if (m_thread_ids.empty()) { - // No, we need to fetch the thread list manually - UpdateThreadIDList(); - } - // We might set some stop info's so make sure the thread list is up to - // date before we do that or we might overwrite what was computed here. - UpdateThreadListIfNeeded(); - // Lock the thread stack while we access it std::lock_guard guard(m_last_stop_packet_mutex); // Get the number of stop packets on the stack