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.
11 #include "lldb-headers.h"
18 // listener thread control
19 extern atomic<bool> g_done;
21 multithreaded_queue<string> g_thread_descriptions;
22 multithreaded_queue<string> g_frame_functions;
24 extern SBListener g_listener;
26 void listener_func() {
29 bool got_event = g_listener.WaitForEvent(1, event);
32 throw Exception("event is not valid in listener thread");
34 // send process description
35 SBProcess process = SBProcess::GetProcessFromEvent(event);
38 for (int i = 0; i < process.GetNumThreads(); ++i) {
39 // send each thread description
41 SBThread thread = process.GetThreadAtIndex(i);
42 thread.GetDescription(description);
43 g_thread_descriptions.push(description.GetData());
45 // send each frame function name
46 uint32_t num_frames = thread.GetNumFrames();
47 for(int j = 0; j < num_frames; ++j) {
48 const char* function_name = thread.GetFrameAtIndex(j).GetSymbol().GetName();
50 g_frame_functions.push(function_name);
57 void check_listener(SBDebugger &dbg) {
58 // check thread description
59 bool got_description = false;
60 string desc = g_thread_descriptions.pop(5, got_description);
62 throw Exception("Expected at least one thread description string");
64 // check at least one frame has a function name
65 desc = g_frame_functions.pop(5, got_description);
67 throw Exception("Expected at least one frame function name string");