From e7a9115680e22fac3dc996800deaec773becfac0 Mon Sep 17 00:00:00 2001 From: Lawrence D'Anna Date: Mon, 14 Oct 2019 20:59:57 +0000 Subject: remove FILE* bindings from SBInstruction. Summary: This patch replaces the FILE* python bindings for SBInstruction and SBInstructionList and replaces them with the new, safe SBFile and FileSP bindings. I also re-enable `Test_Disassemble_VST1_64`, because now we can use the file bindings as an additional test of the disassembler, and we can use the disassembler test as a test of the file bindings. The bugs referred to in the comments appear to have been fixed. The radar is closed now and the bugzilla bug does not reproduce with the instructions given. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68890 llvm-svn: 374820 --- .../TestDisassemble_VST1_64.py | 36 ++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'lldb/packages/Python/lldbsuite/test/python_api/disassemble-raw-data') diff --git a/lldb/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py b/lldb/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py index d171b02f77e..1b627c04ff1 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py @@ -4,6 +4,8 @@ Use lldb Python API to disassemble raw machine code bytes from __future__ import print_function +from io import StringIO +import sys import lldb from lldbsuite.test.decorators import * @@ -15,9 +17,6 @@ class Disassemble_VST1_64(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipTestIfFn( - lambda: True, - "llvm.org/pr24575: all tests get ERRORs in dotest.py after this") @add_test_categories(['pyapi']) @no_debug_info_test @skipIf(triple='^mips') @@ -33,19 +32,38 @@ class Disassemble_VST1_64(TestBase): 0x24, 0xf0, 0x0f, 0x04, 0xa5, 0x46]) + assembly = """ + push {r4, r5, r6, r7, lr} + add r7, sp, #0xc + push.w {r8, r10, r11} + sub.w r4, sp, #0x40 + bic r4, r4, #0xf + mov sp, r4 + """ + def split(s): + return [x.strip() for x in s.strip().splitlines()] + insts = target.GetInstructions(lldb.SBAddress(), raw_bytes) + if sys.version_info.major >= 3: + sio = StringIO() + insts.Print(sio) + self.assertEqual(split(assembly), split(sio.getvalue())) + + self.assertEqual(insts.GetSize(), len(split(assembly))) + + if sys.version_info.major >= 3: + for i,asm in enumerate(split(assembly)): + inst = insts.GetInstructionAtIndex(i) + sio = StringIO() + inst.Print(sio) + self.assertEqual(asm, sio.getvalue().strip()) + if self.TraceOn(): print() for i in insts: print("Disassembled%s" % str(i)) - # Remove the following return statement when the radar is fixed. - return - - # rdar://problem/11034702 - # VST1 (multiple single elements) encoding? - # The disassembler should not crash! raw_bytes = bytearray([0x04, 0xf9, 0xed, 0x82]) insts = target.GetInstructions(lldb.SBAddress(), raw_bytes) -- cgit v1.2.3