llvm-project/lldb/source/Core
Raphael Isemann 92b16738a1 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

llvm-svn: 338733
2018-08-02 16:38:34 +00:00
..
Address.cpp Change AddressClass type from 'enum' to 'enum class'. 2018-06-26 13:06:54 +00:00
AddressRange.cpp Move ArchSpec to the Utility module 2017-11-13 16:16:33 +00:00
AddressResolver.cpp iwyu fixes for lldbCore. 2017-04-06 21:28:29 +00:00
AddressResolverFileLine.cpp iwyu fixes for lldbCore. 2017-04-06 21:28:29 +00:00
AddressResolverName.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
Broadcaster.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
CMakeLists.txt [LLDB] Added syntax highlighting support 2018-08-02 00:30:15 +00:00
Communication.cpp Typo fixes. 2018-05-29 09:10:46 +00:00
Debugger.cpp [LLDB] Added syntax highlighting support 2018-08-02 00:30:15 +00:00
Disassembler.cpp Change AddressClass type from 'enum' to 'enum class'. 2018-06-26 13:06:54 +00:00
DumpDataExtractor.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
DumpRegisterValue.cpp Move dumping code out of RegisterValue class 2018-07-24 15:48:13 +00:00
DynamicLoader.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
EmulateInstruction.cpp Move dumping code out of RegisterValue class 2018-07-24 15:48:13 +00:00
Event.cpp Reimplement EventDataBytes::Dump to avoid DumpDataExtractor 2018-07-24 10:49:14 +00:00
FileLineResolver.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
FileSpecList.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
FormatEntity.cpp Narrow the CompletionRequest API to being append-only. 2018-07-27 18:42:46 +00:00
Highlighter.cpp [LLDB] Added syntax highlighting support 2018-08-02 00:30:15 +00:00
IOHandler.cpp Narrow the CompletionRequest API to being append-only. 2018-07-27 18:42:46 +00:00
Listener.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
Mangled.cpp Use LLVM's new ItaniumPartialDemangler in LLDB 2018-07-25 15:19:04 +00:00
Module.cpp Use llvm::VersionTuple instead of manual version marshalling 2018-06-18 15:02:23 +00:00
ModuleChild.cpp *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
ModuleList.cpp Remove append parameter to FindGlobalVariables 2018-05-31 09:46:26 +00:00
Opcode.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
PluginManager.cpp Replace HostInfo::GetLLDBPath with specific functions 2018-06-19 15:09:07 +00:00
RegisterValue.cpp Move dumping code out of RegisterValue class 2018-07-24 15:48:13 +00:00
Scalar.cpp [IRInterpreter] Fix misevaluation of interpretation expressions with `urem`. 2018-07-12 00:31:04 +00:00
SearchFilter.cpp Update StructuredData::String to return StringRefs. 2017-05-12 05:49:54 +00:00
Section.cpp Add .debug_names section glue code 2018-06-01 12:06:45 +00:00
SourceManager.cpp [LLDB] Added syntax highlighting support 2018-08-02 00:30:15 +00:00
State.cpp iwyu fixes for lldbCore. 2017-04-06 21:28:29 +00:00
StreamAsynchronousIO.cpp Add byte counting mechanism to LLDB's Stream class. 2018-08-02 16:38:34 +00:00
StreamFile.cpp Add byte counting mechanism to LLDB's Stream class. 2018-08-02 16:38:34 +00:00
UserSettingsController.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
Value.cpp DWARFExpression: Convert file addresses to load addresses early on. 2018-05-03 23:32:47 +00:00
ValueObject.cpp Forward declare DumpValueObjectOptions in ValueObject.h 2018-05-26 14:34:49 +00:00
ValueObjectCast.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
ValueObjectChild.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
ValueObjectConstResult.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
ValueObjectConstResultCast.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
ValueObjectConstResultChild.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
ValueObjectConstResultImpl.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
ValueObjectDynamicValue.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
ValueObjectList.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
ValueObjectMemory.cpp Reflow paragraphs in comments. 2018-04-30 16:49:04 +00:00
ValueObjectRegister.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
ValueObjectSyntheticFilter.cpp Fix the libcxx set, multiset, vector and bitset formatters to work on references. 2018-07-13 19:28:32 +00:00
ValueObjectVariable.cpp Typo fixes. 2018-05-29 09:10:46 +00:00