]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / disassembly / TestDisassembleBreakpoint.py
1 """
2 Test some lldb command abbreviations.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15
16 class DisassemblyTestCase(TestBase):
17
18     mydir = TestBase.compute_mydir(__file__)
19
20     @expectedFailureAll(
21         oslist=["windows"],
22         bugnumber="function names print fully demangled instead of name-only")
23     def test(self):
24         self.build()
25         exe = os.path.join(os.getcwd(), "a.out")
26         self.expect("file " + exe,
27                     patterns=["Current executable set to .*a.out.*"])
28
29         match_object = lldbutil.run_break_set_command(self, "br s -n sum")
30         lldbutil.check_breakpoint_result(
31             self,
32             match_object,
33             symbol_name='sum',
34             symbol_match_exact=False,
35             num_locations=1)
36
37         self.expect("run",
38                     patterns=["Process .* launched: "])
39
40         self.runCmd("dis -f")
41         disassembly = self.res.GetOutput()
42
43         # ARCH, if not specified, defaults to x86_64.
44         arch = self.getArchitecture()
45         if arch in ["", 'x86_64', 'i386', 'i686']:
46             breakpoint_opcodes = ["int3"]
47             instructions = [' mov', ' addl ', 'ret']
48         elif arch in ["arm", "aarch64"]:
49             breakpoint_opcodes = ["brk", "udf"]
50             instructions = [' add ', ' ldr ', ' str ']
51         elif re.match("mips", arch):
52             breakpoint_opcodes = ["break"]
53             instructions = ['lw', 'sw']
54         elif arch in ["s390x"]:
55             breakpoint_opcodes = [".long"]
56             instructions = [' l ', ' a ', ' st ']
57         else:
58             # TODO please add your arch here
59             self.fail(
60                 'unimplemented for arch = "{arch}"'.format(
61                     arch=self.getArchitecture()))
62
63         # make sure that the software breakpoint has been removed
64         for op in breakpoint_opcodes:
65             self.assertFalse(op in disassembly)
66
67         # make sure a few reasonable assembly instructions are here
68         self.expect(
69             disassembly,
70             exe=False,
71             startstr="a.out`sum",
72             substrs=instructions)