diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-01-17 20:45:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-01-17 20:45:01 +0000 |
commit | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (patch) | |
tree | 4adf86a776049cbf7f69a1929c4babcbbef925eb /lldb/source/Utility/Stream.cpp | |
parent | 7cc9cf2bf09f069cb2dd947ead05d0b54301fb71 (diff) |
Notes
Diffstat (limited to 'lldb/source/Utility/Stream.cpp')
-rw-r--r-- | lldb/source/Utility/Stream.cpp | 82 |
1 files changed, 18 insertions, 64 deletions
diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index c48a12acd906..b336cb6b5185 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -11,6 +11,7 @@ #include "lldb/Utility/Endian.h" #include "lldb/Utility/VASPrintf.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/Format.h" #include "llvm/Support/LEB128.h" #include <string> @@ -76,28 +77,27 @@ void Stream::QuotedCString(const char *cstr, const char *format) { // Put an address "addr" out to the stream with optional prefix and suffix // strings. -void Stream::Address(uint64_t addr, uint32_t addr_size, const char *prefix, - const char *suffix) { +void lldb_private::DumpAddress(llvm::raw_ostream &s, uint64_t addr, + uint32_t addr_size, const char *prefix, + const char *suffix) { if (prefix == nullptr) prefix = ""; if (suffix == nullptr) suffix = ""; - // int addr_width = m_addr_size << 1; - // Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_width, addr, suffix); - Printf("%s0x%0*" PRIx64 "%s", prefix, addr_size * 2, addr, suffix); + s << prefix << llvm::format_hex(addr, 2 + 2 * addr_size) << suffix; } // Put an address range out to the stream with optional prefix and suffix // strings. -void Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr, - uint32_t addr_size, const char *prefix, - const char *suffix) { +void lldb_private::DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, + uint64_t hi_addr, uint32_t addr_size, + const char *prefix, const char *suffix) { if (prefix && prefix[0]) - PutCString(prefix); - Address(lo_addr, addr_size, "["); - Address(hi_addr, addr_size, "-", ")"); + s << prefix; + DumpAddress(s, lo_addr, addr_size, "["); + DumpAddress(s, hi_addr, addr_size, "-", ")"); if (suffix && suffix[0]) - PutCString(suffix); + s << suffix; } size_t Stream::PutChar(char ch) { return Write(&ch, 1); } @@ -160,65 +160,19 @@ Stream &Stream::operator<<(const void *p) { return *this; } -// Stream a uint8_t "uval" out to this stream. -Stream &Stream::operator<<(uint8_t uval) { - PutHex8(uval); - return *this; -} - -// Stream a uint16_t "uval" out to this stream. -Stream &Stream::operator<<(uint16_t uval) { - PutHex16(uval, m_byte_order); - return *this; -} - -// Stream a uint32_t "uval" out to this stream. -Stream &Stream::operator<<(uint32_t uval) { - PutHex32(uval, m_byte_order); - return *this; -} - -// Stream a uint64_t "uval" out to this stream. -Stream &Stream::operator<<(uint64_t uval) { - PutHex64(uval, m_byte_order); - return *this; -} - -// Stream a int8_t "sval" out to this stream. -Stream &Stream::operator<<(int8_t sval) { - Printf("%i", static_cast<int>(sval)); - return *this; -} - -// Stream a int16_t "sval" out to this stream. -Stream &Stream::operator<<(int16_t sval) { - Printf("%i", static_cast<int>(sval)); - return *this; -} - -// Stream a int32_t "sval" out to this stream. -Stream &Stream::operator<<(int32_t sval) { - Printf("%i", static_cast<int>(sval)); - return *this; -} - -// Stream a int64_t "sval" out to this stream. -Stream &Stream::operator<<(int64_t sval) { - Printf("%" PRIi64, sval); - return *this; -} - // Get the current indentation level -int Stream::GetIndentLevel() const { return m_indent_level; } +unsigned Stream::GetIndentLevel() const { return m_indent_level; } // Set the current indentation level -void Stream::SetIndentLevel(int indent_level) { m_indent_level = indent_level; } +void Stream::SetIndentLevel(unsigned indent_level) { + m_indent_level = indent_level; +} // Increment the current indentation level -void Stream::IndentMore(int amount) { m_indent_level += amount; } +void Stream::IndentMore(unsigned amount) { m_indent_level += amount; } // Decrement the current indentation level -void Stream::IndentLess(int amount) { +void Stream::IndentLess(unsigned amount) { if (m_indent_level >= amount) m_indent_level -= amount; else |