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
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
import os
|
|
|
|
import time
|
2015-03-12 20:07:13 +00:00
|
|
|
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
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-12 20:07:13 +00:00
|
|
|
class DisassemblyTestCase(TestBase):
|
|
|
|
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
|
2016-09-06 20:57:50 +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()
|
2016-09-06 20:57:50 +00:00
|
|
|
exe = os.path.join(os.getcwd(), "a.out")
|
2015-03-12 20:07:13 +00:00
|
|
|
self.expect("file " + exe,
|
2016-09-06 20:57:50 +00:00
|
|
|
patterns=["Current executable set to .*a.out.*"])
|
2015-03-12 20:07:13 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
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)
|
2015-03-12 20:07:13 +00:00
|
|
|
|
|
|
|
self.expect("run",
|
2016-09-06 20:57:50 +00:00
|
|
|
patterns=["Process .* launched: "])
|
2015-03-12 20:07:13 +00:00
|
|
|
|
|
|
|
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 ']
|
2016-09-06 20:57:50 +00:00
|
|
|
elif re.match("mips", arch):
|
2015-11-18 08:18:03 +00:00
|
|
|
breakpoint_opcodes = ["break"]
|
2016-03-07 09:12:49 +00:00
|
|
|
instructions = ['lw', 'sw']
|
2016-04-14 14:28:34 +00:00
|
|
|
elif arch in ["s390x"]:
|
|
|
|
breakpoint_opcodes = [".long"]
|
|
|
|
instructions = [' l ', ' a ', ' st ']
|
2015-03-12 20:07:13 +00:00
|
|
|
else:
|
|
|
|
# TODO please add your arch here
|
2016-09-06 20:57:50 +00:00
|
|
|
self.fail(
|
|
|
|
'unimplemented for arch = "{arch}"'.format(
|
|
|
|
arch=self.getArchitecture()))
|
2015-03-12 20:07:13 +00:00
|
|
|
|
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
|
2016-09-06 20:57:50 +00:00
|
|
|
self.expect(
|
|
|
|
disassembly,
|
|
|
|
exe=False,
|
|
|
|
startstr="a.out`sum",
|
|
|
|
substrs=instructions)
|