[Lldb-commits] [PATCH] D49980: [PDB] Parse UDT symbols and pointers to members (combined patch)
aleksandr.urakov added a comment. Thanks a lot! https://reviews.llvm.org/D49980 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339649 - [PDB] Parse UDT symbols and pointers to members (combined patch)
Author: aleksandr.urakov Date: Tue Aug 14 00:57:44 2018 New Revision: 339649 URL: http://llvm.org/viewvc/llvm-project?rev=339649&view=rev Log: [PDB] Parse UDT symbols and pointers to members (combined patch) Summary: In this patch I've tried to combine the best ideas from D49368 and D49410, so it implements following: - Completion of UDTs from a PDB with a filling of a layout info; - Pointers to members; - Fixes the bug relating to a virtual base offset reading from `vbtable`. The offset was treated as an unsigned, but it can be a negative sometimes. - Support of MSInheritance attribute Reviewers: asmith, zturner, rnk, labath, clayborg, lldb-commits Reviewed By: zturner Subscribers: aleksandr.urakov, stella.stamenova, JDevlieghere, lldb-commits Differential Revision: https://reviews.llvm.org/D49980 Added: lldb/trunk/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp lldb/trunk/lit/SymbolFile/PDB/Inputs/PointerTypeTest.cpp lldb/trunk/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp lldb/trunk/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.script lldb/trunk/lit/SymbolFile/PDB/class-layout.test lldb/trunk/lit/SymbolFile/PDB/pointers.test lldb/trunk/lit/SymbolFile/PDB/udt-layout.test Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.h lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=339649&r1=339648&r2=339649&view=diff == --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Aug 14 00:57:44 2018 @@ -831,6 +831,8 @@ public: bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial); + void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type); + // C++ Base Classes clang::CXXBaseSpecifier * CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, Added: lldb/trunk/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp?rev=339649&view=auto == --- lldb/trunk/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp (added) +++ lldb/trunk/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp Tue Aug 14 00:57:44 2018 @@ -0,0 +1,111 @@ +// To avoid linking MSVC specific libs, we don't test virtual/override methods +// that needs vftable support in this file. + +// Enum. +enum Enum { RED, GREEN, BLUE }; +Enum EnumVar; + +// Union. +union Union { + short Row; + unsigned short Col; + int Line : 16; // Test named bitfield. + short : 8; // Unnamed bitfield symbol won't be generated in PDB. + long Table; +}; +Union UnionVar; + +// Struct. +struct Struct; +typedef Struct StructTypedef; + +struct Struct { + bool A; + unsigned char UCharVar; + unsigned int UIntVar; + long long LongLongVar; + Enum EnumVar; // Test struct has UDT member. + int array[10]; +}; +struct Struct StructVar; + +struct _List; // Forward declaration. +struct Complex { + struct _List *array[90]; + struct { // Test unnamed struct. MSVC treats it as `int x` +int x; + }; + union { // Test unnamed union. MSVC treats it as `int a; float b;` +int a; +float b; + }; +}; +struct Complex c; + +struct _List { // Test doubly linked list. + struct _List *current; + struct _List *previous; + struct _List *next; +}; +struct _List ListVar; + +typedef struct { + int a; +} UnnamedStruct; // Test unnamed typedef-ed struct. +UnnamedStruct UnnanmedVar; + +// Class. +namespace MemberTest { +class Base { +public: + Base() {} + ~Base() {} + +public: + int Get() { return 0; } + +protected: + int a; +}; +class Friend { +public: + int f() { return 3; } +}; +class Class : public Base { // Test base class. + friend Friend; + static int m_static; // Test static member variable. +public: + Class() : m_public(), m_private(), m_protected() {} + explicit Class(int a) { m_public = a; } // Test first reference of m_public. + ~Class() {} + + static int StaticMemberFunc(int a, ...) { +return 1; + } // Test static member function. + int Get() { return 1; } + int f(Friend c) { return c.f(); } + inline bool operator==(const Class &rhs) const // Test operator. + { +return (m_public == rhs.m_public); + } + +public: + int m_public; + struct Struct m_struct; + +private: + Union m_union; + int m_private; + +protected: + friend class Friend; + int m_protected; +}; +} // namespace MemberTest + +int ma
[Lldb-commits] [PATCH] D49980: [PDB] Parse UDT symbols and pointers to members (combined patch)
This revision was automatically updated to reflect the committed changes. Closed by commit rL339649: [PDB] Parse UDT symbols and pointers to members (combined patch) (authored by aleksandr.urakov, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49980?vs=158194&id=160521#toc Repository: rL LLVM https://reviews.llvm.org/D49980 Files: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp lldb/trunk/lit/SymbolFile/PDB/Inputs/PointerTypeTest.cpp lldb/trunk/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp lldb/trunk/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.script lldb/trunk/lit/SymbolFile/PDB/class-layout.test lldb/trunk/lit/SymbolFile/PDB/pointers.test lldb/trunk/lit/SymbolFile/PDB/udt-layout.test lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.h lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Index: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp === --- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -45,7 +45,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h" #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" -#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" +#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" // For IsCPPMangledName #include "Plugins/SymbolFile/PDB/PDBASTParser.h" #include "Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h" @@ -459,10 +459,13 @@ // This should cause the type to get cached and stored in the `m_types` // lookup. -if (!ResolveTypeUID(symbol->getSymIndexId())) - continue; - -++num_added; +if (auto type = ResolveTypeUID(symbol->getSymIndexId())) { + // Resolve the type completely to avoid a completion + // (and so a list change, which causes an iterators invalidation) + // during a TypeList dumping + type->GetFullCompilerType(); + ++num_added; +} } } }; @@ -568,8 +571,20 @@ } bool SymbolFilePDB::CompleteType(lldb_private::CompilerType &compiler_type) { - // TODO: Implement this - return false; + std::lock_guard guard( + GetObjectFile()->GetModule()->GetMutex()); + + ClangASTContext *clang_ast_ctx = llvm::dyn_cast_or_null( + GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); + if (!clang_ast_ctx) +return false; + + PDBASTParser *pdb = + llvm::dyn_cast(clang_ast_ctx->GetPDBParser()); + if (!pdb) +return false; + + return pdb->CompleteTypeFromPDB(compiler_type); } lldb_private::CompilerDecl SymbolFilePDB::GetDeclForUID(lldb::user_id_t uid) { Index: lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp === --- lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ lldb/trunk/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -9,11 +9,15 @@ #include "PDBASTParser.h" +#include "SymbolFilePDB.h" + #include "clang/AST/CharUnits.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" +#include "lldb/Core/Module.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/ClangUtil.h" #include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/SymbolFile.h" @@ -48,8 +52,9 @@ return clang::TTK_Union; case PDB_UdtType::Interface: return clang::TTK_Interface; + default: +llvm_unreachable("unsuported PDB UDT type"); } - return -1; } lldb::Encoding TranslateBuiltinEncoding(PDB_BuiltinType type) { @@ -199,6 +204,68 @@ decl.SetLine(first_line_up->getLineNumber()); return true; } + +AccessType TranslateMemberAccess(PDB_MemberAccess access) { + switch (access) { + case PDB_MemberAccess::Private: +return eAccessPrivate; + case PDB_MemberAccess::Protected: +return eAccessProtected; + case PDB_MemberAccess::Public: +return eAccessPublic; + default: +return eAccessNone; + } +} + +AccessType GetDefaultAccessibilityForUdtKind(PDB_UdtType udt_kind) { + switch (udt_kind) { + case PDB_UdtType::Struct: + case PDB_UdtType::Union: +return eAccessPublic; + case PDB_UdtType::Class: + case PDB_UdtType::Interface: +return eAccessPrivate; + default: +llvm_unreachable("unsupported PDB UDT type"); + } +} + +AccessType GetAccessibilityForUdt(const PDBSymbolTypeUDT &udt) { + AccessType access = TranslateMemberAccess(udt.getAccess()); + if (access != lldb::eAccessNone || !udt.isNested()) +return access; + + auto parent = udt.getClassParent(); + if (!parent) +return lldb::eAccessNone; + + auto parent_udt = llvm::dyn_
Re: [Lldb-commits] [lldb] r339076 - [lit, python] Always add quotes around the python path in lit
Merged to 7.0 in r339657. On Tue, Aug 7, 2018 at 12:37 AM, Stella Stamenova via lldb-commits wrote: > Author: stella.stamenova > Date: Mon Aug 6 15:37:53 2018 > New Revision: 339076 > > URL: http://llvm.org/viewvc/llvm-project?rev=339076&view=rev > Log: > [lit, python] Always add quotes around the python path in lit > > Summary: > The issue with the python path is that the path to python on Windows can > contain spaces. To make the tests always work, the path to python needs to be > surrounded by quotes. > > This is a companion change to: https://reviews.llvm.org/D50206 > > Reviewers: asmith, zturner > > Differential Revision: https://reviews.llvm.org/D50280 > > Modified: > lldb/trunk/lit/lit.cfg > > Modified: lldb/trunk/lit/lit.cfg > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/lit.cfg?rev=339076&r1=339075&r2=339076&view=diff > == > --- lldb/trunk/lit/lit.cfg (original) > +++ lldb/trunk/lit/lit.cfg Mon Aug 6 15:37:53 2018 > @@ -54,7 +54,7 @@ config.environment['LLVM_SRC_ROOT'] = ge > config.environment['PYTHON_EXECUTABLE'] = getattr(config, > 'python_executable', '') > > # Register substitutions > -config.substitutions.append(('%python', config.python_executable)) > +config.substitutions.append(('%python', "'%s'" % (config.python_executable))) > > debugserver = lit.util.which('debugserver', lldb_tools_dir) > lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), > > > ___ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339669 - Fix: ConstString::GetConstCStringAndSetMangledCounterPart() should update the value if the key exists already
Author: stefan.graenitz Date: Tue Aug 14 04:07:18 2018 New Revision: 339669 URL: http://llvm.org/viewvc/llvm-project?rev=339669&view=rev Log: Fix: ConstString::GetConstCStringAndSetMangledCounterPart() should update the value if the key exists already Summary: This issue came up because it caused problems in our unit tests. The StringPool did connect counterparts only once and silently ignored the values passed in subsequent calls. The simplest solution for the unit tests would be silent overwrite. In practice, however, it seems useful to assert that we never overwrite a different mangled counterpart. If we ever have mangled counterparts for other languages than C++, this makes it more likely to notice collisions. I added an assertion that allows the following cases: * inserting a new value * overwriting the empty string * overwriting with an identical value I fixed the unit tests, which used "random" strings and thus produced collisions. It would be even better if there was a way to reset or isolate the StringPool, but that's a different story. Reviewers: jingham, friss, labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D50536 Modified: lldb/trunk/source/Utility/ConstString.cpp lldb/trunk/unittests/Utility/ConstStringTest.cpp Modified: lldb/trunk/source/Utility/ConstString.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ConstString.cpp?rev=339669&r1=339668&r2=339669&view=diff == --- lldb/trunk/source/Utility/ConstString.cpp (original) +++ lldb/trunk/source/Utility/ConstString.cpp Tue Aug 14 04:07:18 2018 @@ -119,11 +119,16 @@ public: const uint8_t h = hash(demangled); llvm::sys::SmartScopedWriter wlock(m_string_pools[h].m_mutex); - // Make string pool entry with the mangled counterpart already set - StringPoolEntryType &entry = - *m_string_pools[h] - .m_string_map.insert(std::make_pair(demangled, mangled_ccstr)) - .first; + // Make or update string pool entry with the mangled counterpart + StringPool &map = m_string_pools[h].m_string_map; + StringPoolEntryType &entry = *map.try_emplace(demangled).first; + + assert((entry.second == nullptr || entry.second == mangled_ccstr || + strlen(entry.second) == 0) && + "The demangled string must have a unique counterpart or otherwise " + "it must be empty"); + + entry.second = mangled_ccstr; // Extract the const version of the demangled_cstr demangled_ccstr = entry.getKeyData(); Modified: lldb/trunk/unittests/Utility/ConstStringTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/ConstStringTest.cpp?rev=339669&r1=339668&r2=339669&view=diff == --- lldb/trunk/unittests/Utility/ConstStringTest.cpp (original) +++ lldb/trunk/unittests/Utility/ConstStringTest.cpp Tue Aug 14 04:07:18 2018 @@ -18,25 +18,45 @@ TEST(ConstStringTest, format_provider) { } TEST(ConstStringTest, MangledCounterpart) { - ConstString foo("foo"); + ConstString uvw("uvw"); ConstString counterpart; - EXPECT_FALSE(foo.GetMangledCounterpart(counterpart)); + EXPECT_FALSE(uvw.GetMangledCounterpart(counterpart)); EXPECT_EQ("", counterpart.GetStringRef()); - ConstString bar; - bar.SetStringWithMangledCounterpart("bar", foo); - EXPECT_EQ("bar", bar.GetStringRef()); + ConstString xyz; + xyz.SetStringWithMangledCounterpart("xyz", uvw); + EXPECT_EQ("xyz", xyz.GetStringRef()); - EXPECT_TRUE(bar.GetMangledCounterpart(counterpart)); - EXPECT_EQ("foo", counterpart.GetStringRef()); + EXPECT_TRUE(xyz.GetMangledCounterpart(counterpart)); + EXPECT_EQ("uvw", counterpart.GetStringRef()); - EXPECT_TRUE(foo.GetMangledCounterpart(counterpart)); - EXPECT_EQ("bar", counterpart.GetStringRef()); + EXPECT_TRUE(uvw.GetMangledCounterpart(counterpart)); + EXPECT_EQ("xyz", counterpart.GetStringRef()); +} + +TEST(ConstStringTest, UpdateMangledCounterpart) { + { // Add counterpart +ConstString some1; +some1.SetStringWithMangledCounterpart("some", ConstString("")); + } + { // Overwrite empty string +ConstString some2; +some2.SetStringWithMangledCounterpart("some", ConstString("one")); + } + { // Overwrite with identical value +ConstString some2; +some2.SetStringWithMangledCounterpart("some", ConstString("one")); + } + { // Check counterpart is set +ConstString counterpart; +EXPECT_TRUE(ConstString("some").GetMangledCounterpart(counterpart)); +EXPECT_EQ("one", counterpart.GetStringRef()); + } } TEST(ConstStringTest, FromMidOfBufferStringRef) { // StringRef's into bigger buffer: no null termination - const char *buffer = "foobarbaz"; + const char *buffer = "abcdefghi"; llvm::StringRef foo_ref(buffer, 3); llvm::StringRef bar_ref(buffer + 3, 3); @@ -44,1
[Lldb-commits] [PATCH] D50536: Fix: ConstString::GetConstCStringAndSetMangledCounterPart() should update the value if the key exists already
This revision was automatically updated to reflect the committed changes. Closed by commit rLLDB339669: Fix: ConstString::GetConstCStringAndSetMangledCounterPart() should update the⦠(authored by stefan.graenitz, committed by ). Changed prior to commit: https://reviews.llvm.org/D50536?vs=160143&id=160549#toc Repository: rLLDB LLDB https://reviews.llvm.org/D50536 Files: source/Utility/ConstString.cpp unittests/Utility/ConstStringTest.cpp Index: unittests/Utility/ConstStringTest.cpp === --- unittests/Utility/ConstStringTest.cpp +++ unittests/Utility/ConstStringTest.cpp @@ -18,40 +18,60 @@ } TEST(ConstStringTest, MangledCounterpart) { - ConstString foo("foo"); + ConstString uvw("uvw"); ConstString counterpart; - EXPECT_FALSE(foo.GetMangledCounterpart(counterpart)); + EXPECT_FALSE(uvw.GetMangledCounterpart(counterpart)); EXPECT_EQ("", counterpart.GetStringRef()); - ConstString bar; - bar.SetStringWithMangledCounterpart("bar", foo); - EXPECT_EQ("bar", bar.GetStringRef()); + ConstString xyz; + xyz.SetStringWithMangledCounterpart("xyz", uvw); + EXPECT_EQ("xyz", xyz.GetStringRef()); - EXPECT_TRUE(bar.GetMangledCounterpart(counterpart)); - EXPECT_EQ("foo", counterpart.GetStringRef()); + EXPECT_TRUE(xyz.GetMangledCounterpart(counterpart)); + EXPECT_EQ("uvw", counterpart.GetStringRef()); - EXPECT_TRUE(foo.GetMangledCounterpart(counterpart)); - EXPECT_EQ("bar", counterpart.GetStringRef()); + EXPECT_TRUE(uvw.GetMangledCounterpart(counterpart)); + EXPECT_EQ("xyz", counterpart.GetStringRef()); +} + +TEST(ConstStringTest, UpdateMangledCounterpart) { + { // Add counterpart +ConstString some1; +some1.SetStringWithMangledCounterpart("some", ConstString("")); + } + { // Overwrite empty string +ConstString some2; +some2.SetStringWithMangledCounterpart("some", ConstString("one")); + } + { // Overwrite with identical value +ConstString some2; +some2.SetStringWithMangledCounterpart("some", ConstString("one")); + } + { // Check counterpart is set +ConstString counterpart; +EXPECT_TRUE(ConstString("some").GetMangledCounterpart(counterpart)); +EXPECT_EQ("one", counterpart.GetStringRef()); + } } TEST(ConstStringTest, FromMidOfBufferStringRef) { // StringRef's into bigger buffer: no null termination - const char *buffer = "foobarbaz"; + const char *buffer = "abcdefghi"; llvm::StringRef foo_ref(buffer, 3); llvm::StringRef bar_ref(buffer + 3, 3); ConstString foo(foo_ref); ConstString bar; bar.SetStringWithMangledCounterpart(bar_ref, foo); - EXPECT_EQ("bar", bar.GetStringRef()); + EXPECT_EQ("def", bar.GetStringRef()); ConstString counterpart; EXPECT_TRUE(bar.GetMangledCounterpart(counterpart)); - EXPECT_EQ("foo", counterpart.GetStringRef()); + EXPECT_EQ("abc", counterpart.GetStringRef()); EXPECT_TRUE(foo.GetMangledCounterpart(counterpart)); - EXPECT_EQ("bar", counterpart.GetStringRef()); + EXPECT_EQ("def", counterpart.GetStringRef()); } TEST(ConstStringTest, NullAndEmptyStates) { Index: source/Utility/ConstString.cpp === --- source/Utility/ConstString.cpp +++ source/Utility/ConstString.cpp @@ -119,11 +119,16 @@ const uint8_t h = hash(demangled); llvm::sys::SmartScopedWriter wlock(m_string_pools[h].m_mutex); - // Make string pool entry with the mangled counterpart already set - StringPoolEntryType &entry = - *m_string_pools[h] - .m_string_map.insert(std::make_pair(demangled, mangled_ccstr)) - .first; + // Make or update string pool entry with the mangled counterpart + StringPool &map = m_string_pools[h].m_string_map; + StringPoolEntryType &entry = *map.try_emplace(demangled).first; + + assert((entry.second == nullptr || entry.second == mangled_ccstr || + strlen(entry.second) == 0) && + "The demangled string must have a unique counterpart or otherwise " + "it must be empty"); + + entry.second = mangled_ccstr; // Extract the const version of the demangled_cstr demangled_ccstr = entry.getKeyData(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339671 - Remove unused FastDemangle sources
Author: stefan.graenitz Date: Tue Aug 14 04:32:51 2018 New Revision: 339671 URL: http://llvm.org/viewvc/llvm-project?rev=339671&view=rev Log: Remove unused FastDemangle sources Removed: lldb/trunk/include/lldb/Utility/FastDemangle.h lldb/trunk/source/Utility/FastDemangle.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/trunk/source/Utility/CMakeLists.txt Removed: lldb/trunk/include/lldb/Utility/FastDemangle.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/FastDemangle.h?rev=339670&view=auto == --- lldb/trunk/include/lldb/Utility/FastDemangle.h (original) +++ lldb/trunk/include/lldb/Utility/FastDemangle.h (removed) @@ -1,26 +0,0 @@ -//===-- FastDemangle.h --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -#ifndef liblldb_FastDemangle_h_ -#define liblldb_FastDemangle_h_ - -#include - -#include - -namespace lldb_private { - -char *FastDemangle(const char *mangled_name); - -char * -FastDemangle(const char *mangled_name, size_t mangled_name_length, - std::function primitive_type_hook = nullptr); -} - -#endif Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=339671&r1=339670&r2=339671&view=diff == --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Aug 14 04:32:51 2018 @@ -295,7 +295,6 @@ 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */; }; 4984BA161B979973008658D4 /* ExpressionVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4984BA151B979973008658D4 /* ExpressionVariable.cpp */; }; 4984BA181B979C08008658D4 /* ExpressionVariable.h in Headers */ = {isa = PBXBuildFile; fileRef = 4984BA171B979C08008658D4 /* ExpressionVariable.h */; }; - AFC2DCE71E6E2ED000283714 /* FastDemangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCE61E6E2ED000283714 /* FastDemangle.cpp */; }; 2689006E13353E1A00698AC0 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C6EA213011581005E16B0 /* File.cpp */; }; 3FDFDDBD199C3A06009756A7 /* FileAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBC199C3A06009756A7 /* FileAction.cpp */; }; 3FDFDDBF199D345E009756A7 /* FileCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBE199D345E009756A7 /* FileCache.cpp */; }; @@ -1807,8 +1806,6 @@ 4C29E77D1BA2403F00DFF855 /* ExpressionTypeSystemHelper.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; name = ExpressionTypeSystemHelper.h; path = include/lldb/Expression/ExpressionTypeSystemHelper.h; sourceTree = ""; }; 4984BA151B979973008658D4 /* ExpressionVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExpressionVariable.cpp; path = source/Expression/ExpressionVariable.cpp; sourceTree = ""; }; 4984BA171B979C08008658D4 /* ExpressionVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExpressionVariable.h; path = include/lldb/Expression/ExpressionVariable.h; sourceTree = ""; }; - AFC2DCE61E6E2ED000283714 /* FastDemangle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FastDemangle.cpp; path = source/Utility/FastDemangle.cpp; sourceTree = ""; }; - AFC2DCED1E6E2F9800283714 /* FastDemangle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FastDemangle.h; path = include/lldb/Utility/FastDemangle.h; sourceTree = ""; }; 260C6EA213011581005E16B0 /* File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = File.cpp; sourceTree = ""; }; 260C6EA013011578005E16B0 /* File.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = File.h; path = include/lldb/Host/File.h; sourceTree = ""; }; 3FDFDDBC199C3A06009756A7 /* FileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileAction.cpp; path = source/Target/FileAction.cpp; sourceTree = ""; }; @@ -4510,8 +4507,6 @@ 49CA96F41E6AAC8E00C03F
[Lldb-commits] [PATCH] D50676: Remove manual byte counting from Highlighter code.
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. cool Repository: rLLDB LLDB https://reviews.llvm.org/D50676 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50681: Remove manual byte counting from internal Stream methods.
labath added a comment. What would you say to moving this class to the header, so that it can be used in all the other byte-counting patches too? Repository: rLLDB LLDB https://reviews.llvm.org/D50681 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50722: Stability improvements for CompletionTest
teemperor created this revision. teemperor added a reviewer: aprantl. Herald added a subscriber: jfb. CompletionTest.DirCompletionAbsolute had a random failure on a CI node (in the failure, the completion count was 0, while we expected it to be 1), but there seems no good reason for it to fail. The sanitizers don't complain about the test when it's run, so I think we don't have some uninitialized memory that we access here. My best bet is that the unique directory selection randomly failed on the CI node because maybe the FS there doesn't actually guarantee the atomic fopen assumptions we make in the LLVM code (or some other funny race condition). In this case a different test run could get the same directory and clean its contents which would lead to 0 results. The other possible explanation is that someone changed the CI configuration on the node and changed the working dir to something very long, which would make our PATH_MAX test fail (which also leads to 0 results), but I think that case is unlikely. This patch is just a stab in the dark that (hopefully) fixes this random failure by giving each test a (more) unique working directory by appending the unique test name to the temp-dir prefix. Also adds one more ASSERT_NO_ERROR to one of our chdir calls just in case that is the reason for failing. The good thing is that this refactor gets rid of most of the static variables and files that we previously had as shared state between the different tests. Potentially fixes rdar://problem/43150260 Repository: rLLDB LLDB https://reviews.llvm.org/D50722 Files: unittests/Interpreter/TestCompletion.cpp Index: unittests/Interpreter/TestCompletion.cpp === --- unittests/Interpreter/TestCompletion.cpp +++ unittests/Interpreter/TestCompletion.cpp @@ -41,32 +41,41 @@ protected: /// Unique temporary directory in which all created filesystem entities must /// be placed. It is removed at the end of the test suite. - static SmallString<128> BaseDir; + SmallString<128> BaseDir; + /// The working directory that we got when starting the test. Every test + /// should chdir into this directory first because some tests maybe chdir + /// into another one during their run. static SmallString<128> OriginalWorkingDir; - static SmallString<128> DirFoo; - static SmallString<128> DirFooA; - static SmallString<128> DirFooB; - static SmallString<128> DirFooC; - static SmallString<128> DirBar; - static SmallString<128> DirBaz; - static SmallString<128> DirTestFolder; - static SmallString<128> DirNested; + SmallString<128> DirFoo; + SmallString<128> DirFooA; + SmallString<128> DirFooB; + SmallString<128> DirFooC; + SmallString<128> DirBar; + SmallString<128> DirBaz; + SmallString<128> DirTestFolder; + SmallString<128> DirNested; + + SmallString<128> FileAA; + SmallString<128> FileAB; + SmallString<128> FileAC; + SmallString<128> FileFoo; + SmallString<128> FileBar; + SmallString<128> FileBaz; + + void SetUp() override { +// chdir back into the original working dir this test binary started with. +// A previous test may have have changed the working dir. +ASSERT_NO_ERROR(fs::set_current_path(OriginalWorkingDir)); + +// Get the name of the current test. To prevent that by chance two tests +// get the same temporary directory if createUniqueDirectory fails. +auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); +ASSERT_TRUE(test_info != nullptr); +std::string name = test_info->name(); +ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion-" + name, BaseDir)); - static SmallString<128> FileAA; - static SmallString<128> FileAB; - static SmallString<128> FileAC; - static SmallString<128> FileFoo; - static SmallString<128> FileBar; - static SmallString<128> FileBaz; - - void SetUp() override { llvm::sys::fs::set_current_path(OriginalWorkingDir); } - - static void SetUpTestCase() { -llvm::sys::fs::current_path(OriginalWorkingDir); - -ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir)); const char *DirNames[] = {"foo", "fooa", "foob","fooc", "bar", "baz", "test_folder", "foo/nested"}; const char *FileNames[] = {"aa1234.tmp", "ab1234.tmp", "ac1234.tmp", @@ -92,10 +101,12 @@ } } - static void TearDownTestCase() { -ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); + static void SetUpTestCase() { +ASSERT_NO_ERROR(fs::current_path(OriginalWorkingDir)); } + void TearDown() override { ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); } + static bool HasEquivalentFile(const Twine &Path, const StringList &Paths) { for (size_t I = 0; I < Paths.GetSize(); ++I) { if (fs::equivalent(Path, Paths[I])) @@ -128,24 +139,7 @@ } }; -SmallString<128> CompletionTest::BaseDir; SmallString<128> CompletionTest::OriginalWorkingDir; - -SmallString<128> CompletionTest:
[Lldb-commits] [lldb] r339695 - Remove manual byte counting from Highlighter code.
Author: teemperor Date: Tue Aug 14 10:12:54 2018 New Revision: 339695 URL: http://llvm.org/viewvc/llvm-project?rev=339695&view=rev Log: Remove manual byte counting from Highlighter code. Summary: This removes the manual byte counting mechanism from the syntax highlighting code. This is no longer necessary as the Stream class now has built-in support for automatically counting the bytes that were written to it so far. The advantage of automatic byte counting via Stream is that it is less error-prone than the manual version and we need to write less boilerplate code. Reviewers: labath Reviewed By: labath Subscribers: labath, lldb-commits Differential Revision: https://reviews.llvm.org/D50676 Modified: lldb/trunk/include/lldb/Core/Highlighter.h lldb/trunk/source/Core/Highlighter.cpp lldb/trunk/source/Core/SourceManager.cpp lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.h Modified: lldb/trunk/include/lldb/Core/Highlighter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Highlighter.h?rev=339695&r1=339694&r2=339695&view=diff == --- lldb/trunk/include/lldb/Core/Highlighter.h (original) +++ lldb/trunk/include/lldb/Core/Highlighter.h Tue Aug 14 10:12:54 2018 @@ -45,9 +45,7 @@ struct HighlightStyle { /// The stream to which the result should be appended. /// \param value /// The value that we should place our strings around. -/// \return -/// The number of bytes that have been written to the given stream. -std::size_t Apply(Stream &s, llvm::StringRef value) const; +void Apply(Stream &s, llvm::StringRef value) const; /// Sets the prefix and suffix strings. /// @param prefix @@ -114,12 +112,8 @@ public: /// \param s /// The stream to which the highlighted version of the user string should /// be written. - /// \return - /// The number of bytes that have been written to the stream. - virtual std::size_t Highlight(const HighlightStyle &options, -llvm::StringRef line, -llvm::StringRef previous_lines, -Stream &s) const = 0; + virtual void Highlight(const HighlightStyle &options, llvm::StringRef line, + llvm::StringRef previous_lines, Stream &s) const = 0; /// Utility method for calling Highlight without a stream. std::string Highlight(const HighlightStyle &options, llvm::StringRef line, @@ -131,9 +125,8 @@ class NoHighlighter : public Highlighter public: llvm::StringRef GetName() const override { return "none"; } - std::size_t Highlight(const HighlightStyle &options, llvm::StringRef line, -llvm::StringRef previous_lines, -Stream &s) const override; + void Highlight(const HighlightStyle &options, llvm::StringRef line, + llvm::StringRef previous_lines, Stream &s) const override; }; /// Manages the available highlighters. Modified: lldb/trunk/source/Core/Highlighter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Highlighter.cpp?rev=339695&r1=339694&r2=339695&view=diff == --- lldb/trunk/source/Core/Highlighter.cpp (original) +++ lldb/trunk/source/Core/Highlighter.cpp Tue Aug 14 10:12:54 2018 @@ -15,11 +15,8 @@ using namespace lldb_private; -std::size_t HighlightStyle::ColorStyle::Apply(Stream &s, - llvm::StringRef value) const { +void HighlightStyle::ColorStyle::Apply(Stream &s, llvm::StringRef value) const { s << m_prefix << value << m_suffix; - // Calculate how many bytes we have written. - return m_prefix.size() + value.size() + m_suffix.size(); } void HighlightStyle::ColorStyle::Set(llvm::StringRef prefix, @@ -28,13 +25,11 @@ void HighlightStyle::ColorStyle::Set(llv m_suffix = lldb_utility::ansi::FormatAnsiTerminalCodes(suffix); } -std::size_t NoHighlighter::Highlight(const HighlightStyle &options, - llvm::StringRef line, - llvm::StringRef previous_lines, - Stream &s) const { +void NoHighlighter::Highlight(const HighlightStyle &options, + llvm::StringRef line, + llvm::StringRef previous_lines, Stream &s) const { // We just forward the input to the output and do no highlighting. s << line; - return line.size(); } static HighlightStyle::ColorStyle GetColor(const char *c) { Modified: lldb/trunk/source/Core/SourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=339695&r1=339694&r2=339695&view=diff ===
[Lldb-commits] [PATCH] D50676: Remove manual byte counting from Highlighter code.
This revision was automatically updated to reflect the committed changes. Closed by commit rLLDB339695: Remove manual byte counting from Highlighter code. (authored by teemperor, committed by ). Repository: rLLDB LLDB https://reviews.llvm.org/D50676 Files: include/lldb/Core/Highlighter.h source/Core/Highlighter.cpp source/Core/SourceManager.cpp source/Plugins/Language/ClangCommon/ClangHighlighter.cpp source/Plugins/Language/ClangCommon/ClangHighlighter.h Index: source/Core/SourceManager.cpp === --- source/Core/SourceManager.cpp +++ source/Core/SourceManager.cpp @@ -533,6 +533,8 @@ if (!m_data_sp) return 0; + size_t bytes_written = s->GetWrittenBytes(); + std::string previous_content; HighlightStyle style = HighlightStyle::MakeVimStyle(); @@ -553,7 +555,6 @@ end_line_offset = m_data_sp->GetByteSize(); assert(start_line_offset <= end_line_offset); -size_t bytes_written = 0; if (start_line_offset < end_line_offset) { size_t count = end_line_offset - start_line_offset; const uint8_t *cstr = m_data_sp->GetBytes() + start_line_offset; @@ -563,8 +564,7 @@ auto debugger_sp = m_debugger_wp.lock(); if (should_highlight_source(debugger_sp)) { -bytes_written += -highlighter.Highlight(style, ref, previous_content, *s); +highlighter.Highlight(style, ref, previous_content, *s); displayed_line = true; // Add the new line to the previous lines. previous_content += ref.str(); @@ -586,7 +586,7 @@ // formatting the column (e.g. underline, inverse, etc.) // First print the part before the column to mark. -bytes_written = s->Write(cstr, column - 1); +s->Write(cstr, column - 1); // Write the pre escape sequence. const SymbolContext *sc = nullptr; @@ -599,15 +599,14 @@ FormatEntity::Format(*ansi_prefix_entry, *s, sc, exe_ctx, &addr, valobj, function_changed, initial_function); -// Write the marked column. -bytes_written += s->Write(cstr + column - 1, 1); +s->Write(cstr + column - 1, 1); // Write the post escape sequence. FormatEntity::Format(*ansi_suffix_entry, *s, sc, exe_ctx, &addr, valobj, function_changed, initial_function); // And finish up with the rest of the line. -bytes_written += s->Write(cstr + column, count - column); +s->Write(cstr + column, count - column); // Keep track of the fact that we just wrote the line. displayed_line = true; @@ -618,15 +617,14 @@ // If we didn't end up displaying the line with ANSI codes for whatever // reason, display it now sans codes. if (!displayed_line) -bytes_written = s->PutCString(ref); +s->PutCString(ref); // Ensure we get an end of line character one way or another. if (!is_newline_char(ref.back())) -bytes_written += s->EOL(); +s->EOL(); } -return bytes_written; } - return 0; + return s->GetWrittenBytes() - bytes_written; } void SourceManager::File::FindLinesMatchingRegex( Index: source/Core/Highlighter.cpp === --- source/Core/Highlighter.cpp +++ source/Core/Highlighter.cpp @@ -15,26 +15,21 @@ using namespace lldb_private; -std::size_t HighlightStyle::ColorStyle::Apply(Stream &s, - llvm::StringRef value) const { +void HighlightStyle::ColorStyle::Apply(Stream &s, llvm::StringRef value) const { s << m_prefix << value << m_suffix; - // Calculate how many bytes we have written. - return m_prefix.size() + value.size() + m_suffix.size(); } void HighlightStyle::ColorStyle::Set(llvm::StringRef prefix, llvm::StringRef suffix) { m_prefix = lldb_utility::ansi::FormatAnsiTerminalCodes(prefix); m_suffix = lldb_utility::ansi::FormatAnsiTerminalCodes(suffix); } -std::size_t NoHighlighter::Highlight(const HighlightStyle &options, - llvm::StringRef line, - llvm::StringRef previous_lines, - Stream &s) const { +void NoHighlighter::Highlight(const HighlightStyle &options, + llvm::StringRef line, + llvm::StringRef previous_lines, Stream &s) const { // We just forward the input to the output and do no highlighting. s << line; - return line.size(); } static HighlightStyle::ColorStyle GetColor(const char *c) { Index: source/Plugins/Language/ClangCommon/ClangHighlighter.h === --- source/Plugins/Language/ClangCommon/ClangHigh
[Lldb-commits] [PATCH] D50722: Stability improvements for CompletionTest
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. Thanks, let's just give it try! Repository: rLLDB LLDB https://reviews.llvm.org/D50722 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50478: Add support for artificial tail call frames
vsk updated this revision to Diff 160666. vsk retitled this revision from "WIP: Basic tail call frame support" to "Add support for artificial tail call frames". vsk edited the summary of this revision. vsk added reviewers: aprantl, probinson, JDevlieghere, jingham, friss, zturner. vsk removed subscribers: JDevlieghere, jingham, probinson, aprantl. vsk added a dependency: D49887: [DebugInfo] Add support for DWARF5 call site-related attributes. https://reviews.llvm.org/D50478 Files: lldb/include/lldb/Symbol/Block.h lldb/include/lldb/Symbol/Function.h lldb/include/lldb/Symbol/SymbolFile.h lldb/include/lldb/Target/StackFrame.h lldb/include/lldb/Target/StackFrameList.h lldb/packages/Python/lldbsuite/test/decorators.py lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/Makefile lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/Makefile lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/Makefile lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/Makefile lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/TestDisambiguateTailCallSeq.py lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/Makefile lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/main.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/Symbol/Block.cpp lldb/source/Symbol/Function.cpp lldb/source/Target/StackFrameList.cpp Index: lldb/source/Target/StackFrameList.cpp === --- lldb/source/Target/StackFrameList.cpp +++ lldb/source/Target/StackFrameList.cpp @@ -27,6 +27,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/Unwind.h" #include "lldb/Utility/Log.h" +#include "llvm/ADT/SmallPtrSet.h" //#define DEBUG_STACK_FRAMES 1 @@ -240,6 +241,152 @@ m_frames.resize(num_frames); } +/// Find the unique path through the call graph from \p begin (at PC offset +/// \p call_pc) to \p end. On success this path is stored into \p path, and on +/// failure \p path is unchanged. +static void FindInterveningFrames(Function &begin, Function &end, + Target &target, addr_t call_pc, + std::vector &path, + ModuleList &images, Log *log) { + LLDB_LOG(log, "Finding frames between {0} and {1}, call-pc={2:x}", + begin.GetDisplayName(), end.GetDisplayName(), call_pc); + + // Find a non-tail calling edge with the first return PC greater than the + // call PC. + auto first_level_edges = begin.GetCallEdges(); + auto first_edge_it = std::lower_bound( + first_level_edges.begin(), first_level_edges.end(), call_pc, + [&](const CallEdge &edge, addr_t target_pc) { +return edge.GetReturnPCAddress(begin, target) < target_pc; + }); + if (first_edge_it == first_level_edges.end()) +return; + CallEdge &first_edge = const_cast(*first_edge_it); + if (first_edge.GetReturnPCAddress(begin, target) == LLDB_INVALID_ADDRESS) +return; + + // The first callee may not be resolved, or there may be nothing to fill in. + Function *first_callee = first_edge.GetCallee(images); + if (!first_callee || first_callee == &end) +return; + + // Run DFS on the tail-calling edges out of the first callee to find \p end. + // Fully explore the set of functions reachable from the first edge via tail + // calls in order to detect ambiguous executions. + struct DFS { +std::vector active_path = {}; +std::vector solution_path = {}; +llvm::SmallPtrSet visited_nodes = {}; +bool ambiguous = false; +Function *end; +ModuleList
[Lldb-commits] [PATCH] D50722: Stability improvements for CompletionTest
This revision was automatically updated to reflect the committed changes. Closed by commit rLLDB339715: Stability improvements for CompletionTest (authored by teemperor, committed by ). Repository: rLLDB LLDB https://reviews.llvm.org/D50722 Files: unittests/Interpreter/TestCompletion.cpp Index: unittests/Interpreter/TestCompletion.cpp === --- unittests/Interpreter/TestCompletion.cpp +++ unittests/Interpreter/TestCompletion.cpp @@ -41,32 +41,41 @@ protected: /// Unique temporary directory in which all created filesystem entities must /// be placed. It is removed at the end of the test suite. - static SmallString<128> BaseDir; + SmallString<128> BaseDir; + /// The working directory that we got when starting the test. Every test + /// should chdir into this directory first because some tests maybe chdir + /// into another one during their run. static SmallString<128> OriginalWorkingDir; - static SmallString<128> DirFoo; - static SmallString<128> DirFooA; - static SmallString<128> DirFooB; - static SmallString<128> DirFooC; - static SmallString<128> DirBar; - static SmallString<128> DirBaz; - static SmallString<128> DirTestFolder; - static SmallString<128> DirNested; - - static SmallString<128> FileAA; - static SmallString<128> FileAB; - static SmallString<128> FileAC; - static SmallString<128> FileFoo; - static SmallString<128> FileBar; - static SmallString<128> FileBaz; + SmallString<128> DirFoo; + SmallString<128> DirFooA; + SmallString<128> DirFooB; + SmallString<128> DirFooC; + SmallString<128> DirBar; + SmallString<128> DirBaz; + SmallString<128> DirTestFolder; + SmallString<128> DirNested; + + SmallString<128> FileAA; + SmallString<128> FileAB; + SmallString<128> FileAC; + SmallString<128> FileFoo; + SmallString<128> FileBar; + SmallString<128> FileBaz; + + void SetUp() override { +// chdir back into the original working dir this test binary started with. +// A previous test may have have changed the working dir. +ASSERT_NO_ERROR(fs::set_current_path(OriginalWorkingDir)); + +// Get the name of the current test. To prevent that by chance two tests +// get the same temporary directory if createUniqueDirectory fails. +auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); +ASSERT_TRUE(test_info != nullptr); +std::string name = test_info->name(); +ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion-" + name, BaseDir)); - void SetUp() override { llvm::sys::fs::set_current_path(OriginalWorkingDir); } - - static void SetUpTestCase() { -llvm::sys::fs::current_path(OriginalWorkingDir); - -ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir)); const char *DirNames[] = {"foo", "fooa", "foob","fooc", "bar", "baz", "test_folder", "foo/nested"}; const char *FileNames[] = {"aa1234.tmp", "ab1234.tmp", "ac1234.tmp", @@ -92,10 +101,12 @@ } } - static void TearDownTestCase() { -ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); + static void SetUpTestCase() { +ASSERT_NO_ERROR(fs::current_path(OriginalWorkingDir)); } + void TearDown() override { ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); } + static bool HasEquivalentFile(const Twine &Path, const StringList &Paths) { for (size_t I = 0; I < Paths.GetSize(); ++I) { if (fs::equivalent(Path, Paths[I])) @@ -128,24 +139,7 @@ } }; -SmallString<128> CompletionTest::BaseDir; SmallString<128> CompletionTest::OriginalWorkingDir; - -SmallString<128> CompletionTest::DirFoo; -SmallString<128> CompletionTest::DirFooA; -SmallString<128> CompletionTest::DirFooB; -SmallString<128> CompletionTest::DirFooC; -SmallString<128> CompletionTest::DirBar; -SmallString<128> CompletionTest::DirBaz; -SmallString<128> CompletionTest::DirTestFolder; -SmallString<128> CompletionTest::DirNested; - -SmallString<128> CompletionTest::FileAA; -SmallString<128> CompletionTest::FileAB; -SmallString<128> CompletionTest::FileAC; -SmallString<128> CompletionTest::FileFoo; -SmallString<128> CompletionTest::FileBar; -SmallString<128> CompletionTest::FileBaz; } static std::vector toVector(const StringList &SL) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339715 - Stability improvements for CompletionTest
Author: teemperor Date: Tue Aug 14 12:36:58 2018 New Revision: 339715 URL: http://llvm.org/viewvc/llvm-project?rev=339715&view=rev Log: Stability improvements for CompletionTest Summary: CompletionTest.DirCompletionAbsolute had a random failure on a CI node (in the failure, the completion count was 0, while we expected it to be 1), but there seems no good reason for it to fail. The sanitizers don't complain about the test when it's run, so I think we don't have some uninitialized memory that we access here. My best bet is that the unique directory selection randomly failed on the CI node because maybe the FS there doesn't actually guarantee the atomic fopen assumptions we make in the LLVM code (or some other funny race condition). In this case a different test run could get the same directory and clean its contents which would lead to 0 results. The other possible explanation is that someone changed the CI configuration on the node and changed the working dir to something very long, which would make our PATH_MAX test fail (which also leads to 0 results), but I think that case is unlikely. This patch is just a stab in the dark that (hopefully) fixes this random failure by giving each test a (more) unique working directory by appending the unique test name to the temp-dir prefix. Also adds one more ASSERT_NO_ERROR to one of our chdir calls just in case that is the reason for failing. The good thing is that this refactor gets rid of most of the static variables and files that we previously had as shared state between the different tests. Potentially fixes rdar://problem/43150260 Reviewers: aprantl Reviewed By: aprantl Subscribers: jfb, lldb-commits Differential Revision: https://reviews.llvm.org/D50722 Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=339715&r1=339714&r2=339715&view=diff == --- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original) +++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Tue Aug 14 12:36:58 2018 @@ -41,32 +41,41 @@ class CompletionTest : public testing::T protected: /// Unique temporary directory in which all created filesystem entities must /// be placed. It is removed at the end of the test suite. - static SmallString<128> BaseDir; + SmallString<128> BaseDir; + /// The working directory that we got when starting the test. Every test + /// should chdir into this directory first because some tests maybe chdir + /// into another one during their run. static SmallString<128> OriginalWorkingDir; - static SmallString<128> DirFoo; - static SmallString<128> DirFooA; - static SmallString<128> DirFooB; - static SmallString<128> DirFooC; - static SmallString<128> DirBar; - static SmallString<128> DirBaz; - static SmallString<128> DirTestFolder; - static SmallString<128> DirNested; - - static SmallString<128> FileAA; - static SmallString<128> FileAB; - static SmallString<128> FileAC; - static SmallString<128> FileFoo; - static SmallString<128> FileBar; - static SmallString<128> FileBaz; + SmallString<128> DirFoo; + SmallString<128> DirFooA; + SmallString<128> DirFooB; + SmallString<128> DirFooC; + SmallString<128> DirBar; + SmallString<128> DirBaz; + SmallString<128> DirTestFolder; + SmallString<128> DirNested; + + SmallString<128> FileAA; + SmallString<128> FileAB; + SmallString<128> FileAC; + SmallString<128> FileFoo; + SmallString<128> FileBar; + SmallString<128> FileBaz; + + void SetUp() override { +// chdir back into the original working dir this test binary started with. +// A previous test may have have changed the working dir. +ASSERT_NO_ERROR(fs::set_current_path(OriginalWorkingDir)); + +// Get the name of the current test. To prevent that by chance two tests +// get the same temporary directory if createUniqueDirectory fails. +auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); +ASSERT_TRUE(test_info != nullptr); +std::string name = test_info->name(); +ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion-" + name, BaseDir)); - void SetUp() override { llvm::sys::fs::set_current_path(OriginalWorkingDir); } - - static void SetUpTestCase() { -llvm::sys::fs::current_path(OriginalWorkingDir); - -ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir)); const char *DirNames[] = {"foo", "fooa", "foob","fooc", "bar", "baz", "test_folder", "foo/nested"}; const char *FileNames[] = {"aa1234.tmp", "ab1234.tmp", "ac1234.tmp", @@ -92,10 +101,12 @@ protected: } } - static void TearDownTestCase() { -ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); + static void SetUpTestCase() { +ASSERT_NO_ERROR(fs::current_path(Origina
[Lldb-commits] [lldb] r339716 - Remove asseration from ConstString::GetConstCStringAndSetMangledCounterPart() to fix more tests first
Author: stefan.graenitz Date: Tue Aug 14 12:38:54 2018 New Revision: 339716 URL: http://llvm.org/viewvc/llvm-project?rev=339716&view=rev Log: Remove asseration from ConstString::GetConstCStringAndSetMangledCounterPart() to fix more tests first Modified: lldb/trunk/source/Utility/ConstString.cpp Modified: lldb/trunk/source/Utility/ConstString.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ConstString.cpp?rev=339716&r1=339715&r2=339716&view=diff == --- lldb/trunk/source/Utility/ConstString.cpp (original) +++ lldb/trunk/source/Utility/ConstString.cpp Tue Aug 14 12:38:54 2018 @@ -123,11 +123,6 @@ public: StringPool &map = m_string_pools[h].m_string_map; StringPoolEntryType &entry = *map.try_emplace(demangled).first; - assert((entry.second == nullptr || entry.second == mangled_ccstr || - strlen(entry.second) == 0) && - "The demangled string must have a unique counterpart or otherwise " - "it must be empty"); - entry.second = mangled_ccstr; // Extract the const version of the demangled_cstr ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50681: Remove manual byte counting from internal Stream methods.
teemperor updated this revision to Diff 160697. teemperor added a comment. - Made ByteDelta public. - Minor fixes. @labath It sounds reasonable to make ByteDelta public. It certainly improves the byte-counting code outside of Stream, even though it hopefully doesn't encourage anyone to do even more byte-counting in LLDB. (Also thanks for reviewing!) https://reviews.llvm.org/D50681 Files: include/lldb/Utility/Stream.h source/Utility/Stream.cpp Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -313,26 +313,25 @@ llvm::SmallString<1024> buf; VASprintf(buf, format, args); - size_t length = 0; + ByteDelta delta(*this); for (char C : buf) -length += _PutHex8(C, false); +_PutHex8(C, false); va_end(args); - return length; + return *delta; } size_t Stream::PutNHex8(size_t n, uint8_t uvalue) { - size_t bytes_written = 0; + ByteDelta delta(*this); for (size_t i = 0; i < n; ++i) -bytes_written += _PutHex8(uvalue, false); - return bytes_written; +_PutHex8(uvalue, false); + return *delta; } -size_t Stream::_PutHex8(uint8_t uvalue, bool add_prefix) { - size_t bytes_written = 0; +void Stream::_PutHex8(uint8_t uvalue, bool add_prefix) { if (m_flags.Test(eBinary)) { -bytes_written = Write(&uvalue, 1); +Write(&uvalue, 1); } else { if (add_prefix) PutCString("0x"); @@ -343,56 +342,62 @@ char nibble_chars[2]; nibble_chars[0] = g_hex_to_ascii_hex_char[(uvalue >> 4) & 0xf]; nibble_chars[1] = g_hex_to_ascii_hex_char[(uvalue >> 0) & 0xf]; -bytes_written = Write(nibble_chars, sizeof(nibble_chars)); +Write(nibble_chars, sizeof(nibble_chars)); } - return bytes_written; } -size_t Stream::PutHex8(uint8_t uvalue) { return _PutHex8(uvalue, false); } +size_t Stream::PutHex8(uint8_t uvalue) { + ByteDelta delta(*this); + _PutHex8(uvalue, false); + return *delta; +} size_t Stream::PutHex16(uint16_t uvalue, ByteOrder byte_order) { + ByteDelta delta(*this); + if (byte_order == eByteOrderInvalid) byte_order = m_byte_order; - size_t bytes_written = 0; if (byte_order == eByteOrderLittle) { for (size_t byte = 0; byte < sizeof(uvalue); ++byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } else { for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } - return bytes_written; + return *delta; } size_t Stream::PutHex32(uint32_t uvalue, ByteOrder byte_order) { + ByteDelta delta(*this); + if (byte_order == eByteOrderInvalid) byte_order = m_byte_order; - size_t bytes_written = 0; if (byte_order == eByteOrderLittle) { for (size_t byte = 0; byte < sizeof(uvalue); ++byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } else { for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } - return bytes_written; + return *delta; } size_t Stream::PutHex64(uint64_t uvalue, ByteOrder byte_order) { + ByteDelta delta(*this); + if (byte_order == eByteOrderInvalid) byte_order = m_byte_order; - size_t bytes_written = 0; if (byte_order == eByteOrderLittle) { for (size_t byte = 0; byte < sizeof(uvalue); ++byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } else { for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } - return bytes_written; + return *delta; } size_t Stream::PutMaxHex64(uint64_t uvalue, size_t byte_size, @@ -438,65 +443,66 @@ size_t Stream::PutRawBytes(const void *s, size_t src_len, ByteOrder src_byte_order, ByteOrder dst_byte_order) { + ByteDelta delta(*this); + if (src_byte_order == eByteOrderInvalid) src_byte_order = m_byte_order; if (dst_byte_order == eByteOrderInvalid) dst_byte_order = m_byte_order; - size_t bytes_written = 0; const uint8_t *src = (const uint8_t *)s; bool binary_was_set = m_flags.Test(eBinary); if (!binary_was_set) m_flags.Set(eBinary); if (src_byte_order == dst_byte_order) { for (size_t i = 0; i < src_len; ++i) - bytes_written += _PutHex8(src[i], false); + _PutHex8(src[i], false); } else { for (size_t i = src_len - 1; i < src_len; --i) - bytes_written += _PutHex8(src[i], false); + _PutHex8(src[i], fals
[Lldb-commits] [PATCH] D50751: WIP: Expose FileCheck-style testing within lldb inline tests
vsk created this revision. This patch isn't quite ready for review. It's a simple proof-of-concept which shows what it would take to make FileCheck available within lldb inline tests. I'll kick off a discussion about this on lldb-dev. https://reviews.llvm.org/D50751 Files: lldb/packages/Python/lldbsuite/test/lldbtest.py Index: lldb/packages/Python/lldbsuite/test/lldbtest.py === --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -48,6 +48,8 @@ import signal from subprocess import * import sys +import commands +import tempfile import time import traceback import types @@ -2143,6 +2145,53 @@ return match_object +def filecheck( +self, +command, +check_file, +filecheck_options = '', +trace = False): +# Run the command. +self.runCmd( +command, +msg="FileCheck'ing result of `{0}`".format(command)) + +# Get the error text if there was an error, and the regular text if not. +output = self.res.GetOutput() if self.res.Succeeded() \ +else self.res.GetError() + +# Write the output to a temporary file. +input_file = tempfile.NamedTemporaryFile() +input_file.write(output) +input_file.flush() + +self.assertTrue(len(output) > 0, "No output to FileCheck") + +# Assemble the absolute path to the check file. +check_file_abs = os.path.join(os.path.dirname(self.test_filename), +check_file) + +# Run FileCheck. Source the check lines from the inline test. +filecheck_bin = os.path.join(os.path.dirname(configuration.compiler), +'FileCheck') +filecheck_cmd = "{0} {1} -input-file {2} {3}".format(filecheck_bin, +check_file_abs, input_file.name, filecheck_options) + +if not is_exe(filecheck_bin): +with recording(self, trace) as sbuf: +print("warning: FileCheck not found, skipping command:", +filecheck_cmd, file=sbuf) +return + +(cmd_status, cmd_output) = commands.getstatusoutput(filecheck_cmd) + +with recording(self, trace) as sbuf: +print("filecheck:", filecheck_cmd, file=sbuf) + +self.assertTrue(cmd_status == 0, +"FileCheck failed (code={0}):\n\n{1}".format(cmd_status, +cmd_output)) + def expect( self, str, Index: lldb/packages/Python/lldbsuite/test/lldbtest.py === --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -48,6 +48,8 @@ import signal from subprocess import * import sys +import commands +import tempfile import time import traceback import types @@ -2143,6 +2145,53 @@ return match_object +def filecheck( +self, +command, +check_file, +filecheck_options = '', +trace = False): +# Run the command. +self.runCmd( +command, +msg="FileCheck'ing result of `{0}`".format(command)) + +# Get the error text if there was an error, and the regular text if not. +output = self.res.GetOutput() if self.res.Succeeded() \ +else self.res.GetError() + +# Write the output to a temporary file. +input_file = tempfile.NamedTemporaryFile() +input_file.write(output) +input_file.flush() + +self.assertTrue(len(output) > 0, "No output to FileCheck") + +# Assemble the absolute path to the check file. +check_file_abs = os.path.join(os.path.dirname(self.test_filename), +check_file) + +# Run FileCheck. Source the check lines from the inline test. +filecheck_bin = os.path.join(os.path.dirname(configuration.compiler), +'FileCheck') +filecheck_cmd = "{0} {1} -input-file {2} {3}".format(filecheck_bin, +check_file_abs, input_file.name, filecheck_options) + +if not is_exe(filecheck_bin): +with recording(self, trace) as sbuf: +print("warning: FileCheck not found, skipping command:", +filecheck_cmd, file=sbuf) +return + +(cmd_status, cmd_output) = commands.getstatusoutput(filecheck_cmd) + +with recording(self, trace) as sbuf: +print("filecheck:", filecheck_cmd, file=sbuf) + +self.assertTrue(cmd_status == 0, +"FileCheck failed (code={0}):\n\n{1}".format(cmd_status, +cmd_output)) + def expect( self, str, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http:/