summaryrefslogtreecommitdiffstats
path: root/lldb/test/python_api
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-12-15 19:56:28 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-12-15 19:56:28 +0000
commit1917bc8de44a0ca64a9ace7a203cd2337d28df28 (patch)
tree44e6438a0ca29eb580dbdddae66bee2559d53ae4 /lldb/test/python_api
parent2d6d3a2f9646e38fcf40ffac88ae2669ce7bfe9e (diff)
downloadbcm5719-llvm-1917bc8de44a0ca64a9ace7a203cd2337d28df28.tar.gz
bcm5719-llvm-1917bc8de44a0ca64a9ace7a203cd2337d28df28.zip
Move disassemble-raw-data dir to reside under test/python_api where they belong.
Add debug statements for the raw bytes and the disassembled instruction. llvm-svn: 146676
Diffstat (limited to 'lldb/test/python_api')
-rw-r--r--lldb/test/python_api/disassemble-raw-data/TestDisassembleRawData.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/lldb/test/python_api/disassemble-raw-data/TestDisassembleRawData.py b/lldb/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
new file mode 100644
index 00000000000..fe5fdf0a3ce
--- /dev/null
+++ b/lldb/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -0,0 +1,45 @@
+"""
+Use lldb Python API to disassemble raw machine code bytes
+"""
+
+import os, time
+import re
+import unittest2
+import lldb, lldbutil
+from lldbtest import *
+
+class DisassembleRawDataTestCase(TestBase):
+
+ mydir = os.path.join("python_api", "disassemble-raw-data")
+
+ @python_api_test
+ def test_disassemble_raw_data(self):
+ """Test disassembling raw bytes with the API."""
+ self.disassemble_raw_data()
+
+ def disassemble_raw_data(self):
+ """Test disassembling raw bytes with the API."""
+ # Create a target from the debugger.
+
+ target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "x86_64-apple-darwin")
+ self.assertTrue(target, VALID_TARGET)
+
+ raw_bytes = bytearray([0x48, 0x89, 0xe5])
+
+ insts = target.GetInstructions(lldb.SBAddress(), raw_bytes)
+
+ inst = insts.GetInstructionAtIndex(0)
+
+ self.assertTrue (inst.GetMnemonic(target) == "movq")
+ self.assertTrue (inst.GetOperands(target) == '%' + "rsp, " + '%' + "rbp")
+
+ if self.TraceOn():
+ print
+ print "Raw bytes: ", [hex(x) for x in raw_bytes]
+ print "Disassembled:", inst
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
OpenPOWER on IntegriCloud