예제 #1
0
    def test_imp_ivar_type(self):
        """Test that dynamically discovered ivars of type IMP do not crash LLDB"""
        lldbutil.execute_command("make repro")

        def cleanup():
            lldbutil.execute_command("make cleanup")

        self.addTearDownHook(cleanup)

        exe = os.path.join(os.getcwd(), "a.out")

        # Create a target from the debugger.
        target = self.dbg.CreateTarget(exe)
        self.assertTrue(target, VALID_TARGET)

        # Set up our breakpoint

        bkpt = lldbutil.run_break_set_by_source_regexp(self, "break here")

        # Now launch the process, and do not stop at the entry point.
        process = target.LaunchSimple(None, None,
                                      self.get_process_working_directory())

        self.assertTrue(process.GetState() == lldb.eStateStopped,
                        PROCESS_STOPPED)

        self.expect(
            'frame variable --ptr-depth=1 --show-types -d run -- object',
            substrs=['(MyClass *) object = 0x', '(void *) myImp = 0x'])
        self.expect('disassemble --start-address `((MyClass*)object)->myImp`',
                    substrs=['-[MyClass init]'])
예제 #2
0
    def test_imp_ivar_type(self):
        """Test that dynamically discovered ivars of type IMP do not crash LLDB"""
        lldbutil.execute_command("make repro")

        def cleanup():
            lldbutil.execute_command("make cleanup")
        self.addTearDownHook(cleanup)

        exe = os.path.join(os.getcwd(), "a.out")

        # Create a target from the debugger.
        target = self.dbg.CreateTarget(exe)
        self.assertTrue(target, VALID_TARGET)

        # Set up our breakpoint

        bkpt = lldbutil.run_break_set_by_source_regexp(self, "break here")

        # Now launch the process, and do not stop at the entry point.
        process = target.LaunchSimple(
            None, None, self.get_process_working_directory())

        self.assertTrue(process.GetState() == lldb.eStateStopped,
                        PROCESS_STOPPED)

        self.expect(
            'frame variable --ptr-depth=1 --show-types -d run -- object',
            substrs=[
                '(MyClass *) object = 0x',
                '(void *) myImp = 0x'])
        self.expect(
            'disassemble --start-address `((MyClass*)object)->myImp`',
            substrs=['-[MyClass init]'])
예제 #3
0
 def cleanup():
     lldbutil.execute_command("make cleanup")
예제 #4
0
 def cleanup():
     lldbutil.execute_command("make cleanup")
예제 #5
0
 def buildAll(self):
     lldbutil.execute_command("make everything")
예제 #6
0
    def test(self):
        if self.getArchitecture() == 'x86_64':
            source = os.path.join(os.getcwd(), "main.cpp")
            o_file = os.path.join(os.getcwd(), "main.o")
            lldbutil.execute_command(
                "'%s' -g -O0 -arch i386 -arch x86_64 '%s' -c -o '%s'" %
                (os.environ["CC"], source, o_file))
            lldbutil.execute_command(
                "'%s' -g -O0 -arch i386 -arch x86_64 '%s'" %
                (os.environ["CC"], o_file))
            if self.debug_info != "dsym":
                dsym_path = os.path.join(os.getcwd(), "a.out.dSYM")
                lldbutil.execute_command("rm -rf '%s'" % (dsym_path))
        else:
            self.build()

        exe = os.path.join(os.getcwd(), "a.out")

        # Create the target
        target = self.dbg.CreateTarget(exe)

        # Create any breakpoints we need
        breakpoint = target.BreakpointCreateBySourceRegex(
            'Set breakpoint 1 here', lldb.SBFileSpec("main.cpp", False))
        self.assertTrue(breakpoint, VALID_BREAKPOINT)

        # Launch the process
        process = target.LaunchSimple(
            None, None, self.get_process_working_directory())
        self.assertTrue(process, PROCESS_IS_VALID)

        for i in range(6):
            # The stop reason of the thread should be breakpoint.
            self.assertTrue(process.GetState() == lldb.eStateStopped,
                            STOPPED_DUE_TO_BREAKPOINT)

            threads = lldbutil.get_threads_stopped_at_breakpoint(
                process, breakpoint)
            self.assertTrue(len(threads) == 1)

            # We had a deadlock tearing down the TypeSystemMap on exec, but only if some
            # expression had been evaluated.  So make sure we do that here so the teardown
            # is not trivial.

            thread = threads[0]
            value = thread.frames[0].EvaluateExpression("1 + 2")
            self.assertTrue(
                value.IsValid(),
                "Expression evaluated successfully")
            int_value = value.GetValueAsSigned()
            self.assertTrue(int_value == 3, "Expression got the right result.")

            # Run and we should stop due to exec
            process.Continue()

            self.assertTrue(process.GetState() == lldb.eStateStopped,
                            "Process should be stopped at __dyld_start")

            threads = lldbutil.get_stopped_threads(
                process, lldb.eStopReasonExec)
            self.assertTrue(
                len(threads) == 1,
                "We got a thread stopped for exec.")

            # Run and we should stop at breakpoint in main after exec
            process.Continue()

            threads = lldbutil.get_threads_stopped_at_breakpoint(
                process, breakpoint)
            self.assertTrue(len(threads) == 1,
                            "Stopped at breakpoint in exec'ed process.")