]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/API/SBBreakpointOptionCommon.cpp
Add libbearssl
[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 // C Includes
11 // C++ Includes
12 // Other libraries and framework includes
13 // Project includes
14 #include "lldb/API/SBBreakpointName.h"
15 #include "lldb/API/SBBreakpointLocation.h"
16 #include "lldb/API/SBDebugger.h"
17 #include "lldb/API/SBEvent.h"
18 #include "lldb/API/SBProcess.h"
19 #include "lldb/API/SBStream.h"
20 #include "lldb/API/SBStringList.h"
21 #include "lldb/API/SBThread.h"
22
23 #include "lldb/Breakpoint/BreakpointName.h"
24 #include "lldb/Breakpoint/StoppointCallbackContext.h"
25 #include "lldb/Core/Address.h"
26 #include "lldb/Core/Debugger.h"
27 #include "lldb/Core/StreamFile.h"
28 #include "lldb/Interpreter/CommandInterpreter.h"
29 #include "lldb/Interpreter/ScriptInterpreter.h"
30 #include "lldb/Target/Process.h"
31 #include "lldb/Target/Target.h"
32 #include "lldb/Target/Thread.h"
33 #include "lldb/Target/ThreadSpec.h"
34 #include "lldb/Utility/Log.h"
35 #include "lldb/Utility/Stream.h"
36
37 #include "lldb/lldb-enumerations.h"
38
39 #include "SBBreakpointOptionCommon.h"
40
41 #include "llvm/ADT/STLExtras.h"
42
43 using namespace lldb;
44 using namespace lldb_private;
45
46 SBBreakpointCallbackBaton::SBBreakpointCallbackBaton(SBBreakpointHitCallback 
47                                                          callback,
48                                                      void *baton)
49       : TypedBaton(llvm::make_unique<CallbackData>()) {
50     getItem()->callback = callback;
51     getItem()->callback_baton = baton;
52   }
53
54  bool SBBreakpointCallbackBaton::PrivateBreakpointHitCallback(void *baton,
55                                                   StoppointCallbackContext *ctx,
56                                                   lldb::user_id_t break_id,
57                                                   lldb::user_id_t break_loc_id)
58 {
59   ExecutionContext exe_ctx(ctx->exe_ctx_ref);
60   BreakpointSP bp_sp(
61       exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
62   if (baton && bp_sp) {
63     CallbackData *data = (CallbackData *)baton;
64     lldb_private::Breakpoint *bp = bp_sp.get();
65     if (bp && data->callback) {
66       Process *process = exe_ctx.GetProcessPtr();
67       if (process) {
68         SBProcess sb_process(process->shared_from_this());
69         SBThread sb_thread;
70         SBBreakpointLocation sb_location;
71         assert(bp_sp);
72         sb_location.SetLocation(bp_sp->FindLocationByID(break_loc_id));
73         Thread *thread = exe_ctx.GetThreadPtr();
74         if (thread)
75           sb_thread.SetThread(thread->shared_from_this());
76
77         return data->callback(data->callback_baton, sb_process, sb_thread,
78                               sb_location);
79       }
80     }
81   }
82   return true; // Return true if we should stop at this breakpoint
83 }
84
85 SBBreakpointCallbackBaton::~SBBreakpointCallbackBaton() = default;