diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
commit | 94994d372d014ce4c8758b9605d63fae651bd8aa (patch) | |
tree | 51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /source/Core/Opcode.cpp | |
parent | 39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff) |
Notes
Diffstat (limited to 'source/Core/Opcode.cpp')
-rw-r--r-- | source/Core/Opcode.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/source/Core/Opcode.cpp b/source/Core/Opcode.cpp index d15fdb3b17be..ed8be78a6d67 100644 --- a/source/Core/Opcode.cpp +++ b/source/Core/Opcode.cpp @@ -13,50 +13,51 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-forward.h" // for DataBufferSP +#include "lldb/lldb-forward.h" -#include <memory> // for make_shared +#include <memory> -#include <inttypes.h> // for PRIx64 +#include <inttypes.h> using namespace lldb; using namespace lldb_private; int Opcode::Dump(Stream *s, uint32_t min_byte_width) { - int bytes_written = 0; + const uint32_t previous_bytes = s->GetWrittenBytes(); switch (m_type) { case Opcode::eTypeInvalid: - bytes_written = s->PutCString("<invalid>"); + s->PutCString("<invalid>"); break; case Opcode::eType8: - bytes_written = s->Printf("0x%2.2x", m_data.inst8); + s->Printf("0x%2.2x", m_data.inst8); break; case Opcode::eType16: - bytes_written = s->Printf("0x%4.4x", m_data.inst16); + s->Printf("0x%4.4x", m_data.inst16); break; case Opcode::eType16_2: case Opcode::eType32: - bytes_written = s->Printf("0x%8.8x", m_data.inst32); + s->Printf("0x%8.8x", m_data.inst32); break; case Opcode::eType64: - bytes_written = s->Printf("0x%16.16" PRIx64, m_data.inst64); + s->Printf("0x%16.16" PRIx64, m_data.inst64); break; case Opcode::eTypeBytes: for (uint32_t i = 0; i < m_data.inst.length; ++i) { if (i > 0) - bytes_written += s->PutChar(' '); - bytes_written += s->Printf("%2.2x", m_data.inst.bytes[i]); + s->PutChar(' '); + s->Printf("%2.2x", m_data.inst.bytes[i]); } break; } - // Add spaces to make sure bytes dispay comes out even in case opcodes aren't - // all the same size - if (static_cast<uint32_t>(bytes_written) < min_byte_width) - bytes_written = s->Printf("%*s", min_byte_width - bytes_written, ""); - return bytes_written; + uint32_t bytes_written_so_far = s->GetWrittenBytes() - previous_bytes; + // Add spaces to make sure bytes display comes out even in case opcodes aren't + // all the same size. + if (bytes_written_so_far < min_byte_width) + s->Printf("%*s", min_byte_width - bytes_written_so_far, ""); + return s->GetWrittenBytes() - previous_bytes; } lldb::ByteOrder Opcode::GetDataByteOrder() const { |