2 // LLDB C++ API Test: verify the event description as obtained by calling
3 // SBEvent::GetCStringFromEvent that is received by an
4 // SBListener object registered with a process with a breakpoint.
18 // listener thread control
19 extern atomic<bool> g_done;
21 multithreaded_queue<string> g_frame_functions;
23 extern SBListener g_listener;
25 void listener_func() {
28 bool got_event = g_listener.WaitForEvent(1, event);
31 throw Exception("event is not valid in listener thread");
32 // send process description
33 SBProcess process = SBProcess::GetProcessFromEvent(event);
34 if (!process.IsValid())
35 throw Exception("process is not valid");
36 if (SBProcess::GetStateFromEvent(event) != lldb::eStateStopped || SBProcess::GetRestartedFromEvent(event))
37 continue; // Only interested in "stopped" events.
41 for (int i = 0; i < process.GetNumThreads(); ++i) {
42 // send each thread description
43 SBThread thread = process.GetThreadAtIndex(i);
44 // send each frame function name
45 uint32_t num_frames = thread.GetNumFrames();
46 for(int j = 0; j < num_frames; ++j) {
47 const char* function_name = thread.GetFrameAtIndex(j).GetSymbol().GetName();
49 g_frame_functions.push(string(function_name));
56 void check_listener(SBDebugger &dbg) {
57 // check thread description
58 bool got_description = false;
59 string func_name = g_frame_functions.pop(5, got_description);
61 if(got_description == false)
62 throw Exception("Expected at least one frame function");