2 // LLDB C++ API Test: verify that the function registered with
3 // SBBreakpoint.SetCallback() is invoked when a breakpoint is hit.
18 condition_variable g_condition;
19 int g_breakpoint_hit_count = 0;
21 bool BPCallback (void *baton,
24 SBBreakpointLocation &location) {
25 lock_guard<mutex> lock(g_mutex);
26 g_breakpoint_hit_count += 1;
27 g_condition.notify_all();
31 void test(SBDebugger &dbg, vector<string> args) {
33 SBTarget target = dbg.CreateTarget(args.at(0).c_str());
34 if (!target.IsValid()) throw Exception("invalid target");
36 SBBreakpoint breakpoint = target.BreakpointCreateByName("next");
37 if (!breakpoint.IsValid()) throw Exception("invalid breakpoint");
38 breakpoint.SetCallback(BPCallback, 0);
40 std::unique_ptr<char> working_dir(get_working_dir());
41 SBProcess process = target.LaunchSimple (0, 0, working_dir.get());
44 unique_lock<mutex> lock(g_mutex);
45 g_condition.wait_for(lock, chrono::seconds(5));
46 if (g_breakpoint_hit_count != 1)
47 throw Exception("Breakpoint hit count expected to be 1");