15ffd83dbSDimitry Andric //===-- SBBreakpointLocation.cpp ------------------------------------------===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "lldb/API/SBBreakpointLocation.h" 10*0b57cec5SDimitry Andric #include "lldb/API/SBAddress.h" 11*0b57cec5SDimitry Andric #include "lldb/API/SBDebugger.h" 12*0b57cec5SDimitry Andric #include "lldb/API/SBDefines.h" 13*0b57cec5SDimitry Andric #include "lldb/API/SBStream.h" 14*0b57cec5SDimitry Andric #include "lldb/API/SBStringList.h" 1504eeddc0SDimitry Andric #include "lldb/API/SBStructuredData.h" 1604eeddc0SDimitry Andric #include "lldb/Utility/Instrumentation.h" 17*0b57cec5SDimitry Andric 18*0b57cec5SDimitry Andric #include "lldb/Breakpoint/Breakpoint.h" 19*0b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointLocation.h" 20*0b57cec5SDimitry Andric #include "lldb/Core/Debugger.h" 21*0b57cec5SDimitry Andric #include "lldb/Core/StreamFile.h" 22480093f4SDimitry Andric #include "lldb/Core/StructuredDataImpl.h" 23*0b57cec5SDimitry Andric #include "lldb/Interpreter/CommandInterpreter.h" 24*0b57cec5SDimitry Andric #include "lldb/Interpreter/ScriptInterpreter.h" 25*0b57cec5SDimitry Andric #include "lldb/Target/Target.h" 26*0b57cec5SDimitry Andric #include "lldb/Target/ThreadSpec.h" 27*0b57cec5SDimitry Andric #include "lldb/Utility/Stream.h" 28*0b57cec5SDimitry Andric #include "lldb/lldb-defines.h" 29*0b57cec5SDimitry Andric #include "lldb/lldb-types.h" 30*0b57cec5SDimitry Andric 31*0b57cec5SDimitry Andric using namespace lldb; 32*0b57cec5SDimitry Andric using namespace lldb_private; 33*0b57cec5SDimitry Andric 3404eeddc0SDimitry Andric SBBreakpointLocation::SBBreakpointLocation() { LLDB_INSTRUMENT_VA(this); } 35*0b57cec5SDimitry Andric 36*0b57cec5SDimitry Andric SBBreakpointLocation::SBBreakpointLocation( 37*0b57cec5SDimitry Andric const lldb::BreakpointLocationSP &break_loc_sp) 38*0b57cec5SDimitry Andric : m_opaque_wp(break_loc_sp) { 3904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, break_loc_sp); 40*0b57cec5SDimitry Andric } 41*0b57cec5SDimitry Andric 42*0b57cec5SDimitry Andric SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) 43*0b57cec5SDimitry Andric : m_opaque_wp(rhs.m_opaque_wp) { 4404eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, rhs); 45*0b57cec5SDimitry Andric } 46*0b57cec5SDimitry Andric 47*0b57cec5SDimitry Andric const SBBreakpointLocation &SBBreakpointLocation:: 48*0b57cec5SDimitry Andric operator=(const SBBreakpointLocation &rhs) { 4904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, rhs); 50*0b57cec5SDimitry Andric 51*0b57cec5SDimitry Andric m_opaque_wp = rhs.m_opaque_wp; 5204eeddc0SDimitry Andric return *this; 53*0b57cec5SDimitry Andric } 54*0b57cec5SDimitry Andric 555ffd83dbSDimitry Andric SBBreakpointLocation::~SBBreakpointLocation() = default; 56*0b57cec5SDimitry Andric 57*0b57cec5SDimitry Andric BreakpointLocationSP SBBreakpointLocation::GetSP() const { 58*0b57cec5SDimitry Andric return m_opaque_wp.lock(); 59*0b57cec5SDimitry Andric } 60*0b57cec5SDimitry Andric 61*0b57cec5SDimitry Andric bool SBBreakpointLocation::IsValid() const { 6204eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 63*0b57cec5SDimitry Andric return this->operator bool(); 64*0b57cec5SDimitry Andric } 65*0b57cec5SDimitry Andric SBBreakpointLocation::operator bool() const { 6604eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 67*0b57cec5SDimitry Andric 68*0b57cec5SDimitry Andric return bool(GetSP()); 69*0b57cec5SDimitry Andric } 70*0b57cec5SDimitry Andric 71*0b57cec5SDimitry Andric SBAddress SBBreakpointLocation::GetAddress() { 7204eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 73*0b57cec5SDimitry Andric 74*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 75*0b57cec5SDimitry Andric if (loc_sp) { 7604eeddc0SDimitry Andric return SBAddress(loc_sp->GetAddress()); 77*0b57cec5SDimitry Andric } 78*0b57cec5SDimitry Andric 7904eeddc0SDimitry Andric return SBAddress(); 80*0b57cec5SDimitry Andric } 81*0b57cec5SDimitry Andric 82*0b57cec5SDimitry Andric addr_t SBBreakpointLocation::GetLoadAddress() { 8304eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 84*0b57cec5SDimitry Andric 85*0b57cec5SDimitry Andric addr_t ret_addr = LLDB_INVALID_ADDRESS; 86*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 87*0b57cec5SDimitry Andric 88*0b57cec5SDimitry Andric if (loc_sp) { 89*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 90*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 91*0b57cec5SDimitry Andric ret_addr = loc_sp->GetLoadAddress(); 92*0b57cec5SDimitry Andric } 93*0b57cec5SDimitry Andric 94*0b57cec5SDimitry Andric return ret_addr; 95*0b57cec5SDimitry Andric } 96*0b57cec5SDimitry Andric 97*0b57cec5SDimitry Andric void SBBreakpointLocation::SetEnabled(bool enabled) { 9804eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, enabled); 99*0b57cec5SDimitry Andric 100*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 101*0b57cec5SDimitry Andric if (loc_sp) { 102*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 103*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 104*0b57cec5SDimitry Andric loc_sp->SetEnabled(enabled); 105*0b57cec5SDimitry Andric } 106*0b57cec5SDimitry Andric } 107*0b57cec5SDimitry Andric 108*0b57cec5SDimitry Andric bool SBBreakpointLocation::IsEnabled() { 10904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 110*0b57cec5SDimitry Andric 111*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 112*0b57cec5SDimitry Andric if (loc_sp) { 113*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 114*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 115*0b57cec5SDimitry Andric return loc_sp->IsEnabled(); 116*0b57cec5SDimitry Andric } else 117*0b57cec5SDimitry Andric return false; 118*0b57cec5SDimitry Andric } 119*0b57cec5SDimitry Andric 120*0b57cec5SDimitry Andric uint32_t SBBreakpointLocation::GetHitCount() { 12104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 122*0b57cec5SDimitry Andric 123*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 124*0b57cec5SDimitry Andric if (loc_sp) { 125*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 126*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 127*0b57cec5SDimitry Andric return loc_sp->GetHitCount(); 128*0b57cec5SDimitry Andric } else 129*0b57cec5SDimitry Andric return 0; 130*0b57cec5SDimitry Andric } 131*0b57cec5SDimitry Andric 132*0b57cec5SDimitry Andric uint32_t SBBreakpointLocation::GetIgnoreCount() { 13304eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 134*0b57cec5SDimitry Andric 135*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 136*0b57cec5SDimitry Andric if (loc_sp) { 137*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 138*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 139*0b57cec5SDimitry Andric return loc_sp->GetIgnoreCount(); 140*0b57cec5SDimitry Andric } else 141*0b57cec5SDimitry Andric return 0; 142*0b57cec5SDimitry Andric } 143*0b57cec5SDimitry Andric 144*0b57cec5SDimitry Andric void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { 14504eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, n); 146*0b57cec5SDimitry Andric 147*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 148*0b57cec5SDimitry Andric if (loc_sp) { 149*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 150*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 151*0b57cec5SDimitry Andric loc_sp->SetIgnoreCount(n); 152*0b57cec5SDimitry Andric } 153*0b57cec5SDimitry Andric } 154*0b57cec5SDimitry Andric 155*0b57cec5SDimitry Andric void SBBreakpointLocation::SetCondition(const char *condition) { 15604eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, condition); 157*0b57cec5SDimitry Andric 158*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 159*0b57cec5SDimitry Andric if (loc_sp) { 160*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 161*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 162*0b57cec5SDimitry Andric loc_sp->SetCondition(condition); 163*0b57cec5SDimitry Andric } 164*0b57cec5SDimitry Andric } 165*0b57cec5SDimitry Andric 166*0b57cec5SDimitry Andric const char *SBBreakpointLocation::GetCondition() { 16704eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 168*0b57cec5SDimitry Andric 169*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 170*0b57cec5SDimitry Andric if (loc_sp) { 171*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 172*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 173*0b57cec5SDimitry Andric return loc_sp->GetConditionText(); 174*0b57cec5SDimitry Andric } 175*0b57cec5SDimitry Andric return nullptr; 176*0b57cec5SDimitry Andric } 177*0b57cec5SDimitry Andric 178*0b57cec5SDimitry Andric void SBBreakpointLocation::SetAutoContinue(bool auto_continue) { 17904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, auto_continue); 180*0b57cec5SDimitry Andric 181*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 182*0b57cec5SDimitry Andric if (loc_sp) { 183*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 184*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 185*0b57cec5SDimitry Andric loc_sp->SetAutoContinue(auto_continue); 186*0b57cec5SDimitry Andric } 187*0b57cec5SDimitry Andric } 188*0b57cec5SDimitry Andric 189*0b57cec5SDimitry Andric bool SBBreakpointLocation::GetAutoContinue() { 19004eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 191*0b57cec5SDimitry Andric 192*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 193*0b57cec5SDimitry Andric if (loc_sp) { 194*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 195*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 196*0b57cec5SDimitry Andric return loc_sp->IsAutoContinue(); 197*0b57cec5SDimitry Andric } 198*0b57cec5SDimitry Andric return false; 199*0b57cec5SDimitry Andric } 200*0b57cec5SDimitry Andric 201*0b57cec5SDimitry Andric void SBBreakpointLocation::SetScriptCallbackFunction( 202*0b57cec5SDimitry Andric const char *callback_function_name) { 20304eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, callback_function_name); 204480093f4SDimitry Andric } 205*0b57cec5SDimitry Andric 206480093f4SDimitry Andric SBError SBBreakpointLocation::SetScriptCallbackFunction( 207480093f4SDimitry Andric const char *callback_function_name, 208480093f4SDimitry Andric SBStructuredData &extra_args) { 20904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, callback_function_name, extra_args); 210480093f4SDimitry Andric SBError sb_error; 211*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 212*0b57cec5SDimitry Andric 213*0b57cec5SDimitry Andric if (loc_sp) { 214480093f4SDimitry Andric Status error; 215*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 216*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 217fe6060f1SDimitry Andric BreakpointOptions &bp_options = loc_sp->GetLocationOptions(); 218480093f4SDimitry Andric error = loc_sp->GetBreakpoint() 219*0b57cec5SDimitry Andric .GetTarget() 220*0b57cec5SDimitry Andric .GetDebugger() 221*0b57cec5SDimitry Andric .GetScriptInterpreter() 222*0b57cec5SDimitry Andric ->SetBreakpointCommandCallbackFunction(bp_options, 223480093f4SDimitry Andric callback_function_name, 224480093f4SDimitry Andric extra_args.m_impl_up 225480093f4SDimitry Andric ->GetObjectSP()); 226480093f4SDimitry Andric sb_error.SetError(error); 227480093f4SDimitry Andric } else 228480093f4SDimitry Andric sb_error.SetErrorString("invalid breakpoint"); 229480093f4SDimitry Andric 23004eeddc0SDimitry Andric return sb_error; 231*0b57cec5SDimitry Andric } 232*0b57cec5SDimitry Andric 233*0b57cec5SDimitry Andric SBError 234*0b57cec5SDimitry Andric SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { 23504eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, callback_body_text); 236*0b57cec5SDimitry Andric 237*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 238*0b57cec5SDimitry Andric 239*0b57cec5SDimitry Andric SBError sb_error; 240*0b57cec5SDimitry Andric if (loc_sp) { 241*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 242*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 243fe6060f1SDimitry Andric BreakpointOptions &bp_options = loc_sp->GetLocationOptions(); 244*0b57cec5SDimitry Andric Status error = 245*0b57cec5SDimitry Andric loc_sp->GetBreakpoint() 246*0b57cec5SDimitry Andric .GetTarget() 247*0b57cec5SDimitry Andric .GetDebugger() 248*0b57cec5SDimitry Andric .GetScriptInterpreter() 249*0b57cec5SDimitry Andric ->SetBreakpointCommandCallback(bp_options, callback_body_text); 250*0b57cec5SDimitry Andric sb_error.SetError(error); 251*0b57cec5SDimitry Andric } else 252*0b57cec5SDimitry Andric sb_error.SetErrorString("invalid breakpoint"); 253*0b57cec5SDimitry Andric 25404eeddc0SDimitry Andric return sb_error; 255*0b57cec5SDimitry Andric } 256*0b57cec5SDimitry Andric 257*0b57cec5SDimitry Andric void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) { 25804eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, commands); 259*0b57cec5SDimitry Andric 260*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 261*0b57cec5SDimitry Andric if (!loc_sp) 262*0b57cec5SDimitry Andric return; 263*0b57cec5SDimitry Andric if (commands.GetSize() == 0) 264*0b57cec5SDimitry Andric return; 265*0b57cec5SDimitry Andric 266*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 267*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 268*0b57cec5SDimitry Andric std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up( 269*0b57cec5SDimitry Andric new BreakpointOptions::CommandData(*commands, eScriptLanguageNone)); 270*0b57cec5SDimitry Andric 271fe6060f1SDimitry Andric loc_sp->GetLocationOptions().SetCommandDataCallback(cmd_data_up); 272*0b57cec5SDimitry Andric } 273*0b57cec5SDimitry Andric 274*0b57cec5SDimitry Andric bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) { 27504eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, commands); 276*0b57cec5SDimitry Andric 277*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 278*0b57cec5SDimitry Andric if (!loc_sp) 279*0b57cec5SDimitry Andric return false; 280*0b57cec5SDimitry Andric StringList command_list; 281*0b57cec5SDimitry Andric bool has_commands = 282fe6060f1SDimitry Andric loc_sp->GetLocationOptions().GetCommandLineCallbacks(command_list); 283*0b57cec5SDimitry Andric if (has_commands) 284*0b57cec5SDimitry Andric commands.AppendList(command_list); 285*0b57cec5SDimitry Andric return has_commands; 286*0b57cec5SDimitry Andric } 287*0b57cec5SDimitry Andric 288*0b57cec5SDimitry Andric void SBBreakpointLocation::SetThreadID(tid_t thread_id) { 28904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, thread_id); 290*0b57cec5SDimitry Andric 291*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 292*0b57cec5SDimitry Andric if (loc_sp) { 293*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 294*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 295*0b57cec5SDimitry Andric loc_sp->SetThreadID(thread_id); 296*0b57cec5SDimitry Andric } 297*0b57cec5SDimitry Andric } 298*0b57cec5SDimitry Andric 299*0b57cec5SDimitry Andric tid_t SBBreakpointLocation::GetThreadID() { 30004eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 301*0b57cec5SDimitry Andric 302*0b57cec5SDimitry Andric tid_t tid = LLDB_INVALID_THREAD_ID; 303*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 304*0b57cec5SDimitry Andric if (loc_sp) { 305*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 306*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 307*0b57cec5SDimitry Andric return loc_sp->GetThreadID(); 308*0b57cec5SDimitry Andric } 309*0b57cec5SDimitry Andric return tid; 310*0b57cec5SDimitry Andric } 311*0b57cec5SDimitry Andric 312*0b57cec5SDimitry Andric void SBBreakpointLocation::SetThreadIndex(uint32_t index) { 31304eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, index); 314*0b57cec5SDimitry Andric 315*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 316*0b57cec5SDimitry Andric if (loc_sp) { 317*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 318*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 319*0b57cec5SDimitry Andric loc_sp->SetThreadIndex(index); 320*0b57cec5SDimitry Andric } 321*0b57cec5SDimitry Andric } 322*0b57cec5SDimitry Andric 323*0b57cec5SDimitry Andric uint32_t SBBreakpointLocation::GetThreadIndex() const { 32404eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 325*0b57cec5SDimitry Andric 326*0b57cec5SDimitry Andric uint32_t thread_idx = UINT32_MAX; 327*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 328*0b57cec5SDimitry Andric if (loc_sp) { 329*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 330*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 331*0b57cec5SDimitry Andric return loc_sp->GetThreadIndex(); 332*0b57cec5SDimitry Andric } 333*0b57cec5SDimitry Andric return thread_idx; 334*0b57cec5SDimitry Andric } 335*0b57cec5SDimitry Andric 336*0b57cec5SDimitry Andric void SBBreakpointLocation::SetThreadName(const char *thread_name) { 33704eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, thread_name); 338*0b57cec5SDimitry Andric 339*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 340*0b57cec5SDimitry Andric if (loc_sp) { 341*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 342*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 343*0b57cec5SDimitry Andric loc_sp->SetThreadName(thread_name); 344*0b57cec5SDimitry Andric } 345*0b57cec5SDimitry Andric } 346*0b57cec5SDimitry Andric 347*0b57cec5SDimitry Andric const char *SBBreakpointLocation::GetThreadName() const { 34804eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 349*0b57cec5SDimitry Andric 350*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 351*0b57cec5SDimitry Andric if (loc_sp) { 352*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 353*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 354*0b57cec5SDimitry Andric return loc_sp->GetThreadName(); 355*0b57cec5SDimitry Andric } 356*0b57cec5SDimitry Andric return nullptr; 357*0b57cec5SDimitry Andric } 358*0b57cec5SDimitry Andric 359*0b57cec5SDimitry Andric void SBBreakpointLocation::SetQueueName(const char *queue_name) { 36004eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, queue_name); 361*0b57cec5SDimitry Andric 362*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 363*0b57cec5SDimitry Andric if (loc_sp) { 364*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 365*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 366*0b57cec5SDimitry Andric loc_sp->SetQueueName(queue_name); 367*0b57cec5SDimitry Andric } 368*0b57cec5SDimitry Andric } 369*0b57cec5SDimitry Andric 370*0b57cec5SDimitry Andric const char *SBBreakpointLocation::GetQueueName() const { 37104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 372*0b57cec5SDimitry Andric 373*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 374*0b57cec5SDimitry Andric if (loc_sp) { 375*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 376*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 377*0b57cec5SDimitry Andric loc_sp->GetQueueName(); 378*0b57cec5SDimitry Andric } 379*0b57cec5SDimitry Andric return nullptr; 380*0b57cec5SDimitry Andric } 381*0b57cec5SDimitry Andric 382*0b57cec5SDimitry Andric bool SBBreakpointLocation::IsResolved() { 38304eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 384*0b57cec5SDimitry Andric 385*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 386*0b57cec5SDimitry Andric if (loc_sp) { 387*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 388*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 389*0b57cec5SDimitry Andric return loc_sp->IsResolved(); 390*0b57cec5SDimitry Andric } 391*0b57cec5SDimitry Andric return false; 392*0b57cec5SDimitry Andric } 393*0b57cec5SDimitry Andric 394*0b57cec5SDimitry Andric void SBBreakpointLocation::SetLocation( 395*0b57cec5SDimitry Andric const lldb::BreakpointLocationSP &break_loc_sp) { 396*0b57cec5SDimitry Andric // Uninstall the callbacks? 397*0b57cec5SDimitry Andric m_opaque_wp = break_loc_sp; 398*0b57cec5SDimitry Andric } 399*0b57cec5SDimitry Andric 400*0b57cec5SDimitry Andric bool SBBreakpointLocation::GetDescription(SBStream &description, 401*0b57cec5SDimitry Andric DescriptionLevel level) { 40204eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, description, level); 403*0b57cec5SDimitry Andric 404*0b57cec5SDimitry Andric Stream &strm = description.ref(); 405*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 406*0b57cec5SDimitry Andric 407*0b57cec5SDimitry Andric if (loc_sp) { 408*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 409*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 410*0b57cec5SDimitry Andric loc_sp->GetDescription(&strm, level); 411*0b57cec5SDimitry Andric strm.EOL(); 412*0b57cec5SDimitry Andric } else 413*0b57cec5SDimitry Andric strm.PutCString("No value"); 414*0b57cec5SDimitry Andric 415*0b57cec5SDimitry Andric return true; 416*0b57cec5SDimitry Andric } 417*0b57cec5SDimitry Andric 418*0b57cec5SDimitry Andric break_id_t SBBreakpointLocation::GetID() { 41904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 420*0b57cec5SDimitry Andric 421*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 422*0b57cec5SDimitry Andric if (loc_sp) { 423*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 424*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 425*0b57cec5SDimitry Andric return loc_sp->GetID(); 426*0b57cec5SDimitry Andric } else 427*0b57cec5SDimitry Andric return LLDB_INVALID_BREAK_ID; 428*0b57cec5SDimitry Andric } 429*0b57cec5SDimitry Andric 430*0b57cec5SDimitry Andric SBBreakpoint SBBreakpointLocation::GetBreakpoint() { 43104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 432*0b57cec5SDimitry Andric 433*0b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 434*0b57cec5SDimitry Andric 435*0b57cec5SDimitry Andric SBBreakpoint sb_bp; 436*0b57cec5SDimitry Andric if (loc_sp) { 437*0b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 438*0b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 439*0b57cec5SDimitry Andric sb_bp = loc_sp->GetBreakpoint().shared_from_this(); 440*0b57cec5SDimitry Andric } 441*0b57cec5SDimitry Andric 44204eeddc0SDimitry Andric return sb_bp; 443*0b57cec5SDimitry Andric } 444