1 //===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // Other libraries and framework includes
14 #include "lldb/API/SBBreakpointName.h"
15 #include "lldb/API/SBBreakpointLocation.h"
16 #include "lldb/API/SBDebugger.h"
17 #include "lldb/API/SBEvent.h"
18 #include "lldb/API/SBProcess.h"
19 #include "lldb/API/SBStream.h"
20 #include "lldb/API/SBStringList.h"
21 #include "lldb/API/SBThread.h"
23 #include "lldb/Breakpoint/BreakpointName.h"
24 #include "lldb/Breakpoint/StoppointCallbackContext.h"
25 #include "lldb/Core/Address.h"
26 #include "lldb/Core/Debugger.h"
27 #include "lldb/Core/StreamFile.h"
28 #include "lldb/Interpreter/CommandInterpreter.h"
29 #include "lldb/Interpreter/ScriptInterpreter.h"
30 #include "lldb/Target/Process.h"
31 #include "lldb/Target/Target.h"
32 #include "lldb/Target/Thread.h"
33 #include "lldb/Target/ThreadSpec.h"
34 #include "lldb/Utility/Log.h"
35 #include "lldb/Utility/Stream.h"
37 #include "lldb/lldb-enumerations.h"
39 #include "SBBreakpointOptionCommon.h"
41 #include "llvm/ADT/STLExtras.h"
44 using namespace lldb_private;
46 SBBreakpointCallbackBaton::SBBreakpointCallbackBaton(SBBreakpointHitCallback
49 : TypedBaton(llvm::make_unique<CallbackData>()) {
50 getItem()->callback = callback;
51 getItem()->callback_baton = baton;
54 bool SBBreakpointCallbackBaton::PrivateBreakpointHitCallback(void *baton,
55 StoppointCallbackContext *ctx,
56 lldb::user_id_t break_id,
57 lldb::user_id_t break_loc_id)
59 ExecutionContext exe_ctx(ctx->exe_ctx_ref);
61 exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
63 CallbackData *data = (CallbackData *)baton;
64 lldb_private::Breakpoint *bp = bp_sp.get();
65 if (bp && data->callback) {
66 Process *process = exe_ctx.GetProcessPtr();
68 SBProcess sb_process(process->shared_from_this());
70 SBBreakpointLocation sb_location;
72 sb_location.SetLocation(bp_sp->FindLocationByID(break_loc_id));
73 Thread *thread = exe_ctx.GetThreadPtr();
75 sb_thread.SetThread(thread->shared_from_this());
77 return data->callback(data->callback_baton, sb_process, sb_thread,
82 return true; // Return true if we should stop at this breakpoint
85 SBBreakpointCallbackBaton::~SBBreakpointCallbackBaton() = default;