diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h --- a/lldb/include/lldb/Utility/Stream.h +++ b/lldb/include/lldb/Utility/Stream.h @@ -222,47 +222,6 @@ Stream &operator<<(int32_t sval) = delete; Stream &operator<<(int64_t sval) = delete; - /// Output an address value to this stream. - /// - /// Put an address \a addr out to the stream with optional \a prefix and \a - /// suffix strings. - /// - /// \param[in] addr - /// An address value. - /// - /// \param[in] addr_size - /// Size in bytes of the address, used for formatting. - /// - /// \param[in] prefix - /// A prefix C string. If nullptr, no prefix will be output. - /// - /// \param[in] suffix - /// A suffix C string. If nullptr, no suffix will be output. - void Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, - const char *suffix = nullptr); - - /// Output an address range to this stream. - /// - /// Put an address range \a lo_addr - \a hi_addr out to the stream with - /// optional \a prefix and \a suffix strings. - /// - /// \param[in] lo_addr - /// The start address of the address range. - /// - /// \param[in] hi_addr - /// The end address of the address range. - /// - /// \param[in] addr_size - /// Size in bytes of the address, used for formatting. - /// - /// \param[in] prefix - /// A prefix C string. If nullptr, no prefix will be output. - /// - /// \param[in] suffix - /// A suffix C string. If nullptr, no suffix will be output. - void AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, - const char *prefix = nullptr, const char *suffix = nullptr); - /// Output a C string to the stream. /// /// Print a C string \a cstr to the stream. @@ -452,6 +411,54 @@ RawOstreamForward m_forwarder; }; +/// Output an address value to this stream. +/// +/// Put an address \a addr out to the stream with optional \a prefix and \a +/// suffix strings. +/// +/// \param[in] s +/// The output stream. +/// +/// \param[in] addr +/// An address value. +/// +/// \param[in] addr_size +/// Size in bytes of the address, used for formatting. +/// +/// \param[in] prefix +/// A prefix C string. If nullptr, no prefix will be output. +/// +/// \param[in] suffix +/// A suffix C string. If nullptr, no suffix will be output. +void DumpAddress(llvm::raw_ostream &s, uint64_t addr, uint32_t addr_size, + const char *prefix = nullptr, const char *suffix = nullptr); + +/// Output an address range to this stream. +/// +/// Put an address range \a lo_addr - \a hi_addr out to the stream with +/// optional \a prefix and \a suffix strings. +/// +/// \param[in] s +/// The output stream. +/// +/// \param[in] lo_addr +/// The start address of the address range. +/// +/// \param[in] hi_addr +/// The end address of the address range. +/// +/// \param[in] addr_size +/// Size in bytes of the address, used for formatting. +/// +/// \param[in] prefix +/// A prefix C string. If nullptr, no prefix will be output. +/// +/// \param[in] suffix +/// A suffix C string. If nullptr, no suffix will be output. +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); + } // namespace lldb_private #endif // liblldb_Stream_h_ diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -418,13 +418,13 @@ section_sp->DumpName(s); s->Printf(" + %" PRIu64, m_offset); } else { - s->Address(m_offset, addr_size); + DumpAddress(s->AsRawOstream(), m_offset, addr_size); } break; case DumpStyleSectionPointerOffset: s->Printf("(Section *)%p + ", static_cast(section_sp.get())); - s->Address(m_offset, addr_size); + DumpAddress(s->AsRawOstream(), m_offset, addr_size); break; case DumpStyleModuleWithFileAddress: @@ -444,7 +444,7 @@ return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size); return false; } - s->Address(file_addr, addr_size); + DumpAddress(s->AsRawOstream(), file_addr, addr_size); if (style == DumpStyleModuleWithFileAddress && section_sp) s->PutChar(']'); } break; @@ -472,7 +472,7 @@ return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size); return false; } - s->Address(load_addr, addr_size); + DumpAddress(s->AsRawOstream(), load_addr, addr_size); } break; case DumpStyleResolvedDescription: @@ -754,7 +754,8 @@ if (dereferenced_addr.Dump(&strm, exe_scope, DumpStyleResolvedDescription, DumpStyleInvalid, addr_size)) { - s->Address(dereferenced_load_addr, addr_size, " -> ", " "); + DumpAddress(s->AsRawOstream(), dereferenced_load_addr, addr_size, + " -> ", " "); s->Write(strm.GetString().data(), strm.GetSize()); return true; } diff --git a/lldb/source/Core/AddressRange.cpp b/lldb/source/Core/AddressRange.cpp --- a/lldb/source/Core/AddressRange.cpp +++ b/lldb/source/Core/AddressRange.cpp @@ -161,7 +161,8 @@ s->PutChar('['); m_base_addr.Dump(s, target, style, fallback_style); s->PutChar('-'); - s->Address(m_base_addr.GetOffset() + GetByteSize(), addr_size); + DumpAddress(s->AsRawOstream(), m_base_addr.GetOffset() + GetByteSize(), + addr_size); s->PutChar(')'); return true; break; @@ -185,7 +186,8 @@ s->Printf("%s", module_sp->GetFileSpec().GetFilename().AsCString( "")); } - s->AddressRange(vmaddr, vmaddr + GetByteSize(), addr_size); + DumpAddressRange(s->AsRawOstream(), vmaddr, vmaddr + GetByteSize(), + addr_size); return true; } else if (fallback_style != Address::DumpStyleInvalid) { return Dump(s, target, fallback_style, Address::DumpStyleInvalid); diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/source/Core/DumpDataExtractor.cpp --- a/lldb/source/Core/DumpDataExtractor.cpp +++ b/lldb/source/Core/DumpDataExtractor.cpp @@ -467,9 +467,10 @@ } break; case eFormatPointer: - s->Address(DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, - item_bit_offset), - sizeof(addr_t)); + DumpAddress(s->AsRawOstream(), + DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, + item_bit_offset), + sizeof(addr_t)); break; case eFormatComplexInteger: { diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -414,9 +414,10 @@ return false; } -static bool DumpAddress(Stream &s, const SymbolContext *sc, - const ExecutionContext *exe_ctx, const Address &addr, - bool print_file_addr_or_load_addr) { +static bool DumpAddressAndContent(Stream &s, const SymbolContext *sc, + const ExecutionContext *exe_ctx, + const Address &addr, + bool print_file_addr_or_load_addr) { Target *target = Target::GetTargetFromContexts(exe_ctx, sc); addr_t vaddr = LLDB_INVALID_ADDRESS; if (exe_ctx && !target->GetSectionLoadList().IsEmpty()) @@ -1145,9 +1146,10 @@ case Entry::Type::AddressFile: case Entry::Type::AddressLoad: case Entry::Type::AddressLoadOrFile: - return (addr != nullptr && addr->IsValid() && - DumpAddress(s, sc, exe_ctx, *addr, - entry.type == Entry::Type::AddressLoadOrFile)); + return ( + addr != nullptr && addr->IsValid() && + DumpAddressAndContent(s, sc, exe_ctx, *addr, + entry.type == Entry::Type::AddressLoadOrFile)); case Entry::Type::ProcessID: if (exe_ctx) { @@ -1415,7 +1417,7 @@ if (frame) { const Address &pc_addr = frame->GetFrameCodeAddress(); if (pc_addr.IsValid()) { - if (DumpAddress(s, sc, exe_ctx, pc_addr, false)) + if (DumpAddressAndContent(s, sc, exe_ctx, pc_addr, false)) return true; } } @@ -1827,7 +1829,7 @@ if (entry.type == Entry::Type::LineEntryEndAddress) addr.Slide(sc->line_entry.range.GetByteSize()); - if (DumpAddress(s, sc, exe_ctx, addr, false)) + if (DumpAddressAndContent(s, sc, exe_ctx, addr, false)) return true; } return false; diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -2929,8 +2929,9 @@ s.PutCString("\n "); s.Indent(); if (cu) - s.AddressRange(start_addr + base_addr, end_addr + base_addr, - cu->GetAddressByteSize(), nullptr, ": "); + DumpAddressRange(s.AsRawOstream(), start_addr + base_addr, + end_addr + base_addr, cu->GetAddressByteSize(), nullptr, + ": "); uint32_t loc_length = debug_loc_data.GetU16(&offset); DataExtractor locationData(debug_loc_data, offset, loc_length); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp @@ -95,13 +95,15 @@ } else if (begin == LLDB_INVALID_ADDRESS) { // A base address selection entry base_addr = end; - s.Address(base_addr, sizeof(dw_addr_t), " Base address = "); + DumpAddress(s.AsRawOstream(), base_addr, sizeof(dw_addr_t), + " Base address = "); } else { // Convert from offset to an address dw_addr_t begin_addr = begin + base_addr; dw_addr_t end_addr = end + base_addr; - s.AddressRange(begin_addr, end_addr, sizeof(dw_addr_t), nullptr); + DumpAddressRange(s.AsRawOstream(), begin_addr, end_addr, + sizeof(dw_addr_t), nullptr); } } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -333,7 +333,7 @@ switch (m_form) { case DW_FORM_addr: - s.Address(uvalue, sizeof(uint64_t)); + DumpAddress(s.AsRawOstream(), uvalue, sizeof(uint64_t)); break; case DW_FORM_flag: case DW_FORM_data1: @@ -409,10 +409,11 @@ assert(m_unit); // Unit must be valid for DW_FORM_ref_addr objects or we // will get this wrong if (m_unit->GetVersion() <= 2) - s.Address(uvalue, sizeof(uint64_t) * 2); + DumpAddress(s.AsRawOstream(), uvalue, sizeof(uint64_t) * 2); else - s.Address(uvalue, 4 * 2); // 4 for DWARF32, 8 for DWARF64, but we don't - // support DWARF64 yet + DumpAddress(s.AsRawOstream(), uvalue, + 4 * 2); // 4 for DWARF32, 8 for DWARF64, but we don't + // support DWARF64 yet break; } case DW_FORM_ref1: diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp --- a/lldb/source/Symbol/Block.cpp +++ b/lldb/source/Symbol/Block.cpp @@ -44,8 +44,8 @@ s->Printf(", range%s = ", num_ranges > 1 ? "s" : ""); for (size_t i = 0; i < num_ranges; ++i) { const Range &range = m_ranges.GetEntryRef(i); - s->AddressRange(base_addr + range.GetRangeBase(), - base_addr + range.GetRangeEnd(), 4); + DumpAddressRange(s->AsRawOstream(), base_addr + range.GetRangeBase(), + base_addr + range.GetRangeEnd(), 4); } } @@ -87,8 +87,8 @@ *s << '!'; else *s << ' '; - s->AddressRange(base_addr + range.GetRangeBase(), - base_addr + range.GetRangeEnd(), 4); + DumpAddressRange(s->AsRawOstream(), base_addr + range.GetRangeBase(), + base_addr + range.GetRangeEnd(), 4); } } s->EOL(); @@ -160,8 +160,8 @@ size_t num_ranges = m_ranges.GetSize(); for (size_t i = 0; i < num_ranges; ++i) { const Range &range = m_ranges.GetEntryRef(i); - s->AddressRange(base_addr + range.GetRangeBase(), - base_addr + range.GetRangeEnd(), 4); + DumpAddressRange(s->AsRawOstream(), base_addr + range.GetRangeBase(), + base_addr + range.GetRangeEnd(), 4); } } } diff --git a/lldb/source/Target/ThreadPlanRunToAddress.cpp b/lldb/source/Target/ThreadPlanRunToAddress.cpp --- a/lldb/source/Target/ThreadPlanRunToAddress.cpp +++ b/lldb/source/Target/ThreadPlanRunToAddress.cpp @@ -97,7 +97,7 @@ s->Printf("run to addresses: "); for (size_t i = 0; i < num_addresses; i++) { - s->Address(m_addresses[i], sizeof(addr_t)); + DumpAddress(s->AsRawOstream(), m_addresses[i], sizeof(addr_t)); s->Printf(" "); } } else { @@ -116,7 +116,7 @@ s->Indent(); } - s->Address(m_addresses[i], sizeof(addr_t)); + DumpAddress(s->AsRawOstream(), m_addresses[i], sizeof(addr_t)); s->Printf(" using breakpoint: %d - ", m_break_ids[i]); Breakpoint *breakpoint = m_thread.CalculateTarget()->GetBreakpointByID(m_break_ids[i]).get(); @@ -143,7 +143,7 @@ all_bps_good = false; if (error) { error->Printf("Could not set breakpoint for address: "); - error->Address(m_addresses[i], sizeof(addr_t)); + DumpAddress(error->AsRawOstream(), m_addresses[i], sizeof(addr_t)); error->Printf("\n"); } } diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp --- a/lldb/source/Target/ThreadPlanStepInRange.cpp +++ b/lldb/source/Target/ThreadPlanStepInRange.cpp @@ -145,8 +145,8 @@ if (log) { StreamString s; - s.Address( - m_thread.GetRegisterContext()->GetPC(), + DumpAddress( + s.AsRawOstream(), m_thread.GetRegisterContext()->GetPC(), m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize()); LLDB_LOGF(log, "ThreadPlanStepInRange reached %s.", s.GetData()); } diff --git a/lldb/source/Target/ThreadPlanStepInstruction.cpp b/lldb/source/Target/ThreadPlanStepInstruction.cpp --- a/lldb/source/Target/ThreadPlanStepInstruction.cpp +++ b/lldb/source/Target/ThreadPlanStepInstruction.cpp @@ -65,7 +65,7 @@ PrintFailureIfAny(); } else { s->Printf("Stepping one instruction past "); - s->Address(m_instruction_addr, sizeof(addr_t)); + DumpAddress(s->AsRawOstream(), m_instruction_addr, sizeof(addr_t)); if (!m_start_has_symbol) s->Printf(" which has no symbol"); @@ -182,14 +182,16 @@ s.PutCString("Stepped in to: "); addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC(); - s.Address(stop_addr, m_thread.CalculateTarget() - ->GetArchitecture() - .GetAddressByteSize()); + DumpAddress(s.AsRawOstream(), stop_addr, + m_thread.CalculateTarget() + ->GetArchitecture() + .GetAddressByteSize()); s.PutCString(" stepping out to: "); addr_t return_addr = return_frame->GetRegisterContext()->GetPC(); - s.Address(return_addr, m_thread.CalculateTarget() - ->GetArchitecture() - .GetAddressByteSize()); + DumpAddress(s.AsRawOstream(), return_addr, + m_thread.CalculateTarget() + ->GetArchitecture() + .GetAddressByteSize()); LLDB_LOGF(log, "%s.", s.GetData()); } diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp b/lldb/source/Target/ThreadPlanStepOverRange.cpp --- a/lldb/source/Target/ThreadPlanStepOverRange.cpp +++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp @@ -128,8 +128,8 @@ if (log) { StreamString s; - s.Address( - m_thread.GetRegisterContext()->GetPC(), + DumpAddress( + s.AsRawOstream(), m_thread.GetRegisterContext()->GetPC(), m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize()); LLDB_LOGF(log, "ThreadPlanStepOverRange reached %s.", s.GetData()); } diff --git a/lldb/source/Target/ThreadPlanStepThrough.cpp b/lldb/source/Target/ThreadPlanStepThrough.cpp --- a/lldb/source/Target/ThreadPlanStepThrough.cpp +++ b/lldb/source/Target/ThreadPlanStepThrough.cpp @@ -119,11 +119,11 @@ s->Printf("Step through"); else { s->PutCString("Stepping through trampoline code from: "); - s->Address(m_start_address, sizeof(addr_t)); + DumpAddress(s->AsRawOstream(), m_start_address, sizeof(addr_t)); if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) { s->Printf(" with backstop breakpoint ID: %d at address: ", m_backstop_bkpt_id); - s->Address(m_backstop_addr, sizeof(addr_t)); + DumpAddress(s->AsRawOstream(), m_backstop_addr, sizeof(addr_t)); } else s->PutCString(" unable to set a backstop breakpoint."); } diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp --- 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 @@ -76,28 +77,27 @@ // 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); } diff --git a/lldb/source/Utility/VMRange.cpp b/lldb/source/Utility/VMRange.cpp --- a/lldb/source/Utility/VMRange.cpp +++ b/lldb/source/Utility/VMRange.cpp @@ -36,8 +36,8 @@ } void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const { - s->AddressRange(offset + GetBaseAddress(), offset + GetEndAddress(), - addr_width); + DumpAddressRange(s->AsRawOstream(), offset + GetBaseAddress(), + offset + GetEndAddress(), addr_width); } bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) { diff --git a/lldb/unittests/Utility/StreamTest.cpp b/lldb/unittests/Utility/StreamTest.cpp --- a/lldb/unittests/Utility/StreamTest.cpp +++ b/lldb/unittests/Utility/StreamTest.cpp @@ -37,94 +37,90 @@ } TEST_F(StreamTest, AddressPrefix) { - s.Address(0x1, 1, "foo"); + DumpAddress(s.AsRawOstream(), 0x1, 1, "foo"); EXPECT_EQ("foo0x01", TakeValue()); } TEST_F(StreamTest, AddressEmptyPrefix) { - s.Address(0x1, 1, nullptr); + DumpAddress(s.AsRawOstream(), 0x1, 1, nullptr); EXPECT_EQ("0x01", TakeValue()); - s.Address(0x1, 1, ""); + DumpAddress(s.AsRawOstream(), 0x1, 1, ""); EXPECT_EQ("0x01", TakeValue()); } TEST_F(StreamTest, AddressSuffix) { - s.Address(0x1, 1, nullptr, "foo"); + DumpAddress(s.AsRawOstream(), 0x1, 1, nullptr, "foo"); EXPECT_EQ("0x01foo", TakeValue()); } TEST_F(StreamTest, AddressNoSuffix) { - s.Address(0x1, 1, nullptr, nullptr); + DumpAddress(s.AsRawOstream(), 0x1, 1, nullptr, nullptr); EXPECT_EQ("0x01", TakeValue()); - s.Address(0x1, 1, nullptr, ""); + DumpAddress(s.AsRawOstream(), 0x1, 1, nullptr, ""); EXPECT_EQ("0x01", TakeValue()); } TEST_F(StreamTest, AddressPrefixAndSuffix) { - s.Address(0x1, 1, "foo", "bar"); + DumpAddress(s.AsRawOstream(), 0x1, 1, "foo", "bar"); EXPECT_EQ("foo0x01bar", TakeValue()); } TEST_F(StreamTest, AddressSize) { - s.Address(0x0, 0); + DumpAddress(s.AsRawOstream(), 0x0, 0); EXPECT_EQ("0x0", TakeValue()); - s.Address(0x1, 0); + DumpAddress(s.AsRawOstream(), 0x1, 0); EXPECT_EQ("0x1", TakeValue()); - s.Address(0x1, 1); + DumpAddress(s.AsRawOstream(), 0x1, 1); EXPECT_EQ("0x01", TakeValue()); - s.Address(0xf1, 1); + DumpAddress(s.AsRawOstream(), 0xf1, 1); EXPECT_EQ("0xf1", TakeValue()); - s.Address(0xff, 1); + DumpAddress(s.AsRawOstream(), 0xff, 1); EXPECT_EQ("0xff", TakeValue()); - s.Address(0x100, 1); + DumpAddress(s.AsRawOstream(), 0x100, 1); EXPECT_EQ("0x100", TakeValue()); - s.Address(0xf00, 4); + DumpAddress(s.AsRawOstream(), 0xf00, 4); EXPECT_EQ("0x00000f00", TakeValue()); - s.Address(0x100, 8); + DumpAddress(s.AsRawOstream(), 0x100, 8); EXPECT_EQ("0x0000000000000100", TakeValue()); - s.Address(0x100, 10); - EXPECT_EQ("0x00000000000000000100", TakeValue()); - s.Address(0x1234, 10); - EXPECT_EQ("0x00000000000000001234", TakeValue()); } TEST_F(StreamTest, AddressRange) { - s.AddressRange(0x100, 0x101, 2); + DumpAddressRange(s.AsRawOstream(), 0x100, 0x101, 2); EXPECT_EQ("[0x0100-0x0101)", TakeValue()); } TEST_F(StreamTest, AddressRangeEmptyRange) { - s.AddressRange(0x100, 0x100, 2); + DumpAddressRange(s.AsRawOstream(), 0x100, 0x100, 2); EXPECT_EQ("[0x0100-0x0100)", TakeValue()); - s.AddressRange(0x0, 0x0, 2); + DumpAddressRange(s.AsRawOstream(), 0x0, 0x0, 2); EXPECT_EQ("[0x0000-0x0000)", TakeValue()); } TEST_F(StreamTest, AddressRangeInvalidRange) { - s.AddressRange(0x100, 0x0FF, 2); + DumpAddressRange(s.AsRawOstream(), 0x100, 0x0FF, 2); EXPECT_EQ("[0x0100-0x00ff)", TakeValue()); - s.AddressRange(0x100, 0x0, 2); + DumpAddressRange(s.AsRawOstream(), 0x100, 0x0, 2); EXPECT_EQ("[0x0100-0x0000)", TakeValue()); } TEST_F(StreamTest, AddressRangeSize) { - s.AddressRange(0x100, 0x101, 0); + DumpAddressRange(s.AsRawOstream(), 0x100, 0x101, 0); EXPECT_EQ("[0x100-0x101)", TakeValue()); - s.AddressRange(0x100, 0x101, 2); + DumpAddressRange(s.AsRawOstream(), 0x100, 0x101, 2); EXPECT_EQ("[0x0100-0x0101)", TakeValue()); - s.AddressRange(0x100, 0x101, 4); + DumpAddressRange(s.AsRawOstream(), 0x100, 0x101, 4); EXPECT_EQ("[0x00000100-0x00000101)", TakeValue()); - s.AddressRange(0x100, 0x101, 4); + DumpAddressRange(s.AsRawOstream(), 0x100, 0x101, 4); EXPECT_EQ("[0x00000100-0x00000101)", TakeValue()); - s.AddressRange(0x1, 0x101, 4); + DumpAddressRange(s.AsRawOstream(), 0x1, 0x101, 4); EXPECT_EQ("[0x00000001-0x00000101)", TakeValue()); - s.AddressRange(0x101, 0x1, 4); + DumpAddressRange(s.AsRawOstream(), 0x101, 0x1, 4); EXPECT_EQ("[0x00000101-0x00000001)", TakeValue()); - s.AddressRange(0x1, 0x101, 1); + DumpAddressRange(s.AsRawOstream(), 0x1, 0x101, 1); EXPECT_EQ("[0x01-0x101)", TakeValue()); }