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