2 Test SBValue.GetObjectDescription() with the value from SBTarget.FindGlobalVariables().
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import lldbutil
11 class ObjectDescriptionAPITestCase(TestBase
):
13 # Call super's setUp().
15 # Find the line number to break at.
16 self
.source
= "main.m"
17 self
.line
= line_number(self
.source
, "// Set break point at this line.")
19 # rdar://problem/10857337
20 @add_test_categories(["pyapi"])
21 def test_find_global_variables_then_object_description(self
):
22 """Exercise SBTarget.FindGlobalVariables() API."""
24 self
.build(dictionary
=d
)
25 self
.setTearDownCleanup(dictionary
=d
)
26 exe
= self
.getBuildArtifact("b.out")
28 # Create a target by the debugger.
29 target
= self
.dbg
.CreateTarget(exe
)
30 self
.assertTrue(target
, VALID_TARGET
)
32 breakpoint
= target
.BreakpointCreateByLocation(self
.source
, self
.line
)
33 self
.assertTrue(breakpoint
, VALID_BREAKPOINT
)
35 # Now launch the process, and do not stop at entry point.
36 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
37 self
.assertTrue(process
, PROCESS_IS_VALID
)
38 # Make sure we hit our breakpoint:
39 thread_list
= lldbutil
.get_threads_stopped_at_breakpoint(process
, breakpoint
)
40 self
.assertEqual(len(thread_list
), 1)
42 thread
= thread_list
[0]
43 frame0
= thread
.GetFrameAtIndex(0)
45 # Note my_global_str's object description prints fine here.
46 value_list1
= frame0
.GetVariables(True, True, True, True)
51 print("object description:", v
.GetObjectDescription())
52 if v
.GetName() == "my_global_str":
53 self
.assertEqual(v
.GetObjectDescription(), "This is a global string")
56 value_list2
= target
.FindGlobalVariables("my_global_str", 3)
61 print("object description:", v
.GetObjectDescription())
62 if v
.GetName() == "my_global_str":
63 self
.assertEqual(v
.GetObjectDescription(), "This is a global string")