/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/API/SBBreakpointOptionCommon.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- SBBreakpointOptionCommon.cpp --------------------------------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #include "lldb/API/SBBreakpointName.h" |
10 | | #include "lldb/API/SBBreakpointLocation.h" |
11 | | #include "lldb/API/SBDebugger.h" |
12 | | #include "lldb/API/SBEvent.h" |
13 | | #include "lldb/API/SBProcess.h" |
14 | | #include "lldb/API/SBStream.h" |
15 | | #include "lldb/API/SBStringList.h" |
16 | | #include "lldb/API/SBThread.h" |
17 | | |
18 | | #include "lldb/Breakpoint/BreakpointName.h" |
19 | | #include "lldb/Breakpoint/StoppointCallbackContext.h" |
20 | | #include "lldb/Core/Address.h" |
21 | | #include "lldb/Core/Debugger.h" |
22 | | #include "lldb/Interpreter/CommandInterpreter.h" |
23 | | #include "lldb/Interpreter/ScriptInterpreter.h" |
24 | | #include "lldb/Target/Process.h" |
25 | | #include "lldb/Target/Target.h" |
26 | | #include "lldb/Target/Thread.h" |
27 | | #include "lldb/Target/ThreadSpec.h" |
28 | | #include "lldb/Utility/Instrumentation.h" |
29 | | #include "lldb/Utility/Log.h" |
30 | | #include "lldb/Utility/Stream.h" |
31 | | |
32 | | #include "lldb/lldb-enumerations.h" |
33 | | |
34 | | #include "SBBreakpointOptionCommon.h" |
35 | | |
36 | | #include "llvm/ADT/STLExtras.h" |
37 | | |
38 | | using namespace lldb; |
39 | | using namespace lldb_private; |
40 | | |
41 | | SBBreakpointCallbackBaton::SBBreakpointCallbackBaton( |
42 | | SBBreakpointHitCallback callback, void *baton) |
43 | 2 | : TypedBaton(std::make_unique<CallbackData>()) { |
44 | 2 | LLDB_INSTRUMENT_VA(this, callback, baton); |
45 | 2 | getItem()->callback = callback; |
46 | 2 | getItem()->callback_baton = baton; |
47 | 2 | } |
48 | | |
49 | | bool SBBreakpointCallbackBaton::PrivateBreakpointHitCallback( |
50 | | void *baton, StoppointCallbackContext *ctx, lldb::user_id_t break_id, |
51 | 2 | lldb::user_id_t break_loc_id) { |
52 | 2 | LLDB_INSTRUMENT_VA(baton, ctx, break_id, break_loc_id); |
53 | 2 | ExecutionContext exe_ctx(ctx->exe_ctx_ref); |
54 | 2 | BreakpointSP bp_sp( |
55 | 2 | exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id)); |
56 | 2 | if (baton && bp_sp) { |
57 | 2 | CallbackData *data = (CallbackData *)baton; |
58 | 2 | lldb_private::Breakpoint *bp = bp_sp.get(); |
59 | 2 | if (bp && data->callback) { |
60 | 2 | Process *process = exe_ctx.GetProcessPtr(); |
61 | 2 | if (process) { |
62 | 2 | SBProcess sb_process(process->shared_from_this()); |
63 | 2 | SBThread sb_thread; |
64 | 2 | SBBreakpointLocation sb_location; |
65 | 2 | assert(bp_sp); |
66 | 2 | sb_location.SetLocation(bp_sp->FindLocationByID(break_loc_id)); |
67 | 2 | Thread *thread = exe_ctx.GetThreadPtr(); |
68 | 2 | if (thread) |
69 | 2 | sb_thread.SetThread(thread->shared_from_this()); |
70 | | |
71 | 2 | return data->callback(data->callback_baton, sb_process, sb_thread, |
72 | 2 | sb_location); |
73 | 2 | } |
74 | 2 | } |
75 | 2 | } |
76 | 0 | return true; // Return true if we should stop at this breakpoint |
77 | 2 | } |
78 | | |
79 | 2 | SBBreakpointCallbackBaton::~SBBreakpointCallbackBaton() = default; |