9#ifndef LLDB_UTILITY_STREAM_H
10#define LLDB_UTILITY_STREAM_H
15#include "llvm/ADT/StringRef.h"
16#include "llvm/Support/FormatVariadic.h"
17#include "llvm/Support/raw_ostream.h"
76 Stream(
bool colors =
false);
112 size_t Write(
const void *src,
size_t src_len) {
113 size_t appended_byte_count =
WriteImpl(src, src_len);
115 return appended_byte_count;
147 __attribute__((__format__(__printf__, 2, 3)));
156 size_t PutHex8(uint8_t uvalue);
158 size_t PutNHex8(
size_t n, uint8_t uvalue);
161 lldb::ByteOrder byte_order =
lldb::eByteOrderInvalid);
164 lldb::ByteOrder byte_order =
lldb::eByteOrderInvalid);
167 lldb::ByteOrder byte_order =
lldb::eByteOrderInvalid);
169 size_t PutMaxHex64(uint64_t uvalue,
size_t byte_size,
170 lldb::ByteOrder byte_order =
lldb::eByteOrderInvalid);
172 lldb::ByteOrder byte_order =
lldb::eByteOrderInvalid);
175 lldb::ByteOrder byte_order =
lldb::eByteOrderInvalid);
178 lldb::ByteOrder byte_order =
lldb::eByteOrderInvalid);
186 lldb::ByteOrder src_byte_order =
lldb::eByteOrderInvalid,
187 lldb::ByteOrder dst_byte_order =
lldb::eByteOrderInvalid);
191 lldb::ByteOrder src_byte_order =
lldb::eByteOrderInvalid,
192 lldb::ByteOrder dst_byte_order =
lldb::eByteOrderInvalid);
204 Stream &operator<<(const
char *cstr);
216 Stream &operator<<(const
void *p);
226 Stream &operator<<(
char ch);
228 Stream &operator<<(uint8_t uval) = delete;
229 Stream &operator<<(uint16_t uval) = delete;
230 Stream &operator<<(uint32_t uval) = delete;
231 Stream &operator<<(uint64_t uval) = delete;
232 Stream &operator<<(int8_t sval) = delete;
233 Stream &operator<<(int16_t sval) = delete;
234 Stream &operator<<(int32_t sval) = delete;
235 Stream &operator<<(int64_t sval) = delete;
275 llvm::StringRef text,
337 void Offset(uint32_t offset, const
char *format = "0x%8.8x: ");
349 size_t Printf(const
char *format, ...) __attribute__((format(printf, 2, 3)));
353 template <typename...
Args>
void Format(const
char *format,
Args &&... args) {
354 PutCString(llvm::formatv(format, std::forward<Args>(args)...).str());
367 void QuotedCString(
const char *cstr,
const char *format =
"\"%s\"");
414 void _PutHex8(uint8_t uvalue,
bool add_prefix);
428 virtual size_t WriteImpl(
const void *src,
size_t src_len) = 0;
453 enable_colors(colors);
478void DumpAddress(llvm::raw_ostream &s, uint64_t addr, uint32_t addr_size,
479 const char *prefix =
nullptr,
const char *suffix =
nullptr);
503void DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, uint64_t hi_addr,
504 uint32_t addr_size,
const char *prefix =
nullptr,
505 const char *suffix =
nullptr);
A command line argument class.
size_t operator*() const
Returns the number of bytes written to the given Stream since this ByteDelta object was created.
size_t m_start
Bytes we have written so far when ByteDelta was created.
This is a wrapper class that exposes a raw_ostream interface that just forwards to an LLDB stream,...
uint64_t current_pos() const override
RawOstreamForward(Stream &target, bool colors=false)
void write_impl(const char *Ptr, size_t Size) override
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
virtual size_t WriteImpl(const void *src, size_t src_len)=0
Output character bytes to the stream.
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.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
@ eBinary
Get and put data as binary instead of as the default string mode.
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)
Stream & operator=(const Stream &rhs)
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.
std::size_t m_bytes_written
Number of bytes written so far.
void PutCStringColorHighlighted(llvm::StringRef text, std::optional< HighlightSettings > settings=std::nullopt)
Output a C string to the stream with color highlighting.
void _PutHex8(uint8_t uvalue, bool add_prefix)
virtual void Flush()=0
Flush the stream.
size_t EOL()
Output and End of Line character to the stream.
size_t GetWrittenBytes() const
lldb::ByteOrder m_byte_order
Byte order to use when encoding scalar types.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Stream(const Stream &other)
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)
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.
A class that represents a running process on the host machine.
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.
Struct to store information for color highlighting in the stream.
llvm::StringRef pattern
Regex pattern for highlighting.
llvm::StringRef prefix
ANSI color code to start colorization.
llvm::StringRef suffix
ANSI color code to end colorization.
HighlightSettings(llvm::StringRef p, llvm::StringRef pre, llvm::StringRef suf)