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