Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBBreakpointLocation.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/SBBreakpointLocation.h" |
Greg Clayton | f644ddf | 2011-09-24 01:37:21 +0000 | [diff] [blame] | 11 | #include "lldb/API/SBAddress.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | #include "lldb/API/SBDebugger.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 13 | #include "lldb/API/SBDefines.h" |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 14 | #include "lldb/API/SBStream.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | |
Greg Clayton | 4e78f60 | 2010-11-18 18:52:36 +0000 | [diff] [blame] | 16 | #include "lldb/Breakpoint/Breakpoint.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/Breakpoint/BreakpointLocation.h" |
Jim Ingham | d80102e | 2014-04-02 01:04:55 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Debugger.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 19 | #include "lldb/Core/StreamFile.h" |
Jim Ingham | d80102e | 2014-04-02 01:04:55 +0000 | [diff] [blame] | 20 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 21 | #include "lldb/Interpreter/ScriptInterpreter.h" |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 22 | #include "lldb/Target/Target.h" |
Jim Ingham | 62b02c6 | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 23 | #include "lldb/Target/ThreadSpec.h" |
Zachary Turner | 6f9e690 | 2017-03-03 20:56:28 +0000 | [diff] [blame] | 24 | #include "lldb/Utility/Log.h" |
Zachary Turner | bf9a773 | 2017-02-02 21:39:50 +0000 | [diff] [blame] | 25 | #include "lldb/Utility/Stream.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 26 | #include "lldb/lldb-defines.h" |
| 27 | #include "lldb/lldb-types.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | |
| 29 | using namespace lldb; |
| 30 | using namespace lldb_private; |
| 31 | |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 32 | SBBreakpointLocation::SBBreakpointLocation() {} |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 34 | SBBreakpointLocation::SBBreakpointLocation( |
| 35 | const lldb::BreakpointLocationSP &break_loc_sp) |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 36 | : m_opaque_wp(break_loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 37 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
| 38 | |
| 39 | if (log) { |
| 40 | SBStream sstr; |
| 41 | GetDescription(sstr, lldb::eDescriptionLevelBrief); |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 42 | LLDB_LOG(log, "location = {0} ({1})", break_loc_sp.get(), sstr.GetData()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 43 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 46 | SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 47 | : m_opaque_wp(rhs.m_opaque_wp) {} |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 48 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 49 | const SBBreakpointLocation &SBBreakpointLocation:: |
| 50 | operator=(const SBBreakpointLocation &rhs) { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 51 | m_opaque_wp = rhs.m_opaque_wp; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 52 | return *this; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 55 | SBBreakpointLocation::~SBBreakpointLocation() {} |
| 56 | |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 57 | BreakpointLocationSP SBBreakpointLocation::GetSP() const { |
| 58 | return m_opaque_wp.lock(); |
| 59 | } |
| 60 | |
| 61 | bool SBBreakpointLocation::IsValid() const { return bool(GetSP()); } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 62 | |
| 63 | SBAddress SBBreakpointLocation::GetAddress() { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 64 | BreakpointLocationSP loc_sp = GetSP(); |
| 65 | if (loc_sp) |
| 66 | return SBAddress(&loc_sp->GetAddress()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 67 | else |
| 68 | return SBAddress(); |
Greg Clayton | efabb12 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 71 | addr_t SBBreakpointLocation::GetLoadAddress() { |
| 72 | addr_t ret_addr = LLDB_INVALID_ADDRESS; |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 73 | BreakpointLocationSP loc_sp = GetSP(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 74 | |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 75 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 76 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 77 | loc_sp->GetTarget().GetAPIMutex()); |
| 78 | ret_addr = loc_sp->GetLoadAddress(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | return ret_addr; |
Greg Clayton | efabb12 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 84 | void SBBreakpointLocation::SetEnabled(bool enabled) { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 85 | BreakpointLocationSP loc_sp = GetSP(); |
| 86 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 87 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 88 | loc_sp->GetTarget().GetAPIMutex()); |
| 89 | loc_sp->SetEnabled(enabled); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 90 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 93 | bool SBBreakpointLocation::IsEnabled() { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 94 | BreakpointLocationSP loc_sp = GetSP(); |
| 95 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 96 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 97 | loc_sp->GetTarget().GetAPIMutex()); |
| 98 | return loc_sp->IsEnabled(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 99 | } else |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 100 | return false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 103 | uint32_t SBBreakpointLocation::GetIgnoreCount() { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 104 | BreakpointLocationSP loc_sp = GetSP(); |
| 105 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 106 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 107 | loc_sp->GetTarget().GetAPIMutex()); |
| 108 | return loc_sp->GetIgnoreCount(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 109 | } else |
| 110 | return 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 113 | void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 114 | BreakpointLocationSP loc_sp = GetSP(); |
| 115 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 116 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 117 | loc_sp->GetTarget().GetAPIMutex()); |
| 118 | loc_sp->SetIgnoreCount(n); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 119 | } |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 122 | void SBBreakpointLocation::SetCondition(const char *condition) { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 123 | BreakpointLocationSP loc_sp = GetSP(); |
| 124 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 125 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 126 | loc_sp->GetTarget().GetAPIMutex()); |
| 127 | loc_sp->SetCondition(condition); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 128 | } |
Jim Ingham | b08a944 | 2012-05-16 00:51:15 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 131 | const char *SBBreakpointLocation::GetCondition() { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 132 | BreakpointLocationSP loc_sp = GetSP(); |
| 133 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 134 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 135 | loc_sp->GetTarget().GetAPIMutex()); |
| 136 | return loc_sp->GetConditionText(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 137 | } |
| 138 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 141 | void SBBreakpointLocation::SetScriptCallbackFunction( |
| 142 | const char *callback_function_name) { |
| 143 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 144 | BreakpointLocationSP loc_sp = GetSP(); |
| 145 | LLDB_LOG(log, "location = {0}, callback = {1}", loc_sp.get(), |
| 146 | callback_function_name); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 147 | |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 148 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 149 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 150 | loc_sp->GetTarget().GetAPIMutex()); |
| 151 | BreakpointOptions *bp_options = loc_sp->GetLocationOptions(); |
| 152 | loc_sp->GetBreakpoint() |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 153 | .GetTarget() |
| 154 | .GetDebugger() |
| 155 | .GetCommandInterpreter() |
| 156 | .GetScriptInterpreter() |
| 157 | ->SetBreakpointCommandCallbackFunction(bp_options, |
| 158 | callback_function_name); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | SBError |
| 163 | SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { |
| 164 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 165 | BreakpointLocationSP loc_sp = GetSP(); |
| 166 | LLDB_LOG(log, "location = {0}: callback body:\n{1}", loc_sp.get(), |
| 167 | callback_body_text); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 168 | |
| 169 | SBError sb_error; |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 170 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 171 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 172 | loc_sp->GetTarget().GetAPIMutex()); |
| 173 | BreakpointOptions *bp_options = loc_sp->GetLocationOptions(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 174 | Error error = |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 175 | loc_sp->GetBreakpoint() |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 176 | .GetTarget() |
| 177 | .GetDebugger() |
| 178 | .GetCommandInterpreter() |
| 179 | .GetScriptInterpreter() |
| 180 | ->SetBreakpointCommandCallback(bp_options, callback_body_text); |
| 181 | sb_error.SetError(error); |
| 182 | } else |
| 183 | sb_error.SetErrorString("invalid breakpoint"); |
| 184 | |
| 185 | return sb_error; |
| 186 | } |
| 187 | |
| 188 | void SBBreakpointLocation::SetThreadID(tid_t thread_id) { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 189 | BreakpointLocationSP loc_sp = GetSP(); |
| 190 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 191 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 192 | loc_sp->GetTarget().GetAPIMutex()); |
| 193 | loc_sp->SetThreadID(thread_id); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | |
| 197 | tid_t SBBreakpointLocation::GetThreadID() { |
| 198 | tid_t tid = LLDB_INVALID_THREAD_ID; |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 199 | BreakpointLocationSP loc_sp = GetSP(); |
| 200 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 201 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 202 | loc_sp->GetTarget().GetAPIMutex()); |
| 203 | return loc_sp->GetThreadID(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 204 | } |
| 205 | return tid; |
| 206 | } |
| 207 | |
| 208 | void SBBreakpointLocation::SetThreadIndex(uint32_t index) { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 209 | BreakpointLocationSP loc_sp = GetSP(); |
| 210 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 211 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 212 | loc_sp->GetTarget().GetAPIMutex()); |
| 213 | loc_sp->SetThreadIndex(index); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 214 | } |
| 215 | } |
| 216 | |
| 217 | uint32_t SBBreakpointLocation::GetThreadIndex() const { |
| 218 | uint32_t thread_idx = UINT32_MAX; |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 219 | BreakpointLocationSP loc_sp = GetSP(); |
| 220 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 221 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 222 | loc_sp->GetTarget().GetAPIMutex()); |
| 223 | return loc_sp->GetThreadIndex(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 224 | } |
| 225 | return thread_idx; |
| 226 | } |
| 227 | |
| 228 | void SBBreakpointLocation::SetThreadName(const char *thread_name) { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 229 | BreakpointLocationSP loc_sp = GetSP(); |
| 230 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 231 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 232 | loc_sp->GetTarget().GetAPIMutex()); |
| 233 | loc_sp->SetThreadName(thread_name); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
| 237 | const char *SBBreakpointLocation::GetThreadName() const { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 238 | BreakpointLocationSP loc_sp = GetSP(); |
| 239 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 240 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 241 | loc_sp->GetTarget().GetAPIMutex()); |
| 242 | return loc_sp->GetThreadName(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 243 | } |
| 244 | return NULL; |
| 245 | } |
| 246 | |
| 247 | void SBBreakpointLocation::SetQueueName(const char *queue_name) { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 248 | BreakpointLocationSP loc_sp = GetSP(); |
| 249 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 250 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 251 | loc_sp->GetTarget().GetAPIMutex()); |
| 252 | loc_sp->SetQueueName(queue_name); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
| 256 | const char *SBBreakpointLocation::GetQueueName() const { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 257 | BreakpointLocationSP loc_sp = GetSP(); |
| 258 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 259 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 260 | loc_sp->GetTarget().GetAPIMutex()); |
| 261 | loc_sp->GetQueueName(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 262 | } |
| 263 | return NULL; |
| 264 | } |
| 265 | |
| 266 | bool SBBreakpointLocation::IsResolved() { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 267 | BreakpointLocationSP loc_sp = GetSP(); |
| 268 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 269 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 270 | loc_sp->GetTarget().GetAPIMutex()); |
| 271 | return loc_sp->IsResolved(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 272 | } |
| 273 | return false; |
| 274 | } |
| 275 | |
| 276 | void SBBreakpointLocation::SetLocation( |
| 277 | const lldb::BreakpointLocationSP &break_loc_sp) { |
| 278 | // Uninstall the callbacks? |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 279 | m_opaque_wp = break_loc_sp; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | bool SBBreakpointLocation::GetDescription(SBStream &description, |
| 283 | DescriptionLevel level) { |
| 284 | Stream &strm = description.ref(); |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 285 | BreakpointLocationSP loc_sp = GetSP(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 286 | |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 287 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 288 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 289 | loc_sp->GetTarget().GetAPIMutex()); |
| 290 | loc_sp->GetDescription(&strm, level); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 291 | strm.EOL(); |
| 292 | } else |
| 293 | strm.PutCString("No value"); |
| 294 | |
| 295 | return true; |
| 296 | } |
| 297 | |
| 298 | break_id_t SBBreakpointLocation::GetID() { |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 299 | BreakpointLocationSP loc_sp = GetSP(); |
| 300 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 301 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 302 | loc_sp->GetTarget().GetAPIMutex()); |
| 303 | return loc_sp->GetID(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 304 | } else |
| 305 | return LLDB_INVALID_BREAK_ID; |
| 306 | } |
| 307 | |
| 308 | SBBreakpoint SBBreakpointLocation::GetBreakpoint() { |
| 309 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 310 | BreakpointLocationSP loc_sp = GetSP(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 311 | |
| 312 | SBBreakpoint sb_bp; |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 313 | if (loc_sp) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 314 | std::lock_guard<std::recursive_mutex> guard( |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 315 | loc_sp->GetTarget().GetAPIMutex()); |
| 316 | sb_bp = loc_sp->GetBreakpoint().shared_from_this(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | if (log) { |
| 320 | SBStream sstr; |
| 321 | sb_bp.GetDescription(sstr); |
Pavel Labath | c578943 | 2017-03-01 10:08:48 +0000 | [diff] [blame] | 322 | LLDB_LOG(log, "location = {0}, breakpoint = {1} ({2})", loc_sp.get(), |
| 323 | sb_bp.GetSP().get(), sstr.GetData()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 324 | } |
| 325 | return sb_bp; |
| 326 | } |