Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / bindings / interface / SBEventDocstrings.i
bloba15a7b9954dae92d791eda12e2cfb2fc1e99aaef
1 %feature("docstring",
2 "API clients can register to receive events.
4 For example, check out the following output: ::
6 Try wait for event...
7 Event description: 0x103d0bb70 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = running}
8 Event data flavor: Process::ProcessEventData
9 Process state: running
11 Try wait for event...
12 Event description: 0x103a700a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = stopped}
13 Event data flavor: Process::ProcessEventData
14 Process state: stopped
16 Try wait for event...
17 Event description: 0x103d0d4a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = exited}
18 Event data flavor: Process::ProcessEventData
19 Process state: exited
21 Try wait for event...
22 timeout occurred waiting for event...
24 from test/python_api/event/TestEventspy: ::
26 def do_listen_for_and_print_event(self):
27 '''Create a listener and use SBEvent API to print the events received.'''
28 exe = os.path.join(os.getcwd(), 'a.out')
30 # Create a target by the debugger.
31 target = self.dbg.CreateTarget(exe)
32 self.assertTrue(target, VALID_TARGET)
34 # Now create a breakpoint on main.c by name 'c'.
35 breakpoint = target.BreakpointCreateByName('c', 'a.out')
37 # Now launch the process, and do not stop at the entry point.
38 process = target.LaunchSimple(None, None, os.getcwd())
39 self.assertTrue(process.GetState() == lldb.eStateStopped,
40 PROCESS_STOPPED)
42 # Get a handle on the process's broadcaster.
43 broadcaster = process.GetBroadcaster()
45 # Create an empty event object.
46 event = lldb.SBEvent()
48 # Create a listener object and register with the broadcaster.
49 listener = lldb.SBListener('my listener')
50 rc = broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged)
51 self.assertTrue(rc, 'AddListener successfully retruns')
53 traceOn = self.TraceOn()
54 if traceOn:
55 lldbutil.print_stacktraces(process)
57 # Create MyListeningThread class to wait for any kind of event.
58 import threading
59 class MyListeningThread(threading.Thread):
60 def run(self):
61 count = 0
62 # Let's only try at most 4 times to retrieve any kind of event.
63 # After that, the thread exits.
64 while not count > 3:
65 if traceOn:
66 print('Try wait for event...')
67 if listener.WaitForEventForBroadcasterWithType(5,
68 broadcaster,
69 lldb.SBProcess.eBroadcastBitStateChanged,
70 event):
71 if traceOn:
72 desc = lldbutil.get_description(event))
73 print('Event description:', desc)
74 print('Event data flavor:', event.GetDataFlavor())
75 print('Process state:', lldbutil.state_type_to_str(process.GetState()))
76 print()
77 else:
78 if traceOn:
79 print 'timeout occurred waiting for event...'
80 count = count + 1
81 return
83 # Let's start the listening thread to retrieve the events.
84 my_thread = MyListeningThread()
85 my_thread.start()
87 # Use Python API to continue the process. The listening thread should be
88 # able to receive the state changed events.
89 process.Continue()
91 # Use Python API to kill the process. The listening thread should be
92 # able to receive the state changed event, too.
93 process.Kill()
95 # Wait until the 'MyListeningThread' terminates.
96 my_thread.join()"
97 ) lldb::SBEvent;
99 %feature("autodoc",
100 "__init__(self, int type, str data) -> SBEvent (make an event that contains a C string)"
101 ) lldb::SBEvent::SBEvent;