summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Opcode.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-03-25 18:03:16 +0000
committerGreg Clayton <gclayton@apple.com>2011-03-25 18:03:16 +0000
commit1080edbcdd7d24ad5213749e396e23b54c1a3040 (patch)
tree25cb5d0a1e62ba603df46e3376cdf4dfeb1969ca /lldb/source/Core/Opcode.cpp
parent6f4c9425eb5b689a2a4bfa19531ef9ab4c5c6e5d (diff)
downloadbcm5719-llvm-1080edbcdd7d24ad5213749e396e23b54c1a3040.tar.gz
bcm5719-llvm-1080edbcdd7d24ad5213749e396e23b54c1a3040.zip
Cleaned up the Disassembler code a bit more. You can now request a disassembler
plugin by name on the command line for when there is more than one disassembler plugin. Taught the Opcode class to dump itself so that "disassembler -b" will dump the bytes correctly for each opcode type. Modified all places that were passing the opcode bytes buffer in so that the bytes could be displayed to just pass in a bool that indicates if we should dump the opcode bytes since the opcode now lives inside llvm_private::Instruction. llvm-svn: 128290
Diffstat (limited to 'lldb/source/Core/Opcode.cpp')
-rw-r--r--lldb/source/Core/Opcode.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/lldb/source/Core/Opcode.cpp b/lldb/source/Core/Opcode.cpp
index cb0b4d038b6..d33c80c76de 100644
--- a/lldb/source/Core/Opcode.cpp
+++ b/lldb/source/Core/Opcode.cpp
@@ -13,6 +13,52 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Core/Stream.h"
using namespace lldb;
-using namespace lldb_private; \ No newline at end of file
+using namespace lldb_private;
+
+
+int
+Opcode::Dump (Stream *s, uint32_t min_byte_width)
+{
+ int bytes_written = 0;
+ switch (m_type)
+ {
+ case Opcode::eTypeInvalid:
+ bytes_written = s->PutCString ("<invalid>");
+ break;
+ case Opcode::eType8:
+ bytes_written = s->Printf ("0x%2.2x", m_data.inst8);
+ break;
+ case Opcode::eType16:
+ bytes_written = s->Printf ("0x%4.4x", m_data.inst16);
+ break;
+
+ case Opcode::eType32:
+ bytes_written = s->Printf ("0x%8.8x", m_data.inst32);
+ break;
+
+ case Opcode::eType64:
+ bytes_written = s->Printf ("0x%16.16llx", m_data.inst64);
+ break;
+
+ case Opcode::eTypeBytes:
+ {
+ for (uint32_t i=0; i<m_data.inst.length; ++i)
+ {
+ if (i > 0)
+ s->PutChar (' ');
+ bytes_written += 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 (bytes_written < min_byte_width)
+ bytes_written = s->Printf ("%*s", min_byte_width - bytes_written, "");
+ return bytes_written;
+}
+
OpenPOWER on IntegriCloud