llvm-project/lldb/unittests
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
..
Breakpoint Rename Error -> Status. 2017-05-12 04:51:55 +00:00
Core Unit test for Symtab::InitNameIndexes 2018-08-02 10:13:18 +00:00
Editline Move PseudoTerminal to the lldb_private namespace 2017-12-11 10:09:14 +00:00
Expression Really fix ClangParserTest 2018-06-05 10:29:48 +00:00
Host [FileSpec] Make style argument mandatory for SetFile. NFC 2018-06-13 22:54:52 +00:00
Interpreter Modernize completion tests 2018-06-29 09:06:42 +00:00
Language [LLDB] Added syntax highlighting support 2018-08-02 00:30:15 +00:00
ObjectFile ELF: Replace the header-extension unit test with a lit one 2018-07-19 14:38:30 +00:00
Platform Use llvm::VersionTuple instead of manual version marshalling 2018-06-18 15:02:23 +00:00
Process Add support for parsing Breakpad minidump files that can have extra padding in the module, thread and memory lists. 2018-07-23 14:16:08 +00:00
ScriptInterpreter Added new API to SBStructuredData class 2017-05-29 08:25:46 +00:00
Signals Make LLDB skip server-client roundtrip for signals that don't require any actions 2017-03-07 21:34:40 +00:00
Symbol Refactor ExecuteAndWait to take StringRefs. 2018-06-12 17:43:52 +00:00
SymbolFile Revert "PDB support of function-level linking and splitted functions" 2018-06-06 09:16:00 +00:00
Target Remove UUID::SetFromCString 2018-06-21 15:24:39 +00:00
TestingSupport cmake + xcode: prevent gtests from using includes from project root 2017-10-03 21:20:18 +00:00
UnwindAssembly [LLDB] Initial version of PPC64 InstEmulation 2018-02-27 18:42:46 +00:00
Utility Add byte counting mechanism to LLDB's Stream class. 2018-08-02 16:38:34 +00:00
debugserver [CMake] Need to set WITH_LOCKDOWN on debugserver target 2017-09-06 20:15:43 +00:00
tools Remove the unused m_signal member variable, but leave the code that gets it out of the json. 2018-07-12 03:52:46 +00:00
CMakeLists.txt [cmake, unittests] Fix the CMake file for the LLDB unittests to support multiple configurations 2018-05-09 19:58:51 +00:00
gtest_common.h [Windows] Remove the #include <eh.h> hack. 2017-03-03 20:21:59 +00:00