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