[Lldb-commits] [PATCH] D50159: Add byte counting mechanism to LLDB's Stream class.
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. I think there's a small difference in semantics between this and the `tell` function on llvm streams. This tells the number of bytes written, while the other one an absolute position within the stream. The two probably only differ if you open a StreamFile in append mode. However, even then, I doubt anyone will care about the distinction, so it shouldn't impede the migration. So, I'm happy to sign off on this. Thanks for doing it. https://reviews.llvm.org/D50159 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50159: Add byte counting mechanism to LLDB's Stream class.
JDevlieghere added inline comments. Comment at: include/lldb/Utility/Stream.h:542 int m_indent_level; ///< Indention level. + std::size_t m_bytes_written = 0; /// The bytes this stream has written so far. I believe you need the `<` for Doxygen to associate the comment with the var, like the line(s) above. https://reviews.llvm.org/D50159 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50161: Add raw_ostream wrapper to the Stream class
labath added a comment. Wouldn't it be even better to actually expose the llvm class via some accessor or something? This way we could slowly migrate existing code by changing it to write to `stream.accessor()` instead of `stream` ? (I am not saying to do that now, but it opens up possibilities for the future.) I also found it hard to deduce who is forwarding to whom from the member names. Maybe rename `m_forward_to` to `m_target` or something like that? https://reviews.llvm.org/D50161 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338695 - Unit test for Symtab::InitNameIndexes
Author: stefan.graenitz Date: Thu Aug 2 03:13:18 2018 New Revision: 338695 URL: http://llvm.org/viewvc/llvm-project?rev=338695&view=rev Log: Unit test for Symtab::InitNameIndexes Summary: In order to exploit the potential of LLVM's new ItaniumPartialDemangler for indexing in LLDB, we expect conceptual changes in the implementation of the InitNameIndexes function. Here is a unit test that aims at covering all relevant code paths in that function. Reviewers: labath, jingham, JDevlieghere Reviewed By: JDevlieghere Subscribers: friss, teemperor, davide, clayborg, erik.pilkington, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D49909 Added: lldb/trunk/unittests/Core/Inputs/ lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml Modified: lldb/trunk/unittests/Core/CMakeLists.txt lldb/trunk/unittests/Core/MangledTest.cpp Modified: lldb/trunk/unittests/Core/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/CMakeLists.txt?rev=338695&r1=338694&r2=338695&view=diff == --- lldb/trunk/unittests/Core/CMakeLists.txt (original) +++ lldb/trunk/unittests/Core/CMakeLists.txt Thu Aug 2 03:13:18 2018 @@ -11,7 +11,19 @@ add_lldb_unittest(LLDBCoreTests LINK_LIBS lldbCore lldbHost +lldbSymbol +lldbPluginObjectFileELF +lldbPluginSymbolVendorELF +lldbUtilityHelpers LLVMTestingSupport LINK_COMPONENTS Support ) + +add_dependencies(LLDBCoreTests yaml2obj) +add_definitions(-DYAML2OBJ="$") + +set(test_inputs + mangled-function-names.yaml + ) +add_unittest_inputs(LLDBCoreTests "${test_inputs}") Added: lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml?rev=338695&view=auto == --- lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml (added) +++ lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml Thu Aug 2 03:13:18 2018 @@ -0,0 +1,116 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_EXEC + Machine: EM_X86_64 +Sections: + - Name:.text +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +AddressAlign:0x0010 +Content: 554889E58B0425A8005DC30F1F00 + - Name:.anothertext +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +Address: 0x0010 +AddressAlign:0x0010 +Content: 554889E54883EC20488D0425A800C745FC488945F0488B45F08B08894DECE8C7FF8B4DEC01C189C84883C4205D746573742073747200C3 + - Name:.eh_frame +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC ] +Address: 0x0050 +AddressAlign:0x0008 +Content: 1400017A5200017810011B0C070890011C001C0090FF0D410E108602430D06001C003C0080FF3F410E108602430D0600 + - Name:.data +Type:SHT_PROGBITS +Flags: [ SHF_WRITE, SHF_ALLOC ] +Address: 0x00A8 +AddressAlign:0x0004 +Content: '0100' + - Name:.comment +Type:SHT_PROGBITS +Flags: [ SHF_MERGE, SHF_STRINGS ] +AddressAlign:0x0001 +Content: 5562756E747520636C616E672076657273696F6E20332E352D317562756E74753120287472756E6B2920286261736564206F6E204C4C564D20332E352900 +Symbols: + Local: +- Type:STT_SECTION + Section: .text +- Type:STT_SECTION + Section: .anothertext + Value: 0x0010 +- Type:STT_SECTION + Section: .eh_frame + Value: 0x0050 +- Type:STT_SECTION + Section: .data + Value: 0x00A8 +- Type:STT_SECTION + Section: .comment +- Name:/tmp/a.c + Type:STT_FILE +- Type:STT_FILE + Global: +- Name:somedata + Type:STT_OBJECT + Section: .anothertext + Value: 0x0045 +- Name:main + Type:STT_FUNC + Section: .anothertext + Value: 0x0010 + Size:0x003F +- Name:_Z3foov + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:puts@GLIBC_2.5 + Type:STT_FUNC + Section:
[Lldb-commits] [PATCH] D49909: Unit test for Symtab::InitNameIndexes
This revision was automatically updated to reflect the committed changes. Closed by commit rL338695: Unit test for Symtab::InitNameIndexes (authored by stefan.graenitz, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D49909 Files: lldb/trunk/unittests/Core/CMakeLists.txt lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml lldb/trunk/unittests/Core/MangledTest.cpp Index: lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml === --- lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml +++ lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml @@ -0,0 +1,116 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_EXEC + Machine: EM_X86_64 +Sections: + - Name:.text +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +AddressAlign:0x0010 +Content: 554889E58B0425A8005DC30F1F00 + - Name:.anothertext +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +Address: 0x0010 +AddressAlign:0x0010 +Content: 554889E54883EC20488D0425A800C745FC488945F0488B45F08B08894DECE8C7FF8B4DEC01C189C84883C4205D746573742073747200C3 + - Name:.eh_frame +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC ] +Address: 0x0050 +AddressAlign:0x0008 +Content: 1400017A5200017810011B0C070890011C001C0090FF0D410E108602430D06001C003C0080FF3F410E108602430D0600 + - Name:.data +Type:SHT_PROGBITS +Flags: [ SHF_WRITE, SHF_ALLOC ] +Address: 0x00A8 +AddressAlign:0x0004 +Content: '0100' + - Name:.comment +Type:SHT_PROGBITS +Flags: [ SHF_MERGE, SHF_STRINGS ] +AddressAlign:0x0001 +Content: 5562756E747520636C616E672076657273696F6E20332E352D317562756E74753120287472756E6B2920286261736564206F6E204C4C564D20332E352900 +Symbols: + Local: +- Type:STT_SECTION + Section: .text +- Type:STT_SECTION + Section: .anothertext + Value: 0x0010 +- Type:STT_SECTION + Section: .eh_frame + Value: 0x0050 +- Type:STT_SECTION + Section: .data + Value: 0x00A8 +- Type:STT_SECTION + Section: .comment +- Name:/tmp/a.c + Type:STT_FILE +- Type:STT_FILE + Global: +- Name:somedata + Type:STT_OBJECT + Section: .anothertext + Value: 0x0045 +- Name:main + Type:STT_FUNC + Section: .anothertext + Value: 0x0010 + Size:0x003F +- Name:_Z3foov + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:puts@GLIBC_2.5 + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:puts@GLIBC_2.6 + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:_Z5annotv@VERSION3 + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:_ZN1AC2Ev + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:_ZN1AD2Ev + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:_ZN1A3barEv + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:_ZGVZN4llvm4dbgsEvE7thestrm + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:_ZZN4llvm4dbgsEvE7thestrm + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:_ZTVN5clang4DeclE + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:-[ObjCfoo] + Type:STT_FUNC + Section: .text + Size:0x000D +- Name:+[B ObjCbar(WithCategory)] + Type
[Lldb-commits] [PATCH] D50071: Use rich mangling information in Symtab::InitNameIndexes()
labath added a comment. In https://reviews.llvm.org/D50071#1184960, @sgraenitz wrote: > > If I understand things correctly, we could avoid circular deps and untyped > > pointers (or llvm::Any, which is essentially the same thing), by moving > > CPlusPlusLanguage::MethodName to a separate file. > > Banning public nested classes in general is a good practice as long as C++ is > lacking rich forward declarations. This is the issue here. If we could > forward declare the class, all was great. The problem is, of course, that > there is a pattern behind `Language::MethodName` within the language plugins. > So changing all of them? Hmm.. > > > moving CPlusPlusLanguage::MethodName to a separate file. > > You mean putting it in a separate file and include that one in the > `RichManglingInfo.h`? I am not so familiar with the code yet, but it looks > like there are reasons for having `CPlusPlusLanguage` under `Plugins` and > separate these from other things like `Core` or `Symbol`. I don't think we > should include a `Plugins` header from a `Core` header.. I'd actually draw the line even higher, generic code shouldn't include Plugin code, ever (the SystemInitializer classes being the only exception, I guess). While having dependencies in the headers is more troublesome (e.g. for modules), it is not a line that can easily be held as refactorings (such as yours) which move functionality around (even with a single module) can easily cause a dep which was previously cpp-only to show up in the header too. However, it is true that we are very far from the line I wish to hold, while yours is almost there (I see only one exception where we include some clang stuff from `ClangASTContext.h`). I was not aware of this fact until now, so I do concede that it's good to not make this worse here. > > >> Could we do that as a preparatory step for this patch? > > Well, now I spent the time to make the hack nice haha. > To be honest, I am happy to talk about a follow-up task here, but doing this > now and before finishing the demangling sounds like a big unrelated piece of > work. FWIW, I was not thinking of any major changes. Just moving the single c++ class to a separate file and that's it. We could even leave behind a typedef in CPlusPlusLanguage so that it's accessible under the old name too. (However if you are interested in something like this, then it might be interesting to look at whether this MethodName stuff couldn't be properly pluginified. Something like where a Language class registers a callback for a specific mangling type, and then accessing that through this) Comment at: include/lldb/Core/RichManglingInfo.h:83-84 +public: + RichManglingInfo *SetItaniumInfo(); + RichManglingInfo *SetLegacyCxxParserInfo(const ConstString &mangled); + sgraenitz wrote: > labath wrote: > > I find it odd that one of these functions is stateless > > (`SetLegacyCxxParserInfo` takes the string which initializes the object as > > an argument), while the other receives the state magically via the IPD > > accessor. > > > > Would it be possible to change it so that the other option is stateless too > > (`SetItaniumInfo(ConstString mangled)`)? > > > > We could change `RichManglingInfo` to return the full demangled name too, > > so that you have access to the demangled name via this API too (which /I > > think/ is the reason why you created a separate > > `GetItaniumRichDemangleInfo` function). > > Would it be possible to change it so that the other option is stateless too > > (`SetItaniumInfo(ConstString mangled)`)? > I think that would be misleading for the reader. Symmetry is always nice to > indicate congruent behavior, but this is not the case here. The fallback C++ > parser version mimics the previous behavior: demangle the name in step 1 and > if that succeeds, parse it with `CPlusPlusLanguage::MethodName` to decode its > properties. The IPD does that in a single step and so there is nothing to do > in `SetItaniumInfo()`. `SetLegacyCxxParserInfo()` on the other hand has to > create a `CPlusPlusLanguage::MethodName` from the mangled string. > > > We could change `RichManglingInfo` to return the full demangled name too, > > so that you have access to the demangled name via this API too (which /I > > think/ is the reason why you created a separate GetItaniumRichDemangleInfo > > function). > The interface wants to provide access to the name's encoded properties. That > doesn't really include the demangled "human readable" string representation > (it's also not needed in `Symtab::RegisterMangledNameEntry()`). > > Of course `Symtab::InitNameIndexes()` will ask for `GetDemangledName()` just > after processing the mangled one. I think chances are good that for symbols > that are not filtered out anyway, we reached `DemangleWithRichManglingInfo()` > earlier and it will be in the string pool already (see Mangled.cpp:322). > Otherwise, yes it will be d
[Lldb-commits] [lldb] r338712 - Move ClangHighlighter.cpp to hopefully better place in Xcode project.
Author: tnorthover Date: Thu Aug 2 05:50:23 2018 New Revision: 338712 URL: http://llvm.org/viewvc/llvm-project?rev=338712&view=rev Log: Move ClangHighlighter.cpp to hopefully better place in Xcode project. But with a write-only format, who can really say? Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=338712&r1=338711&r2=338712&view=diff == --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Aug 2 05:50:23 2018 @@ -65,6 +65,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 228B1B672113340200E61C70 /* ClangHighlighter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58A080AB2112AABB00D5580F /* ClangHighlighter.cpp */; }; 268900E813353E6F00698AC0 /* ABI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 497E7B9D1188F6690065CCA1 /* ABI.cpp */; }; 26DB3E161379E7AD0080DC73 /* ABIMacOSX_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DB3E071379E7AD0080DC73 /* ABIMacOSX_arm.cpp */; }; 26DB3E191379E7AD0080DC73 /* ABIMacOSX_arm64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DB3E0B1379E7AD0080DC73 /* ABIMacOSX_arm64.cpp */; }; @@ -1283,8 +1284,6 @@ dstPath = "$(DEVELOPER_INSTALL_DIR)/usr/share/man/man1"; dstSubfolderSpec = 0; files = ( - 58A080AE2112AAC500D5580F /* ClangHighlighter.h in CopyFiles */, - 58A080AC2112AABB00D5580F /* ClangHighlighter.cpp in CopyFiles */, AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; @@ -7958,6 +7957,7 @@ 268900F313353E6F00698AC0 /* StackFrame.cpp in Sources */, 268900F413353E6F00698AC0 /* StackFrameList.cpp in Sources */, 268900F513353E6F00698AC0 /* StackID.cpp in Sources */, + 228B1B672113340200E61C70 /* ClangHighlighter.cpp in Sources */, 268900F613353E6F00698AC0 /* StopInfo.cpp in Sources */, 256CBDB41ADD0EFD00BC6CDC /* RegisterContextPOSIXCore_arm.cpp in Sources */, 267F684F1CC02E270086832B /* RegisterContextPOSIXCore_s390x.cpp in Sources */, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50192: Fix: ClangHighlighter.cpp should not be in CopyFiles, but in lldb-core targets
sgraenitz created this revision. sgraenitz added a reviewer: teemperor. Fix linker error: Undefined symbols for architecture x86_64: "lldb_private::ClangHighlighter::ClangHighlighter()", referenced from: lldb_private::ObjCLanguage::ObjCLanguage() in liblldb-core.a(ObjCLanguage.o) lldb_private::CPlusPlusLanguage::CPlusPlusLanguage() in liblldb-core.a(CPlusPlusLanguage.o) lldb_private::ObjCPlusPlusLanguage::ObjCPlusPlusLanguage() in liblldb-core.a(ObjCPlusPlusLanguage.o) "vtable for lldb_private::ClangHighlighter", referenced from: lldb_private::ClangHighlighter::~ClangHighlighter() in liblldb-core.a(ObjCLanguage.o) lldb_private::ClangHighlighter::~ClangHighlighter() in liblldb-core.a(CPlusPlusLanguage.o) lldb_private::ClangHighlighter::~ClangHighlighter() in liblldb-core.a(ObjCPlusPlusLanguage.o) https://reviews.llvm.org/D50192 Files: lldb.xcodeproj/project.pbxproj Index: lldb.xcodeproj/project.pbxproj === --- lldb.xcodeproj/project.pbxproj +++ lldb.xcodeproj/project.pbxproj @@ -1283,8 +1283,6 @@ dstPath = "$(DEVELOPER_INSTALL_DIR)/usr/share/man/man1"; dstSubfolderSpec = 0; files = ( - 58A080AE2112AAC500D5580F /* ClangHighlighter.h in CopyFiles */, - 58A080AC2112AABB00D5580F /* ClangHighlighter.cpp in CopyFiles */, AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; @@ -7950,6 +7948,7 @@ 4C2479BD1BA39295009C9A7B /* FunctionCaller.cpp in Sources */, AF2907BF1D3F082400E10654 /* DynamicLoaderMacOS.cpp in Sources */, 268900EF13353E6F00698AC0 /* Platform.cpp in Sources */, + 4FA04FFA211362230011EDE5 /* ClangHighlighter.cpp in Sources */, 268900F013353E6F00698AC0 /* Process.cpp in Sources */, 26BC17AD18C7F4CB00D2196D /* RegisterContextPOSIXCore_mips64.cpp in Sources */, 268900F113353E6F00698AC0 /* RegisterContext.cpp in Sources */, Index: lldb.xcodeproj/project.pbxproj === --- lldb.xcodeproj/project.pbxproj +++ lldb.xcodeproj/project.pbxproj @@ -1283,8 +1283,6 @@ dstPath = "$(DEVELOPER_INSTALL_DIR)/usr/share/man/man1"; dstSubfolderSpec = 0; files = ( -58A080AE2112AAC500D5580F /* ClangHighlighter.h in CopyFiles */, -58A080AC2112AABB00D5580F /* ClangHighlighter.cpp in CopyFiles */, AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; @@ -7950,6 +7948,7 @@ 4C2479BD1BA39295009C9A7B /* FunctionCaller.cpp in Sources */, AF2907BF1D3F082400E10654 /* DynamicLoaderMacOS.cpp in Sources */, 268900EF13353E6F00698AC0 /* Platform.cpp in Sources */, +4FA04FFA211362230011EDE5 /* ClangHighlighter.cpp in Sources */, 268900F013353E6F00698AC0 /* Process.cpp in Sources */, 26BC17AD18C7F4CB00D2196D /* RegisterContextPOSIXCore_mips64.cpp in Sources */, 268900F113353E6F00698AC0 /* RegisterContext.cpp in Sources */, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50192: Fix: ClangHighlighter.cpp should not be in CopyFiles, but in lldb-core targets
teemperor added a reviewer: t.p.northover. teemperor added a comment. This was changed by https://reviews.llvm.org/rLLDB338712 so I think Tim probably knows better what's going on here. https://reviews.llvm.org/D50192 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50192: Fix: ClangHighlighter.cpp should not be in CopyFiles, but in lldb-core targets
davide added a comment. My understanding is that @t.p.northover just committed the same patch. https://reviews.llvm.org/D50192 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50159: Add byte counting mechanism to LLDB's Stream class.
teemperor updated this revision to Diff 158777. teemperor added a comment. - Fixing some of the merge conflicts. - Fixed doxygen comment. Thanks for the reviews! https://reviews.llvm.org/D50159 Files: include/lldb/Core/StreamAsynchronousIO.h include/lldb/Core/StreamBuffer.h include/lldb/Core/StreamFile.h include/lldb/Utility/Stream.h include/lldb/Utility/StreamString.h include/lldb/Utility/StreamTee.h source/Core/StreamAsynchronousIO.cpp source/Core/StreamFile.cpp source/Utility/StreamString.cpp unittests/Utility/StreamTeeTest.cpp unittests/Utility/StreamTest.cpp Index: unittests/Utility/StreamTest.cpp === --- unittests/Utility/StreamTest.cpp +++ unittests/Utility/StreamTest.cpp @@ -44,149 +44,211 @@ TEST_F(StreamTest, PutChar) { s.PutChar('a'); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ("a", TakeValue()); s.PutChar('1'); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ("1", TakeValue()); } TEST_F(StreamTest, PutCharWhitespace) { s.PutChar(' '); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ(" ", TakeValue()); s.PutChar('\n'); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ("\n", TakeValue()); s.PutChar('\r'); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ("\r", TakeValue()); s.PutChar('\t'); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ("\t", TakeValue()); } TEST_F(StreamTest, PutCString) { s.PutCString(""); + EXPECT_EQ(0U, s.GetWrittenBytes()); EXPECT_EQ("", TakeValue()); s.PutCString("foobar"); + EXPECT_EQ(6U, s.GetWrittenBytes()); EXPECT_EQ("foobar", TakeValue()); s.PutCString(" "); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ(" ", TakeValue()); } TEST_F(StreamTest, PutCStringWithStringRef) { s.PutCString(llvm::StringRef("")); + EXPECT_EQ(0U, s.GetWrittenBytes()); EXPECT_EQ("", TakeValue()); s.PutCString(llvm::StringRef("foobar")); + EXPECT_EQ(6U, s.GetWrittenBytes()); EXPECT_EQ("foobar", TakeValue()); s.PutCString(llvm::StringRef(" ")); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ(" ", TakeValue()); } TEST_F(StreamTest, QuotedCString) { s.QuotedCString("foo"); + EXPECT_EQ(5U, s.GetWrittenBytes()); EXPECT_EQ(R"("foo")", TakeValue()); s.QuotedCString("ba r"); + EXPECT_EQ(6U, s.GetWrittenBytes()); EXPECT_EQ(R"("ba r")", TakeValue()); s.QuotedCString(" "); + EXPECT_EQ(3U, s.GetWrittenBytes()); EXPECT_EQ(R"(" ")", TakeValue()); } TEST_F(StreamTest, PutCharNull) { s.PutChar('\0'); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ(std::string("\0", 1), TakeValue()); s.PutChar('a'); + EXPECT_EQ(1U, s.GetWrittenBytes()); EXPECT_EQ(std::string("a", 1), TakeValue()); } TEST_F(StreamTest, PutCStringAsRawHex8) { s.PutCStringAsRawHex8(""); + EXPECT_EQ(0U, s.GetWrittenBytes()); EXPECT_EQ("", TakeValue()); s.PutCStringAsRawHex8("foobar"); + EXPECT_EQ(12U, s.GetWrittenBytes()); EXPECT_EQ("666f6f626172", TakeValue()); s.PutCStringAsRawHex8(" "); + EXPECT_EQ(2U, s.GetWrittenBytes()); EXPECT_EQ("20", TakeValue()); } TEST_F(StreamTest, PutHex8) { s.PutHex8((uint8_t)55); + EXPECT_EQ(2U, s.GetWrittenBytes()); EXPECT_EQ("37", TakeValue()); + s.PutHex8(std::numeric_limits::max()); + EXPECT_EQ(2U, s.GetWrittenBytes()); EXPECT_EQ("ff", TakeValue()); + s.PutHex8((uint8_t)0); + EXPECT_EQ(2U, s.GetWrittenBytes()); EXPECT_EQ("00", TakeValue()); } TEST_F(StreamTest, PutNHex8) { s.PutNHex8(0, (uint8_t)55); + EXPECT_EQ(0U, s.GetWrittenBytes()); EXPECT_EQ("", TakeValue()); + s.PutNHex8(1, (uint8_t)55); + EXPECT_EQ(2U, s.GetWrittenBytes()); EXPECT_EQ("37", TakeValue()); + s.PutNHex8(2, (uint8_t)55); + EXPECT_EQ(4U, s.GetWrittenBytes()); EXPECT_EQ("3737", TakeValue()); + s.PutNHex8(1, (uint8_t)56); + EXPECT_EQ(2U, s.GetWrittenBytes()); EXPECT_EQ("38", TakeValue()); } TEST_F(StreamTest, PutHex16ByteOrderLittle) { s.PutHex16(0x1234U, lldb::eByteOrderLittle); + EXPECT_EQ(4U, s.GetWrittenBytes()); EXPECT_EQ("3412", TakeValue()); + s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderLittle); + EXPECT_EQ(4U, s.GetWrittenBytes()); EXPECT_EQ("", TakeValue()); + s.PutHex16(0U, lldb::eByteOrderLittle); + EXPECT_EQ(4U, s.GetWrittenBytes()); EXPECT_EQ("", TakeValue()); } TEST_F(StreamTest, PutHex16ByteOrderBig) { s.PutHex16(0x1234U, lldb::eByteOrderBig); + EXPECT_EQ(4U, s.GetWrittenBytes()); EXPECT_EQ("1234", TakeValue()); + s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderBig); + EXPECT_EQ(4U, s.GetWrittenBytes()); EXPECT_EQ("", TakeValue()); + s.PutHex16(0U, lldb::eByteOrderBig); + EXPECT_EQ(4U, s.GetWrittenBytes()); EXPECT_EQ("", TakeValue()); } TEST_F(StreamTest, PutHex32ByteOrderLittle) { s.PutHex32(0x12345678U, lldb::eByteOrderLittle); + EXPECT_EQ(8U, s.GetWrittenBytes()); EXPECT_EQ("78563412", TakeValue()); +
[Lldb-commits] [lldb] r338733 - Add byte counting mechanism to LLDB's Stream class.
Author: teemperor Date: Thu Aug 2 09:38:34 2018 New Revision: 338733 URL: http://llvm.org/viewvc/llvm-project?rev=338733&view=rev Log: Add byte counting mechanism to LLDB's Stream class. Summary: This patch allows LLDB's Stream class to count the bytes it has written to so far. There are two major motivations for this patch: The first one is that this will allow us to get rid of all the handwritten byte counting code we have in LLDB so far. Examples for this are pretty much all functions in LLDB that take a Stream to write to and return a size_t, which usually represents the bytes written. By moving to this centralized byte counting mechanism, we hopefully can avoid some tricky errors that happen when some code forgets to count the written bytes while writing something to a stream. The second motivation is that this is needed for the migration away from LLDB's `Stream` and towards LLVM's `raw_ostream`. My current plan is to start offering a fake raw_ostream class that just forwards to a LLDB Stream. However, for this raw_ostream wrapper we need to fulfill the raw_ostream interface with LLDB's Stream, which currently lacks the ability to count the bytes written so far (which raw_ostream exposes by it's `tell()` method). By adding this functionality it is trivial to start rolling out our raw_ostream wrapper (and then eventually completely move to raw_ostream). Also, once this fake raw_ostream is available, we can start replacing our own code writing to LLDB's Stream by LLVM code writing to raw_ostream. The best example for this is the LEB128 encoding we currently ship, which can be replaced with by LLVM's version which accepts an raw_ostream. From the point of view of the pure source changes this test does, we essentially just renamed the Write implementation in Stream to `WriteImpl` while the `Write` method everyone is using to write its raw bytes is now just forwarding and counting the written bytes. Reviewers: labath, davide Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Differential Revision: https://reviews.llvm.org/D50159 Modified: lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h lldb/trunk/include/lldb/Core/StreamBuffer.h lldb/trunk/include/lldb/Core/StreamFile.h lldb/trunk/include/lldb/Utility/Stream.h lldb/trunk/include/lldb/Utility/StreamString.h lldb/trunk/include/lldb/Utility/StreamTee.h lldb/trunk/source/Core/StreamAsynchronousIO.cpp lldb/trunk/source/Core/StreamFile.cpp lldb/trunk/source/Utility/StreamString.cpp lldb/trunk/unittests/Utility/StreamTeeTest.cpp lldb/trunk/unittests/Utility/StreamTest.cpp Modified: lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h?rev=338733&r1=338732&r2=338733&view=diff == --- lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h (original) +++ lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h Thu Aug 2 09:38:34 2018 @@ -30,7 +30,8 @@ public: void Flush() override; - size_t Write(const void *src, size_t src_len) override; +protected: + size_t WriteImpl(const void *src, size_t src_len) override; private: Debugger &m_debugger; Modified: lldb/trunk/include/lldb/Core/StreamBuffer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamBuffer.h?rev=338733&r1=338732&r2=338733&view=diff == --- lldb/trunk/include/lldb/Core/StreamBuffer.h (original) +++ lldb/trunk/include/lldb/Core/StreamBuffer.h Thu Aug 2 09:38:34 2018 @@ -30,12 +30,6 @@ public: // Nothing to do when flushing a buffer based stream... } - virtual size_t Write(const void *s, size_t length) { -if (s && length) - m_packet.append((const char *)s, ((const char *)s) + length); -return length; - } - void Clear() { m_packet.clear(); } // Beware, this might not be NULL terminated as you can expect from @@ -48,6 +42,12 @@ public: protected: llvm::SmallVector m_packet; + + virtual size_t WriteImpl(const void *s, size_t length) { +if (s && length) + m_packet.append((const char *)s, ((const char *)s) + length); +return length; + } }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Core/StreamFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamFile.h?rev=338733&r1=338732&r2=338733&view=diff == --- lldb/trunk/include/lldb/Core/StreamFile.h (original) +++ lldb/trunk/include/lldb/Core/StreamFile.h Thu Aug 2 09:38:34 2018 @@ -46,13 +46,13 @@ public: void Flush() override; - size_t Write(const void *s, size_t length) override; protected: //-- // Classes that inherit from StreamFile can see an
[Lldb-commits] [PATCH] D50159: Add byte counting mechanism to LLDB's Stream class.
This revision was automatically updated to reflect the committed changes. Closed by commit rL338733: Add byte counting mechanism to LLDB's Stream class. (authored by teemperor, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50159?vs=158777&id=158779#toc Repository: rL LLVM https://reviews.llvm.org/D50159 Files: lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h lldb/trunk/include/lldb/Core/StreamBuffer.h lldb/trunk/include/lldb/Core/StreamFile.h lldb/trunk/include/lldb/Utility/Stream.h lldb/trunk/include/lldb/Utility/StreamString.h lldb/trunk/include/lldb/Utility/StreamTee.h lldb/trunk/source/Core/StreamAsynchronousIO.cpp lldb/trunk/source/Core/StreamFile.cpp lldb/trunk/source/Utility/StreamString.cpp lldb/trunk/unittests/Utility/StreamTeeTest.cpp lldb/trunk/unittests/Utility/StreamTest.cpp Index: lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h === --- lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h +++ lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h @@ -30,7 +30,8 @@ void Flush() override; - size_t Write(const void *src, size_t src_len) override; +protected: + size_t WriteImpl(const void *src, size_t src_len) override; private: Debugger &m_debugger; Index: lldb/trunk/include/lldb/Core/StreamFile.h === --- lldb/trunk/include/lldb/Core/StreamFile.h +++ lldb/trunk/include/lldb/Core/StreamFile.h @@ -46,13 +46,13 @@ void Flush() override; - size_t Write(const void *s, size_t length) override; protected: //-- // Classes that inherit from StreamFile can see and modify these //-- File m_file; + size_t WriteImpl(const void *s, size_t length) override; private: DISALLOW_COPY_AND_ASSIGN(StreamFile); Index: lldb/trunk/include/lldb/Core/StreamBuffer.h === --- lldb/trunk/include/lldb/Core/StreamBuffer.h +++ lldb/trunk/include/lldb/Core/StreamBuffer.h @@ -30,12 +30,6 @@ // Nothing to do when flushing a buffer based stream... } - virtual size_t Write(const void *s, size_t length) { -if (s && length) - m_packet.append((const char *)s, ((const char *)s) + length); -return length; - } - void Clear() { m_packet.clear(); } // Beware, this might not be NULL terminated as you can expect from @@ -48,6 +42,12 @@ protected: llvm::SmallVector m_packet; + + virtual size_t WriteImpl(const void *s, size_t length) { +if (s && length) + m_packet.append((const char *)s, ((const char *)s) + length); +return length; + } }; } // namespace lldb_private Index: lldb/trunk/include/lldb/Utility/StreamTee.h === --- lldb/trunk/include/lldb/Utility/StreamTee.h +++ lldb/trunk/include/lldb/Utility/StreamTee.h @@ -70,29 +70,6 @@ } } - size_t Write(const void *s, size_t length) override { -std::lock_guard guard(m_streams_mutex); -if (m_streams.empty()) - return 0; - -size_t min_bytes_written = SIZE_MAX; -collection::iterator pos, end; -for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) { - // Allow for our collection to contain NULL streams. This allows the - // StreamTee to be used with hard coded indexes for clients that might - // want N total streams with only a few that are set to valid values. - Stream *strm = pos->get(); - if (strm) { -const size_t bytes_written = strm->Write(s, length); -if (min_bytes_written > bytes_written) - min_bytes_written = bytes_written; - } -} -if (min_bytes_written == SIZE_MAX) - return 0; -return min_bytes_written; - } - size_t AppendStream(const lldb::StreamSP &stream_sp) { size_t new_idx = m_streams.size(); std::lock_guard guard(m_streams_mutex); @@ -131,6 +108,29 @@ typedef std::vector collection; mutable std::recursive_mutex m_streams_mutex; collection m_streams; + + size_t WriteImpl(const void *s, size_t length) override { +std::lock_guard guard(m_streams_mutex); +if (m_streams.empty()) + return 0; + +size_t min_bytes_written = SIZE_MAX; +collection::iterator pos, end; +for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) { + // Allow for our collection to contain NULL streams. This allows the + // StreamTee to be used with hard coded indexes for clients that might + // want N total streams with only a few that are set to valid values. + Stream *strm = pos->get(); + if (strm) { +const size_t bytes_written = strm->Write(s, length); +if (min_bytes_written > bytes_written) + min_bytes_writte
[Lldb-commits] [lldb] r338734 - Add support for ARM and ARM64 breakpad generated minidump files
Author: gclayton Date: Thu Aug 2 09:46:15 2018 New Revision: 338734 URL: http://llvm.org/viewvc/llvm-project?rev=338734&view=rev Log: Add support for ARM and ARM64 breakpad generated minidump files In this patch I add support for ARM and ARM64 break pad files. There are two flavors of ARM: Apple where FP is R7, and non Apple where FP is R11. Added minimal tests that load up ARM64 and the two flavors or ARM core files with a single thread and known register values in each register. Each register is checked for the exact value. Differential Revision: https://reviews.llvm.org/D49750 Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp (with props) lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp (with props) lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp (with props) lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h Modified: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=338734&r1=338733&r2=338734&view=diff == --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Thu Aug 2 09:46:15 2018 @@ -913,28 +913,30 @@ public: /// Set the architecture for this target. /// /// If the current target has no Images read in, then this just sets the - /// architecture, which will - /// be used to select the architecture of the ExecutableModule when that is - /// set. - /// If the current target has an ExecutableModule, then calling - /// SetArchitecture with a different + /// architecture, which will be used to select the architecture of the + /// ExecutableModule when that is set. If the current target has an + /// ExecutableModule, then calling SetArchitecture with a different /// architecture from the currently selected one will reset the - /// ExecutableModule to that slice - /// of the file backing the ExecutableModule. If the file backing the - /// ExecutableModule does not - /// contain a fork of this architecture, then this code will return false, and - /// the architecture - /// won't be changed. - /// If the input arch_spec is the same as the already set architecture, this - /// is a no-op. + /// ExecutableModule to that slice of the file backing the ExecutableModule. + /// If the file backing the ExecutableModule does not contain a fork of this + /// architecture, then this code will return false, and the architecture + /// won't be changed. If the input arch_spec is the same as the already set + /// architecture, this is a no-op. /// /// @param[in] arch_spec /// The new architecture. /// + /// @param[in] set_platform + /// If \b true, then the platform will be adjusted if the currently + /// selected platform is not compatible with the archicture being set. + /// If \b false, then just the architecture will be set even if the + /// currently selected platform isn't compatible (in case it might be + /// manually set following this function call). + /// /// @return /// \b true if the architecture was successfully set, \bfalse otherwise. //-- - bool SetArchitecture(const ArchSpec &arch_spec); + bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false); bool MergeArchitecture(const ArchSpec &arch_spec); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=338734&r1=338733&r2=338734&view=diff == --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Aug 2 09:46:15 2018 @@ -665,6 +665,10 @@ 26474CBE18D0CB2D0073DEBA /* RegisterContextMach_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CB818D0CB
[Lldb-commits] [PATCH] D49750: Add support for ARM and ARM64 breakpad generated minidump files.
This revision was automatically updated to reflect the committed changes. Closed by commit rL338734: Add support for ARM and ARM64 breakpad generated minidump files (authored by gclayton, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49750?vs=158631&id=158784#toc Repository: rL LLVM https://reviews.llvm.org/D49750 Files: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp lldb/trunk/source/Target/Target.cpp Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py @@ -189,6 +189,161 @@ stop_description = thread.GetStopDescription(256) self.assertEqual(stop_description, "") +def check_register_unsigned(self, set, name, expected): +reg_value = set.GetChildMemberWithName(name) +self.assertTrue(reg_value.IsValid(), +'Verify we have a register named "%s"' % (name)) +self.assertEqual(reg_value.GetValueAsUnsigned(), expected, + 'Verify "%s" == %i' % (name, expected)) + +def check_register_string_value(self, set, name, expected, format): +reg_value = set.GetChildMemberWithName(name) +self.assertTrue(reg_value.IsValid(), +'Verify we have a register named "%s"' % (name)) +if format is not None: +reg_value.SetFormat(format) +self.assertEqual(reg_value.GetValue(), expected, + 'Verify "%s" has string value "%s"' % (name, +expected)) + +def test_arm64_registers(self): +"""Test ARM64 registers from a breakpad created minidump.""" +# target create -c arm64-macos.dmp +self.dbg.CreateTarget(None) +self.target = self.dbg.GetSelectedTarget() +self.process = self.target.LoadCore("arm64-macos.dmp") +self.check_state() +self.assertEqual(self.process.GetNumThreads(), 1) +thread = self.process.GetThreadAtIndex(0) +self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) +stop_description = thread.GetStopDescription(256) +self.assertEqual(stop_description, "") +registers = thread.GetFrameAtIndex(0).GetRegisters() +# Verify the GPR registers are all correct +# Verify x0 - x31 register values +gpr = registers.GetValueAtIndex(0) +for i in range(32): +v = i+1 | i+2 << 32 | i+3 << 48 +w = i+1 +self.check_register_unsigned(gpr, 'x%i' % (i), v) +self.check_register_unsigned(gpr, 'w%i' % (i), w) +# Verify arg1 - arg8 register values +for i in range(1, 9): +v = i | i+1 << 32 | i+2 << 48 +self.check_register_unsigned(gpr, 'arg%i' % (i), v) +i = 29 +v = i+1 | i+2 << 32 | i+3 << 48 +self.check_register_unsigned(gpr, 'fp', v) +i = 30 +v = i+1 | i+2 << 32 | i+3 << 48 +self.check_register_unsigned(gpr, 'lr', v) +i = 31 +v = i+1 | i+2 << 32 | i+3 << 48 +self.check_register_unsigned(gpr, 'sp', v) +self.check_register_unsigned(gpr, 'pc', 0x1000) +self.check_register_unsigned(gpr, 'cpsr', 0x11223344) +self.check_register_unsigned(gpr, 'psr', 0x11223344) + +# Verify the FPR registers are all correct +fpr = registers.GetValueAtIndex(1) +for i in range(32): +v = "0x" +d = "0x" +s = "0x" +h = "0x" +for j in range(i+15, i-1, -1): +v += "%2.2x" % (j)
[Lldb-commits] [PATCH] D50192: Fix: ClangHighlighter.cpp should not be in CopyFiles, but in lldb-core targets
sgraenitz abandoned this revision. sgraenitz added a comment. Yep https://reviews.llvm.org/D50192 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49750: Add support for ARM and ARM64 breakpad generated minidump files.
zturner added a comment. Please remember to test with the cmake build when you add or remove files, as that is the build that all of the buildbots use. I almost reverted this since it broke every LLDB buildbot, but I noticed that it's just forgetting to remove the files from the CMakeLists.txt so I'll fix it. Repository: rL LLVM https://reviews.llvm.org/D49750 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D49750: Add support for ARM and ARM64 breakpad generated minidump files.
Please remember to test with the cmake build when you add or remove files, as that is the build that all of the buildbots use. I almost reverted this since it broke every LLDB buildbot, but I noticed that it's just forgetting to remove the files from the CMakeLists.txt so I'll fix it. On Thu, Aug 2, 2018 at 9:46 AM Phabricator via Phabricator < revi...@reviews.llvm.org> wrote: > This revision was automatically updated to reflect the committed changes. > Closed by commit rL338734: Add support for ARM and ARM64 breakpad > generated minidump files (authored by gclayton, committed by ). > Herald added a subscriber: llvm-commits. > > Changed prior to commit: > https://reviews.llvm.org/D49750?vs=158631&id=158784#toc > > Repository: > rL LLVM > > https://reviews.llvm.org/D49750 > > Files: > lldb/trunk/include/lldb/Target/Target.h > lldb/trunk/lldb.xcodeproj/project.pbxproj > lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme > > lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py > > lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp > > lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp > > lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp > lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp > lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h > lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp > > lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp > lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h > > lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp > > lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h > lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp > lldb/trunk/source/Target/Target.cpp > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338746 - Fix CMake build.
Author: zturner Date: Thu Aug 2 10:44:41 2018 New Revision: 338746 URL: http://llvm.org/viewvc/llvm-project?rev=338746&view=rev Log: Fix CMake build. Some new files were committed to the repository but not added to the CMakeLists.txt, so this patch fixes the build. Modified: lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt Modified: lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt?rev=338746&r1=338745&r2=338746&view=diff == --- lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt (original) +++ lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt Thu Aug 2 10:44:41 2018 @@ -1,6 +1,8 @@ add_lldb_library(lldbPluginProcessMinidump PLUGIN MinidumpTypes.cpp MinidumpParser.cpp + RegisterContextMinidump_ARM.cpp + RegisterContextMinidump_ARM64.cpp RegisterContextMinidump_x86_32.cpp RegisterContextMinidump_x86_64.cpp ProcessMinidump.cpp ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50071: Use rich mangling information in Symtab::InitNameIndexes()
sgraenitz added a comment. > (However if you are interested in something like this, then it might be > interesting to look at whether this MethodName stuff couldn't be properly > pluginified. Something like where a Language class registers a callback for a > specific mangling type, and then accessing that through this) Yes this sounds more like a plan. An isolated refactoring patch without would be appropriate I think. In contrast, making a quick fix just to avoid the `llvm::Any` seems less appealing to me. Comment at: include/lldb/Core/RichManglingInfo.h:83-84 +public: + RichManglingInfo *SetItaniumInfo(); + RichManglingInfo *SetLegacyCxxParserInfo(const ConstString &mangled); + labath wrote: > sgraenitz wrote: > > labath wrote: > > > I find it odd that one of these functions is stateless > > > (`SetLegacyCxxParserInfo` takes the string which initializes the object > > > as an argument), while the other receives the state magically via the IPD > > > accessor. > > > > > > Would it be possible to change it so that the other option is stateless > > > too (`SetItaniumInfo(ConstString mangled)`)? > > > > > > We could change `RichManglingInfo` to return the full demangled name too, > > > so that you have access to the demangled name via this API too (which /I > > > think/ is the reason why you created a separate > > > `GetItaniumRichDemangleInfo` function). > > > Would it be possible to change it so that the other option is stateless > > > too (`SetItaniumInfo(ConstString mangled)`)? > > I think that would be misleading for the reader. Symmetry is always nice to > > indicate congruent behavior, but this is not the case here. The fallback > > C++ parser version mimics the previous behavior: demangle the name in step > > 1 and if that succeeds, parse it with `CPlusPlusLanguage::MethodName` to > > decode its properties. The IPD does that in a single step and so there is > > nothing to do in `SetItaniumInfo()`. `SetLegacyCxxParserInfo()` on the > > other hand has to create a `CPlusPlusLanguage::MethodName` from the mangled > > string. > > > > > We could change `RichManglingInfo` to return the full demangled name too, > > > so that you have access to the demangled name via this API too (which /I > > > think/ is the reason why you created a separate > > > GetItaniumRichDemangleInfo function). > > The interface wants to provide access to the name's encoded properties. > > That doesn't really include the demangled "human readable" string > > representation (it's also not needed in > > `Symtab::RegisterMangledNameEntry()`). > > > > Of course `Symtab::InitNameIndexes()` will ask for `GetDemangledName()` > > just after processing the mangled one. I think chances are good that for > > symbols that are not filtered out anyway, we reached > > `DemangleWithRichManglingInfo()` earlier and it will be in the string pool > > already (see Mangled.cpp:322). Otherwise, yes it will be demangled in with > > a new IPD instance. > > > > I think it's not bad to keep these cases as they are. I would propose to > > investigate the performance of the current implementation in more detail > > and think about the benefits before mixing them. Not sure at all, if it > > would bring measurable gain. > I don't see how this would be misleading. Both versions provide a way to > access the name's properties. The fact that they take slightly different > inputs (one takes a mangled name, one demangled) makes them slightly > different, but I don't find that too troublesome. We could encode that > difference in the method name to make it more obvious. What troubles me more > is that you have two-step initialization for the IPD case. It's always nice > to avoid that, and that's particularly important when it's asymmetric with > the other method. > > Let me try to elaborate on how I'd do this. `RichManglingContext` (ps: maybe > it's not correct to call this a *mangling* context, because the second method > does not use mangled names. `RichMethodContext` ?) would have two methods: > `fromItaniumName(ConstString ItaniumMangled)` and > `fromCxxMethodName(ConstString Name)`. Both would return `RichManglingInfo` > (`RichMethodInfo` ?) as they do now. > > Then the usage would be something like: > ``` > case eManglingSchemeItanium: > auto *info = context.fromItaniumName(m_mangled); > m_demangled.SetCStringWithMangledCounterPart(info->GetFullName(), > m_mangled); > return info; > > case eManglingSchemeMSVC: > > m_demangled.SetCStringWithMangledCounterpart(demangle_manually(m_mangled), > m_mangled); > return context.fromCxxMethodName(m_demangled); > ``` > The only change necessary for this is to include the full demangled name in > the "name's encoded properties". While that may not be a *property* of the > name by the strictest definition, I don't think it's much of a stretch to > include it there, and it does not require making any compromi
[Lldb-commits] [PATCH] D49632: [lldb-mi] Re-implement MI HandleProcessEventStateSuspended.
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. Hmm.. yeah, this looks more like a side-channel than a proper part of the MI protocol. That said, this is also what the original code was doing, so we can investigate the proper protocol separately. https://reviews.llvm.org/D49632 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338769 - [lldbsuite, windows] Mark tests as XFAIL on Windows or skip them
Author: stella.stamenova Date: Thu Aug 2 14:26:19 2018 New Revision: 338769 URL: http://llvm.org/viewvc/llvm-project?rev=338769&view=rev Log: [lldbsuite, windows] Mark tests as XFAIL on Windows or skip them Summary: 1) Several tests that are flakey on windows fail the run even if they are marked as expected to be flakey. This is because they fail frequently enough that even a retry won't help 2) Skip several tests on Windows that will occasionally hang rather than failing or exiting. This is causing the entire test suite to hang Reviewers: asmith, labath, zturner Reviewed By: zturner Differential Revision: https://reviews.llvm.org/D50198 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py lldb/trunk/packages/Python/lldbsuite/test/python_api/event/TestEvents.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py?rev=338769&r1=338768&r2=338769&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py Thu Aug 2 14:26:19 2018 @@ -21,7 +21,7 @@ class AttachResumeTestCase(TestBase): @skipIfRemote @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19310') -@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") +@skipIfWindows # llvm.org/pr24778, llvm.org/pr21753 def test_attach_continue_interrupt_detach(self): """Test attach/continue/interrupt/detach""" self.build() Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py?rev=338769&r1=338768&r2=338769&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py Thu Aug 2 14:26:19 2018 @@ -18,12 +18,14 @@ class BreakpointIgnoreCountTestCase(Test mydir = TestBase.compute_mydir(__file__) +@skipIfWindows # This test will hang on windows llvm.org/pr21753 def test_with_run_command(self): """Exercise breakpoint ignore count with 'breakpoint set -i '.""" self.build() self.breakpoint_ignore_count() @add_test_categories(['pyapi']) +@skipIfWindows # This test will hang on windows llvm.org/pr21753 def test_with_python_api(self): """Use Python APIs to set breakpoint ignore count.""" self.build() Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py?rev=338769&r1=338768&r2=338769&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py Thu Aug 2 14:26:19 2018 @@ -24,7 +24,9 @@ class MemoryCacheTestCase(TestBase): # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') -@expectedFlakeyOS(oslist=["windows"]) +# The test is actually flakey on Windows, failing every dozen or so runs, but even with the flakey +# decorator it still fails +@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr38373") def test_memory_cache(self): """Test the MemoryCache class with a sequence of 'memory read' and 'memory write' operations.""" self.build() Modified: lldb/trunk/packages/Python/lldbsuite/test/f
[Lldb-commits] [lldb] r338772 - [lldb] Remove unused variable.
Author: dlj Date: Thu Aug 2 14:45:05 2018 New Revision: 338772 URL: http://llvm.org/viewvc/llvm-project?rev=338772&view=rev Log: [lldb] Remove unused variable. The use of this variable was removed in r338734. It now causes unused variable warnings. Modified: lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp Modified: lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp?rev=338772&r1=338771&r2=338772&view=diff == --- lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp (original) +++ lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp Thu Aug 2 14:45:05 2018 @@ -56,7 +56,6 @@ RegisterContextSP ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) { RegisterContextSP reg_ctx_sp; uint32_t concrete_frame_idx = 0; - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); if (frame) concrete_frame_idx = frame->GetConcreteFrameIndex(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49750: Add support for ARM and ARM64 breakpad generated minidump files.
stella.stamenova added a comment. There are a number of minidump tests that started failing for us on both Linux and Windows and I suspect it's due to this change. Did the unit tests pass for you with the changes on either Linux or Windows? Failing Tests (6): lldb-Unit :: Process/minidump/./LLDBMinidumpTests/MinidumpParserTest.GetMemoryListNotPadded lldb-Unit :: Process/minidump/./LLDBMinidumpTests/MinidumpParserTest.GetMemoryListPadded lldb-Unit :: Process/minidump/./LLDBMinidumpTests/MinidumpParserTest.GetModuleListNotPadded lldb-Unit :: Process/minidump/./LLDBMinidumpTests/MinidumpParserTest.GetModuleListPadded lldb-Unit :: Process/minidump/./LLDBMinidumpTests/MinidumpParserTest.GetThreadListNotPadded lldb-Unit :: Process/minidump/./LLDBMinidumpTests/MinidumpParserTest.GetThreadListPadded Repository: rL LLVM https://reviews.llvm.org/D49750 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50225: Use a DenseMap for looking up functions by UID in CompileUnit::FindFunctionByUID
teemperor created this revision. teemperor added a reviewer: vsk. Instead of iterating over our vector of functions, we might as well use a map here to directly get the function we need. Thanks to Vedant for pointing this out. Repository: rLLDB LLDB https://reviews.llvm.org/D50225 Files: include/lldb/Symbol/CompileUnit.h source/Symbol/CompileUnit.cpp Index: source/Symbol/CompileUnit.cpp === --- source/Symbol/CompileUnit.cpp +++ source/Symbol/CompileUnit.cpp @@ -106,6 +106,7 @@ // Add a function to this compile unit //-- void CompileUnit::AddFunction(FunctionSP &funcSP) { + m_function_uid_to_index[funcSP->GetID()] = m_functions.size(); // TODO: order these by address m_functions.push_back(funcSP); } @@ -163,18 +164,10 @@ //} FunctionSP CompileUnit::FindFunctionByUID(lldb::user_id_t func_uid) { - FunctionSP funcSP; - if (!m_functions.empty()) { -std::vector::const_iterator pos; -std::vector::const_iterator end = m_functions.end(); -for (pos = m_functions.begin(); pos != end; ++pos) { - if ((*pos)->GetID() == func_uid) { -funcSP = *pos; -break; - } -} - } - return funcSP; + auto it = m_function_uid_to_index.find(func_uid); + if (it == m_function_uid_to_index.end()) +return FunctionSP(); + return m_functions[it->second]; } lldb::LanguageType CompileUnit::GetLanguage() { Index: include/lldb/Symbol/CompileUnit.h === --- include/lldb/Symbol/CompileUnit.h +++ include/lldb/Symbol/CompileUnit.h @@ -18,6 +18,8 @@ #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" +#include "llvm/ADT/DenseMap.h" + namespace lldb_private { //-- /// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" @@ -418,6 +420,9 @@ std::vector m_functions; ///< The sparsely populated list of ///shared pointers to functions ///< that gets populated as functions get partially parsed. + + /// Maps function UIDs to indexes in m_functions. + llvm::DenseMap m_function_uid_to_index; std::vector m_imported_modules; ///< All modules, including the ///current module, imported by ///this Index: source/Symbol/CompileUnit.cpp === --- source/Symbol/CompileUnit.cpp +++ source/Symbol/CompileUnit.cpp @@ -106,6 +106,7 @@ // Add a function to this compile unit //-- void CompileUnit::AddFunction(FunctionSP &funcSP) { + m_function_uid_to_index[funcSP->GetID()] = m_functions.size(); // TODO: order these by address m_functions.push_back(funcSP); } @@ -163,18 +164,10 @@ //} FunctionSP CompileUnit::FindFunctionByUID(lldb::user_id_t func_uid) { - FunctionSP funcSP; - if (!m_functions.empty()) { -std::vector::const_iterator pos; -std::vector::const_iterator end = m_functions.end(); -for (pos = m_functions.begin(); pos != end; ++pos) { - if ((*pos)->GetID() == func_uid) { -funcSP = *pos; -break; - } -} - } - return funcSP; + auto it = m_function_uid_to_index.find(func_uid); + if (it == m_function_uid_to_index.end()) +return FunctionSP(); + return m_functions[it->second]; } lldb::LanguageType CompileUnit::GetLanguage() { Index: include/lldb/Symbol/CompileUnit.h === --- include/lldb/Symbol/CompileUnit.h +++ include/lldb/Symbol/CompileUnit.h @@ -18,6 +18,8 @@ #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" +#include "llvm/ADT/DenseMap.h" + namespace lldb_private { //-- /// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" @@ -418,6 +420,9 @@ std::vector m_functions; ///< The sparsely populated list of ///shared pointers to functions ///< that gets populated as functions get partially parsed. + + /// Maps function UIDs to indexes in m_functions. + llvm::DenseMap m_function_uid_to_index; std::vector m_imported_modules; ///< All modules, including the ///current module, imported by ///this ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D49750: Add support for ARM and ARM64 breakpad generated minidump files.
teemperor added a comment. I don't see this mentioned here yet, so: This patch also seems to introduce a few hundred warnings with -Wextended-offsetof (which is enabled by default on the macOS builds): [...]llvm/tools/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp:510:5: warning: using extended field designator is an extension [-Wextended-offsetof] DEF_S(20), ^ [...]llvm/tools/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp:67:25: note: expanded from macro 'DEF_S' "s" #i, nullptr, 4, OFFSET(v[i * 16]), eEncodingVector, \ ^ [...]llvm/tools/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp:29:20: note: expanded from macro 'OFFSET' #define OFFSET(r) (offsetof(RegisterContextMinidump_ARM64::Context, r)) ^~~ [...]stddef.h:120:24: note: expanded from macro 'offsetof' #define offsetof(t, d) __builtin_offsetof(t, d) ^ ~ (And the tests also fail on macOS, but they are probably fixed when the Linux/Windows tests are fixed). Repository: rL LLVM https://reviews.llvm.org/D49750 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D50161: Add raw_ostream wrapper to the Stream class
teemperor updated this revision to Diff 158926. teemperor added a reviewer: labath. teemperor added a comment. - Renamed m_forward_to to m_target. - Added a getter to allow external code to use the raw_ostream API. - Renamed m_forward to m_forwarder. @labath Thanks, fixed the problems you pointed out. I already made the API public in this patch, it's probably good for encouraging people to use LLVM's raw_ostream classes. https://reviews.llvm.org/D50161 Files: include/lldb/Utility/Stream.h source/Utility/Stream.cpp Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -23,11 +23,11 @@ Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order) : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order), - m_indent_level(0) {} + m_indent_level(0), m_forwarder(*this) {} Stream::Stream() : m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()), - m_indent_level(0) {} + m_indent_level(0), m_forwarder(*this) {} //-- // Destructor Index: include/lldb/Utility/Stream.h === --- include/lldb/Utility/Stream.h +++ include/lldb/Utility/Stream.h @@ -15,6 +15,7 @@ #include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderInvalid #include "llvm/ADT/StringRef.h" // for StringRef #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" #include #include // for size_t @@ -52,6 +53,17 @@ //-- Stream(); + // FIXME: Streams should not be copyable. + Stream(const Stream &other) : m_forwarder(*this) { (*this) = other; } + + Stream &operator=(const Stream &rhs) { +m_flags = rhs.m_flags; +m_addr_size = rhs.m_addr_size; +m_byte_order = rhs.m_byte_order; +m_indent_level = rhs.m_indent_level; +return *this; + } + //-- /// Destructor //-- @@ -520,6 +532,13 @@ //-- size_t PutULEB128(uint64_t uval); + //-- + /// Returns a raw_ostream that forwards the data to this Stream object. + //-- + llvm::raw_ostream &AsRawOstream() { +return m_forwarder; + } + protected: //-- // Member variables @@ -548,6 +567,34 @@ /// The number of bytes that were appended to the stream. //-- virtual size_t WriteImpl(const void *src, size_t src_len) = 0; + + //-- + /// @class RawOstreamForward Stream.h "lldb/Utility/Stream.h" + /// This is a wrapper class that exposes a raw_ostream interface that just + /// forwards to an LLDB stream, allowing to reuse LLVM algorithms that take + /// a raw_ostream within the LLDB code base. + //-- + class RawOstreamForward : public llvm::raw_ostream { +// Note: This stream must *not* maintain its own buffer, but instead +// directly write everything to the internal Stream class. Without this, +// we would run into the problem that the Stream written byte count would +// differ from the actually written bytes by the size of the internal +// raw_ostream buffer. + +Stream &m_target; +void write_impl(const char *Ptr, size_t Size) override { + m_target.Write(Ptr, Size); +} + +uint64_t current_pos() const override { + return m_target.GetWrittenBytes(); +} + + public: +RawOstreamForward(Stream &target) +: llvm::raw_ostream(/*unbuffered*/ true), m_target(target) {} + }; + RawOstreamForward m_forwarder; }; } // namespace lldb_private Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -23,11 +23,11 @@ Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order) : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order), - m_indent_level(0) {} + m_indent_level(0), m_forwarder(*this) {} Stream::Stream() : m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()), - m_indent_level(0) {} + m_indent_level(0), m_forwarder(*this) {} //-- // Destructor Index: include/lldb/Utility/Stream.h ==
[Lldb-commits] [PATCH] D50162: Replace LLDB's LEB128 implementation with the one from LLVM
teemperor updated this revision to Diff 158930. teemperor added a reviewer: labath. teemperor added a comment. - Fixed compilation errors after changes in parent revision. https://reviews.llvm.org/D50162 Files: source/Utility/Stream.cpp Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -12,6 +12,7 @@ #include "lldb/Utility/Endian.h" #include "lldb/Utility/VASPrintf.h" #include "llvm/ADT/SmallString.h" // for SmallString +#include "llvm/Support/LEB128.h" #include @@ -49,47 +50,20 @@ // Put an SLEB128 "uval" out to the stream using the printf format in "format". //-- size_t Stream::PutSLEB128(int64_t sval) { - size_t bytes_written = 0; - if (m_flags.Test(eBinary)) { -bool more = true; -while (more) { - uint8_t byte = sval & 0x7fu; - sval >>= 7; - /* sign bit of byte is 2nd high order bit (0x40) */ - if ((sval == 0 && !(byte & 0x40)) || (sval == -1 && (byte & 0x40))) -more = false; - else -// more bytes to come -byte |= 0x80u; - bytes_written += Write(&byte, 1); -} - } else { -bytes_written = Printf("0x%" PRIi64, sval); - } - - return bytes_written; + if (m_flags.Test(eBinary)) +return llvm::encodeSLEB128(sval, m_forwarder); + else +return Printf("0x%" PRIi64, sval); } //-- // Put an ULEB128 "uval" out to the stream using the printf format in "format". //-- size_t Stream::PutULEB128(uint64_t uval) { - size_t bytes_written = 0; - if (m_flags.Test(eBinary)) { -do { - - uint8_t byte = uval & 0x7fu; - uval >>= 7; - if (uval != 0) { -// more bytes to come -byte |= 0x80u; - } - bytes_written += Write(&byte, 1); -} while (uval != 0); - } else { -bytes_written = Printf("0x%" PRIx64, uval); - } - return bytes_written; + if (m_flags.Test(eBinary)) +return llvm::encodeULEB128(uval, m_forwarder); + else +return Printf("0x%" PRIx64, uval); } //-- Index: source/Utility/Stream.cpp === --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -12,6 +12,7 @@ #include "lldb/Utility/Endian.h" #include "lldb/Utility/VASPrintf.h" #include "llvm/ADT/SmallString.h" // for SmallString +#include "llvm/Support/LEB128.h" #include @@ -49,47 +50,20 @@ // Put an SLEB128 "uval" out to the stream using the printf format in "format". //-- size_t Stream::PutSLEB128(int64_t sval) { - size_t bytes_written = 0; - if (m_flags.Test(eBinary)) { -bool more = true; -while (more) { - uint8_t byte = sval & 0x7fu; - sval >>= 7; - /* sign bit of byte is 2nd high order bit (0x40) */ - if ((sval == 0 && !(byte & 0x40)) || (sval == -1 && (byte & 0x40))) -more = false; - else -// more bytes to come -byte |= 0x80u; - bytes_written += Write(&byte, 1); -} - } else { -bytes_written = Printf("0x%" PRIi64, sval); - } - - return bytes_written; + if (m_flags.Test(eBinary)) +return llvm::encodeSLEB128(sval, m_forwarder); + else +return Printf("0x%" PRIi64, sval); } //-- // Put an ULEB128 "uval" out to the stream using the printf format in "format". //-- size_t Stream::PutULEB128(uint64_t uval) { - size_t bytes_written = 0; - if (m_flags.Test(eBinary)) { -do { - - uint8_t byte = uval & 0x7fu; - uval >>= 7; - if (uval != 0) { -// more bytes to come -byte |= 0x80u; - } - bytes_written += Write(&byte, 1); -} while (uval != 0); - } else { -bytes_written = Printf("0x%" PRIx64, uval); - } - return bytes_written; + if (m_flags.Test(eBinary)) +return llvm::encodeULEB128(uval, m_forwarder); + else +return Printf("0x%" PRIx64, uval); } //-- ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits