102 lines · plain
1%feature("docstring",2"API clients can register to receive events.3 4For example, check out the following output: ::5 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::ProcessEventData9 Process state: running10 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::ProcessEventData14 Process state: stopped15 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::ProcessEventData19 Process state: exited20 21 Try wait for event...22 timeout occurred waiting for event...23 24from test/python_api/event/TestEventspy: ::25 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')29 30 # Create a target by the debugger.31 target = self.dbg.CreateTarget(exe)32 self.assertTrue(target, VALID_TARGET)33 34 # Now create a breakpoint on main.c by name 'c'.35 breakpoint = target.BreakpointCreateByName('c', 'a.out')36 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)41 42 # Get a handle on the process's broadcaster.43 broadcaster = process.GetBroadcaster()44 45 # Create an empty event object.46 event = lldb.SBEvent()47 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')52 53 traceOn = self.TraceOn()54 if traceOn:55 lldbutil.print_stacktraces(process)56 57 # Create MyListeningThread class to wait for any kind of event.58 import threading59 class MyListeningThread(threading.Thread):60 def run(self):61 count = 062 # 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 + 181 return82 83 # Let's start the listening thread to retrieve the events.84 my_thread = MyListeningThread()85 my_thread.start()86 87 # Use Python API to continue the process. The listening thread should be88 # able to receive the state changed events.89 process.Continue()90 91 # Use Python API to kill the process. The listening thread should be92 # able to receive the state changed event, too.93 process.Kill()94 95 # Wait until the 'MyListeningThread' terminates.96 my_thread.join()"97) lldb::SBEvent;98 99%feature("autodoc",100"__init__(self, int type, str data) -> SBEvent (make an event that contains a C string)"101) lldb::SBEvent::SBEvent;102