2 // LLDB C++ API Test: verify the event description that is received by an
3 // SBListener object registered with a process with a breakpoint.
18 // listener thread control
19 extern atomic<bool> g_done;
20 extern SBListener g_listener;
22 multithreaded_queue<string> g_event_descriptions;
25 void listener_func() {
28 bool got_event = g_listener.WaitForEvent(1, event);
32 throw Exception("event is not valid in listener thread");
35 event.GetDescription(description);
36 string str(description.GetData());
37 g_event_descriptions.push(str);
42 bool check_state(string &state, string &desc, bool got_description)
48 g_error_desc.append("Did not get expected event description");
52 if (desc.find("state-changed") == desc.npos)
53 g_error_desc.append("Event description incorrect: missing 'state-changed' ");
55 if (desc.find("pid = ") == desc.npos)
56 g_error_desc.append("Event description incorrect: missing process pid ");
58 string state_search_str = "state = " + state;
59 if (desc.find(state_search_str) == desc.npos)
61 string errString = ("Event description incorrect: expected state "
65 g_error_desc.append(errString);
68 if (g_error_desc.length() > 0)
71 cout << "check_state: " << state << " OK\n";
75 void check_listener(SBDebugger &dbg)
80 // check for "launching" state, this may or may not be present
81 string desc = g_event_descriptions.pop(5, got_description);
83 if (check_state(state, desc, got_description))
85 // found a 'launching' state, pop next one from queue
86 desc = g_event_descriptions.pop(5, got_description);
90 if( !check_state(state, desc, got_description) )
91 throw Exception(g_error_desc);
93 desc = g_event_descriptions.pop(5, got_description);
95 if( !check_state(state, desc, got_description) )
96 throw Exception(g_error_desc);