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"
15 #include "lldb/API/SBStringList.h"
16 #include "lldb/API/SBThread.h"
17 
20 #include "lldb/Core/Address.h"
21 #include "lldb/Core/Debugger.h"
22 #include "lldb/Core/StreamFile.h"
25 #include "lldb/Target/Process.h"
26 #include "lldb/Target/Target.h"
27 #include "lldb/Target/Thread.h"
28 #include "lldb/Target/ThreadSpec.h"
29 #include "lldb/Utility/Log.h"
30 #include "lldb/Utility/Stream.h"
31 
32 #include "lldb/lldb-enumerations.h"
33 
35 
36 #include "llvm/ADT/STLExtras.h"
37 
38 using namespace lldb;
39 using namespace lldb_private;
40 
42  callback,
43  void *baton)
44  : TypedBaton(std::make_unique<CallbackData>()) {
45  getItem()->callback = callback;
46  getItem()->callback_baton = baton;
47  }
48 
51  lldb::user_id_t break_id,
52  lldb::user_id_t break_loc_id)
53 {
54  ExecutionContext exe_ctx(ctx->exe_ctx_ref);
55  BreakpointSP bp_sp(
56  exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
57  if (baton && bp_sp) {
58  CallbackData *data = (CallbackData *)baton;
59  lldb_private::Breakpoint *bp = bp_sp.get();
60  if (bp && data->callback) {
61  Process *process = exe_ctx.GetProcessPtr();
62  if (process) {
63  SBProcess sb_process(process->shared_from_this());
64  SBThread sb_thread;
65  SBBreakpointLocation sb_location;
66  assert(bp_sp);
67  sb_location.SetLocation(bp_sp->FindLocationByID(break_loc_id));
68  Thread *thread = exe_ctx.GetThreadPtr();
69  if (thread)
70  sb_thread.SetThread(thread->shared_from_this());
71 
72  return data->callback(data->callback_baton, sb_process, sb_thread,
73  sb_location);
74  }
75  }
76  }
77  return true; // Return true if we should stop at this breakpoint
78 }
79 
lldb::SBBreakpointLocation
Definition: SBBreakpointLocation.h:17
BreakpointName.h
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb::SBThread
Definition: SBThread.h:20
lldb::SBThread::SetThread
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition: SBThread.cpp:379
lldb_private::StoppointCallbackContext
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
Definition: StoppointCallbackContext.h:26
lldb::CallbackData
Definition: SBBreakpointOptionCommon.h:17
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:208
SBBreakpointOptionCommon.h
SBStringList.h
lldb_private::TypedBaton< CallbackData >::data
void * data() override
Definition: Baton.h:69
lldb_private::Process
Definition: Process.h:340
lldb_private::StoppointCallbackContext::exe_ctx_ref
ExecutionContextRef exe_ctx_ref
Definition: StoppointCallbackContext.h:43
StoppointCallbackContext.h
lldb::CallbackData::callback
SBBreakpointHitCallback callback
Definition: SBBreakpointOptionCommon.h:18
lldb::SBProcess
Definition: SBProcess.h:23
lldb_private::Target::GetBreakpointList
BreakpointList & GetBreakpointList(bool internal=false)
Definition: Target.cpp:289
Debugger.h
lldb_private::ExecutionContext::GetThreadPtr
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
Definition: ExecutionContext.h:399
lldb::SBBreakpointCallbackBaton::~SBBreakpointCallbackBaton
~SBBreakpointCallbackBaton() override
Process.h
SBBreakpointName.h
lldb::SBBreakpointCallbackBaton::SBBreakpointCallbackBaton
SBBreakpointCallbackBaton(SBBreakpointHitCallback callback, void *baton)
Definition: SBBreakpointOptionCommon.cpp:41
Target.h
SBStream.h
lldb::CallbackData::callback_baton
void * callback_baton
Definition: SBBreakpointOptionCommon.h:19
SBThread.h
Log.h
lldb_private::Thread
Definition: Thread.h:60
ThreadSpec.h
lldb-enumerations.h
lldb_private::TypedBaton< CallbackData >::getItem
CallbackData * getItem()
Definition: Baton.h:66
lldb_private::TypedBaton
Definition: Baton.h:62
SBDebugger.h
Thread.h
lldb::SBBreakpointCallbackBaton::PrivateBreakpointHitCallback
static bool PrivateBreakpointHitCallback(void *baton, lldb_private::StoppointCallbackContext *ctx, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Definition: SBBreakpointOptionCommon.cpp:49
Address.h
StreamFile.h
lldb::SBBreakpointHitCallback
bool(* SBBreakpointHitCallback)(void *baton, SBProcess &process, SBThread &thread, lldb::SBBreakpointLocation &location)
Definition: SBDefines.h:97
SBBreakpointLocation.h
SBEvent.h
lldb_private::ExecutionContext::GetTargetRef
Target & GetTargetRef() const
Returns a reference to the target object.
Definition: ExecutionContext.cpp:226
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
CommandInterpreter.h
SBProcess.h
lldb::SBBreakpointLocation::SetLocation
void SetLocation(const lldb::BreakpointLocationSP &break_loc_sp)
Definition: SBBreakpointLocation.cpp:417
Stream.h
lldb_private::BreakpointList::FindBreakpointByID
lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const
Returns a shared pointer to the breakpoint with id breakID.
Definition: BreakpointList.cpp:124
ScriptInterpreter.h
lldb
Definition: SBAddress.h:15
lldb_private::Breakpoint
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:79