[Lldb-commits] [PATCH] D80556: [lldb] Don't complete ObjCInterfaceDecls in ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName
This revision was automatically updated to reflect the committed changes. Closed by commit rG019bd6485c52: [lldb] Dont complete ObjCInterfaceDecls in ClangExternalASTSourceCallbacks… (authored by teemperor). Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80556/new/ https://reviews.llvm.org/D80556 Files: lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm lldb/unittests/Symbol/TestTypeSystemClang.cpp Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp === --- lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -688,3 +688,37 @@ auto *record = llvm::cast(ClangUtil::GetAsTagDecl(t)); EXPECT_TRUE(record->hasUserDeclaredCopyConstructor()); } + +TEST_F(TestTypeSystemClang, AddMethodToObjCObjectType) { + // Create an interface decl and mark it as having external storage. + CompilerType c = m_ast->CreateObjCClass("A", m_ast->GetTranslationUnitDecl(), + OptionalClangModuleID(), + /*IsForwardDecl*/ false, + /*IsInternal*/ false); + ObjCInterfaceDecl *interface = m_ast->GetAsObjCInterfaceDecl(c); + m_ast->SetHasExternalStorage(c.GetOpaqueQualType(), true); + EXPECT_TRUE(interface->hasExternalLexicalStorage()); + + // Add a method to the interface. + std::vector args; + CompilerType func_type = + m_ast->CreateFunctionType(m_ast->GetBasicType(lldb::eBasicTypeInt), +args.data(), args.size(), /*variadic*/ false, +/*quals*/ 0, clang::CallingConv::CC_C); + bool variadic = false; + bool artificial = false; + bool objc_direct = false; + clang::ObjCMethodDecl *method = TypeSystemClang::AddMethodToObjCObjectType( + c, "-[A foo]", func_type, lldb::eAccessPublic, artificial, variadic, + objc_direct); + ASSERT_NE(method, nullptr); + + // The interface decl should still have external lexical storage. + EXPECT_TRUE(interface->hasExternalLexicalStorage()); + + // Test some properties of the created ObjCMethodDecl. + EXPECT_FALSE(method->isVariadic()); + EXPECT_TRUE(method->isImplicit()); + EXPECT_FALSE(method->isDirectMethod()); + EXPECT_EQ(method->getDeclName().getObjCSelector().getAsString(), "foo"); +} Index: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm === --- lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm +++ lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm @@ -46,7 +46,7 @@ // RUN: lldb-test symbols -dump-clang-ast -find type --language=ObjC++ \ // RUN: -compiler-context 'Module:A,Struct:SomeClass' %t.o \ // RUN: | FileCheck %s --check-prefix=CHECK-OBJC -// CHECK-OBJC: ObjCInterfaceDecl {{.*}} imported in A SomeClass +// CHECK-OBJC: ObjCInterfaceDecl {{.*}} imported in A SomeClass // CHECK-OBJC-NEXT: |-ObjCIvarDecl // CHECK-OBJC-NEXT: |-ObjCMethodDecl 0x[[NUMBER:[0-9a-f]+]]{{.*}} imported in A // CHECK-OBJC-NEXT: `-ObjCPropertyDecl {{.*}} imported in A number 'int' readonly Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp === --- lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp @@ -53,7 +53,8 @@ // Objective-C methods are not added into the LookupPtr when they originate // from an external source. SetExternalVisibleDeclsForName() adds them. if (auto *oid = llvm::dyn_cast(DC)) { -for (auto *omd : oid->methods()) +clang::ObjCContainerDecl::method_range noload_methods(oid->noload_decls()); +for (auto *omd : noload_methods) if (omd->getDeclName() == Name) decls.push_back(omd); } Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp === --- lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -688,3 +688,37 @@ auto *record = llvm::cast(ClangUtil::GetAsTagDecl(t)); EXPECT_TRUE(record->hasUserDeclaredCopyConstructor()); } + +TEST_F(TestTypeSystemClang, AddMethodToObjCObjectType) { + // Create an interface decl and mark it as having external storage. + CompilerType c = m_ast->CreateObjCClass("A", m_ast->GetTranslationUnitDecl(), + OptionalClangModuleID(), + /*IsForwardDecl*/ false, + /*IsInternal*/ false); + ObjCInterfaceDecl *interface = m_ast->GetAsObjCInterfaceDecl(c); +
[Lldb-commits] [lldb] 019bd64 - [lldb] Don't complete ObjCInterfaceDecls in ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName
Author: Raphael Isemann Date: 2020-05-27T12:39:24+02:00 New Revision: 019bd6485c52a62c008eacfdf0d13a26ca6b0a6f URL: https://github.com/llvm/llvm-project/commit/019bd6485c52a62c008eacfdf0d13a26ca6b0a6f DIFF: https://github.com/llvm/llvm-project/commit/019bd6485c52a62c008eacfdf0d13a26ca6b0a6f.diff LOG: [lldb] Don't complete ObjCInterfaceDecls in ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName Summary: For ObjCInterfaceDecls, LLDB iterates over the `methods` of the interface in FindExternalVisibleDeclsByName since commit ef423a3ba57045f80b0fcafce72121449a8b54d4 . However, when LLDB calls `oid->methods()` in that function, Clang will pull in all declarations in the current DeclContext from the current ExternalASTSource (which is again, `ClangExternalASTSourceCallbacks`). The reason for that is that `methods()` is just a wrapper for `decls()` which is supposed to provide a list of *all* (both currently loaded and external) decls in the DeclContext. However, `ClangExternalASTSourceCallbacks::FindExternalLexicalDecls` doesn't implement support for ObjCInterfaceDecl, so we don't actually add any declarations and just mark the ObjCInterfaceDecl as having no ExternalLexicalStorage. As LLDB uses the ExternalLexicalStorage to see if it can complete a type with the ExternalASTSource, this causes that LLDB thinks our class can't be completed any further by the ExternalASTSource and will from on no longer make any CompleteType/FindExternalLexicalDecls calls to that decl. This essentially renders those types unusable in the expression parser as they will always be considered incomplete. This patch just changes the call to `methods` (which is just a `decls()` wrapper), to some ad-hoc `noload_methods` call which is wrapping `noload_decls()`. `noload_decls()` won't trigger any calls to the ExternalASTSource, so this prevents that ExternalLexicalStorage will be set to false. The test for this is just adding a method to an ObjC interface. Before this patch, this unset the ExternalLexicalStorage flag and put the interface into the state described above. In a normal user session this situation was triggered by setting a breakpoint in a method of some ObjC class. This caused LLDB to create the MethodDecl for that specific method and put it into the the ObjCInterfaceDecl. Also `ObjCLanguageRuntime::LookupInCompleteClassCache` needs to be unable to resolve the type do an actual definition when the breakpoint is set (I'm not sure how exactly this can happen, but we just found no Type instance that had the `TypePayloadClang::IsCompleteObjCClass` flag set in its payload in the situation where this happens. This however doesn't seem to be a regression as logic wasn't changed from what I can see). The module-ownership.mm test had to be changed as the only reason why the ObjC interface in that test had it's ExternalLexicalStorage flag set to false was because of this unintended side effect. What actually happens in the test is that ExternalLexicalStorage is first set to false in `DWARFASTParserClang::CompleteTypeFromDWARF` when we try to complete the `SomeClass` interface, but is then the flag is set back to true once we add the last ivar of `SomeClass` (see `SetMemberOwningModule` in `TypeSystemClang.cpp` which is called when we add the ivar). I'll fix the code for that in a follow-up patch. I think some of the code here needs some rethinking. LLDB and Clang shouldn't infer anything about the ExternalASTSource and its ability to complete the current type form the `ExternalLexicalStorage` flag. We probably should also actually provide any declarations when we get asked for the lexical decls of an ObjCInterfaceDecl. But both of those changes are bigger (and most likely would cause us to eagerly complete more types), so those will be follow up patches and this patch just brings us back to the state before commit ef423a3ba57045f80b0fcafce72121449a8b54d4 . Fixes rdar://63584164 Reviewers: aprantl, friss, shafik Reviewed By: aprantl, shafik Subscribers: arphaman, abidh, JDevlieghere Differential Revision: https://reviews.llvm.org/D80556 Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm lldb/unittests/Symbol/TestTypeSystemClang.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp index e4054b441d55..390afb458b5a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp @@ -53,7 +53,8 @@ bool ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName( // Objective-C methods are not added into the LookupPtr when
[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint
kwk updated this revision to Diff 266493. kwk marked an inline comment as done. kwk added a comment. - don't hard-code --color and --dump-input on FileCheck invocation Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74136/new/ https://reviews.llvm.org/D74136 Files: lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Core/SearchFilter.cpp lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp lldb/test/Shell/Breakpoint/Inputs/search-support-files.h lldb/test/Shell/Breakpoint/search-support-files.test Index: lldb/test/Shell/Breakpoint/search-support-files.test === --- /dev/null +++ lldb/test/Shell/Breakpoint/search-support-files.test @@ -0,0 +1,46 @@ +# In these tests we will set breakpoints on a function by name. That function +# is defined in a header file (search-support-files.h) and will therefore be +# inlined into the file that includes it (search-support-files.cpp). +# +# TODO(kwk): Check that we can also do the same with C++ methods in files? +#(See https://lldb.llvm.org/use/tutorial.html and look for --method.) + +# RUN: %build %p/Inputs/search-support-files.cpp -o %t.out +# RUN: %lldb -b -s %s %t.out | FileCheck %s + +#Set breakpoint by function name. + +breakpoint set -n function_in_header +# CHECK: (lldb) breakpoint set -n function_in_header +# CHECK-NEXT: Breakpoint 1: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h + +breakpoint set -n main +# CHECK: (lldb) breakpoint set -n main +# CHECK-NEXT: Breakpoint 2: where = {{.*}}.out`main{{.*}} at search-support-files.cpp + +# Set breakpoint by function name and filename (the one in which the function +# is inlined, aka the compilation unit). + +breakpoint set -n function_in_header -f search-support-files.cpp +# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp +# CHECK-NEXT: Breakpoint 3: no locations (pending). + +# Set breakpoint by function name and source filename (the file in which the +# function is defined). +# +# NOTE: This test is the really interesting one as it shows that we can +# search by source files that are themselves no compilation units. + +breakpoint set -n function_in_header -f search-support-files.h +# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h +# CHECK-NEXT: Breakpoint 4: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h + +# Set breakpoint by function name and source filename. This time the file +# doesn't exist to prove that we haven't widen the search space too much. When +# we search for a function in a file that doesn't exist, we should get no +# results. + +breakpoint set -n function_in_header -f file-not-existing.h +# CHECK: (lldb) breakpoint set -n function_in_header -f file-not-existing.h +# CHECK-NEXT: Breakpoint 5: no locations (pending). +# CHECK-NEXT: WARNING: Unable to resolve breakpoint to any actual locations. Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h === --- /dev/null +++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.h @@ -0,0 +1 @@ +int function_in_header() { return 42; } Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp === --- /dev/null +++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp @@ -0,0 +1,6 @@ +#include "search-support-files.h" + +int main(int argc, char *argv[]) { + int a = function_in_header(); + return a; +} Index: lldb/source/Core/SearchFilter.cpp === --- lldb/source/Core/SearchFilter.cpp +++ lldb/source/Core/SearchFilter.cpp @@ -712,12 +712,7 @@ if (m_cu_spec_list.GetSize() != 0) return false; // Has no comp_unit so can't pass the file check. } - FileSpec cu_spec; - if (sym_ctx.comp_unit) -cu_spec = sym_ctx.comp_unit->GetPrimaryFile(); - if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX) -return false; // Fails the file check - return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); + return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); } bool SearchFilterByModuleListAndCU::CompUnitPasses(FileSpec ) { @@ -811,7 +806,7 @@ } uint32_t SearchFilterByModuleListAndCU::GetFilterRequiredItems() { - return eSymbolContextModule | eSymbolContextCompUnit; + return eSymbolContextModule | eSymbolContextCompUnit | eSymbolContextFunction; } void SearchFilterByModuleListAndCU::Dump(Stream *s) const {} Index: lldb/source/Breakpoint/BreakpointResolverName.cpp === --- lldb/source/Breakpoint/BreakpointResolverName.cpp +++ lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -260,6 +260,8 @@ SymbolContextList func_list; bool
[Lldb-commits] [PATCH] D80447: [lldb] Fix a potential bug that may cause assert failure in CommandObject::CheckRequirements
This revision was automatically updated to reflect the committed changes. Closed by commit rG18bb1f106702: [lldb] Fix a potential bug that may cause assert failure in CommandObject… (authored by teemperor). Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80447/new/ https://reviews.llvm.org/D80447 Files: lldb/source/Interpreter/CommandObject.cpp Index: lldb/source/Interpreter/CommandObject.cpp === --- lldb/source/Interpreter/CommandObject.cpp +++ lldb/source/Interpreter/CommandObject.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/Address.h" #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ArchSpec.h" +#include "llvm/ADT/ScopeExit.h" // These are for the Sourcename completers. // FIXME: Make a separate file for the completers. @@ -269,6 +270,7 @@ void CommandObject::HandleCompletion(CompletionRequest ) { m_exe_ctx = m_interpreter.GetExecutionContext(); + auto reset_ctx = llvm::make_scope_exit([this]() { Cleanup(); }); // Default implementation of WantsCompletion() is !WantsRawCommandString(). // Subclasses who want raw command string but desire, for example, argument @@ -296,8 +298,6 @@ // If we got here, the last word is not an option or an option argument. HandleArgumentCompletion(request, opt_element_vector); } - - m_exe_ctx.Clear(); } bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word, Index: lldb/source/Interpreter/CommandObject.cpp === --- lldb/source/Interpreter/CommandObject.cpp +++ lldb/source/Interpreter/CommandObject.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/Address.h" #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ArchSpec.h" +#include "llvm/ADT/ScopeExit.h" // These are for the Sourcename completers. // FIXME: Make a separate file for the completers. @@ -269,6 +270,7 @@ void CommandObject::HandleCompletion(CompletionRequest ) { m_exe_ctx = m_interpreter.GetExecutionContext(); + auto reset_ctx = llvm::make_scope_exit([this]() { Cleanup(); }); // Default implementation of WantsCompletion() is !WantsRawCommandString(). // Subclasses who want raw command string but desire, for example, argument @@ -296,8 +298,6 @@ // If we got here, the last word is not an option or an option argument. HandleArgumentCompletion(request, opt_element_vector); } - - m_exe_ctx.Clear(); } bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D79929: [lldb] Tab completion for process plugin name
This revision was automatically updated to reflect the committed changes. Closed by commit rG763bc2305797: [lldb] Tab completion for process plugin name (authored by MrHate, committed by teemperor). Herald added a subscriber: lldb-commits. Changed prior to commit: https://reviews.llvm.org/D79929?vs=265742=266498#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79929/new/ https://reviews.llvm.org/D79929 Files: lldb/include/lldb/Core/PluginManager.h lldb/include/lldb/Interpreter/CommandCompletions.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Core/PluginManager.cpp lldb/source/Interpreter/CommandObject.cpp lldb/test/API/functionalities/completion/TestCompletion.py Index: lldb/test/API/functionalities/completion/TestCompletion.py === --- lldb/test/API/functionalities/completion/TestCompletion.py +++ lldb/test/API/functionalities/completion/TestCompletion.py @@ -85,6 +85,13 @@ ['mips', 'arm64']) +def test_process_plugin_completion(self): +subcommands = ['attach -P', 'connect -p', 'launch -p'] + +for subcommand in subcommands: +self.complete_from_to('process ' + subcommand + ' mac', + 'process ' + subcommand + ' mach-o-core') + def test_process_signal(self): # The tab completion for "process signal" won't work without a running process. self.complete_from_to('process signal ', Index: lldb/source/Interpreter/CommandObject.cpp === --- lldb/source/Interpreter/CommandObject.cpp +++ lldb/source/Interpreter/CommandObject.cpp @@ -1080,7 +1080,7 @@ { eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." }, { eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." }, { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { nullptr, false }, "The process ID number." }, -{ eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, +{ eArgTypePlugin, "plugin", CommandCompletions::eProcessPluginCompletion, { nullptr, false }, "Help text goes here." }, { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the process." }, { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python class." }, { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python function." }, Index: lldb/source/Core/PluginManager.cpp === --- lldb/source/Core/PluginManager.cpp +++ lldb/source/Core/PluginManager.cpp @@ -830,6 +830,14 @@ return GetProcessInstances().GetCallbackForName(name); } +void PluginManager::AutoCompleteProcessName(llvm::StringRef name, +CompletionRequest ) { + for (const auto : GetProcessInstances().GetInstances()) { +if (instance.name.GetStringRef().startswith(name)) + request.AddCompletion(instance.name.GetCString(), instance.description); + } +} + #pragma mark ScriptInterpreter struct ScriptInterpreterInstance Index: lldb/source/Commands/CommandObjectProcess.cpp === --- lldb/source/Commands/CommandObjectProcess.cpp +++ lldb/source/Commands/CommandObjectProcess.cpp @@ -325,34 +325,38 @@ int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index; - // We are only completing the name option for now... - - // Are we in the name? - if (GetDefinitions()[opt_defs_index].short_option != 'n') -return; - - // Look to see if there is a -P argument provided, and if so use that - // plugin, otherwise use the default plugin. - - const char *partial_name = nullptr; - partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos); - - PlatformSP platform_sp(interpreter.GetPlatform(true)); - if (!platform_sp) -return; - ProcessInstanceInfoList process_infos; - ProcessInstanceInfoMatch match_info; - if (partial_name) { -match_info.GetProcessInfo().GetExecutableFile().SetFile( -partial_name, FileSpec::Style::native); -match_info.SetNameMatchType(NameMatch::StartsWith); - } - platform_sp->FindProcesses(match_info, process_infos); - const size_t num_matches = process_infos.size(); - if
[Lldb-commits] [lldb] 18bb1f1 - [lldb] Fix a potential bug that may cause assert failure in CommandObject::CheckRequirements
Author: Raphael Isemann Date: 2020-05-27T14:05:17+02:00 New Revision: 18bb1f1067028fbeaf92774e640bd865c53e1ce1 URL: https://github.com/llvm/llvm-project/commit/18bb1f1067028fbeaf92774e640bd865c53e1ce1 DIFF: https://github.com/llvm/llvm-project/commit/18bb1f1067028fbeaf92774e640bd865c53e1ce1.diff LOG: [lldb] Fix a potential bug that may cause assert failure in CommandObject::CheckRequirements Summary: `CommandObject::CheckRequirements` requires cleaning up `m_exe_ctx` between commands. Function `HandleOptionCompletion` returns without cleaning up `m_exe_ctx` could cause assert failure in later `CheckRequirements`. Reviewers: teemperor, JDevlieghere Reviewed By: teemperor Tags: #lldb Differential Revision: https://reviews.llvm.org/D80447 Added: Modified: lldb/source/Interpreter/CommandObject.cpp Removed: diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index f1f17dbd66ef..ddf1f5511ecd 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/Address.h" #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ArchSpec.h" +#include "llvm/ADT/ScopeExit.h" // These are for the Sourcename completers. // FIXME: Make a separate file for the completers. @@ -269,6 +270,7 @@ void CommandObject::Cleanup() { void CommandObject::HandleCompletion(CompletionRequest ) { m_exe_ctx = m_interpreter.GetExecutionContext(); + auto reset_ctx = llvm::make_scope_exit([this]() { Cleanup(); }); // Default implementation of WantsCompletion() is !WantsRawCommandString(). // Subclasses who want raw command string but desire, for example, argument @@ -296,8 +298,6 @@ void CommandObject::HandleCompletion(CompletionRequest ) { // If we got here, the last word is not an option or an option argument. HandleArgumentCompletion(request, opt_element_vector); } - - m_exe_ctx.Clear(); } bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint
kwk marked 2 inline comments as done. kwk added inline comments. Comment at: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h:1 +int inlined_42() { return 42; } labath wrote: > Calling this `inlined` is misleading. The function won't get inlined anywhere > at -O0, and in fact your test would not work if it got inlined. Maybe just > call it `function_in_header` ? Thank you for finding this. My understanding needs a lot of sharpening I guess. Comment at: lldb/test/Shell/Breakpoint/search-support-files.test:15 +# CHECK: (lldb) breakpoint set -n inlined_42 +# CHECK-NEXT: Breakpoint 1: where = dummy.out`inlined_42() + 4 at search-support-files.h:1:20, address = 0x0{{.*}} + labath wrote: > These check lines hardcode too much stuff. The `+4` thingy can easily change > due to unrelated codegen changes, and even the `:1:20` seems unnecessarily > strict. > Maybe something like this would be enough: > ``` > CHECK-NEXT: Breakpoint 1: where = {{.8}}`inlined_42{{.*}} at > search-support-files.h > ``` Yes, you're right. Although I don't know what `{{.8}}` does in this case. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74136/new/ https://reviews.llvm.org/D74136 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint
kwk updated this revision to Diff 266472. kwk added a comment. - make test CHECKs less strict Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74136/new/ https://reviews.llvm.org/D74136 Files: lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Core/SearchFilter.cpp lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp lldb/test/Shell/Breakpoint/Inputs/search-support-files.h lldb/test/Shell/Breakpoint/search-support-files.test Index: lldb/test/Shell/Breakpoint/search-support-files.test === --- /dev/null +++ lldb/test/Shell/Breakpoint/search-support-files.test @@ -0,0 +1,46 @@ +# In these tests we will set breakpoints on a function by name. That function +# is defined in a header file (search-support-files.h) and will therefore be +# inlined into the file that includes it (search-support-files.cpp). +# +# TODO(kwk): Check that we can also do the same with C++ methods in files? +#(See https://lldb.llvm.org/use/tutorial.html and look for --method.) + +# RUN: %build %p/Inputs/search-support-files.cpp -o %t.out +# RUN: %lldb -b -s %s %t.out | FileCheck --color --dump-input=fail %s + +#Set breakpoint by function name. + +breakpoint set -n function_in_header +# CHECK: (lldb) breakpoint set -n function_in_header +# CHECK-NEXT: Breakpoint 1: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h + +breakpoint set -n main +# CHECK: (lldb) breakpoint set -n main +# CHECK-NEXT: Breakpoint 2: where = {{.*}}.out`main{{.*}} at search-support-files.cpp + +# Set breakpoint by function name and filename (the one in which the function +# is inlined, aka the compilation unit). + +breakpoint set -n function_in_header -f search-support-files.cpp +# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp +# CHECK-NEXT: Breakpoint 3: no locations (pending). + +# Set breakpoint by function name and source filename (the file in which the +# function is defined). +# +# NOTE: This test is the really interesting one as it shows that we can +# search by source files that are themselves no compilation units. + +breakpoint set -n function_in_header -f search-support-files.h +# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h +# CHECK-NEXT: Breakpoint 4: where = {{.*}}.out`function_in_header(){{.*}} at search-support-files.h + +# Set breakpoint by function name and source filename. This time the file +# doesn't exist to prove that we haven't widen the search space too much. When +# we search for a function in a file that doesn't exist, we should get no +# results. + +breakpoint set -n function_in_header -f file-not-existing.h +# CHECK: (lldb) breakpoint set -n function_in_header -f file-not-existing.h +# CHECK-NEXT: Breakpoint 5: no locations (pending). +# CHECK-NEXT: WARNING: Unable to resolve breakpoint to any actual locations. Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h === --- /dev/null +++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.h @@ -0,0 +1 @@ +int function_in_header() { return 42; } Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp === --- /dev/null +++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp @@ -0,0 +1,6 @@ +#include "search-support-files.h" + +int main(int argc, char *argv[]) { + int a = function_in_header(); + return a; +} Index: lldb/source/Core/SearchFilter.cpp === --- lldb/source/Core/SearchFilter.cpp +++ lldb/source/Core/SearchFilter.cpp @@ -712,12 +712,7 @@ if (m_cu_spec_list.GetSize() != 0) return false; // Has no comp_unit so can't pass the file check. } - FileSpec cu_spec; - if (sym_ctx.comp_unit) -cu_spec = sym_ctx.comp_unit->GetPrimaryFile(); - if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX) -return false; // Fails the file check - return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); + return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); } bool SearchFilterByModuleListAndCU::CompUnitPasses(FileSpec ) { @@ -811,7 +806,7 @@ } uint32_t SearchFilterByModuleListAndCU::GetFilterRequiredItems() { - return eSymbolContextModule | eSymbolContextCompUnit; + return eSymbolContextModule | eSymbolContextCompUnit | eSymbolContextFunction; } void SearchFilterByModuleListAndCU::Dump(Stream *s) const {} Index: lldb/source/Breakpoint/BreakpointResolverName.cpp === --- lldb/source/Breakpoint/BreakpointResolverName.cpp +++ lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -260,6 +260,8 @@ SymbolContextList func_list; bool filter_by_cu = (filter.GetFilterRequiredItems()
[Lldb-commits] [lldb] 763bc23 - [lldb] Tab completion for process plugin name
Author: Gongyu Deng Date: 2020-05-27T14:11:16+02:00 New Revision: 763bc2305797c980a4f4fa2f6314ed78a010678d URL: https://github.com/llvm/llvm-project/commit/763bc2305797c980a4f4fa2f6314ed78a010678d DIFF: https://github.com/llvm/llvm-project/commit/763bc2305797c980a4f4fa2f6314ed78a010678d.diff LOG: [lldb] Tab completion for process plugin name Summary: 1. Added tab completion to `process launch -p`, `process attach -P`, `process connect -p`; 2. Bound the plugin name common completion as the default completion for `eArgTypePlugin` arguments. Reviewers: teemperor, JDevlieghere Tags: #lldb Differential Revision: https://reviews.llvm.org/D79929 Added: Modified: lldb/include/lldb/Core/PluginManager.h lldb/include/lldb/Interpreter/CommandCompletions.h lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Core/PluginManager.cpp lldb/source/Interpreter/CommandObject.cpp lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index 4cae597d3732..5e0c9395dae0 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -243,6 +243,9 @@ class PluginManager { static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx); + static void AutoCompleteProcessName(llvm::StringRef partial_name, + CompletionRequest ); + // ScriptInterpreter static bool RegisterPlugin(ConstString name, const char *description, lldb::ScriptLanguage script_lang, diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index dc2bf841620d..39d1c98eaa39 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -36,10 +36,11 @@ class CommandCompletions { eVariablePathCompletion = (1u << 8), eRegisterCompletion = (1u << 9), eBreakpointCompletion = (1u << 10), +eProcessPluginCompletion = (1u << 11), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. -eCustomCompletion = (1u << 11) +eCustomCompletion = (1u << 12) }; static bool InvokeCommonCompletionCallbacks( @@ -89,6 +90,10 @@ class CommandCompletions { static void Breakpoints(CommandInterpreter , CompletionRequest , SearchFilter *searcher); + + static void ProcessPluginNames(CommandInterpreter , + CompletionRequest , + SearchFilter *searcher); }; } // namespace lldb_private diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index d4e4f6a5ebb5..11198f68490d 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -58,6 +58,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {eVariablePathCompletion, CommandCompletions::VariablePath}, {eRegisterCompletion, CommandCompletions::Registers}, {eBreakpointCompletion, CommandCompletions::Breakpoints}, + {eProcessPluginCompletion, CommandCompletions::ProcessPluginNames}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -582,3 +583,10 @@ void CommandCompletions::Breakpoints(CommandInterpreter , request.TryCompleteCurrentArg(std::to_string(bp->GetID()), bp_info); } } + +void CommandCompletions::ProcessPluginNames(CommandInterpreter , +CompletionRequest , +SearchFilter *searcher) { + PluginManager::AutoCompleteProcessName(request.GetCursorArgumentPrefix(), + request); +} \ No newline at end of file diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 043765a0c09c..4f591b53aaa6 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -325,34 +325,38 @@ class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach { int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index; - // We are only completing the name option for now... - - // Are we in the name? - if (GetDefinitions()[opt_defs_index].short_option != 'n') -return; - - // Look to see if there is a -P argument provided, and if so use that - // plugin, otherwise use the default plugin.
[Lldb-commits] [PATCH] D79929: [lldb] Tab completion for process plugin name
jingham added a comment. This change makes the eArgTypePlugin be the completion for process plugins. Shouldn't we change the enum name and completion name to indicate that? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79929/new/ https://reviews.llvm.org/D79929 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D80292: [lldb] Make order of completions for expressions deterministic and sorted by Clang's priority values.
This revision was automatically updated to reflect the committed changes. Closed by commit rG74a51753a6c2: [lldb] Make order of completions for expressions deterministic and sorted by… (authored by teemperor). Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80292/new/ https://reviews.llvm.org/D80292 Files: lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/test/API/commands/expression/completion/TestExprCompletion.py lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -967,7 +967,7 @@ text.c_str(), actual_column, 0, -1, matches, descriptions); - size_t count = std::min((uint32_t)50, matches.GetSize()); + size_t count = std::min((uint32_t)100, matches.GetSize()); targets.reserve(count); for (size_t i = 0; i < count; i++) { std::string match = matches.GetStringAtIndex(i); Index: lldb/test/API/commands/expression/completion/TestExprCompletion.py === --- lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -201,26 +201,26 @@ '// Break here', self.main_source_spec) self.check_completion_with_desc("expr ", [ -# VarDecls have their type as description. -["some_expr", "Expr &"], # builtin types have no description. ["int", ""], -["float", ""] -]) +["float", ""], +# VarDecls have their type as description. +["some_expr", "Expr &"], +], enforce_order = True) self.check_completion_with_desc("expr some_expr.", [ # Functions have their signature as description. -["some_expr.Self()", "Expr ()"], +["some_expr.~Expr()", "inline ~Expr()"], ["some_expr.operator=(", "inline Expr =(const Expr &)"], -["some_expr.FooNumbersBar1()", "int FooNumbersBar1()"], +# FieldDecls have their type as description. +["some_expr.MemberVariableBar", "int"], ["some_expr.StaticMemberMethodBar()", "static int StaticMemberMethodBar()"], -["some_expr.FooWithArgsBar(", "int FooWithArgsBar(int)"], +["some_expr.Self()", "Expr ()"], ["some_expr.FooNoArgsBar()", "int FooNoArgsBar()"], +["some_expr.FooWithArgsBar(", "int FooWithArgsBar(int)"], +["some_expr.FooNumbersBar1()", "int FooNumbersBar1()"], ["some_expr.FooUnderscoreBar_()", "int FooUnderscoreBar_()"], ["some_expr.FooWithMultipleArgsBar(", "int FooWithMultipleArgsBar(int, int)"], -["some_expr.~Expr()", "inline ~Expr()"], -# FieldDecls have their type as description. -["some_expr.MemberVariableBar", "int"], -]) +], enforce_order = True) def assume_no_completions(self, str_input, cursor_pos = None): interp = self.dbg.GetCommandInterpreter() Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp === --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -666,11 +666,33 @@ std::string m_expr; unsigned m_position = 0; - CompletionRequest _request; /// The printing policy we use when printing declarations for our completion /// descriptions. clang::PrintingPolicy m_desc_policy; + struct CompletionWithPriority { +CompletionResult::Completion completion; +/// See CodeCompletionResult::Priority; +unsigned Priority; + +/// Establishes a deterministic order in a list of CompletionWithPriority. +/// The order returned here is the order in which the completions are +/// displayed to the user. +bool operator<(const CompletionWithPriority ) const { + // High priority results should come first. + if (Priority != o.Priority) +return Priority > o.Priority; + + // Identical priority, so just make sure it's a deterministic order. + return completion.GetUniqueKey() < o.completion.GetUniqueKey(); +} + }; + + /// The stored completions. + /// Warning: These are in a non-deterministic order until they are sorted + /// and returned back to the caller. + std::vector m_completions; + /// Returns true if the given character can be used in an identifier. /// This also returns true for numbers because for completion we usually /// just iterate backwards over iterators. @@
[Lldb-commits] [lldb] 74a5175 - [lldb] Make order of completions for expressions deterministic and sorted by Clang's priority values.
Author: Raphael Isemann Date: 2020-05-27T19:22:01+02:00 New Revision: 74a51753a6c2c587f650174e19f99279e8e4ef35 URL: https://github.com/llvm/llvm-project/commit/74a51753a6c2c587f650174e19f99279e8e4ef35 DIFF: https://github.com/llvm/llvm-project/commit/74a51753a6c2c587f650174e19f99279e8e4ef35.diff LOG: [lldb] Make order of completions for expressions deterministic and sorted by Clang's priority values. Summary: It turns out that the order in which we provide completions for expressions is nondeterministic. This leads to confusing user experience and also breaks the reproducer tests (as two LLDB tests can go out of sync due to the non-determinism in the completion lists) The reason for the non-determinism is that the CompletionConsumer informs us about decls in the order in which it finds declarations in the lookup store of the DeclContexts it visits (mainly this snippet in SemaLookup.cpp): ``` lang=c++ // Enumerate all of the results in this context. for (DeclContextLookupResult R : Load ? Ctx->lookups() : Ctx->noload_lookups(/*PreserveInternalState=*/false)) { [...] ``` This storage of the lookup is sorted by pointer values (see the hash of `DeclarationName`) and can therefore be non-deterministic. The LLDB code completion consumer that receives these calls originally expected that the order of declarations is defined by Clang, but it seems the API expects the client to provide an order to the completions. This patch fixes the issue as follows: * We sort the completions we get from Clang alphabetically and also by the priority value we get from Clang (with priority value sorting having precedence over the alphabetical sorting) * We make all the functions/variables that touch a completion before the sorting const-qualified. The idea is that this should prevent that we never have observable side-effect from touching these declarations in a non-deterministic order (e.g., we don't try to complete the type by accident). This way we behave like the other parts of Clang which also sort the results by some deterministic value (usually the name or something computed from a name, e.g., edit distance to a given string). We most likely also need to fix the Clang code to make the loop I listed above deterministic to prevent these issues in the future (tracked in rdar://63442513 ). This wouldn't replace the functionality provided in this patch though as we would still need the priority and overall alphabetical sorting. Note: I had to increase the lldb-vscode completion limit to 100 as the tests look for strings that aren't in the first 50 results anymore due to variable names starting with letters like 'v' (which are now always shown much further down in the list due to the alphabetical sorting). Fixes rdar://63200995 Reviewers: JDevlieghere, clayborg Reviewed By: JDevlieghere Subscribers: mgrang, abidh Differential Revision: https://reviews.llvm.org/D80292 Added: Modified: lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/test/API/commands/expression/completion/TestExprCompletion.py lldb/tools/lldb-vscode/lldb-vscode.cpp Removed: diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 639f99463d92..0dee4f217c80 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2147,13 +2147,27 @@ def match( return match_object -def check_completion_with_desc(self, str_input, match_desc_pairs): +def check_completion_with_desc(self, str_input, match_desc_pairs, enforce_order=False): +""" +Checks that when the given input is completed at the given list of +completions and descriptions is returned. +:param str_input: The input that should be completed. The completion happens at the end of the string. +:param match_desc_pairs: A list of pairs that indicate what completions have to be in the list of + completions returned by LLDB. The first element of the pair is the completion + string that LLDB should generate and the second element the description. +:param enforce_order: True iff the order in which the completions are returned by LLDB + should match the order of the match_desc_pairs pairs. +""" interp = self.dbg.GetCommandInterpreter() match_strings = lldb.SBStringList() description_strings = lldb.SBStringList() num_matches = interp.HandleCompletionWithDescriptions(str_input, len(str_input), 0, -1, match_strings, description_strings) self.assertEqual(len(description_strings), len(match_strings)) +# The index of the last matched
[Lldb-commits] [lldb] e7f1067 - [lldb/Reproducers] Skip API logging in the DUMMY macro
Author: Jonas Devlieghere Date: 2020-05-27T10:35:43-07:00 New Revision: e7f1067ad6f116ff1e4bfc0f7fe1977f172b0ea0 URL: https://github.com/llvm/llvm-project/commit/e7f1067ad6f116ff1e4bfc0f7fe1977f172b0ea0 DIFF: https://github.com/llvm/llvm-project/commit/e7f1067ad6f116ff1e4bfc0f7fe1977f172b0ea0.diff LOG: [lldb/Reproducers] Skip API logging in the DUMMY macro The purpose of the LLDB_RECORD_DUMMY macro is twofold: it is used in functions that take arguments that we don't know how to serialize (e.g. void*) and it's used by function where we want to avoid doing excessive work because they can be called from a signal handler (e.g. setTerminalWidth). To support the latter case, I've disabled API logging form the Recorder ctor used by the DUMMY macro. This ensures we don't allocate memory when called from a signal handler. Added: Modified: lldb/include/lldb/Utility/ReproducerInstrumentation.h lldb/source/Utility/ReproducerInstrumentation.cpp Removed: diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h index 346eac52501a..f06b8c038818 100644 --- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h +++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h @@ -207,11 +207,10 @@ template inline std::string stringify_args(const Ts &... ts) { /// anything. It's used to track API boundaries when we cannot record for /// technical reasons. #define LLDB_RECORD_DUMMY(Result, Class, Method, Signature, ...) \ - lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION, \ - stringify_args(__VA_ARGS__)); + lldb_private::repro::Recorder _recorder; #define LLDB_RECORD_DUMMY_NO_ARGS(Result, Class, Method) \ - lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION); + lldb_private::repro::Recorder _recorder; namespace lldb_private { namespace repro { @@ -727,7 +726,8 @@ struct EmptyArg {}; /// this class is also used for logging. class Recorder { public: - Recorder(llvm::StringRef pretty_func = {}, std::string &_args = {}); + Recorder(); + Recorder(llvm::StringRef pretty_func, std::string &_args = {}); ~Recorder(); /// Records a single function call. diff --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp index 46bf6b76e1d2..09aea69d8313 100644 --- a/lldb/source/Utility/ReproducerInstrumentation.cpp +++ b/lldb/source/Utility/ReproducerInstrumentation.cpp @@ -179,6 +179,15 @@ unsigned ObjectToIndex::GetIndexForObjectImpl(const void *object) { return m_mapping[object]; } +Recorder::Recorder() +: m_serializer(nullptr), m_pretty_func(), m_pretty_args(), + m_local_boundary(false), m_result_recorded(true) { + if (!g_global_boundary) { +g_global_boundary = true; +m_local_boundary = true; + } +} + Recorder::Recorder(llvm::StringRef pretty_func, std::string &_args) : m_serializer(nullptr), m_pretty_func(pretty_func), m_pretty_args(pretty_args), m_local_boundary(false), ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D80680: save_crashlog should not be using the load_addr property of an SBAddress
friss accepted this revision. friss added a comment. This revision is now accepted and ready to land. Thanks for adding a test! this LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80680/new/ https://reviews.llvm.org/D80680 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D80680: save_crashlog should not be using the load_addr property of an SBAddress
jingham created this revision. jingham added a reviewer: clayborg. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. friss accepted this revision. friss added a comment. This revision is now accepted and ready to land. Thanks for adding a test! this LGTM The load_addr property relies on there being a variable called "target" in the current module. It is explicitly marked only to be used in the interactive interpreter, and not in commands. We used to be sloppy about leaving lldb.target sitting around in the script interpreter between uses of the interactive interpreter, so this mostly worked (unless the current target the last time you used the script interpreter wasn't the current target when you ran the command...) But Jonas cleaned that up a little while ago. That uncovered the bug in save_crashlog. I added a quick test. You could definitely do more rigorous testing of the output here, but this is better than the previous nothing, and what I have time for. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D80680 Files: lldb/examples/python/crashlog.py lldb/test/API/macosx/save_crashlog/Makefile lldb/test/API/macosx/save_crashlog/TestSaveCrashlog.py lldb/test/API/macosx/save_crashlog/main.c Index: lldb/test/API/macosx/save_crashlog/main.c === --- /dev/null +++ lldb/test/API/macosx/save_crashlog/main.c @@ -0,0 +1,13 @@ +#include + +void +call_me() { + printf("I was called"); +} + +int +main() +{ + call_me(); + return 0; +} Index: lldb/test/API/macosx/save_crashlog/TestSaveCrashlog.py === --- /dev/null +++ lldb/test/API/macosx/save_crashlog/TestSaveCrashlog.py @@ -0,0 +1,68 @@ +""" +Test that the save_crashlog command functions +""" + + +import os +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestSaveCrashlog(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +# If your test case doesn't stress debug info, the +# set this to true. That way it won't be run once for +# each debug info format. +NO_DEBUG_INFO_TESTCASE = True + +@skipUnlessDarwin +def test_save_crashlog(self): +"""There can be many tests in a test case - describe this test here.""" +self.build() +self.main_source_file = lldb.SBFileSpec("main.c") +self.save_crashlog() + +def save_crashlog(self): + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "I was called", self.main_source_file) + +self.runCmd("command script import lldb.macosx.crashlog") +out_file = os.path.join(self.getBuildDir(), "crash.log") +self.runCmd("save_crashlog '%s'"%(out_file)) + +# Make sure we wrote the file: +self.assertTrue(os.path.exists(out_file), "We wrote our file") + +# Now scan the file to make sure it looks right: +# First get a few facts we'll use: +exe_module = target.FindModule(target.GetExecutable()) +uuid_str = exe_module.GetUUIDString() + +# We'll set these to true when we find the elements in the file +found_call_me = False +found_main_line = False +found_thread_header = False +found_uuid_str = False + +with open(out_file, "r") as f: +# We want to see a line with +for line in f: +if "Thread 0:" in line: +found_thread_header = True +if "call_me" in line and "main.c:" in line: +found_call_me = True +if "main" in line and "main.c:" in line: +found_main_line = True +if uuid_str in line and "a.out" in line: +found_uuid_str = True + +self.assertTrue(found_thread_header, "Found thread header") +self.assertTrue(found_call_me, "Found call_me line in stack") +self.assertTrue(found_uuid_str, "Found main binary UUID") +self.assertTrue(found_main_line, "Found main line in call stack") + Index: lldb/test/API/macosx/save_crashlog/Makefile === --- /dev/null +++ lldb/test/API/macosx/save_crashlog/Makefile @@ -0,0 +1,4 @@ +C_SOURCES := main.c +CFLAGS_EXTRAS := -std=c99 + +include Makefile.rules Index: lldb/examples/python/crashlog.py === --- lldb/examples/python/crashlog.py +++ lldb/examples/python/crashlog.py @@ -791,11 +791,11 @@ block_range = block.range[frame.addr] if block_range: block_start_addr = block_range[0] -frame_offset = frame_pc - block_start_addr.load_addr +
[Lldb-commits] [PATCH] D79929: [lldb] Tab completion for process plugin name
MrHate marked an inline comment as done. MrHate added a comment. That does make sense. I will split it into `eArgTypeProcessPlugin` and `eArgTypeDisassemblePlugin` along with the corresponding completion function names at the time I implement the `disassemble` related completion function. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79929/new/ https://reviews.llvm.org/D79929 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D80595: Also cache negative results in GetXcodeSDKPath (NFC)
This revision was automatically updated to reflect the committed changes. Closed by commit rG334552150770: Also cache negative results in GetXcodeSDKPath (NFC) (authored by aprantl). Herald added a project: LLDB. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80595/new/ https://reviews.llvm.org/D80595 Files: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm === --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -367,8 +367,10 @@ static std::mutex g_sdk_path_mutex; std::lock_guard guard(g_sdk_path_mutex); - std::string = g_sdk_path[sdk.GetString()]; - if (path.empty()) -path = GetXcodeSDK(sdk); + auto it = g_sdk_path.find(sdk.GetString()); + if (it != g_sdk_path.end()) +return it->second; + std::string path = GetXcodeSDK(sdk); + g_sdk_path.insert({sdk.GetString(), path}); return path; } Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm === --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -367,8 +367,10 @@ static std::mutex g_sdk_path_mutex; std::lock_guard guard(g_sdk_path_mutex); - std::string = g_sdk_path[sdk.GetString()]; - if (path.empty()) -path = GetXcodeSDK(sdk); + auto it = g_sdk_path.find(sdk.GetString()); + if (it != g_sdk_path.end()) +return it->second; + std::string path = GetXcodeSDK(sdk); + g_sdk_path.insert({sdk.GetString(), path}); return path; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f9bea9b - [lldb/Reproducers] Skip & add FIXME to tests failing with unexpected packet.
Author: Jonas Devlieghere Date: 2020-05-27T13:52:48-07:00 New Revision: f9bea9bc4acf4c412eab4767c31674d0caa60322 URL: https://github.com/llvm/llvm-project/commit/f9bea9bc4acf4c412eab4767c31674d0caa60322 DIFF: https://github.com/llvm/llvm-project/commit/f9bea9bc4acf4c412eab4767c31674d0caa60322.diff LOG: [lldb/Reproducers] Skip & add FIXME to tests failing with unexpected packet. Add skip decorator to tests failing with an unexpected packet during passive replay. Added: Modified: lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py Removed: diff --git a/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py b/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py index de883f47f935..3839f7d89235 100644 --- a/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py +++ b/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py @@ -53,6 +53,7 @@ def test_conditional_bktp(self): @add_test_categories(['pyapi']) @expectedFlakeyNetBSD +@skipIfReproducer # FIXME: Unexpected packet during (passive) replay def test_unwind_expression(self): """Test unwinding from an expression.""" self.build_and_run_to_bkpt() diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py b/lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py index 142861a37dff..f66f58379890 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py @@ -8,6 +8,7 @@ class TestRestartBug(GDBRemoteTestBase): @expectedFailureAll(bugnumber="llvm.org/pr24530") +@skipIfReproducer # FIXME: Unexpected packet during (passive) replay def test(self): """ Test auto-continue behavior when a process is interrupted to deliver diff --git a/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py b/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py index 5930ffdc958a..cc3922ccf9f4 100644 --- a/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py +++ b/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py @@ -30,6 +30,7 @@ def setUp(self): @skipIf( debug_info=no_match("dsym"), bugnumber="This test requires a stripped binary and a dSYM") +@skipIfReproducer # FIXME: Unexpected packet during (passive) replay def test_expr_stripped(self): if self.getArchitecture() == 'i386': self.skipTest("requires modern objc runtime") @@ -38,6 +39,7 @@ def test_expr_stripped(self): self.expr(True) @skipUnlessDarwin +@skipIfReproducer # FIXME: Unexpected packet during (passive) replay def test_expr(self): if self.getArchitecture() == 'i386': self.skipTest("requires modern objc runtime") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5f97a54 - [lldb/Reproducers] Differentiate active and passive replay unexpected packet.
Author: Jonas Devlieghere Date: 2020-05-27T13:52:38-07:00 New Revision: 5f97a540ad8dd4baac47873fa4bdfba2f37e0f82 URL: https://github.com/llvm/llvm-project/commit/5f97a540ad8dd4baac47873fa4bdfba2f37e0f82 DIFF: https://github.com/llvm/llvm-project/commit/5f97a540ad8dd4baac47873fa4bdfba2f37e0f82.diff LOG: [lldb/Reproducers] Differentiate active and passive replay unexpected packet. Added: Modified: lldb/test/API/commands/command/script/TestCommandScript.py lldb/test/API/commands/expression/issue_11588/Test11588.py lldb/test/API/commands/process/attach-resume/TestAttachResume.py lldb/test/API/commands/process/attach/TestProcessAttach.py lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py lldb/test/API/functionalities/conditional_break/TestConditionalBreak.py lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py lldb/test/API/functionalities/signal/TestSendSignal.py lldb/test/API/functionalities/step_scripted/TestStepScripted.py lldb/test/API/lang/objc/foundation/TestRuntimeTypes.py lldb/test/API/lang/objc/modules/TestObjCModules.py lldb/test/API/lang/objc/print-obj/TestPrintObj.py lldb/test/API/python_api/hello_world/TestHelloWorld.py Removed: diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py index 6663c3641452..caf97ea8db97 100644 --- a/lldb/test/API/commands/command/script/TestCommandScript.py +++ b/lldb/test/API/commands/command/script/TestCommandScript.py @@ -14,7 +14,7 @@ class CmdPythonTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) NO_DEBUG_INFO_TESTCASE = True -@skipIfReproducer # Unexpected packet during replay +@skipIfReproducer # FIXME: Unexpected packet during (active) replay def test(self): self.build() self.pycmd_tests() diff --git a/lldb/test/API/commands/expression/issue_11588/Test11588.py b/lldb/test/API/commands/expression/issue_11588/Test11588.py index 8ed7797d5fff..eb5b86e96363 100644 --- a/lldb/test/API/commands/expression/issue_11588/Test11588.py +++ b/lldb/test/API/commands/expression/issue_11588/Test11588.py @@ -17,7 +17,7 @@ class Issue11581TestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") -@skipIfReproducer # Unexpected packet during replay +@skipIfReproducer # FIXME: Unexpected packet during (active) replay def test_11581_commands(self): # This is the function to remove the custom commands in order to have a # clean slate for the next test case. diff --git a/lldb/test/API/commands/process/attach-resume/TestAttachResume.py b/lldb/test/API/commands/process/attach-resume/TestAttachResume.py index ebb4345aca91..48a281e096a9 100644 --- a/lldb/test/API/commands/process/attach-resume/TestAttachResume.py +++ b/lldb/test/API/commands/process/attach-resume/TestAttachResume.py @@ -21,7 +21,7 @@ class AttachResumeTestCase(TestBase): @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19310') @expectedFailureNetBSD @skipIfWindows # llvm.org/pr24778, llvm.org/pr21753 -@skipIfReproducer # Unexpected packet during replay +@skipIfReproducer # FIXME: Unexpected packet during (active) replay def test_attach_continue_interrupt_detach(self): """Test attach/continue/interrupt/detach""" self.build() diff --git a/lldb/test/API/commands/process/attach/TestProcessAttach.py b/lldb/test/API/commands/process/attach/TestProcessAttach.py index 792a8cee61f9..f9b273309956 100644 --- a/lldb/test/API/commands/process/attach/TestProcessAttach.py +++ b/lldb/test/API/commands/process/attach/TestProcessAttach.py @@ -39,7 +39,7 @@ def test_attach_to_process_by_id(self): self.assertTrue(process, PROCESS_IS_VALID) @expectedFailureNetBSD -@skipIfReproducer # Unexpected packet during replay +@skipIfReproducer # FIXME: Unexpected packet during (active) replay def test_attach_to_process_from_ diff erent_dir_by_id(self): """Test attach by process id""" newdir = self.getBuildArtifact("newdir") diff --git a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py index b08dfc78cea3..f4bbde755e69 100644 --- a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py +++ b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py @@ -16,7 +16,7 @@ class TestScriptedResolver(TestBase): NO_DEBUG_INFO_TESTCASE = True @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") -@skipIfReproducer # Unexpected packet during replay +@skipIfReproducer # FIXME: Unexpected packet during (active)
[Lldb-commits] [lldb] c30c236 - [lldb/Reproducers] Skip tests relying on timeouts
Author: Jonas Devlieghere Date: 2020-05-27T12:08:41-07:00 New Revision: c30c2368c77f05a1447bb7442c6ac2fad2912a57 URL: https://github.com/llvm/llvm-project/commit/c30c2368c77f05a1447bb7442c6ac2fad2912a57 DIFF: https://github.com/llvm/llvm-project/commit/c30c2368c77f05a1447bb7442c6ac2fad2912a57.diff LOG: [lldb/Reproducers] Skip tests relying on timeouts The reproducer don't model timeouts so tests that rely on them end up with unexpected packets during replay. Skip them until we can handle this scenario. Added: Modified: lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py Removed: diff --git a/lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py b/lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py index d7d963390b05..3423ec6e6ab9 100644 --- a/lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py +++ b/lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py @@ -17,6 +17,7 @@ class ExprDoesntDeadlockTestCase(TestBase): @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17946') @add_test_categories(["basic_process"]) +@skipIfReproducer # Timeouts are not currently modeled. def test_with_run_command(self): """Test that expr will time out and allow other threads to run if it blocks.""" self.build() diff --git a/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py b/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py index 42e28a5a440a..36ed7ce26de1 100644 --- a/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py +++ b/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py @@ -26,6 +26,7 @@ def setUp(self): oslist=[ "windows"], bugnumber="llvm.org/pr21765") +@skipIfReproducer # Timeouts are not currently modeled. def test(self): """Test calling std::String member function.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fe9d844 - [lldb/Test] Generate YAML binary in build directory
Author: Jonas Devlieghere Date: 2020-05-27T12:08:41-07:00 New Revision: fe9d8442e0dfc8c83e9a0a31f5079e7a70b54d9d URL: https://github.com/llvm/llvm-project/commit/fe9d8442e0dfc8c83e9a0a31f5079e7a70b54d9d DIFF: https://github.com/llvm/llvm-project/commit/fe9d8442e0dfc8c83e9a0a31f5079e7a70b54d9d.diff LOG: [lldb/Test] Generate YAML binary in build directory Although it's not entirely clear to me why, this test was generating its binary in the source directory instead of the build directory. This patch fixes that following the same approach as other tests. Added: Modified: lldb/test/API/functionalities/show_location/TestShowLocationDwarf5.py Removed: diff --git a/lldb/test/API/functionalities/show_location/TestShowLocationDwarf5.py b/lldb/test/API/functionalities/show_location/TestShowLocationDwarf5.py index 1d4bc6f13450..76d24d5d4e52 100644 --- a/lldb/test/API/functionalities/show_location/TestShowLocationDwarf5.py +++ b/lldb/test/API/functionalities/show_location/TestShowLocationDwarf5.py @@ -14,17 +14,9 @@ class TestTargetSourceMap(TestBase): def test_source_map(self): # Set the target soure map to map "./" to the current test directory. yaml_path = os.path.join(self.getSourceDir(), "a.yaml") -yaml_base, ext = os.path.splitext(yaml_path) -obj_path = self.getBuildArtifact(yaml_base) +obj_path = self.getBuildArtifact('a.out') self.yaml2obj(yaml_path, obj_path) -def cleanup(): -if os.path.exists(obj_path): -os.unlink(obj_path) - -# Execute the cleanup function during test case tear down. -self.addTearDownHook(cleanup) - # Create a target with the object file we just created from YAML target = self.dbg.CreateTarget(obj_path) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D80666: Fix a use-after-free in GetXcodeSDKPath
aprantl created this revision. aprantl added reviewers: JDevlieghere, friss. JDevlieghere accepted this revision. This revision is now accepted and ready to land. I'm sorry, I just introduced this in https://reviews.llvm.org/D80595. Thanks Jonas for noticing! https://reviews.llvm.org/D80666 Files: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm === --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -370,7 +370,6 @@ auto it = g_sdk_path.find(sdk.GetString()); if (it != g_sdk_path.end()) return it->second; - std::string path = GetXcodeSDK(sdk); - g_sdk_path.insert({sdk.GetString(), path}); - return path; + auto it_new = g_sdk_path.insert({sdk.GetString(), GetXcodeSDK(sdk)}); + return it_new.first->second; } Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm === --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -370,7 +370,6 @@ auto it = g_sdk_path.find(sdk.GetString()); if (it != g_sdk_path.end()) return it->second; - std::string path = GetXcodeSDK(sdk); - g_sdk_path.insert({sdk.GetString(), path}); - return path; + auto it_new = g_sdk_path.insert({sdk.GetString(), GetXcodeSDK(sdk)}); + return it_new.first->second; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3345521 - Also cache negative results in GetXcodeSDKPath (NFC)
Author: Adrian Prantl Date: 2020-05-27T12:26:04-07:00 New Revision: 334552150770faaa407fecab42f5333bb2a898a6 URL: https://github.com/llvm/llvm-project/commit/334552150770faaa407fecab42f5333bb2a898a6 DIFF: https://github.com/llvm/llvm-project/commit/334552150770faaa407fecab42f5333bb2a898a6.diff LOG: Also cache negative results in GetXcodeSDKPath (NFC) This fixes a performance issue in the failure case. rdar://63547920 Differential Revision: https://reviews.llvm.org/D80595 Added: Modified: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm Removed: diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm index 79ccc5277d2e..cb6f03465ef7 100644 --- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -367,8 +367,10 @@ static void ParseOSVersion(llvm::VersionTuple , NSString *Key) { static std::mutex g_sdk_path_mutex; std::lock_guard guard(g_sdk_path_mutex); - std::string = g_sdk_path[sdk.GetString()]; - if (path.empty()) -path = GetXcodeSDK(sdk); + auto it = g_sdk_path.find(sdk.GetString()); + if (it != g_sdk_path.end()) +return it->second; + std::string path = GetXcodeSDK(sdk); + g_sdk_path.insert({sdk.GetString(), path}); return path; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D80659: [lldb-vscode] Redirect stderr and stdout to DAPs console message
aadsm created this revision. aadsm added reviewers: clayborg, labath, rmaz. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Doing this for 2 main reasons: - Avoid stdout from corrupting DAP messages - Make sure we can see in VSCode (or any other DAP client) the same output we see when debugging from the command line Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D80659 Files: lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -485,6 +485,31 @@ } } +int RedirectFileDescriptorToConsoleOutput(int fd) { + int new_fd = dup(fd); + int captured_fd[2]; + + pipe(captured_fd); + dup2(captured_fd[1], fd); + int read_fd = captured_fd[0]; + + std::thread([read_fd] { +char buffer[4096]; +fd_set readfds; +while (true) { + FD_ZERO(); + FD_SET(read_fd, ); + select(read_fd + 1, , nullptr, nullptr, nullptr); + if (FD_ISSET(read_fd, )) { +read(read_fd, , sizeof(buffer)); +g_vsc.SendOutput(OutputType::Console, buffer); + } +} + }).detach(); + + return new_fd; +} + // "AttachRequest": { // "allOf": [ { "$ref": "#/definitions/Request" }, { // "type": "object", @@ -2818,9 +2843,10 @@ exit(1); } } else { +int new_stdout_fd = RedirectFileDescriptorToConsoleOutput(fileno(stdout)); +RedirectFileDescriptorToConsoleOutput(fileno(stderr)); g_vsc.input.descriptor = StreamDescriptor::from_file(fileno(stdin), false); -g_vsc.output.descriptor = -StreamDescriptor::from_file(fileno(stdout), false); +g_vsc.output.descriptor = StreamDescriptor::from_file(new_stdout_fd, false); } auto request_handlers = GetRequestHandlers(); uint32_t packet_idx = 0; Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -485,6 +485,31 @@ } } +int RedirectFileDescriptorToConsoleOutput(int fd) { + int new_fd = dup(fd); + int captured_fd[2]; + + pipe(captured_fd); + dup2(captured_fd[1], fd); + int read_fd = captured_fd[0]; + + std::thread([read_fd] { +char buffer[4096]; +fd_set readfds; +while (true) { + FD_ZERO(); + FD_SET(read_fd, ); + select(read_fd + 1, , nullptr, nullptr, nullptr); + if (FD_ISSET(read_fd, )) { +read(read_fd, , sizeof(buffer)); +g_vsc.SendOutput(OutputType::Console, buffer); + } +} + }).detach(); + + return new_fd; +} + // "AttachRequest": { // "allOf": [ { "$ref": "#/definitions/Request" }, { // "type": "object", @@ -2818,9 +2843,10 @@ exit(1); } } else { +int new_stdout_fd = RedirectFileDescriptorToConsoleOutput(fileno(stdout)); +RedirectFileDescriptorToConsoleOutput(fileno(stderr)); g_vsc.input.descriptor = StreamDescriptor::from_file(fileno(stdin), false); -g_vsc.output.descriptor = -StreamDescriptor::from_file(fileno(stdout), false); +g_vsc.output.descriptor = StreamDescriptor::from_file(new_stdout_fd, false); } auto request_handlers = GetRequestHandlers(); uint32_t packet_idx = 0; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D79752: [lldb] Move ClangModulesDeclVendor ownership to ClangPersistentVariables
shafik added inline comments. Comment at: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:854 - ClangModulesDeclVendor *modules_decl_vendor = - m_target->GetClangModulesDeclVendor(); + auto *persistent_vars = llvm::cast( + m_target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC)); Can we just write a helper method to these two steps in `ClangASTSource` and then `ClangExpressionDeclMap` will just get it as well. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79752/new/ https://reviews.llvm.org/D79752 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D80666: Fix a use-after-free in GetXcodeSDKPath
This revision was automatically updated to reflect the committed changes. Closed by commit rGa57a67c59b3f: Fix a use-after-free in GetXcodeSDKPath (authored by aprantl). Herald added a project: LLDB. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80666/new/ https://reviews.llvm.org/D80666 Files: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm === --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -370,7 +370,6 @@ auto it = g_sdk_path.find(sdk.GetString()); if (it != g_sdk_path.end()) return it->second; - std::string path = GetXcodeSDK(sdk); - g_sdk_path.insert({sdk.GetString(), path}); - return path; + auto it_new = g_sdk_path.insert({sdk.GetString(), GetXcodeSDK(sdk)}); + return it_new.first->second; } Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm === --- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -370,7 +370,6 @@ auto it = g_sdk_path.find(sdk.GetString()); if (it != g_sdk_path.end()) return it->second; - std::string path = GetXcodeSDK(sdk); - g_sdk_path.insert({sdk.GetString(), path}); - return path; + auto it_new = g_sdk_path.insert({sdk.GetString(), GetXcodeSDK(sdk)}); + return it_new.first->second; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a57a67c - Fix a use-after-free in GetXcodeSDKPath
Author: Adrian Prantl Date: 2020-05-27T14:27:16-07:00 New Revision: a57a67c59b3f7529f4aa30009b214248772b544b URL: https://github.com/llvm/llvm-project/commit/a57a67c59b3f7529f4aa30009b214248772b544b DIFF: https://github.com/llvm/llvm-project/commit/a57a67c59b3f7529f4aa30009b214248772b544b.diff LOG: Fix a use-after-free in GetXcodeSDKPath Introduced in https://reviews.llvm.org/D80595. Thanks Jonas for noticing! Differential Revision: https://reviews.llvm.org/D80666 Added: Modified: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm Removed: diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm index cb6f03465ef7..615f77b2dbcc 100644 --- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -370,7 +370,6 @@ static void ParseOSVersion(llvm::VersionTuple , NSString *Key) { auto it = g_sdk_path.find(sdk.GetString()); if (it != g_sdk_path.end()) return it->second; - std::string path = GetXcodeSDK(sdk); - g_sdk_path.insert({sdk.GetString(), path}); - return path; + auto it_new = g_sdk_path.insert({sdk.GetString(), GetXcodeSDK(sdk)}); + return it_new.first->second; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5238b80 - [lldb/Reproducers] Skip or fix the remaining tests.
Author: Jonas Devlieghere Date: 2020-05-27T21:02:36-07:00 New Revision: 5238b80058a6d096220eb9fbf606d9d983f37b0b URL: https://github.com/llvm/llvm-project/commit/5238b80058a6d096220eb9fbf606d9d983f37b0b DIFF: https://github.com/llvm/llvm-project/commit/5238b80058a6d096220eb9fbf606d9d983f37b0b.diff LOG: [lldb/Reproducers] Skip or fix the remaining tests. After this patch all remaining tests should pass on macOS when replayed from a reproducer. To capture the reproducers: ./bin/llvm-lit ../llvm-project/lldb/test/ --param lldb-run-with-repro=capture To replay the reproducers: ./bin/llvm-lit ../llvm-project/lldb/test/ --param lldb-run-with-repro=replay Added: Modified: lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py lldb/test/API/functionalities/load_unload/TestLoadUnload.py lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py lldb/test/API/lang/cpp/thread_local/TestThreadLocal.py lldb/test/API/macosx/version_zero/TestGetVersionZeroVersion.py lldb/test/API/python_api/symbol-context/TestSymbolContext.py Removed: diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py b/lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py index 73bd292463f0..83fa197c2fe3 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py @@ -6,6 +6,7 @@ class TestWriteMemory(GDBRemoteTestBase): +@skipIfReproducer # SBProcess::WriteMemory is not instrumented. def test(self): class MyResponder(MockGDBServerResponder): diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py index 853c0b2cea20..538f7b1734ba 100644 --- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py +++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py @@ -223,6 +223,7 @@ def test_lldb_process_load_and_unload_commands_with_svr4(self): self.setSvr4Support(True) self.run_lldb_process_load_and_unload_commands() +@skipIfReproducer # FIXME: Unexpected packet during (passive) replay def run_lldb_process_load_and_unload_commands(self): """Test that lldb process load/unload command work correctly.""" self.copy_shlibs_to_remote() diff --git a/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py b/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py index a7d5f07a0976..9e10bd3ce833 100644 --- a/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py +++ b/lldb/test/API/functionalities/load_using_paths/TestLoadUsingPaths.py @@ -41,6 +41,7 @@ def setUp(self): @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work diff erently @expectedFlakeyNetBSD @expectedFailureAll(oslist=["linux"], archs=['arm'], bugnumber="llvm.org/pr45894") +@skipIfReproducer # FIXME: Unexpected packet during (passive) replay def test_load_using_paths(self): """Test that we can load a module by providing a set of search paths.""" if self.platformIsDarwin(): diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py index 3e1abc3353c3..012f9b67d9e3 100644 --- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py +++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py @@ -344,6 +344,7 @@ def test_deeper_stack_in_minidump(self): "linux-x86_64_not_crashed.dmp", self._linux_x86_64_not_crashed_pid) +@skipIfReproducer # VFS is a snapshot. def do_change_pid_in_minidump(self, core, newcore, offset, oldpid, newpid): """ This assumes that the minidump is breakpad generated on Linux - meaning that the PID in the file will be an ascii string part of diff --git a/lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py b/lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py index 93597b4edae3..124d13ed97a4 100644 --- a/lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py +++ b/lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py @@ -24,6 +24,7 @@ def setUp(self): @skipIfWindows # setpgid call does not exist on Windows @expectedFailureAndroid("http://llvm.org/pr23762;, api_levels=[16]) @expectedFailureNetBSD +@skipIfReproducer # File synchronization is not
[Lldb-commits] [lldb] e5bb542 - [lldb/Test] Import all decorators.
Author: Jonas Devlieghere Date: 2020-05-27T21:13:08-07:00 New Revision: e5bb542362dfbb6c57a597810d740987afbc4202 URL: https://github.com/llvm/llvm-project/commit/e5bb542362dfbb6c57a597810d740987afbc4202 DIFF: https://github.com/llvm/llvm-project/commit/e5bb542362dfbb6c57a597810d740987afbc4202.diff LOG: [lldb/Test] Import all decorators. Fixes "NameError: name 'skipIfReproducer' is not defined". Added: Modified: lldb/test/API/macosx/version_zero/TestGetVersionZeroVersion.py Removed: diff --git a/lldb/test/API/macosx/version_zero/TestGetVersionZeroVersion.py b/lldb/test/API/macosx/version_zero/TestGetVersionZeroVersion.py index 53a59c923d84..5f9772b8fb20 100644 --- a/lldb/test/API/macosx/version_zero/TestGetVersionZeroVersion.py +++ b/lldb/test/API/macosx/version_zero/TestGetVersionZeroVersion.py @@ -5,7 +5,7 @@ import lldb -from lldbsuite.test import decorators +from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil from lldbsuite.test.lldbtest import * ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint
kwk updated this revision to Diff 266465. kwk marked 3 inline comments as done. kwk added a comment. - use %t in files created in tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74136/new/ https://reviews.llvm.org/D74136 Files: lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Core/SearchFilter.cpp lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp lldb/test/Shell/Breakpoint/Inputs/search-support-files.h lldb/test/Shell/Breakpoint/search-support-files.test Index: lldb/test/Shell/Breakpoint/search-support-files.test === --- /dev/null +++ lldb/test/Shell/Breakpoint/search-support-files.test @@ -0,0 +1,46 @@ +# In these tests we will set breakpoints on a function by name. That function +# is defined in a header file (search-support-files.h) and will therefore be +# inlined into the file that includes it (search-support-files.cpp). +# +# TODO(kwk): Check that we can also do the same with C++ methods in files? +#(See https://lldb.llvm.org/use/tutorial.html and look for --method.) + +# RUN: %build %p/Inputs/search-support-files.cpp -o %t.out +# RUN: %lldb -b -s %s %t.out | FileCheck --color --dump-input=fail %s + +#Set breakpoint by function name. + +breakpoint set -n function_in_header +# CHECK: (lldb) breakpoint set -n function_in_header +# CHECK-NEXT: Breakpoint 1: where = {{.*}}.out`function_in_header() + 4 at search-support-files.h:1:20, address = 0x0{{.*}} + +breakpoint set -n main +# CHECK: (lldb) breakpoint set -n main +# CHECK-NEXT: Breakpoint 2: where = {{.*}}.out`main + 22 at search-support-files.cpp:4:11, address = 0x0{{.*}} + +# Set breakpoint by function name and filename (the one in which the function +# is inlined, aka the compilation unit). + +breakpoint set -n function_in_header -f search-support-files.cpp +# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp +# CHECK-NEXT: Breakpoint 3: no locations (pending). + +# Set breakpoint by function name and source filename (the file in which the +# function is defined). +# +# NOTE: This test is the really interesting one as it shows that we can +# search by source files that are themselves no compilation units. + +breakpoint set -n function_in_header -f search-support-files.h +# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h +# CHECK-NEXT: Breakpoint 4: where = {{.*}}.out`function_in_header() + 4 at search-support-files.h:1:20, address = 0x0{{.*}} + +# Set breakpoint by function name and source filename. This time the file +# doesn't exist to prove that we haven't widen the search space too much. When +# we search for a function in a file that doesn't exist, we should get no +# results. + +breakpoint set -n function_in_header -f file-not-existing.h +# CHECK: (lldb) breakpoint set -n function_in_header -f file-not-existing.h +# CHECK-NEXT: Breakpoint 5: no locations (pending). +# CHECK-NEXT: WARNING: Unable to resolve breakpoint to any actual locations. Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h === --- /dev/null +++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.h @@ -0,0 +1 @@ +int function_in_header() { return 42; } Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp === --- /dev/null +++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp @@ -0,0 +1,6 @@ +#include "search-support-files.h" + +int main(int argc, char *argv[]) { + int a = function_in_header(); + return a; +} Index: lldb/source/Core/SearchFilter.cpp === --- lldb/source/Core/SearchFilter.cpp +++ lldb/source/Core/SearchFilter.cpp @@ -712,12 +712,7 @@ if (m_cu_spec_list.GetSize() != 0) return false; // Has no comp_unit so can't pass the file check. } - FileSpec cu_spec; - if (sym_ctx.comp_unit) -cu_spec = sym_ctx.comp_unit->GetPrimaryFile(); - if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX) -return false; // Fails the file check - return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); + return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); } bool SearchFilterByModuleListAndCU::CompUnitPasses(FileSpec ) { @@ -811,7 +806,7 @@ } uint32_t SearchFilterByModuleListAndCU::GetFilterRequiredItems() { - return eSymbolContextModule | eSymbolContextCompUnit; + return eSymbolContextModule | eSymbolContextCompUnit | eSymbolContextFunction; } void SearchFilterByModuleListAndCU::Dump(Stream *s) const {} Index: lldb/source/Breakpoint/BreakpointResolverName.cpp === --- lldb/source/Breakpoint/BreakpointResolverName.cpp +++ lldb/source/Breakpoint/BreakpointResolverName.cpp
[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint
kwk updated this revision to Diff 266463. kwk marked 3 inline comments as done. kwk added a comment. Herald added a subscriber: sstefan1. - rebase - Rename function in test from inlined_42 to function_in_header - Typo: compulation -> compilation Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74136/new/ https://reviews.llvm.org/D74136 Files: lldb/source/Breakpoint/BreakpointResolverName.cpp lldb/source/Core/SearchFilter.cpp lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp lldb/test/Shell/Breakpoint/Inputs/search-support-files.h lldb/test/Shell/Breakpoint/search-support-files.test Index: lldb/test/Shell/Breakpoint/search-support-files.test === --- /dev/null +++ lldb/test/Shell/Breakpoint/search-support-files.test @@ -0,0 +1,46 @@ +# In these tests we will set breakpoints on a function by name. That function +# is defined in a header file (search-support-files.h) and will therefore be +# inlined into the file that includes it (search-support-files.cpp). +# +# TODO(kwk): Check that we can also do the same with C++ methods in files? +#(See https://lldb.llvm.org/use/tutorial.html and look for --method.) + +# RUN: %build %p/Inputs/search-support-files.cpp -o dummy.out +# RUN: %lldb -b -s %s dummy.out | FileCheck --color --dump-input=fail %s + +#Set breakpoint by function name. + +breakpoint set -n function_in_header +# CHECK: (lldb) breakpoint set -n function_in_header +# CHECK-NEXT: Breakpoint 1: where = dummy.out`function_in_header() + 4 at search-support-files.h:1:20, address = 0x0{{.*}} + +breakpoint set -n main +# CHECK: (lldb) breakpoint set -n main +# CHECK-NEXT: Breakpoint 2: where = dummy.out`main + 22 at search-support-files.cpp:4:11, address = 0x0{{.*}} + +# Set breakpoint by function name and filename (the one in which the function +# is inlined, aka the compilation unit). + +breakpoint set -n function_in_header -f search-support-files.cpp +# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.cpp +# CHECK-NEXT: Breakpoint 3: no locations (pending). + +# Set breakpoint by function name and source filename (the file in which the +# function is defined). +# +# NOTE: This test is the really interesting one as it shows that we can +# search by source files that are themselves no compilation units. + +breakpoint set -n function_in_header -f search-support-files.h +# CHECK: (lldb) breakpoint set -n function_in_header -f search-support-files.h +# CHECK-NEXT: Breakpoint 4: where = dummy.out`function_in_header() + 4 at search-support-files.h:1:20, address = 0x0{{.*}} + +# Set breakpoint by function name and source filename. This time the file +# doesn't exist to prove that we haven't widen the search space too much. When +# we search for a function in a file that doesn't exist, we should get no +# results. + +breakpoint set -n function_in_header -f file-not-existing.h +# CHECK: (lldb) breakpoint set -n function_in_header -f file-not-existing.h +# CHECK-NEXT: Breakpoint 5: no locations (pending). +# CHECK-NEXT: WARNING: Unable to resolve breakpoint to any actual locations. Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.h === --- /dev/null +++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.h @@ -0,0 +1 @@ +int function_in_header() { return 42; } Index: lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp === --- /dev/null +++ lldb/test/Shell/Breakpoint/Inputs/search-support-files.cpp @@ -0,0 +1,6 @@ +#include "search-support-files.h" + +int main(int argc, char *argv[]) { + int a = function_in_header(); + return a; +} Index: lldb/source/Core/SearchFilter.cpp === --- lldb/source/Core/SearchFilter.cpp +++ lldb/source/Core/SearchFilter.cpp @@ -712,12 +712,7 @@ if (m_cu_spec_list.GetSize() != 0) return false; // Has no comp_unit so can't pass the file check. } - FileSpec cu_spec; - if (sym_ctx.comp_unit) -cu_spec = sym_ctx.comp_unit->GetPrimaryFile(); - if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX) -return false; // Fails the file check - return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); + return SearchFilterByModuleList::ModulePasses(sym_ctx.module_sp); } bool SearchFilterByModuleListAndCU::CompUnitPasses(FileSpec ) { @@ -811,7 +806,7 @@ } uint32_t SearchFilterByModuleListAndCU::GetFilterRequiredItems() { - return eSymbolContextModule | eSymbolContextCompUnit; + return eSymbolContextModule | eSymbolContextCompUnit | eSymbolContextFunction; } void SearchFilterByModuleListAndCU::Dump(Stream *s) const {} Index: lldb/source/Breakpoint/BreakpointResolverName.cpp