diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-02-13 15:01:33 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-02-13 15:01:33 +0000 | 
| commit | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (patch) | |
| tree | 525149683974afa86747b749d45f0425749e972e /packages/Python/lldbsuite | |
| parent | e195173fdf080138dbb42936dea88c605e4b9a56 (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite')
7 files changed, 127 insertions, 5 deletions
| diff --git a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py index 90e847fd5fa2..5e1f307f622d 100644 --- a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py +++ b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py @@ -65,5 +65,6 @@ class ExprCharTestCase(TestBase):      @expectedFailurei386("llvm.org/pr23069")      @expectedFailurex86_64("llvm.org/pr23069")      @expectedFailureWindows("llvm.org/pr21765") +    @expectedFailureAll(bugnumber="llvm.org/pr23069", triple = 'mips*')      def test_unsigned_char(self):          self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'}) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/Makefile new file mode 100644 index 000000000000..77aa24afc0f7 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules + diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py new file mode 100644 index 000000000000..324401ff44e1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py @@ -0,0 +1,84 @@ +""" +Test specific to MIPS  +""" + +from __future__ import print_function + +import os, time +import re +import unittest2 +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + +class AvoidBreakpointInDelaySlotAPITestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @skipUnlessArch(archs=re.compile('mips*')) +    def test(self): +        self.build() +        exe = os.path.join(os.getcwd(), "a.out") +        self.expect("file " + exe, +                    patterns = [ "Current executable set to .*a.out.*" ]) +         +        # Create a target by the debugger. +        target = self.dbg.CreateTarget(exe) +        self.assertTrue(target, VALID_TARGET) + +        breakpoint = target.BreakpointCreateByName('main', 'a.out') +        self.assertTrue(breakpoint and +                        breakpoint.GetNumLocations() == 1, +                        VALID_BREAKPOINT) + +        # Now launch the process, and do not stop at entry point. +        process = target.LaunchSimple (None, None, self.get_process_working_directory()) +        self.assertTrue(process, PROCESS_IS_VALID) + +        list = target.FindFunctions('foo', lldb.eFunctionNameTypeAuto) +        self.assertTrue(list.GetSize() == 1) +        sc = list.GetContextAtIndex(0) +        self.assertTrue(sc.GetSymbol().GetName() == "foo") +        function = sc.GetFunction() +        self.assertTrue(function) +        self.function(function, target) + +    def function (self, function, target): +        """Iterate over instructions in function and place a breakpoint on delay slot instruction""" +        # Get the list of all instructions in the function +        insts = function.GetInstructions(target) +        print(insts) +        i = 0 +        for inst in insts: +            if (inst.HasDelaySlot()): +                # Remember the address of branch instruction. +                branchinstaddress = inst.GetAddress().GetLoadAddress(target) + +                # Get next instruction i.e delay slot instruction. +                delayinst = insts.GetInstructionAtIndex(i+1) +                delayinstaddr = delayinst.GetAddress().GetLoadAddress(target) + +                # Set breakpoint on delay slot instruction +                breakpoint = target.BreakpointCreateByAddress(delayinstaddr) + +                # Verify the breakpoint. +                self.assertTrue(breakpoint and +                                breakpoint.GetNumLocations() == 1, +                                VALID_BREAKPOINT) +                # Get the location from breakpoint +                location = breakpoint.GetLocationAtIndex(0) + +                # Get the address where breakpoint is actually set. +                bpaddr = location.GetLoadAddress() +		 +                # Breakpoint address should be adjusted to the address of branch instruction. +                self.assertTrue(branchinstaddress ==  bpaddr) +                i += 1 +            else: +                i += 1 + +if __name__ == '__main__': +    import atexit +    lldb.SBDebugger.Initialize() +    atexit.register(lambda: lldb.SBDebugger.Terminate()) +    unittest2.main() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/main.c new file mode 100644 index 000000000000..bc3eceea7693 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/main.c @@ -0,0 +1,21 @@ +#include <stdio.h> + +foo (int a, int b) +{ +    int c; +    if (a<=b) +        c=b-a; +    else +        c=b+a; +    return c; +} + +int main() +{ +    int a=7, b=8, c; +     +    c = foo(a, b); + +return 0; +} + diff --git a/packages/Python/lldbsuite/test/lldbtest.py b/packages/Python/lldbsuite/test/lldbtest.py index 3ad6d29a1d7a..de8f57f63706 100644 --- a/packages/Python/lldbsuite/test/lldbtest.py +++ b/packages/Python/lldbsuite/test/lldbtest.py @@ -633,6 +633,14 @@ def check_list_or_lambda(list_or_lambda, value):      else:          return list_or_lambda is None or value is None or list_or_lambda == value +def matchArchitectures(archs, actual_arch): +    retype = type(re.compile('hello, world')) +    list_passes = isinstance(archs, list) and actual_arch in archs +    basestring_passes = isinstance(archs, six.string_types) and actual_arch == archs +    regex_passes = isinstance(archs, retype) and re.match(archs, actual_arch) + +    return (list_passes or basestring_passes or regex_passes) +  # provide a function to xfail on defined oslist, compiler version, and archs  # if none is specified for any argument, that argument won't be checked and thus means for all  # for example, @@ -1026,7 +1034,7 @@ def skipUnlessHostPlatform(oslist):      return unittest2.skipUnless(getHostPlatform() in oslist,                                  "requires on of %s" % (", ".join(oslist))) -def skipUnlessArch(archlist): +def skipUnlessArch(archs):      """Decorate the item to skip tests unless running on one of the listed architectures."""      def myImpl(func):          if isinstance(func, type) and issubclass(func, unittest2.TestCase): @@ -1035,9 +1043,8 @@ def skipUnlessArch(archlist):          @wraps(func)          def wrapper(*args, **kwargs):              self = args[0] -            if self.getArchitecture() not in archlist: -                self.skipTest("skipping for architecture %s (requires one of %s)" %  -                    (self.getArchitecture(), ", ".join(archlist))) +            if not matchArchitectures(archs, self.getArchitecture()): +                self.skipTest("skipping for architecture %s" % (self.getArchitecture()))               else:                  func(*args, **kwargs)          return wrapper diff --git a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py index d45f5724f49c..187ba69def0e 100644 --- a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py +++ b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py @@ -24,7 +24,6 @@ class SymbolAPITestCase(TestBase):          self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.')      @add_test_categories(['pyapi']) -    @expectedFailureWindows("llvm.org/pr24778")      def test(self):          """Exercise some SBSymbol and SBAddress APIs."""          self.build() diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py index b48ded4dd365..97bfa3956f6c 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py @@ -22,6 +22,10 @@ class ThreadsStackTracesTestCase(TestBase):          self.line = line_number('main.cpp', '// Set break point at this line.')      @expectedFailureAll("llvm.org/pr23043", ["linux"], archs=["i386"]) # We are unable to produce a backtrace of the main thread when the thread is blocked in fgets + +    #The __thread_start function in libc doesn't contain any epilogue and prologue instructions  +    #hence unwinding fail when we are stopped in __thread_start +    @expectedFailureAll(triple = 'mips*')      @expectedFailureWindows("llvm.org/pr24778")      @add_test_categories(['pyapi'])      def test_stack_traces(self): | 
