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 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBBreakpointName.h"
11 #include "lldb/API/SBBreakpointLocation.h"
12 #include "lldb/API/SBDebugger.h"
13 #include "lldb/API/SBEvent.h"
14 #include "lldb/API/SBProcess.h"
15 #include "lldb/API/SBStream.h"
16 #include "lldb/API/SBStringList.h"
17 #include "lldb/API/SBThread.h"
19 #include "lldb/Breakpoint/BreakpointName.h"
20 #include "lldb/Breakpoint/StoppointCallbackContext.h"
21 #include "lldb/Core/Address.h"
22 #include "lldb/Core/Debugger.h"
23 #include "lldb/Core/StreamFile.h"
24 #include "lldb/Interpreter/CommandInterpreter.h"
25 #include "lldb/Interpreter/ScriptInterpreter.h"
26 #include "lldb/Target/Process.h"
27 #include "lldb/Target/Target.h"
28 #include "lldb/Target/Thread.h"
29 #include "lldb/Target/ThreadSpec.h"
30 #include "lldb/Utility/Log.h"
31 #include "lldb/Utility/Stream.h"
33 #include "lldb/lldb-enumerations.h"
35 #include "SBBreakpointOptionCommon.h"
37 #include "llvm/ADT/STLExtras.h"
40 using namespace lldb_private;
42 SBBreakpointCallbackBaton::SBBreakpointCallbackBaton(SBBreakpointHitCallback
45 : TypedBaton(llvm::make_unique<CallbackData>()) {
46 getItem()->callback = callback;
47 getItem()->callback_baton = baton;
50 bool SBBreakpointCallbackBaton::PrivateBreakpointHitCallback(void *baton,
51 StoppointCallbackContext *ctx,
52 lldb::user_id_t break_id,
53 lldb::user_id_t break_loc_id)
55 ExecutionContext exe_ctx(ctx->exe_ctx_ref);
57 exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
59 CallbackData *data = (CallbackData *)baton;
60 lldb_private::Breakpoint *bp = bp_sp.get();
61 if (bp && data->callback) {
62 Process *process = exe_ctx.GetProcessPtr();
64 SBProcess sb_process(process->shared_from_this());
66 SBBreakpointLocation sb_location;
68 sb_location.SetLocation(bp_sp->FindLocationByID(break_loc_id));
69 Thread *thread = exe_ctx.GetThreadPtr();
71 sb_thread.SetThread(thread->shared_from_this());
73 return data->callback(data->callback_baton, sb_process, sb_thread,
78 return true; // Return true if we should stop at this breakpoint
81 SBBreakpointCallbackBaton::~SBBreakpointCallbackBaton() = default;