13#include "llvm/ADT/SmallString.h"
14#include "llvm/Support/Format.h"
15#include "llvm/Support/LEB128.h"
27 : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order),
28 m_forwarder(*this, colors) {}
31 : m_flags(0), m_byte_order(endian::InlHostByteOrder()),
32 m_forwarder(*this, colors) {}
40 return old_byte_order;
51 return Printf(
"0x%" PRIi64, sval);
59 return Printf(
"0x%" PRIx64, uval);
64 size_t bytes_written = 0;
65 bytes_written =
Write(str.data(), str.size());
82 uint32_t addr_size,
const char *prefix,
84 if (prefix ==
nullptr)
86 if (suffix ==
nullptr)
88 s << prefix << llvm::format_hex(addr, 2 + 2 * addr_size) << suffix;
94 uint64_t hi_addr,
uint32_t addr_size,
95 const char *prefix,
const char *suffix) {
96 if (prefix && prefix[0])
100 if (suffix && suffix[0])
109 va_start(args, format);
117 llvm::SmallString<1024> buf;
121 size_t length = buf.size();
124 return Write(buf.c_str(), length);
133 return ind_length + str_length;
149 Write(str.data(), str.size());
155 Printf(
"0x%.*tx",
static_cast<int>(
sizeof(
const void *)) * 2, (ptrdiff_t)p);
196 va_start(args, format);
198 llvm::SmallString<1024> buf;
212 for (
size_t i = 0; i < n; ++i)
224 static char g_hex_to_ascii_hex_char[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
225 '6',
'7',
'8',
'9',
'a',
'b',
227 char nibble_chars[2];
228 nibble_chars[0] = g_hex_to_ascii_hex_char[(uvalue >> 4) & 0xf];
229 nibble_chars[1] = g_hex_to_ascii_hex_char[(uvalue >> 0) & 0xf];
230 Write(nibble_chars,
sizeof(nibble_chars));
247 for (
size_t byte = 0;
byte <
sizeof(uvalue); ++byte)
248 _PutHex8(
static_cast<uint8_t
>(uvalue >> (
byte * 8)),
false);
250 for (
size_t byte =
sizeof(uvalue) - 1;
byte <
sizeof(uvalue); --byte)
251 _PutHex8(
static_cast<uint8_t
>(uvalue >> (
byte * 8)),
false);
263 for (
size_t byte = 0;
byte <
sizeof(uvalue); ++byte)
264 _PutHex8(
static_cast<uint8_t
>(uvalue >> (
byte * 8)),
false);
266 for (
size_t byte =
sizeof(uvalue) - 1;
byte <
sizeof(uvalue); --byte)
267 _PutHex8(
static_cast<uint8_t
>(uvalue >> (
byte * 8)),
false);
279 for (
size_t byte = 0;
byte <
sizeof(uvalue); ++byte)
280 _PutHex8(
static_cast<uint8_t
>(uvalue >> (
byte * 8)),
false);
282 for (
size_t byte =
sizeof(uvalue) - 1;
byte <
sizeof(uvalue); --byte)
283 _PutHex8(
static_cast<uint8_t
>(uvalue >> (
byte * 8)),
false);
292 return PutHex8(
static_cast<uint8_t
>(uvalue));
298 return PutHex64(uvalue, byte_order);
339 const uint8_t *src =
static_cast<const uint8_t *
>(s);
343 if (src_byte_order == dst_byte_order) {
344 for (
size_t i = 0; i < src_len; ++i)
347 for (
size_t i = src_len; i > 0; --i)
367 const uint8_t *src =
static_cast<const uint8_t *
>(s);
370 if (src_byte_order == dst_byte_order) {
371 for (
size_t i = 0; i < src_len; ++i)
374 for (
size_t i = src_len; i > 0; --i)
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
bool Test(ValueType bit) const
Test a single flag bit.
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
A stream class that can stream formatted output to a file.
unsigned m_indent_level
Indention level.
size_t PrintfAsRawHex8(const char *format,...) __attribute__((__format__(__printf__
Format a C string from a printf style format and variable arguments and encode and append the resulti...
Flags & GetFlags()
The flags accessor.
lldb::ByteOrder GetByteOrder() const
size_t PutNHex8(size_t n, uint8_t uvalue)
uint32_t GetAddressByteSize() const
Get the address size in bytes.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
void Offset(uint32_t offset, const char *format="0x%8.8x: ")
Output an offset value.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t PutDouble(double d, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
size_t size_t PutHex8(uint8_t uvalue)
Append an uint8_t value in the hexadecimal format to the stream.
size_t PutStringAsRawHex8(llvm::StringRef s)
uint32_t m_addr_size
Size of an address in bytes.
size_t PutHex64(uint64_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
void SetAddressByteSize(uint32_t addr_size)
Set the address size in bytes.
RawOstreamForward m_forwarder
virtual ~Stream()
Destructor.
lldb::ByteOrder SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
size_t PutHex16(uint16_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
void QuotedCString(const char *cstr, const char *format="\"%s\"")
Output a quoted C string value to the stream.
size_t size_t PrintfVarArg(const char *format, va_list args)
size_t PutHex32(uint32_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
void SetIndentLevel(unsigned level)
Set the current indentation level.
Stream & operator<<(const char *cstr)
Output a NULL terminated C string cstr to the stream s.
Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order, bool colors=false)
Construct with flags and address size and byte order.
void _PutHex8(uint8_t uvalue, bool add_prefix)
size_t EOL()
Output and End of Line character to the stream.
lldb::ByteOrder m_byte_order
Byte order to use when encoding scalar types.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
size_t PutULEB128(uint64_t uval)
Output a ULEB128 number to the stream.
size_t PutBytesAsRawHex8(const void *src, size_t src_len, lldb::ByteOrder src_byte_order=lldb::eByteOrderInvalid, lldb::ByteOrder dst_byte_order=lldb::eByteOrderInvalid)
size_t PutLongDouble(long double ld, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
@ eBinary
Get and put data as binary instead of as the default string mode.
size_t PutSLEB128(int64_t uval)
Output a SLEB128 number to the stream.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
size_t PutPointer(void *ptr)
size_t PutRawBytes(const void *s, size_t src_len, lldb::ByteOrder src_byte_order=lldb::eByteOrderInvalid, lldb::ByteOrder dst_byte_order=lldb::eByteOrderInvalid)
size_t PutFloat(float f, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
size_t PutMaxHex64(uint64_t uvalue, size_t byte_size, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
unsigned GetIndentLevel() const
Get the current indentation level.
lldb::ByteOrder InlHostByteOrder()
A class that represents a running process on the host machine.
bool VASprintf(llvm::SmallVectorImpl< char > &buf, const char *fmt, va_list args)
void DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix=nullptr, const char *suffix=nullptr)
Output an address range to this stream.
void DumpAddress(llvm::raw_ostream &s, uint64_t addr, uint32_t addr_size, const char *prefix=nullptr, const char *suffix=nullptr)
Output an address value to this stream.
ByteOrder
Byte ordering definitions.