Path: blob/main/contrib/llvm-project/lldb/source/API/SBBreakpointOptionCommon.cpp
39587 views
//===-- SBBreakpointOptionCommon.cpp --------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/API/SBBreakpointName.h"9#include "lldb/API/SBBreakpointLocation.h"10#include "lldb/API/SBDebugger.h"11#include "lldb/API/SBEvent.h"12#include "lldb/API/SBProcess.h"13#include "lldb/API/SBStream.h"14#include "lldb/API/SBStringList.h"15#include "lldb/API/SBThread.h"1617#include "lldb/Breakpoint/BreakpointName.h"18#include "lldb/Breakpoint/StoppointCallbackContext.h"19#include "lldb/Core/Address.h"20#include "lldb/Core/Debugger.h"21#include "lldb/Interpreter/CommandInterpreter.h"22#include "lldb/Interpreter/ScriptInterpreter.h"23#include "lldb/Target/Process.h"24#include "lldb/Target/Target.h"25#include "lldb/Target/Thread.h"26#include "lldb/Target/ThreadSpec.h"27#include "lldb/Utility/Instrumentation.h"28#include "lldb/Utility/Log.h"29#include "lldb/Utility/Stream.h"3031#include "lldb/lldb-enumerations.h"3233#include "SBBreakpointOptionCommon.h"3435#include "llvm/ADT/STLExtras.h"3637using namespace lldb;38using namespace lldb_private;3940SBBreakpointCallbackBaton::SBBreakpointCallbackBaton(41SBBreakpointHitCallback callback, void *baton)42: TypedBaton(std::make_unique<CallbackData>()) {43LLDB_INSTRUMENT_VA(this, callback, baton);44getItem()->callback = callback;45getItem()->callback_baton = baton;46}4748bool SBBreakpointCallbackBaton::PrivateBreakpointHitCallback(49void *baton, StoppointCallbackContext *ctx, lldb::user_id_t break_id,50lldb::user_id_t break_loc_id) {51LLDB_INSTRUMENT_VA(baton, ctx, break_id, break_loc_id);52ExecutionContext exe_ctx(ctx->exe_ctx_ref);53BreakpointSP bp_sp(54exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));55if (baton && bp_sp) {56CallbackData *data = (CallbackData *)baton;57lldb_private::Breakpoint *bp = bp_sp.get();58if (bp && data->callback) {59Process *process = exe_ctx.GetProcessPtr();60if (process) {61SBProcess sb_process(process->shared_from_this());62SBThread sb_thread;63SBBreakpointLocation sb_location;64assert(bp_sp);65sb_location.SetLocation(bp_sp->FindLocationByID(break_loc_id));66Thread *thread = exe_ctx.GetThreadPtr();67if (thread)68sb_thread.SetThread(thread->shared_from_this());6970return data->callback(data->callback_baton, sb_process, sb_thread,71sb_location);72}73}74}75return true; // Return true if we should stop at this breakpoint76}7778SBBreakpointCallbackBaton::~SBBreakpointCallbackBaton() = default;798081