2 debugserver used to block replying to the 'D' packet
3 till it had joined the profiling thread. If the profiling interval
4 was too long, that would mean it would take longer than the packet
5 timeout to reply, and the detach would time out. Make sure that doesn't
11 import lldbsuite
.test
.lldbutil
as lldbutil
12 from lldbsuite
.test
.lldbtest
import *
13 from lldbsuite
.test
.decorators
import *
18 class TestDetachVrsProfile(TestBase
):
19 NO_DEBUG_INFO_TESTCASE
= True
22 @skipIfOutOfTreeDebugserver
24 def test_profile_and_detach(self
):
25 """There can be many tests in a test case - describe this test here."""
27 self
.main_source_file
= lldb
.SBFileSpec("main.c")
28 self
.do_profile_and_detach()
30 def do_profile_and_detach(self
):
31 (target
, process
, thread
, bkpt
) = lldbutil
.run_to_source_breakpoint(
32 self
, "Set a breakpoint here", self
.main_source_file
35 interp
= self
.dbg
.GetCommandInterpreter()
36 result
= lldb
.SBCommandReturnObject()
38 # First make sure we are getting async data. Set a short interval, continue a bit and check:
40 "process plugin packet send 'QSetEnableAsyncProfiling;enable:1;interval_usec:500000;scan_type=0x5;'",
44 result
.Succeeded(), "process packet send failed: %s" % (result
.GetError())
47 # Run a bit to give us a change to collect profile data:
48 bkpt
.SetIgnoreCount(1)
49 threads
= lldbutil
.continue_to_breakpoint(process
, bkpt
)
50 self
.assertEqual(len(threads
), 1, "Hit our breakpoint again.")
51 str = process
.GetAsyncProfileData(1000)
52 self
.assertGreater(len(str), 0, "Got some profile data")
54 # Now make the profiling interval very long and try to detach.
56 "process plugin packet send 'QSetEnableAsyncProfiling;enable:1;interval_usec:10000000;scan_type=0x5;'",
60 result
.Succeeded(), "process packet send failed: %s" % (result
.GetError())
62 self
.dbg
.SetAsync(True)
63 listener
= self
.dbg
.GetListener()
65 # We don't want to hit our breakpoint anymore.
66 bkpt
.SetEnabled(False)
68 # Record our process pid so we can kill it since we are going to detach...
69 self
.pid
= process
.GetProcessID()
72 self
.dbg
.SetAsync(False)
73 os
.kill(self
.pid
, signal
.SIGKILL
)
75 self
.addTearDownHook(cleanup
)
79 event
= lldb
.SBEvent()
80 success
= listener
.WaitForEventForBroadcaster(
81 0, process
.GetBroadcaster(), event
83 self
.assertTrue(success
, "Got an event which should be running.")
84 event_state
= process
.GetStateFromEvent(event
)
85 self
.assertState(event_state
, lldb
.eStateRunning
, "Got the running event")
88 error
= process
.Detach()
89 self
.assertSuccess(error
, "Detached successfully")