73 lines
2.2 KiB
Python
Raw Normal View History

"""
Test some lldb command abbreviations.
"""
from __future__ import print_function
import os
import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class DisassemblyTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@expectedFailureAll(
oslist=["windows"],
bugnumber="function names print fully demangled instead of name-only")
Merge dwarf and dsym tests Currently most of the test files have a separate dwarf and a separate dsym test with almost identical content (only the build step is different). With adding dwo symbol file handling to the test suit it would increase this to a 3-way duplication. The purpose of this change is to eliminate this redundancy with generating 2 test case (one dwarf and one dsym) for each test function specified (dwo handling will be added at a later commit). Main design goals: * There should be no boilerplate code in each test file to support the multiple debug info in most of the tests (custom scenarios are acceptable in special cases) so adding a new test case is easier and we can't miss one of the debug info type. * In case of a test failure, the debug symbols used during the test run have to be cleanly visible from the output of dotest.py to make debugging easier both from build bot logs and from local test runs * Each test case should have a unique, fully qualified name so we can run exactly 1 test with "-f <test-case>.<test-function>" syntax * Test output should be grouped based on test files the same way as it happens now (displaying dwarf/dsym results separately isn't preferable) Proposed solution (main logic in lldbtest.py, rest of them are test cases fixed up for the new style): * Have only 1 test fuction in the test files what will run for all debug info separately and this test function should call just "self.build(...)" to build an inferior with the right debug info * When a class is created by python (the class object, not the class instance), we will generate a new test method for each debug info format in the test class with the name "<test-function>_<debug-info>" and remove the original test method. This way unittest2 see multiple test methods (1 for each debug info, pretty much as of now) and will handle the test selection and the failure reporting correctly (the debug info will be visible from the end of the test name) * Add new annotation @no_debug_info_test to disable the generation of multiple tests for each debug info format when the test don't have an inferior Differential revision: http://reviews.llvm.org/D13028 llvm-svn: 248883
2015-09-30 10:12:40 +00:00
def test(self):
self.build()
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.
arch = self.getArchitecture()
if arch in ["", 'x86_64', 'i386', 'i686']:
breakpoint_opcodes = ["int3"]
instructions = [' mov', ' addl ', 'ret']
elif arch in ["arm", "aarch64"]:
breakpoint_opcodes = ["brk", "udf"]
instructions = [' add ', ' ldr ', ' str ']
elif re.match("mips", arch):
breakpoint_opcodes = ["break"]
instructions = ['lw', 'sw']
Support Linux on SystemZ as platform This patch adds support for Linux on SystemZ: - A new ArchSpec value of eCore_s390x_generic - A new directory Plugins/ABI/SysV-s390x providing an ABI implementation - Register context support - Native Linux support including watchpoint support - ELF core file support - Misc. support throughout the code base (e.g. breakpoint opcodes) - Test case updates to support the platform This should provide complete support for debugging the SystemZ platform. Not yet supported are optional features like transaction support (zEC12) or SIMD vector support (z13). There is no instruction emulation, since our ABI requires that all code provide correct DWARF CFI at all PC locations in .eh_frame to support unwinding (i.e. -fasynchronous-unwind-tables is on by default). The implementation follows existing platforms in a mostly straightforward manner. A couple of things that are different: - We do not use PTRACE_PEEKUSER / PTRACE_POKEUSER to access single registers, since some registers (access register) reside at offsets in the user area that are multiples of 4, but the PTRACE_PEEKUSER interface only allows accessing aligned 8-byte blocks in the user area. Instead, we use a s390 specific ptrace interface PTRACE_PEEKUSR_AREA / PTRACE_POKEUSR_AREA that allows accessing a whole block of the user area in one go, so in effect allowing to treat parts of the user area as register sets. - SystemZ hardware does not provide any means to implement read watchpoints, only write watchpoints. In fact, we can only support a *single* write watchpoint (but this can span a range of arbitrary size). In LLDB this means we support only a single watchpoint. I've set all test cases that require read watchpoints (or multiple watchpoints) to expected failure on the platform. [ Note that there were two test cases that install a read/write watchpoint even though they nowhere rely on the "read" property. I've changed those to simply use plain write watchpoints. ] Differential Revision: http://reviews.llvm.org/D18978 llvm-svn: 266308
2016-04-14 14:28:34 +00:00
elif arch in ["s390x"]:
breakpoint_opcodes = [".long"]
instructions = [' l ', ' a ', ' st ']
else:
# TODO please add your arch here
self.fail(
'unimplemented for arch = "{arch}"'.format(
arch=self.getArchitecture()))
# 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
self.expect(
disassembly,
exe=False,
startstr="a.out`sum",
substrs=instructions)