]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/API/SBBreakpointOptionCommon.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / API / SBBreakpointOptionCommon.cpp
1 //===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
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"
18
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"
32
33 #include "lldb/lldb-enumerations.h"
34
35 #include "SBBreakpointOptionCommon.h"
36
37 #include "llvm/ADT/STLExtras.h"
38
39 using namespace lldb;
40 using namespace lldb_private;
41
42 SBBreakpointCallbackBaton::SBBreakpointCallbackBaton(SBBreakpointHitCallback 
43                                                          callback,
44                                                      void *baton)
45       : TypedBaton(llvm::make_unique<CallbackData>()) {
46     getItem()->callback = callback;
47     getItem()->callback_baton = baton;
48   }
49
50  bool SBBreakpointCallbackBaton::PrivateBreakpointHitCallback(void *baton,
51                                                   StoppointCallbackContext *ctx,
52                                                   lldb::user_id_t break_id,
53                                                   lldb::user_id_t break_loc_id)
54 {
55   ExecutionContext exe_ctx(ctx->exe_ctx_ref);
56   BreakpointSP bp_sp(
57       exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
58   if (baton && bp_sp) {
59     CallbackData *data = (CallbackData *)baton;
60     lldb_private::Breakpoint *bp = bp_sp.get();
61     if (bp && data->callback) {
62       Process *process = exe_ctx.GetProcessPtr();
63       if (process) {
64         SBProcess sb_process(process->shared_from_this());
65         SBThread sb_thread;
66         SBBreakpointLocation sb_location;
67         assert(bp_sp);
68         sb_location.SetLocation(bp_sp->FindLocationByID(break_loc_id));
69         Thread *thread = exe_ctx.GetThreadPtr();
70         if (thread)
71           sb_thread.SetThread(thread->shared_from_this());
72
73         return data->callback(data->callback_baton, sb_process, sb_thread,
74                               sb_location);
75       }
76     }
77   }
78   return true; // Return true if we should stop at this breakpoint
79 }
80
81 SBBreakpointCallbackBaton::~SBBreakpointCallbackBaton() = default;