Index: lldb/trunk/include/lldb/Core/DumpRegisterValue.h =================================================================== --- lldb/trunk/include/lldb/Core/DumpRegisterValue.h +++ lldb/trunk/include/lldb/Core/DumpRegisterValue.h @@ -0,0 +1,31 @@ +//===-- DumpRegisterValue.h -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_CORE_DUMPREGISTERVALUE_H +#define LLDB_CORE_DUMPREGISTERVALUE_H + +#include "lldb/lldb-enumerations.h" +#include + +namespace lldb_private { + +class RegisterValue; +struct RegisterInfo; +class Stream; + +// The default value of 0 for reg_name_right_align_at means no alignment at +// all. +bool DumpRegisterValue(const RegisterValue ®_val, Stream *s, + const RegisterInfo *reg_info, bool prefix_with_name, + bool prefix_with_alt_name, lldb::Format format, + uint32_t reg_name_right_align_at = 0); + +} // namespace lldb_private + +#endif // LLDB_CORE_DUMPREGISTERVALUE_H Index: lldb/trunk/include/lldb/Core/RegisterValue.h =================================================================== --- lldb/trunk/include/lldb/Core/RegisterValue.h +++ lldb/trunk/include/lldb/Core/RegisterValue.h @@ -248,12 +248,6 @@ Status SetValueFromData(const RegisterInfo *reg_info, DataExtractor &data, lldb::offset_t offset, bool partial_data_ok); - // The default value of 0 for reg_name_right_align_at means no alignment at - // all. - bool Dump(Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, - bool prefix_with_alt_name, lldb::Format format, - uint32_t reg_name_right_align_at = 0) const; - const void *GetBytes() const; lldb::ByteOrder GetByteOrder() const { Index: lldb/trunk/source/Commands/CommandObjectRegister.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp @@ -9,6 +9,7 @@ #include "CommandObjectRegister.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" #include "lldb/Host/OptionParser.h" @@ -92,8 +93,8 @@ bool prefix_with_altname = (bool)m_command_options.alternate_name; bool prefix_with_name = !prefix_with_altname; - reg_value.Dump(&strm, reg_info, prefix_with_name, prefix_with_altname, - m_format_options.GetFormat(), 8); + DumpRegisterValue(reg_value, &strm, reg_info, prefix_with_name, + prefix_with_altname, m_format_options.GetFormat(), 8); if ((reg_info->encoding == eEncodingUint) || (reg_info->encoding == eEncodingSint)) { Process *process = exe_ctx.GetProcessPtr(); Index: lldb/trunk/source/Core/CMakeLists.txt =================================================================== --- lldb/trunk/source/Core/CMakeLists.txt +++ lldb/trunk/source/Core/CMakeLists.txt @@ -18,6 +18,7 @@ Debugger.cpp Disassembler.cpp DumpDataExtractor.cpp + DumpRegisterValue.cpp DynamicLoader.cpp EmulateInstruction.cpp Event.cpp Index: lldb/trunk/source/Core/DumpRegisterValue.cpp =================================================================== --- lldb/trunk/source/Core/DumpRegisterValue.cpp +++ lldb/trunk/source/Core/DumpRegisterValue.cpp @@ -0,0 +1,79 @@ +//===-- DumpRegisterValue.cpp -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Core/DumpRegisterValue.h" +#include "lldb/Core/DumpDataExtractor.h" +#include "lldb/Core/RegisterValue.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/lldb-private-types.h" + +using namespace lldb; + +bool lldb_private::DumpRegisterValue(const RegisterValue ®_val, Stream *s, + const RegisterInfo *reg_info, + bool prefix_with_name, + bool prefix_with_alt_name, Format format, + uint32_t reg_name_right_align_at) { + DataExtractor data; + if (reg_val.GetData(data)) { + bool name_printed = false; + // For simplicity, alignment of the register name printing applies only in + // the most common case where: + // + // prefix_with_name^prefix_with_alt_name is true + // + StreamString format_string; + if (reg_name_right_align_at && (prefix_with_name ^ prefix_with_alt_name)) + format_string.Printf("%%%us", reg_name_right_align_at); + else + format_string.Printf("%%s"); + std::string fmt = format_string.GetString(); + if (prefix_with_name) { + if (reg_info->name) { + s->Printf(fmt.c_str(), reg_info->name); + name_printed = true; + } else if (reg_info->alt_name) { + s->Printf(fmt.c_str(), reg_info->alt_name); + prefix_with_alt_name = false; + name_printed = true; + } + } + if (prefix_with_alt_name) { + if (name_printed) + s->PutChar('/'); + if (reg_info->alt_name) { + s->Printf(fmt.c_str(), reg_info->alt_name); + name_printed = true; + } else if (!name_printed) { + // No alternate name but we were asked to display a name, so show the + // main name + s->Printf(fmt.c_str(), reg_info->name); + name_printed = true; + } + } + if (name_printed) + s->PutCString(" = "); + + if (format == eFormatDefault) + format = reg_info->format; + + DumpDataExtractor(data, s, + 0, // Offset in "data" + format, // Format to use when dumping + reg_info->byte_size, // item_byte_size + 1, // item_count + UINT32_MAX, // num_per_line + LLDB_INVALID_ADDRESS, // base_addr + 0, // item_bit_size + 0); // item_bit_offset + return true; + } + return false; +} Index: lldb/trunk/source/Core/EmulateInstruction.cpp =================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp +++ lldb/trunk/source/Core/EmulateInstruction.cpp @@ -10,6 +10,7 @@ #include "lldb/Core/EmulateInstruction.h" #include "lldb/Core/Address.h" +#include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/StreamFile.h" @@ -361,7 +362,7 @@ const RegisterValue ®_value) { StreamFile strm(stdout, false); strm.Printf(" Write to Register (name = %s, value = ", reg_info->name); - reg_value.Dump(&strm, reg_info, false, false, eFormatDefault); + DumpRegisterValue(reg_value, &strm, reg_info, false, false, eFormatDefault); strm.PutCString(", context = "); context.Dump(strm, instruction); strm.EOL(); Index: lldb/trunk/source/Core/FormatEntity.cpp =================================================================== --- lldb/trunk/source/Core/FormatEntity.cpp +++ lldb/trunk/source/Core/FormatEntity.cpp @@ -12,6 +12,7 @@ #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" // for AddressRange #include "lldb/Core/Debugger.h" +#include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/Module.h" #include "lldb/Core/RegisterValue.h" // for RegisterValue #include "lldb/Core/ValueObject.h" @@ -621,7 +622,7 @@ if (reg_info) { RegisterValue reg_value; if (reg_ctx->ReadRegister(reg_info, reg_value)) { - reg_value.Dump(&s, reg_info, false, false, format); + DumpRegisterValue(reg_value, &s, reg_info, false, false, format); return true; } } @@ -1018,7 +1019,7 @@ if (reg_info) { RegisterValue reg_value; if (reg_ctx->ReadRegister(reg_info, reg_value)) { - reg_value.Dump(&s, reg_info, false, false, format); + DumpRegisterValue(reg_value, &s, reg_info, false, false, format); return true; } } Index: lldb/trunk/source/Core/RegisterValue.cpp =================================================================== --- lldb/trunk/source/Core/RegisterValue.cpp +++ lldb/trunk/source/Core/RegisterValue.cpp @@ -9,7 +9,6 @@ #include "lldb/Core/RegisterValue.h" -#include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Scalar.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/DataExtractor.h" @@ -34,67 +33,6 @@ using namespace lldb; using namespace lldb_private; -bool RegisterValue::Dump(Stream *s, const RegisterInfo *reg_info, - bool prefix_with_name, bool prefix_with_alt_name, - Format format, - uint32_t reg_name_right_align_at) const { - DataExtractor data; - if (GetData(data)) { - bool name_printed = false; - // For simplicity, alignment of the register name printing applies only in - // the most common case where: - // - // prefix_with_name^prefix_with_alt_name is true - // - StreamString format_string; - if (reg_name_right_align_at && (prefix_with_name ^ prefix_with_alt_name)) - format_string.Printf("%%%us", reg_name_right_align_at); - else - format_string.Printf("%%s"); - std::string fmt = format_string.GetString(); - if (prefix_with_name) { - if (reg_info->name) { - s->Printf(fmt.c_str(), reg_info->name); - name_printed = true; - } else if (reg_info->alt_name) { - s->Printf(fmt.c_str(), reg_info->alt_name); - prefix_with_alt_name = false; - name_printed = true; - } - } - if (prefix_with_alt_name) { - if (name_printed) - s->PutChar('/'); - if (reg_info->alt_name) { - s->Printf(fmt.c_str(), reg_info->alt_name); - name_printed = true; - } else if (!name_printed) { - // No alternate name but we were asked to display a name, so show the - // main name - s->Printf(fmt.c_str(), reg_info->name); - name_printed = true; - } - } - if (name_printed) - s->PutCString(" = "); - - if (format == eFormatDefault) - format = reg_info->format; - - DumpDataExtractor(data, s, - 0, // Offset in "data" - format, // Format to use when dumping - reg_info->byte_size, // item_byte_size - 1, // item_count - UINT32_MAX, // num_per_line - LLDB_INVALID_ADDRESS, // base_addr - 0, // item_bit_size - 0); // item_bit_offset - return true; - } - return false; -} - bool RegisterValue::GetData(DataExtractor &data) const { return data.SetData(GetBytes(), GetByteSize(), GetByteOrder()) > 0; } Index: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp =================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp @@ -12,6 +12,7 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/DumpDataExtractor.h" +#include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/PluginManager.h" #include "lldb/Target/ExecutionContext.h" @@ -486,7 +487,7 @@ strm.Printf("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => " "synthetic_value = %i, value = ", reg_info->name, synthetic); - reg_value.Dump(&strm, reg_info, false, false, eFormatDefault); + DumpRegisterValue(reg_value, &strm, reg_info, false, false, eFormatDefault); log->PutString(strm.GetString()); } return true; @@ -512,7 +513,7 @@ strm.Printf( "UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = ", reg_info->name); - reg_value.Dump(&strm, reg_info, false, false, eFormatDefault); + DumpRegisterValue(reg_value, &strm, reg_info, false, false, eFormatDefault); strm.PutCString(", context = "); context.Dump(strm, instruction); log->PutString(strm.GetString()); Index: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp =================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp @@ -15,6 +15,7 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Address.h" +#include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/ABI.h" @@ -186,7 +187,8 @@ reg_idx < num_registers; ++reg_idx) { const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_idx); if (reg_ctx->ReadRegister(reg_info, reg_value)) { - reg_value.Dump(&strm, reg_info, true, false, eFormatDefault); + DumpRegisterValue(reg_value, &strm, reg_info, true, false, + eFormatDefault); strm.EOL(); } } Index: lldb/trunk/source/Target/ThreadPlanTracer.cpp =================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" +#include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/Module.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" @@ -217,7 +218,8 @@ reg_value != m_register_values[reg_num]) { if (reg_value.GetType() != RegisterValue::eTypeInvalid) { stream->PutCString("\n\t"); - reg_value.Dump(stream, reg_info, true, false, eFormatDefault); + DumpRegisterValue(reg_value, stream, reg_info, true, false, + eFormatDefault); } } m_register_values[reg_num] = reg_value;