diff options
author | Greg Clayton <gclayton@apple.com> | 2011-03-25 18:03:16 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-03-25 18:03:16 +0000 |
commit | 1080edbcdd7d24ad5213749e396e23b54c1a3040 (patch) | |
tree | 25cb5d0a1e62ba603df46e3376cdf4dfeb1969ca /lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp | |
parent | 6f4c9425eb5b689a2a4bfa19531ef9ab4c5c6e5d (diff) | |
download | bcm5719-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/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp')
-rw-r--r-- | lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp index 9835dea6675..9c55042640f 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp @@ -100,8 +100,7 @@ DisassemblerLLVM::InstructionLLVM::Dump ( Stream *s, bool show_address, - const DataExtractor *bytes, - uint32_t bytes_offset, + bool show_bytes, const lldb_private::ExecutionContext* exe_ctx, bool raw ) @@ -125,18 +124,20 @@ DisassemblerLLVM::InstructionLLVM::Dump } // If we are supposed to show bytes, "bytes" will be non-NULL. - if (bytes) + if (show_bytes) { - uint32_t bytes_dumped = bytes->Dump(s, bytes_offset, eFormatBytes, 1, EDInstByteSize(m_inst), UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0) - bytes_offset; - // Allow for 15 bytes of opcodes since this is the max for x86_64. - // TOOD: We need to taylor this better for different architectures. For - // ARM we would want to show 16 bit opcodes for Thumb as properly byte - // swapped uint16_t values, or 32 bit values swapped values for ARM. - const uint32_t default_num_opcode_bytes = 15; - if (bytes_dumped * 3 < (default_num_opcode_bytes*3)) + if (m_opcode.GetType() == Opcode::eTypeBytes) { - uint32_t indent_level = (default_num_opcode_bytes*3) - (bytes_dumped * 3) + 1; - s->Printf("%*.*s", indent_level, indent_level, ""); + // x86_64 and i386 are the only ones that use bytes right now so + // pad out the byte dump to be able to always show 15 bytes (3 chars each) + // plus a space + m_opcode.Dump (s, 15 * 3 + 1); + } + else + { + // Else, we have ARM which can show up to a uint32_t 0x00000000 (10 spaces) + // plus two for padding... + m_opcode.Dump (s, 12); } } @@ -328,12 +329,6 @@ DisassemblerLLVM::InstructionLLVM::DoesBranch() const } size_t -DisassemblerLLVM::InstructionLLVM::GetByteSize() const -{ - return EDInstByteSize(m_inst); -} - -size_t DisassemblerLLVM::InstructionLLVM::Extract (const Disassembler &disassembler, const lldb_private::DataExtractor &data, uint32_t data_offset) @@ -351,16 +346,21 @@ DisassemblerLLVM::InstructionLLVM::Extract (const Disassembler &disassembler, break; case llvm::Triple::arm: - assert (byte_size == 4); - m_opcode.SetOpcode32 (data.GetU32 (&offset)); - break; - case llvm::Triple::thumb: - assert ((byte_size == 2) || (byte_size == 4)); - if (byte_size == 2) - m_opcode.SetOpcode16 (data.GetU16 (&offset)); - else + switch (byte_size) + { + case 2: + m_opcode.SetOpcode16 (data.GetU16 (&offset)); + break; + + case 4: m_opcode.SetOpcode32 (data.GetU32 (&offset)); + break; + + default: + assert (!"Invalid ARM opcode size"); + break; + } break; default: @@ -497,13 +497,13 @@ DisassemblerLLVM::Terminate() const char * DisassemblerLLVM::GetPluginNameStatic() { - return "disassembler.llvm"; + return "llvm"; } const char * DisassemblerLLVM::GetPluginDescriptionStatic() { - return "Disassembler that uses LLVM opcode tables to disassemble i386 and x86_64."; + return "Disassembler that uses LLVM opcode tables to disassemble i386, x86_64 and ARM."; } //------------------------------------------------------------------ |