LLDB mainline
SBBreakpointOptionCommon.cpp
Go to the documentation of this file.
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
11#include "lldb/API/SBDebugger.h"
12#include "lldb/API/SBEvent.h"
13#include "lldb/API/SBProcess.h"
14#include "lldb/API/SBStream.h"
16#include "lldb/API/SBThread.h"
17
20#include "lldb/Core/Address.h"
21#include "lldb/Core/Debugger.h"
24#include "lldb/Target/Process.h"
25#include "lldb/Target/Target.h"
26#include "lldb/Target/Thread.h"
29#include "lldb/Utility/Log.h"
30#include "lldb/Utility/Stream.h"
31
33
35
36#include "llvm/ADT/STLExtras.h"
37
38using namespace lldb;
39using namespace lldb_private;
40
42 SBBreakpointHitCallback callback, void *baton)
43 : TypedBaton(std::make_unique<CallbackData>()) {
44 LLDB_INSTRUMENT_VA(this, callback, baton);
45 getItem()->callback = callback;
46 getItem()->callback_baton = baton;
47}
48
50 void *baton, StoppointCallbackContext *ctx, lldb::user_id_t break_id,
51 lldb::user_id_t break_loc_id) {
52 LLDB_INSTRUMENT_VA(baton, ctx, break_id, break_loc_id);
53 ExecutionContext exe_ctx(ctx->exe_ctx_ref);
54 BreakpointSP bp_sp(
56 if (baton && bp_sp) {
57 CallbackData *data = (CallbackData *)baton;
58 lldb_private::Breakpoint *bp = bp_sp.get();
59 if (bp && data->callback) {
60 Process *process = exe_ctx.GetProcessPtr();
61 if (process) {
62 SBProcess sb_process(process->shared_from_this());
63 SBThread sb_thread;
64 SBBreakpointLocation sb_location;
65 assert(bp_sp);
66 sb_location.SetLocation(bp_sp->FindLocationByID(break_loc_id));
67 Thread *thread = exe_ctx.GetThreadPtr();
68 if (thread)
69 sb_thread.SetThread(thread->shared_from_this());
70
71 return data->callback(data->callback_baton, sb_process, sb_thread,
72 sb_location);
73 }
74 }
75 }
76 return true; // Return true if we should stop at this breakpoint
77}
78
#define LLDB_INSTRUMENT_VA(...)
SBBreakpointCallbackBaton(SBBreakpointHitCallback callback, void *baton)
static bool PrivateBreakpointHitCallback(void *baton, lldb_private::StoppointCallbackContext *ctx, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
void SetLocation(const lldb::BreakpointLocationSP &break_loc_sp)
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition: SBThread.cpp:372
lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const
Returns a shared pointer to the breakpoint with id breakID.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:81
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
BreakpointList & GetBreakpointList(bool internal=false)
Definition: Target.cpp:314
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
Definition: lldb-forward.h:316
bool(* SBBreakpointHitCallback)(void *baton, SBProcess &process, SBThread &thread, lldb::SBBreakpointLocation &location)
Definition: SBDefines.h:137
uint64_t user_id_t
Definition: lldb-types.h:82
SBBreakpointHitCallback callback