I have added a function to SBTarget that allows
clients to disassemble a series of raw bytes as
demonstrated by a new testcase.
In the future, this API will also allow clients
to provide a callback that adds comments for
addresses in the disassembly.
I also modified the SWIG harness to ensure that
Python ByteArrays work as well as strings as
sources of raw data.
llvm-svn: 146611
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index 1628f3a..fe044a6 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -230,6 +230,37 @@
return disasm_sp;
}
+lldb::DisassemblerSP
+Disassembler::DisassembleBytes
+(
+ const ArchSpec &arch,
+ const char *plugin_name,
+ const Address &start,
+ const void *bytes,
+ size_t length
+)
+{
+ lldb::DisassemblerSP disasm_sp;
+
+ if (bytes)
+ {
+ disasm_sp.reset(Disassembler::FindPlugin(arch, plugin_name));
+
+ if (disasm_sp)
+ {
+ DataExtractor data(bytes, length, arch.GetByteOrder(), arch.GetAddressByteSize());
+
+ (void)disasm_sp->DecodeInstructions (start,
+ data,
+ 0,
+ UINT32_MAX,
+ false);
+ }
+ }
+
+ return disasm_sp;
+}
+
bool
Disassembler::Disassemble