2015-03-12 20:07:13 +00:00
|
|
|
"""
|
|
|
|
Test some lldb command abbreviations.
|
|
|
|
"""
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2015-10-22 20:06:20 +00:00
|
|
|
|
2015-03-12 20:07:13 +00:00
|
|
|
import os, time
|
|
|
|
import lldb
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test import lldbutil
|
2015-03-12 20:07:13 +00:00
|
|
|
|
|
|
|
class DisassemblyTestCase(TestBase):
|
|
|
|
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
|
2016-02-08 19:34:59 +00:00
|
|
|
@expectedFailureAll(oslist=["windows"], bugnumber="function names print fully demangled instead of name-only")
|
2015-09-30 10:12:40 +00:00
|
|
|
def test(self):
|
|
|
|
self.build()
|
2015-03-12 20:07:13 +00:00
|
|
|
exe = os.path.join (os.getcwd(), "a.out")
|
|
|
|
self.expect("file " + exe,
|
|
|
|
patterns = [ "Current executable set to .*a.out.*" ])
|
|
|
|
|
|
|
|
match_object = lldbutil.run_break_set_command (self, "br s -n sum")
|
|
|
|
lldbutil.check_breakpoint_result (self, match_object, symbol_name='sum', symbol_match_exact=False, num_locations=1)
|
|
|
|
|
|
|
|
self.expect("run",
|
|
|
|
patterns = [ "Process .* launched: "])
|
|
|
|
|
|
|
|
self.runCmd("dis -f")
|
|
|
|
disassembly = self.res.GetOutput()
|
|
|
|
|
|
|
|
# ARCH, if not specified, defaults to x86_64.
|
2015-11-18 08:18:03 +00:00
|
|
|
arch = self.getArchitecture()
|
|
|
|
if arch in ["", 'x86_64', 'i386', 'i686']:
|
2015-07-03 10:32:55 +00:00
|
|
|
breakpoint_opcodes = ["int3"]
|
|
|
|
instructions = [' mov', ' addl ', 'ret']
|
2015-11-18 08:18:03 +00:00
|
|
|
elif arch in ["arm", "aarch64"]:
|
2015-07-03 10:32:55 +00:00
|
|
|
breakpoint_opcodes = ["brk", "udf"]
|
|
|
|
instructions = [' add ', ' ldr ', ' str ']
|
2015-11-18 08:18:03 +00:00
|
|
|
elif re.match("mips" , arch):
|
|
|
|
breakpoint_opcodes = ["break"]
|
2016-03-07 09:12:49 +00:00
|
|
|
instructions = ['lw', 'sw']
|
2015-03-12 20:07:13 +00:00
|
|
|
else:
|
|
|
|
# TODO please add your arch here
|
|
|
|
self.fail('unimplemented for arch = "{arch}"'.format(arch=self.getArchitecture()))
|
|
|
|
|
2015-07-03 10:32:55 +00:00
|
|
|
# make sure that the software breakpoint has been removed
|
|
|
|
for op in breakpoint_opcodes:
|
|
|
|
self.assertFalse(op in disassembly)
|
|
|
|
|
|
|
|
# make sure a few reasonable assembly instructions are here
|
2015-07-24 08:54:22 +00:00
|
|
|
self.expect(disassembly, exe=False, startstr = "a.out`sum", substrs = instructions)
|