1 """Test stepping and setting breakpoints in indirect and re-exported symbols."""
5 from lldbsuite
.test
.decorators
import *
6 from lldbsuite
.test
.lldbtest
import *
7 from lldbsuite
.test
import lldbutil
10 class TestIndirectFunctions(TestBase
):
12 # Call super's setUp().
14 # Find the line numbers that we will step to in main:
15 self
.main_source
= "main.c"
18 @add_test_categories(["pyapi"])
19 @skipIf(bugnumber
="rdar://120796553")
20 def test_with_python_api(self
):
21 """Test stepping and setting breakpoints in indirect and re-exported symbols."""
23 exe
= self
.getBuildArtifact("a.out")
25 target
= self
.dbg
.CreateTarget(exe
)
26 self
.assertTrue(target
, VALID_TARGET
)
28 lib1
= self
.getBuildArtifact("libindirect.dylib")
29 lib2
= self
.getBuildArtifact("libreexport.dylib")
30 self
.registerSharedLibrariesWithTarget(target
, [lib1
, lib2
])
32 self
.main_source_spec
= lldb
.SBFileSpec(self
.main_source
)
34 break1
= target
.BreakpointCreateBySourceRegex(
35 "Set breakpoint here to step in indirect.", self
.main_source_spec
37 self
.assertTrue(break1
, VALID_BREAKPOINT
)
39 break2
= target
.BreakpointCreateBySourceRegex(
40 "Set breakpoint here to step in reexported.", self
.main_source_spec
42 self
.assertTrue(break2
, VALID_BREAKPOINT
)
44 # Now launch the process, and do not stop at entry point.
45 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
47 self
.assertTrue(process
, PROCESS_IS_VALID
)
49 # The stop reason of the thread should be breakpoint.
50 threads
= lldbutil
.get_threads_stopped_at_breakpoint(process
, break1
)
52 self
.fail("Failed to stop at breakpoint 1.")
56 # Now do a step-into, and we should end up in the hidden target of this
59 curr_function
= thread
.GetFrameAtIndex(0).GetFunctionName()
62 "call_through_indirect_hidden",
63 "Stepped into indirect symbols.",
66 # Now set a breakpoint using the indirect symbol name, and make sure we
68 break_indirect
= target
.BreakpointCreateByName("call_through_indirect")
69 self
.assertTrue(break_indirect
, VALID_BREAKPOINT
)
71 # Now continue should take us to the second call through the indirect
74 threads
= lldbutil
.continue_to_breakpoint(process
, break_indirect
)
75 self
.assertEqual(len(threads
), 1, "Stopped at breakpoint in indirect function.")
76 curr_function
= thread
.GetFrameAtIndex(0).GetFunctionName()
79 "call_through_indirect_hidden",
80 "Stepped into indirect symbols.",
83 # Delete this breakpoint so it won't get in the way:
84 target
.BreakpointDelete(break_indirect
.GetID())
86 # Now continue to the site of the first re-exported function call in
88 threads
= lldbutil
.continue_to_breakpoint(process
, break2
)
90 # This is stepping Into through a re-exported symbol to an indirect
93 curr_function
= thread
.GetFrameAtIndex(0).GetFunctionName()
96 "call_through_indirect_hidden",
97 "Stepped into indirect symbols.",
100 # And the last bit is to set a breakpoint on the re-exported symbol and
101 # make sure we are again in out target function.
102 break_reexported
= target
.BreakpointCreateByName("reexport_to_indirect")
103 self
.assertEqual(break_reexported
.GetNumLocations(), 1, VALID_BREAKPOINT
)
105 # Now continue should take us to the second call through the indirect
108 threads
= lldbutil
.continue_to_breakpoint(process
, break_reexported
)
110 len(threads
), 1, "Stopped at breakpoint in reexported function target."
112 curr_function
= thread
.GetFrameAtIndex(0).GetFunctionName()
115 "call_through_indirect_hidden",
116 "Stepped into indirect symbols.",