brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · f8ab3a7 Raw
72 lines · python
1"""Test that SBFrame::FindValue finds things but does not duplicate the entire variables list"""2 3 4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9 10class SBFrameFindValueTestCase(TestBase):11    NO_DEBUG_INFO_TESTCASE = True12 13    def test_formatters_api(self):14        """Test that SBFrame::FindValue finds things but does not duplicate the entire variables list"""15        self.build()16        self.setTearDownCleanup()17 18        exe = self.getBuildArtifact("a.out")19 20        # Create the target21        target = self.dbg.CreateTarget(exe)22        self.assertTrue(target, VALID_TARGET)23 24        # Set the breakpoints25        breakpoint = target.BreakpointCreateBySourceRegex(26            "Set breakpoint here", lldb.SBFileSpec("main.cpp")27        )28        self.assertGreater(breakpoint.GetNumLocations(), 0, VALID_BREAKPOINT)29 30        # Launch the process, and do not stop at the entry point.31        process = target.LaunchSimple(None, None, self.get_process_working_directory())32 33        self.assertTrue(process, PROCESS_IS_VALID)34 35        # Frame #0 should be at our breakpoint.36        threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint)37 38        self.assertEqual(len(threads), 1)39        self.thread = threads[0]40        self.frame = self.thread.frames[0]41        self.assertTrue(self.frame, "Frame 0 is valid.")42 43        self.assertEqual(44            self.frame.GetVariables(True, True, False, True).GetSize(),45            2,46            "variable count is off",47        )48        self.assertFalse(49            self.frame.FindValue(50                "NoSuchThing",51                lldb.eValueTypeVariableArgument,52                lldb.eDynamicCanRunTarget,53            ).IsValid(),54            "found something that should not be here",55        )56        self.assertEqual(57            self.frame.GetVariables(True, True, False, True).GetSize(),58            2,59            "variable count is off after failed FindValue()",60        )61        self.assertTrue(62            self.frame.FindValue(63                "a", lldb.eValueTypeVariableArgument, lldb.eDynamicCanRunTarget64            ).IsValid(),65            "FindValue() didn't find an argument",66        )67        self.assertEqual(68            self.frame.GetVariables(True, True, False, True).GetSize(),69            2,70            "variable count is off after successful FindValue()",71        )72