[Lldb-commits] [PATCH] D48752: Quiet command regex instructions during batch execution
kastiglione updated this revision to Diff 172488. kastiglione added a comment. Added IOHandlerActivatedInteractively https://reviews.llvm.org/D48752 Files: include/lldb/Core/IOHandler.h packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py source/Commands/CommandObjectCommands.cpp source/Core/IOHandler.cpp Index: source/Core/IOHandler.cpp === --- source/Core/IOHandler.cpp +++ source/Core/IOHandler.cpp @@ -333,6 +333,8 @@ void IOHandlerEditline::Activate() { IOHandler::Activate(); m_delegate.IOHandlerActivated(*this); + if (GetIsInteractive()) +m_delegate.IOHandlerActivatedInteractively(*this); } void IOHandlerEditline::Deactivate() { Index: source/Commands/CommandObjectCommands.cpp === --- source/Commands/CommandObjectCommands.cpp +++ source/Commands/CommandObjectCommands.cpp @@ -980,10 +980,10 @@ ~CommandObjectCommandsAddRegex() override = default; protected: - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivatedInteractively(IOHandler &io_handler) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); if (output_sp) { - output_sp->PutCString("Enter one of more sed substitution commands in " + output_sp->PutCString("Enter one or more sed substitution commands in " "the form: 's///'.\nTerminate the " "substitution list with an empty line.\n"); output_sp->Flush(); Index: packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py === --- packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py +++ packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py @@ -24,7 +24,7 @@ """Test a simple scenario of 'command regex' invocation and subsequent use.""" import pexpect prompt = "(lldb) " -regex_prompt = "Enter one of more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n" +regex_prompt = "Enter one or more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n" regex_prompt1 = "\r\n" child = pexpect.spawn('%s %s' % Index: include/lldb/Core/IOHandler.h === --- include/lldb/Core/IOHandler.h +++ include/lldb/Core/IOHandler.h @@ -200,6 +200,8 @@ virtual void IOHandlerActivated(IOHandler &io_handler) {} + virtual void IOHandlerActivatedInteractively(IOHandler &io_handler) {} + virtual void IOHandlerDeactivated(IOHandler &io_handler) {} virtual int IOHandlerComplete(IOHandler &io_handler, const char *current_line, Index: source/Core/IOHandler.cpp === --- source/Core/IOHandler.cpp +++ source/Core/IOHandler.cpp @@ -333,6 +333,8 @@ void IOHandlerEditline::Activate() { IOHandler::Activate(); m_delegate.IOHandlerActivated(*this); + if (GetIsInteractive()) +m_delegate.IOHandlerActivatedInteractively(*this); } void IOHandlerEditline::Deactivate() { Index: source/Commands/CommandObjectCommands.cpp === --- source/Commands/CommandObjectCommands.cpp +++ source/Commands/CommandObjectCommands.cpp @@ -980,10 +980,10 @@ ~CommandObjectCommandsAddRegex() override = default; protected: - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivatedInteractively(IOHandler &io_handler) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); if (output_sp) { - output_sp->PutCString("Enter one of more sed substitution commands in " + output_sp->PutCString("Enter one or more sed substitution commands in " "the form: 's///'.\nTerminate the " "substitution list with an empty line.\n"); output_sp->Flush(); Index: packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py === --- packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py +++ packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py @@ -24,7 +24,7 @@ """Test a simple scenario of 'command regex' invocation and subsequent use.""" import pexpect prompt = "(lldb) " -regex_prompt = "Enter one of more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n" +regex_prompt = "Enter one or more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n
[Lldb-commits] [PATCH] D48752: Quiet command regex instructions during batch execution
kastiglione added a comment. There are other commands that print instructions in the same way that `command regex` does, should they be updated in this change too? https://reviews.llvm.org/D48752 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53989: Fix formatting of wchar, char16, and char32
labath added a comment. lldb-server is used on architectures that don't have python (readily) available, and it uses the same codebase as the rest of lldb. (Granted, it only needs a small subset of that codebase, and this subset doesn't/shouldn't care about python, but we aren't able to split out that part cleanly (yet)). So I don't think requiring python is a good idea. What we could do is make it a build-time error if we failed to detect&configure python *AND* the user hasn't explicitly disabled it. This would catch this problem early and avoid other surprises later on (e.g. the entire dotest test suite only works with python enabled. without it, you'd likely get some weird error). https://reviews.llvm.org/D53989 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54053: [NativePDB] Add the ability to create clang record decls from mangled names.
labath added a comment. A very nice use of the structured demangler. https://reviews.llvm.org/D54053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52461: [PDB] Introduce `MSVCUndecoratedNameParser`
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. Thanks for your patience. This looks good to me now. https://reviews.llvm.org/D52461 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52941: NativeProcessProtocol: Simplify breakpoint setting code
labath added a comment. Kamil, I think you're the best qualified person to look at the lldb-server changes right now, so I'd like to hear your opinion on the other changes too. Otherwise, I'll just commit this some time next week. https://reviews.llvm.org/D52941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52941: NativeProcessProtocol: Simplify breakpoint setting code
krytarowski added a comment. This looks fine to me. https://reviews.llvm.org/D52941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54059: Remove Java debugger plugin
JDevlieghere added a comment. In https://reviews.llvm.org/D54059#1286293, @teemperor wrote: > Minor detail: The revision title only mentions Java, but this revision > removes both Go and Java. Actually, this review is only for removing the Java plugin. There’s a different review for the Go plugin: https://reviews.llvm.org/D54057. I suppose the confusion is the result of the first file removing both enum values. I’ll update the review. > Did anyone actually went through with Jim's proposal and posted this proposal > to some Go mailing list or so? I didn’t but I’m not sure about Davide. I’ll check with him on Monday. In https://reviews.llvm.org/D54059#1286293, @teemperor wrote: > Minor detail: The revision title only mentions Java, but this revision > removes both Go and Java. > > Did anyone actually went through with Jim's proposal and posted this proposal > to some Go mailing list or so? https://reviews.llvm.org/D54059 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54053: [NativePDB] Add the ability to create clang record decls from mangled names.
zturner added a comment. I actually found some issues with this, or at least some potential issues which I'm not sure are actual issues. But I'm adding some new functionality to LLDB to help me confirm whether these are real issues or not, and worst case scenario it will open up some new testing possibilities and help us understand the consequences of messing around with clang ASTs in various ways. So I'm not going to commit this quite yet. Stay tuned. https://reviews.llvm.org/D54053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54072: Add a command to dump a module's clang ast.
zturner created this revision. zturner added reviewers: vsk, davide, labath, jingham, aleksandr.urakov, clayborg. Herald added subscribers: JDevlieghere, aprantl. This can be useful when diagnosing AST related problems. For example, I had a bug where I was accidentally creating a record type multiple times instead of re-using the first one. This is easy to see with a dump of the AST, because it will look like this: TranslationUnitDecl 0x18a2bc53b98 <> |-CXXRecordDecl 0x18a2bc54458 <> class ClassWithPadding |-CXXRecordDecl 0x18a2bc54520 <> class ClassWithPadding |-CXXRecordDecl 0x18a2bc545e0 <> class ClassWithPadding definition | |-DefinitionData pass_in_registers standard_layout trivially_copyable trivial literal | | |-DefaultConstructor exists trivial needs_implicit | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param | | |-MoveConstructor exists simple trivial needs_implicit | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param | | |-MoveAssignment exists simple trivial needs_implicit | | `-Destructor simple irrelevant trivial needs_implicit | |-MSInheritanceAttr 0x18a2bc546a0 <> Implicit __single_inheritance | |-FieldDecl 0x18a2bc54748 <> a 'char' | |-FieldDecl 0x18a2bc54798 <> b 'short' | |-FieldDecl 0x18a2bc54828 <> c 'char [2]' | |-FieldDecl 0x18a2bc54878 <> d 'int' | |-FieldDecl 0x18a2bc548c8 <> e 'char' | |-FieldDecl 0x18a2bc54918 <> f 'int' | |-FieldDecl 0x18a2bc54968 <> g 'long long' | |-FieldDecl 0x18a2bc549f8 <> h 'char [3]' | |-FieldDecl 0x18a2bc54a48 <> i 'long long' | |-FieldDecl 0x18a2bc54a98 <> j 'char [2]' | |-FieldDecl 0x18a2bc54ae8 <> k 'long long' | |-FieldDecl 0x18a2bc54b38 <> l 'char' | `-FieldDecl 0x18a2bd96f00 <> m 'long long' `- Note there are 3 `CXXRecordDecl`s with the same name, but only one definition. Given the complex interactions between debug info and AST reconstruction, a command like this makes problems within the AST very obvious. I found several other AST-related problems, so this was not even the only one, so I think this is a largely unexplored front when it comes to areas for potentially improved test coverage. And since it's in the REPL, it makes it very easy to test out commands in different orders, get a dump, do something else, get another dump, etc to see how the order of commands affects things. https://reviews.llvm.org/D54072 Files: lldb/include/lldb/Symbol/SymbolFile.h lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h === --- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -169,6 +169,8 @@ const llvm::pdb::IPDBSession &GetPDBSession() const; + void DumpClangAST() override; + private: struct SecContribInfo { uint32_t Offset; Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp === --- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1356,6 +1356,14 @@ return types.GetSize(); } +void SymbolFilePDB::DumpClangAST() { + auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + auto clang_type_system = llvm::dyn_cast_or_null(type_system); + if (!clang_type_system) +return; + clang_type_system->getASTContext()->getTranslationUnitDecl()->dumpColor(); +} + void SymbolFilePDB::FindTypesByRegex( const lldb_private::RegularExpression ®ex, uint32_t max_matches, lldb_private::TypeMap &types) { Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h === --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -155,6 +155,8 @@ ClangASTContext &GetASTContext() { return *m_clang; } ClangASTImporter &GetASTImporter() { return *m_importer; } + void DumpClangAST() override; + private: size_t FindTypesByName(llvm::StringRef name, uint32_t max_matches, TypeMap &types); Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp === --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePD
[Lldb-commits] [PATCH] D54074: CPlusPlusLanguage: Use new demangler API to implement type substitution
labath created this revision. labath added reviewers: sgraenitz, erik.pilkington, JDevlieghere. Now that llvm demangler supports more generic customization, we can implement type substitution directly on top of this API. This will allow us to remove the specialized hooks which were added to the demangler to support this use case. https://reviews.llvm.org/D54074 Files: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -21,7 +21,7 @@ // Other libraries and framework includes #include "llvm/ADT/StringRef.h" -#include "llvm/Demangle/Demangle.h" +#include "llvm/Demangle/ItaniumDemangle.h" // Project includes #include "lldb/Core/PluginManager.h" @@ -274,72 +274,67 @@ return false; } -/// Given a mangled function `mangled`, replace all the primitive function type -/// arguments of `search` with type `replace`. -static ConstString SubsPrimitiveParmItanium(llvm::StringRef mangled, -llvm::StringRef search, -llvm::StringRef replace) { - class PrimitiveParmSubs { -llvm::StringRef mangled; -llvm::StringRef search; -llvm::StringRef replace; -ptrdiff_t read_pos; -std::string output; -std::back_insert_iterator writer; +namespace { +class NodeAllocator { + llvm::BumpPtrAllocator Alloc; - public: -PrimitiveParmSubs(llvm::StringRef m, llvm::StringRef s, llvm::StringRef r) -: mangled(m), search(s), replace(r), read_pos(0), - writer(std::back_inserter(output)) {} - -void Substitute(llvm::StringRef tail) { - assert(tail.data() >= mangled.data() && - tail.data() < mangled.data() + mangled.size() && - "tail must point into range of mangled"); - - if (tail.startswith(search)) { -auto reader = mangled.begin() + read_pos; -ptrdiff_t read_len = tail.data() - (mangled.data() + read_pos); - -// First write the unmatched part of the original. Then write the -// replacement string. Finally skip the search string in the original. -writer = std::copy(reader, reader + read_len, writer); -writer = std::copy(replace.begin(), replace.end(), writer); -read_pos += read_len + search.size(); - } -} +public: + void reset() { Alloc.Reset(); } -ConstString Finalize() { - // If we did a substitution, write the remaining part of the original. - if (read_pos > 0) { -writer = std::copy(mangled.begin() + read_pos, mangled.end(), writer); -read_pos = mangled.size(); - } + template T *makeNode(Args &&... args) { +return new (Alloc.Allocate(sizeof(T), alignof(T))) +T(std::forward(args)...); + } - return ConstString(output); + void *allocateNodeArray(size_t sz) { +return Alloc.Allocate(sizeof(llvm::itanium_demangle::Node *) * sz, + alignof(llvm::itanium_demangle::Node *)); + } +}; + +/// Given a mangled function `Mangled`, replace all the primitive function type +/// arguments of `Search` with type `Replace`. +class TypeSubstitutor +: public llvm::itanium_demangle::AbstractManglingParser { + const char *Written; + llvm::StringRef Search; + llvm::StringRef Replace; + llvm::SmallString<128> Result; + llvm::raw_svector_ostream OS{Result}; + bool Substituted = false; + + TypeSubstitutor(llvm::StringRef Mangled, llvm::StringRef Search, + llvm::StringRef Replace) + : AbstractManglingParser(Mangled.begin(), Mangled.end()), +Written(Mangled.begin()), Search(Search), Replace(Replace) {} + +public: + static ConstString substitute(llvm::StringRef Mangled, llvm::StringRef From, +llvm::StringRef To) { +Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE); + +TypeSubstitutor TS(Mangled, From, To); +if (TS.parse() == nullptr) { + LLDB_LOG(log, "Failed to substitute mangling in {0}", Mangled); + return ConstString(); } +if (!TS.Substituted) + return ConstString(); +TS.OS << llvm::StringRef(TS.Written, TS.First - TS.Written); +LLDB_LOG(log, "Substituted mangling {0} -> {1}", Mangled, TS.OS.str()); +return ConstString(TS.OS.str()); + } -static void Callback(void *context, const char *match) { - ((PrimitiveParmSubs *)context)->Substitute(llvm::StringRef(match)); + llvm::itanium_demangle::Node *parseType() { +if (llvm::StringRef(First, Last - First).startswith(Search)) { + OS << llvm::StringRef(Written, First - Written) << Replace; + Written = First + Search.size(); + Substituted = true; } - }; - - // The demangler will call back for each instance of a primitive type, - // allowing us to perform substitution - Pr
[Lldb-commits] [PATCH] D52461: [PDB] Introduce `MSVCUndecoratedNameParser`
aleksandr.urakov added a comment. Thank you! https://reviews.llvm.org/D52461 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D53368: [Symbol] Search symbols with name and type in a symbol file
aleksandr.urakov reopened this revision. aleksandr.urakov added a comment. This revision is now accepted and ready to land. @davide You are right, this patch was the cause of the failure, sorry for that. It seems that I've found a generic issue with this patch. Thanks again for pointing to that! @clayborg The problem is that there is a bunch of places where a symtab is retrieved directly from an object file, not from a symbol vendor. So it remains uncalculated. If we will just return the recalculation / finalization to object files, it will fix the issue, but symbols from PDB will not be available in this places. We can try to use the symbol vendor instead everywhere in this places (we can retrieve a module from an object file, and we can retrieve a symbol vendor from a module, so it is guaranteed that we can get the symbol vendor in all these places). What do you think about the such approach? What pitfalls can be with it? Repository: rLLDB LLDB https://reviews.llvm.org/D53368 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54056: Add SetAllowJIT (the SBExpressionOptions equivalent of "expression --allow-jit")
jankratochvil added a comment. It broke the testsuite for me: $ time PYTHONPATH=$PWD/lib64/python2.7/site-packages:$PWD/lib64/python2.7/site-packages/lldb ../llvm-git/tools/lldb/test/dotest.py --executable $PWD/bin/lldb -C $PWD/bin/clang -t ../llvm-git/tools/lldb/packages/Python/lldbsuite/test/ WARNING:root:No valid FileCheck executable; some tests may fail... WARNING:root:(Double-check the --filecheck argument to dotest.py) LLDB library dir: /home/jkratoch/redhat/llvm-git-build-release-clang/bin LLDB import library dir: /home/jkratoch/redhat/llvm-git-build-release-clang/bin lldb version 8.0.0 clang revision 6974b990e13dfb4190a6dffdcc8bac9edbd1cde5 llvm revision 7fad5fb0d0d32beea4e95e239cc065a850733358 Libc++ tests will not be run because: Unable to find libc++ installation Skipping following debug info categories: ['dsym', 'gmodules'] Traceback (most recent call last): File "../llvm-git/tools/lldb/test/dotest.py", line 7, in lldbsuite.test.run_suite() File "/home/jkratoch/redhat/llvm-git/tools/lldb/packages/Python/lldbsuite/test/dotest.py", line 1323, in run_suite visit('Test', dirpath, filenames) File "/home/jkratoch/redhat/llvm-git/tools/lldb/packages/Python/lldbsuite/test/dotest.py", line 965, in visit raise Exception("Found multiple tests with the name %s" % name) Exception: Found multiple tests with the name TestSampleTest.py As really there are now: $ find -name TestSampleTest.py ./packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py ./packages/Python/lldbsuite/test/sample_test/TestSampleTest.py Repository: rL LLVM https://reviews.llvm.org/D54056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54056: Add SetAllowJIT (the SBExpressionOptions equivalent of "expression --allow-jit")
davide added a comment. In https://reviews.llvm.org/D54056#1286620, @jankratochvil wrote: > It broke the testsuite for me: > > $ time > PYTHONPATH=$PWD/lib64/python2.7/site-packages:$PWD/lib64/python2.7/site-packages/lldb > ../llvm-git/tools/lldb/test/dotest.py --executable $PWD/bin/lldb -C > $PWD/bin/clang -t ../llvm-git/tools/lldb/packages/Python/lldbsuite/test/ > WARNING:root:No valid FileCheck executable; some tests may fail... > WARNING:root:(Double-check the --filecheck argument to dotest.py) > LLDB library dir: /home/jkratoch/redhat/llvm-git-build-release-clang/bin > LLDB import library dir: > /home/jkratoch/redhat/llvm-git-build-release-clang/bin > lldb version 8.0.0 > clang revision 6974b990e13dfb4190a6dffdcc8bac9edbd1cde5 > llvm revision 7fad5fb0d0d32beea4e95e239cc065a850733358 > Libc++ tests will not be run because: Unable to find libc++ installation > Skipping following debug info categories: ['dsym', 'gmodules'] > Traceback (most recent call last): > File "../llvm-git/tools/lldb/test/dotest.py", line 7, in > lldbsuite.test.run_suite() > File > "/home/jkratoch/redhat/llvm-git/tools/lldb/packages/Python/lldbsuite/test/dotest.py", > line 1323, in run_suite > visit('Test', dirpath, filenames) > File > "/home/jkratoch/redhat/llvm-git/tools/lldb/packages/Python/lldbsuite/test/dotest.py", > line 965, in visit > raise Exception("Found multiple tests with the name %s" % name) > Exception: Found multiple tests with the name TestSampleTest.py > > > As really there are now: > > $ find -name TestSampleTest.py > > ./packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py > ./packages/Python/lldbsuite/test/sample_test/TestSampleTest.py > I don't think anybody will look at this until Monday, so if you want a quick fix you might consider renaming the test yourself. - Davide Repository: rL LLVM https://reviews.llvm.org/D54056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54072: Add a command to dump a module's clang ast.
zturner updated this revision to Diff 172510. zturner added a comment. clang dumps to stderr. Only use color if stderr supports this (e.g. if it's not redirected to a file). https://reviews.llvm.org/D54072 Files: lldb/include/lldb/Symbol/SymbolFile.h lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h === --- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -169,6 +169,8 @@ const llvm::pdb::IPDBSession &GetPDBSession() const; + void DumpClangAST() override; + private: struct SecContribInfo { uint32_t Offset; Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp === --- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1356,6 +1356,18 @@ return types.GetSize(); } +void SymbolFilePDB::DumpClangAST() { + auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + auto clang = llvm::dyn_cast_or_null(type_system); + if (!clang) +return; + clang::TranslationUnitDecl *tu = clang->getASTContext()->getTranslationUnitDecl(); + if (llvm::errs().has_colors()) +tu->dumpColor(); + else +tu->dump(); +} + void SymbolFilePDB::FindTypesByRegex( const lldb_private::RegularExpression ®ex, uint32_t max_matches, lldb_private::TypeMap &types) { Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h === --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -155,6 +155,8 @@ ClangASTContext &GetASTContext() { return *m_clang; } ClangASTImporter &GetASTImporter() { return *m_importer; } + void DumpClangAST() override; + private: size_t FindTypesByName(llvm::StringRef name, uint32_t max_matches, TypeMap &types); Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp === --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1391,6 +1391,17 @@ return 0; } +void SymbolFileNativePDB::DumpClangAST() { + if (!m_clang) +return; + + clang::TranslationUnitDecl *tu = m_clang->getASTContext()->getTranslationUnitDecl(); + if (llvm::errs().has_colors()) +tu->dumpColor(); + else +tu->dump(); +} + uint32_t SymbolFileNativePDB::FindGlobalVariables( const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables) { Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h === --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -126,6 +126,8 @@ std::vector ParseCallEdgesInFunction(lldb_private::UserID func_id) override; + void DumpClangAST() override; + //-- // PluginInterface protocol //-- Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp === --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1227,6 +1227,13 @@ return matching_namespace; } +void SymbolFileDWARFDebugMap::DumpClangAST() { + ForEachSymbolFile([](SymbolFileDWARF *oso_dwarf) -> bool { +oso_dwarf->DumpClangAST(); +return true; + }); +} + //-- // PluginInterface protocol //-- Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h === --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -329,6 +329,8 @@ void Dump(lldb_private::Stream &s) override; + void DumpClangAST() override; + protected: typedef llvm::DenseMap
[Lldb-commits] [PATCH] D54053: [NativePDB] Add the ability to create clang record decls from mangled names.
zturner updated this revision to Diff 172511. zturner added a comment. I just added a new test which dumps the clang AST and makes sure no bogus records get introduced. Since this is already LGTM'ed I'm assuming this is good to go, but since it now depends on https://reviews.llvm.org/D54072, I figure I might as well update this diff since I can't commit it yet. https://reviews.llvm.org/D54053 Files: lldb/lit/SymbolFile/NativePDB/Inputs/ast-reconstruction.lldbinit lldb/lit/SymbolFile/NativePDB/ast-reconstruction.cpp lldb/lit/SymbolFile/NativePDB/function-types-classes.cpp lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt lldb/source/Plugins/SymbolFile/NativePDB/MangledAST.cpp lldb/source/Plugins/SymbolFile/NativePDB/MangledAST.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h === --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -177,7 +177,8 @@ lldb::TypeSP CreateProcedureType(PdbSymUid type_uid, const llvm::codeview::ProcedureRecord &pr); lldb::TypeSP - CreateClassStructUnion(PdbSymUid type_uid, llvm::StringRef name, size_t size, + CreateClassStructUnion(PdbSymUid type_uid, llvm::StringRef name, + llvm::StringRef unique_name, size_t size, clang::TagTypeKind ttk, clang::MSInheritanceAttr::Spelling inheritance); Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp === --- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -51,6 +51,7 @@ #include "Plugins/Language/CPlusPlus/CPlusPlusNameParser.h" +#include "MangledAST.h" #include "PdbSymUid.h" #include "PdbUtil.h" #include "UdtRecordCompleter.h" @@ -731,27 +732,11 @@ } lldb::TypeSP SymbolFileNativePDB::CreateClassStructUnion( -PdbSymUid type_uid, llvm::StringRef name, size_t size, -clang::TagTypeKind ttk, clang::MSInheritanceAttr::Spelling inheritance) { +PdbSymUid type_uid, llvm::StringRef name, llvm::StringRef unique_name, +size_t size, clang::TagTypeKind ttk, +clang::MSInheritanceAttr::Spelling inheritance) { - // Ignore unnamed-tag UDTs. - name = DropNameScope(name); - if (name.empty()) -return nullptr; - - clang::DeclContext *decl_context = m_clang->GetTranslationUnitDecl(); - - lldb::AccessType access = - (ttk == clang::TTK_Class) ? lldb::eAccessPrivate : lldb::eAccessPublic; - - ClangASTMetadata metadata; - metadata.SetUserID(type_uid.toOpaqueId()); - metadata.SetIsDynamicCXXType(false); - - CompilerType ct = - m_clang->CreateRecordType(decl_context, access, name.str().c_str(), ttk, -lldb::eLanguageTypeC_plus_plus, &metadata); - lldbassert(ct.IsValid()); + CompilerType ct = CreateClangDeclFromMangledName(*m_clang, unique_name); clang::CXXRecordDecl *record_decl = m_clang->GetAsCXXRecordDecl(ct.GetOpaqueQualType()); @@ -771,7 +756,7 @@ // FIXME: Search IPI stream for LF_UDT_MOD_SRC_LINE. Declaration decl; return std::make_shared(type_uid.toOpaqueId(), m_clang->GetSymbolFile(), -ConstString(name), size, nullptr, +ct.GetTypeName(), size, nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID, decl, ct, Type::eResolveStateForward); } @@ -782,14 +767,15 @@ clang::MSInheritanceAttr::Spelling inheritance = GetMSInheritance(m_index->tpi().typeCollection(), cr); - return CreateClassStructUnion(type_uid, cr.getName(), cr.getSize(), ttk, -inheritance); + return CreateClassStructUnion(type_uid, cr.getName(), cr.getUniqueName(), +cr.getSize(), ttk, inheritance); } lldb::TypeSP SymbolFileNativePDB::CreateTagType(PdbSymUid type_uid, const UnionRecord &ur) { return CreateClassStructUnion( - type_uid, ur.getName(), ur.getSize(), clang::TTK_Union, + type_uid, ur.getName(), ur.getUniqueName(), ur.getSize(), + clang::TTK_Union, clang::MSInheritanceAttr::Spelling::Keyword_single_inheritance); } Index: lldb/source/Plugins/SymbolFile/NativePDB/MangledAST.h === --- /dev/null +++ lldb/source/Plugins/SymbolFile/NativePDB/MangledAST.h @@ -0,0 +1,30 @@ +//===-- MangledAST.h *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dist
[Lldb-commits] [PATCH] D54053: [NativePDB] Add the ability to create clang record decls from mangled names.
zturner added a comment. Bleh, I think I found a problem with this approach. Since we assume everything is a namespace, it can lead to ambiguities. I think we need to actually consult the debug info while parsing components of the mangled name. For example, suppose you have this code: namespace NS1 { struct Tag2 { class TagRecord {}; }; } NS1::Tag2::TagRecord ATR; NS1::Tag2 T2; And in LLDB you run the following commands: (lldb) target variable ATR (lldb) target variable T2 We demangle the first name and create an AST from it, but we don't know what `Tag2` is so we assume it's a namespace and we create a `NamespaceDecl`. Then we get to the second one we actually know what it is because we have a precise debug info record for it so we know it's a struct so we create a `CXXRecordDecl` for it. So now we end up creating an invalid AST. Clang will accept it, but it's going to lead to ambiguities on name lookup and create problems down the line. So, I think what we should do instead is ask the debug info "Do you know what the type named `NS1` is in the global scope?" If no, it's a namespace. Otherwise we create (or lookup) the appropriate decl. Then we can repeat this at each step along the way. BTW, when I run those above 2 commands with the patch as it is above, here is the output I get. And you can see that there are two conflicting decls. D:\src\llvmbuild\ninja-x64>"bin\lldb" "-f" "D:\src\llvmbuild\ninja-x64\tools\lldb\lit\SymbolFile\NativePDB\Output\ast-reconstruction.cpp.tmp.exe" (lldb) target create "D:\\src\\llvmbuild\\ninja-x64\\tools\\lldb\\lit\\SymbolFile\\NativePDB\\Output\\ast-reconstruction.cpp.tmp.exe" Current executable set to 'D:\src\llvmbuild\ninja-x64\tools\lldb\lit\SymbolFile\NativePDB\Output\ast-reconstruction.cpp.tmp.exe' (x86_64). (lldb) target variable ATR (NS1::Tag2::TagRecord) ATR = {} (lldb) target variable T2 (NS1::Tag2) T2 = {} (lldb) target modules dump ast TranslationUnitDecl 0x2247dff6fd8 <> |-NamespaceDecl 0x2247dff7898 <> NS1 | |-NamespaceDecl 0x2247dff7918 <> Tag2 | | `-CXXRecordDecl 0x2247dff7998 <> class TagRecord definition | | |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init | | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr | | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param | | | |-MoveConstructor exists simple trivial needs_implicit | | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param | | | |-MoveAssignment exists simple trivial needs_implicit | | | `-Destructor simple irrelevant trivial needs_implicit | | `-MSInheritanceAttr 0x2247dff7a60 <> Implicit __single_inheritance | `-CXXRecordDecl 0x2247dff7b08 <> struct Tag2 definition | |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param | | |-MoveConstructor exists simple trivial needs_implicit | | |-CopyAssignment trivial has_const_param needs_implicit implicit_has_const_param | | |-MoveAssignment exists simple trivial needs_implicit | | `-Destructor simple irrelevant trivial needs_implicit | `-MSInheritanceAttr 0x2247dff7bd0 <> Implicit __single_inheritance `- Dumping clang ast for 1 modules. https://reviews.llvm.org/D54053 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r346089 - Fix duplicate testcase filename
Author: jankratochvil Date: Sat Nov 3 23:13:09 2018 New Revision: 346089 URL: http://llvm.org/viewvc/llvm-project?rev=346089&view=rev Log: Fix duplicate testcase filename dotest.py started reporting: Exception: Found multiple tests with the name TestSampleTest.py After the commit of: https://reviews.llvm.org/D54056 Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestAllowJIT.py - copied unchanged from r346088, lldb/trunk/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py Removed: lldb/trunk/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py Removed: lldb/trunk/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py?rev=346088&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py (removed) @@ -1,94 +0,0 @@ -""" -Test that --allow-jit=false does disallow JITting: -""" - -from __future__ import print_function - - -import os -import time -import re -import lldb -import lldbsuite.test.lldbutil as lldbutil -from lldbsuite.test.lldbtest import * -from lldbsuite.test.decorators import * - -class TestAllowJIT(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 - -@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") -def test_allow_jit_expr_command(self): -"""Test the --allow-jit command line flag""" -self.build() -self.main_source_file = lldb.SBFileSpec("main.c") -self.expr_cmd_test() - -@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") -def test_allow_jit_options(self): -"""Test the SetAllowJIT SBExpressionOption setting""" -self.build() -self.main_source_file = lldb.SBFileSpec("main.c") -self.expr_options_test() - - - -def setUp(self): -# Call super's setUp(). -TestBase.setUp(self) - -def expr_cmd_test(self): -(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, - "Set a breakpoint here", self.main_source_file) - -frame = thread.GetFrameAtIndex(0) - -# First make sure we can call the function with -interp = self.dbg.GetCommandInterpreter() -self.expect("expr --allow-jit 1 -- call_me(10)", -substrs = ["(int) $", "= 18"]) -# Now make sure it fails with the "can't IR interpret message" if allow-jit is false: -self.expect("expr --allow-jit 0 -- call_me(10)", -error=True, -substrs = ["Can't run the expression locally"]) - -def expr_options_test(self): -(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, - "Set a breakpoint here", self.main_source_file) - -frame = thread.GetFrameAtIndex(0) - -# First make sure we can call the function with the default option set. -options = lldb.SBExpressionOptions() -# Check that the default is to allow JIT: -self.assertEqual(options.GetAllowJIT(), True, "Default is true") - -# Now use the options: -result = frame.EvaluateExpression("call_me(10)", options) -self.assertTrue(result.GetError().Success(), "expression succeeded") -self.assertEqual(result.GetValueAsSigned(), 18, "got the right value.") - -# Now disallow JIT and make sure it fails: -options.SetAllowJIT(False) -# Check that we got the right value: -self.assertEqual(options.GetAllowJIT(), False, "Got False after setting to False") - -# Again use it and ensure we fail: -result = frame.EvaluateExpression("call_me(10)", options) -self.assertTrue(result.GetError().Fail(), "expression failed with no JIT") -self.assertTrue("Can't run the expression locally" in result.GetError().GetCString(), "Got right error") - -# Finally set the allow JIT value back to true and make sure that works: -options.SetAllowJIT(True) -self.assertEqual(options.GetAllowJIT(), True, "Set back to True correctly") - -# And again, make sure this works: -result = frame.EvaluateExpression("call_me(10)", options) -self.assertTrue(result.GetError().Success(), "expression succeeded") -self.assertEqual(result.GetValueAsSigned(), 18, "got
[Lldb-commits] [PATCH] D54056: Add SetAllowJIT (the SBExpressionOptions equivalent of "expression --allow-jit")
jankratochvil added a comment. In https://reviews.llvm.org/D54056#1286635, @davide wrote: > I don't think anybody will look at this until Monday, so if you want a quick > fix you might consider renaming the test yourself. Checked in as: https://reviews.llvm.org/rLLDB346089 Repository: rL LLVM https://reviews.llvm.org/D54056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits