[lldb][NFC] Move Address and AddressRange functions out of Stream and let them take raw_ostream

Summary:
Yet another step on the long road towards getting rid of lldb's Stream class.

We probably should just make this some kind of member of Address/AddressRange, but it seems quite often we just push
in random integers in there and this is just about getting rid of Stream and not improving arbitrary APIs.

I had to rename another `DumpAddress` function in FormatEntity that is dumping the content of an address to make Clang happy.

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71052
This commit is contained in:
Raphael Isemann
2019-12-05 14:41:09 +01:00
parent 18b72d337e
commit 1462f5a4c1
17 changed files with 149 additions and 134 deletions

View File

@@ -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); }