15ffd83dbSDimitry Andric //===-- SBBreakpointLocation.cpp ------------------------------------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #include "lldb/API/SBBreakpointLocation.h" 100b57cec5SDimitry Andric #include "lldb/API/SBAddress.h" 110b57cec5SDimitry Andric #include "lldb/API/SBDebugger.h" 120b57cec5SDimitry Andric #include "lldb/API/SBDefines.h" 130b57cec5SDimitry Andric #include "lldb/API/SBStream.h" 140b57cec5SDimitry Andric #include "lldb/API/SBStringList.h" 1504eeddc0SDimitry Andric #include "lldb/API/SBStructuredData.h" 1604eeddc0SDimitry Andric #include "lldb/Utility/Instrumentation.h" 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric #include "lldb/Breakpoint/Breakpoint.h" 190b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointLocation.h" 200b57cec5SDimitry Andric #include "lldb/Core/Debugger.h" 210b57cec5SDimitry Andric #include "lldb/Core/StreamFile.h" 22480093f4SDimitry Andric #include "lldb/Core/StructuredDataImpl.h" 230b57cec5SDimitry Andric #include "lldb/Interpreter/CommandInterpreter.h" 240b57cec5SDimitry Andric #include "lldb/Interpreter/ScriptInterpreter.h" 250b57cec5SDimitry Andric #include "lldb/Target/Target.h" 260b57cec5SDimitry Andric #include "lldb/Target/ThreadSpec.h" 270b57cec5SDimitry Andric #include "lldb/Utility/Stream.h" 280b57cec5SDimitry Andric #include "lldb/lldb-defines.h" 290b57cec5SDimitry Andric #include "lldb/lldb-types.h" 300b57cec5SDimitry Andric 31bdd1243dSDimitry Andric #include "SBBreakpointOptionCommon.h" 32bdd1243dSDimitry Andric 330b57cec5SDimitry Andric using namespace lldb; 340b57cec5SDimitry Andric using namespace lldb_private; 350b57cec5SDimitry Andric 3604eeddc0SDimitry Andric SBBreakpointLocation::SBBreakpointLocation() { LLDB_INSTRUMENT_VA(this); } 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric SBBreakpointLocation::SBBreakpointLocation( 390b57cec5SDimitry Andric const lldb::BreakpointLocationSP &break_loc_sp) 400b57cec5SDimitry Andric : m_opaque_wp(break_loc_sp) { 4104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, break_loc_sp); 420b57cec5SDimitry Andric } 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) 450b57cec5SDimitry Andric : m_opaque_wp(rhs.m_opaque_wp) { 4604eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, rhs); 470b57cec5SDimitry Andric } 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric const SBBreakpointLocation &SBBreakpointLocation:: 500b57cec5SDimitry Andric operator=(const SBBreakpointLocation &rhs) { 5104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, rhs); 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric m_opaque_wp = rhs.m_opaque_wp; 5404eeddc0SDimitry Andric return *this; 550b57cec5SDimitry Andric } 560b57cec5SDimitry Andric 575ffd83dbSDimitry Andric SBBreakpointLocation::~SBBreakpointLocation() = default; 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric BreakpointLocationSP SBBreakpointLocation::GetSP() const { 600b57cec5SDimitry Andric return m_opaque_wp.lock(); 610b57cec5SDimitry Andric } 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric bool SBBreakpointLocation::IsValid() const { 6404eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 650b57cec5SDimitry Andric return this->operator bool(); 660b57cec5SDimitry Andric } 670b57cec5SDimitry Andric SBBreakpointLocation::operator bool() const { 6804eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric return bool(GetSP()); 710b57cec5SDimitry Andric } 720b57cec5SDimitry Andric 730b57cec5SDimitry Andric SBAddress SBBreakpointLocation::GetAddress() { 7404eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 750b57cec5SDimitry Andric 760b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 770b57cec5SDimitry Andric if (loc_sp) { 7804eeddc0SDimitry Andric return SBAddress(loc_sp->GetAddress()); 790b57cec5SDimitry Andric } 800b57cec5SDimitry Andric 8104eeddc0SDimitry Andric return SBAddress(); 820b57cec5SDimitry Andric } 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric addr_t SBBreakpointLocation::GetLoadAddress() { 8504eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric addr_t ret_addr = LLDB_INVALID_ADDRESS; 880b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric if (loc_sp) { 910b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 920b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 930b57cec5SDimitry Andric ret_addr = loc_sp->GetLoadAddress(); 940b57cec5SDimitry Andric } 950b57cec5SDimitry Andric 960b57cec5SDimitry Andric return ret_addr; 970b57cec5SDimitry Andric } 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric void SBBreakpointLocation::SetEnabled(bool enabled) { 10004eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, enabled); 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 1030b57cec5SDimitry Andric if (loc_sp) { 1040b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1050b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 1060b57cec5SDimitry Andric loc_sp->SetEnabled(enabled); 1070b57cec5SDimitry Andric } 1080b57cec5SDimitry Andric } 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric bool SBBreakpointLocation::IsEnabled() { 11104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 1120b57cec5SDimitry Andric 1130b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 1140b57cec5SDimitry Andric if (loc_sp) { 1150b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1160b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 1170b57cec5SDimitry Andric return loc_sp->IsEnabled(); 1180b57cec5SDimitry Andric } else 1190b57cec5SDimitry Andric return false; 1200b57cec5SDimitry Andric } 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andric uint32_t SBBreakpointLocation::GetHitCount() { 12304eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 1240b57cec5SDimitry Andric 1250b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 1260b57cec5SDimitry Andric if (loc_sp) { 1270b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1280b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 1290b57cec5SDimitry Andric return loc_sp->GetHitCount(); 1300b57cec5SDimitry Andric } else 1310b57cec5SDimitry Andric return 0; 1320b57cec5SDimitry Andric } 1330b57cec5SDimitry Andric 1340b57cec5SDimitry Andric uint32_t SBBreakpointLocation::GetIgnoreCount() { 13504eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 1380b57cec5SDimitry Andric if (loc_sp) { 1390b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1400b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 1410b57cec5SDimitry Andric return loc_sp->GetIgnoreCount(); 1420b57cec5SDimitry Andric } else 1430b57cec5SDimitry Andric return 0; 1440b57cec5SDimitry Andric } 1450b57cec5SDimitry Andric 1460b57cec5SDimitry Andric void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { 14704eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, n); 1480b57cec5SDimitry Andric 1490b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 1500b57cec5SDimitry Andric if (loc_sp) { 1510b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1520b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 1530b57cec5SDimitry Andric loc_sp->SetIgnoreCount(n); 1540b57cec5SDimitry Andric } 1550b57cec5SDimitry Andric } 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andric void SBBreakpointLocation::SetCondition(const char *condition) { 15804eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, condition); 1590b57cec5SDimitry Andric 1600b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 1610b57cec5SDimitry Andric if (loc_sp) { 1620b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1630b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 1640b57cec5SDimitry Andric loc_sp->SetCondition(condition); 1650b57cec5SDimitry Andric } 1660b57cec5SDimitry Andric } 1670b57cec5SDimitry Andric 1680b57cec5SDimitry Andric const char *SBBreakpointLocation::GetCondition() { 16904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 1700b57cec5SDimitry Andric 1710b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 172*fe013be4SDimitry Andric if (!loc_sp) 173*fe013be4SDimitry Andric return nullptr; 174*fe013be4SDimitry Andric 1750b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1760b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 177*fe013be4SDimitry Andric return ConstString(loc_sp->GetConditionText()).GetCString(); 1780b57cec5SDimitry Andric } 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andric void SBBreakpointLocation::SetAutoContinue(bool auto_continue) { 18104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, auto_continue); 1820b57cec5SDimitry Andric 1830b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 1840b57cec5SDimitry Andric if (loc_sp) { 1850b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1860b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 1870b57cec5SDimitry Andric loc_sp->SetAutoContinue(auto_continue); 1880b57cec5SDimitry Andric } 1890b57cec5SDimitry Andric } 1900b57cec5SDimitry Andric 1910b57cec5SDimitry Andric bool SBBreakpointLocation::GetAutoContinue() { 19204eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 1930b57cec5SDimitry Andric 1940b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 1950b57cec5SDimitry Andric if (loc_sp) { 1960b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 1970b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 1980b57cec5SDimitry Andric return loc_sp->IsAutoContinue(); 1990b57cec5SDimitry Andric } 2000b57cec5SDimitry Andric return false; 2010b57cec5SDimitry Andric } 2020b57cec5SDimitry Andric 203bdd1243dSDimitry Andric void SBBreakpointLocation::SetCallback(SBBreakpointHitCallback callback, 204bdd1243dSDimitry Andric void *baton) { 205bdd1243dSDimitry Andric LLDB_INSTRUMENT_VA(this, callback, baton); 206bdd1243dSDimitry Andric 207bdd1243dSDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 208bdd1243dSDimitry Andric 209bdd1243dSDimitry Andric if (loc_sp) { 210bdd1243dSDimitry Andric std::lock_guard<std::recursive_mutex> guard( 211bdd1243dSDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 212bdd1243dSDimitry Andric BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton)); 213bdd1243dSDimitry Andric loc_sp->SetCallback(SBBreakpointCallbackBaton::PrivateBreakpointHitCallback, 214bdd1243dSDimitry Andric baton_sp, false); 215bdd1243dSDimitry Andric } 216bdd1243dSDimitry Andric } 217bdd1243dSDimitry Andric 2180b57cec5SDimitry Andric void SBBreakpointLocation::SetScriptCallbackFunction( 2190b57cec5SDimitry Andric const char *callback_function_name) { 22004eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, callback_function_name); 221480093f4SDimitry Andric } 2220b57cec5SDimitry Andric 223480093f4SDimitry Andric SBError SBBreakpointLocation::SetScriptCallbackFunction( 224480093f4SDimitry Andric const char *callback_function_name, 225480093f4SDimitry Andric SBStructuredData &extra_args) { 22604eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, callback_function_name, extra_args); 227480093f4SDimitry Andric SBError sb_error; 2280b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andric if (loc_sp) { 231480093f4SDimitry Andric Status error; 2320b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 2330b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 234fe6060f1SDimitry Andric BreakpointOptions &bp_options = loc_sp->GetLocationOptions(); 235480093f4SDimitry Andric error = loc_sp->GetBreakpoint() 2360b57cec5SDimitry Andric .GetTarget() 2370b57cec5SDimitry Andric .GetDebugger() 2380b57cec5SDimitry Andric .GetScriptInterpreter() 2390b57cec5SDimitry Andric ->SetBreakpointCommandCallbackFunction(bp_options, 240480093f4SDimitry Andric callback_function_name, 241480093f4SDimitry Andric extra_args.m_impl_up 242480093f4SDimitry Andric ->GetObjectSP()); 243480093f4SDimitry Andric sb_error.SetError(error); 244480093f4SDimitry Andric } else 245480093f4SDimitry Andric sb_error.SetErrorString("invalid breakpoint"); 246480093f4SDimitry Andric 24704eeddc0SDimitry Andric return sb_error; 2480b57cec5SDimitry Andric } 2490b57cec5SDimitry Andric 2500b57cec5SDimitry Andric SBError 2510b57cec5SDimitry Andric SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { 25204eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, callback_body_text); 2530b57cec5SDimitry Andric 2540b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 2550b57cec5SDimitry Andric 2560b57cec5SDimitry Andric SBError sb_error; 2570b57cec5SDimitry Andric if (loc_sp) { 2580b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 2590b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 260fe6060f1SDimitry Andric BreakpointOptions &bp_options = loc_sp->GetLocationOptions(); 2610b57cec5SDimitry Andric Status error = 2620b57cec5SDimitry Andric loc_sp->GetBreakpoint() 2630b57cec5SDimitry Andric .GetTarget() 2640b57cec5SDimitry Andric .GetDebugger() 2650b57cec5SDimitry Andric .GetScriptInterpreter() 266*fe013be4SDimitry Andric ->SetBreakpointCommandCallback(bp_options, callback_body_text, 267*fe013be4SDimitry Andric /*is_callback=*/false); 2680b57cec5SDimitry Andric sb_error.SetError(error); 2690b57cec5SDimitry Andric } else 2700b57cec5SDimitry Andric sb_error.SetErrorString("invalid breakpoint"); 2710b57cec5SDimitry Andric 27204eeddc0SDimitry Andric return sb_error; 2730b57cec5SDimitry Andric } 2740b57cec5SDimitry Andric 2750b57cec5SDimitry Andric void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) { 27604eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, commands); 2770b57cec5SDimitry Andric 2780b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 2790b57cec5SDimitry Andric if (!loc_sp) 2800b57cec5SDimitry Andric return; 2810b57cec5SDimitry Andric if (commands.GetSize() == 0) 2820b57cec5SDimitry Andric return; 2830b57cec5SDimitry Andric 2840b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 2850b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 2860b57cec5SDimitry Andric std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up( 2870b57cec5SDimitry Andric new BreakpointOptions::CommandData(*commands, eScriptLanguageNone)); 2880b57cec5SDimitry Andric 289fe6060f1SDimitry Andric loc_sp->GetLocationOptions().SetCommandDataCallback(cmd_data_up); 2900b57cec5SDimitry Andric } 2910b57cec5SDimitry Andric 2920b57cec5SDimitry Andric bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) { 29304eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, commands); 2940b57cec5SDimitry Andric 2950b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 2960b57cec5SDimitry Andric if (!loc_sp) 2970b57cec5SDimitry Andric return false; 2980b57cec5SDimitry Andric StringList command_list; 2990b57cec5SDimitry Andric bool has_commands = 300fe6060f1SDimitry Andric loc_sp->GetLocationOptions().GetCommandLineCallbacks(command_list); 3010b57cec5SDimitry Andric if (has_commands) 3020b57cec5SDimitry Andric commands.AppendList(command_list); 3030b57cec5SDimitry Andric return has_commands; 3040b57cec5SDimitry Andric } 3050b57cec5SDimitry Andric 3060b57cec5SDimitry Andric void SBBreakpointLocation::SetThreadID(tid_t thread_id) { 30704eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, thread_id); 3080b57cec5SDimitry Andric 3090b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 3100b57cec5SDimitry Andric if (loc_sp) { 3110b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 3120b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 3130b57cec5SDimitry Andric loc_sp->SetThreadID(thread_id); 3140b57cec5SDimitry Andric } 3150b57cec5SDimitry Andric } 3160b57cec5SDimitry Andric 3170b57cec5SDimitry Andric tid_t SBBreakpointLocation::GetThreadID() { 31804eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 3190b57cec5SDimitry Andric 3200b57cec5SDimitry Andric tid_t tid = LLDB_INVALID_THREAD_ID; 3210b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 3220b57cec5SDimitry Andric if (loc_sp) { 3230b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 3240b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 3250b57cec5SDimitry Andric return loc_sp->GetThreadID(); 3260b57cec5SDimitry Andric } 3270b57cec5SDimitry Andric return tid; 3280b57cec5SDimitry Andric } 3290b57cec5SDimitry Andric 3300b57cec5SDimitry Andric void SBBreakpointLocation::SetThreadIndex(uint32_t index) { 33104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, index); 3320b57cec5SDimitry Andric 3330b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 3340b57cec5SDimitry Andric if (loc_sp) { 3350b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 3360b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 3370b57cec5SDimitry Andric loc_sp->SetThreadIndex(index); 3380b57cec5SDimitry Andric } 3390b57cec5SDimitry Andric } 3400b57cec5SDimitry Andric 3410b57cec5SDimitry Andric uint32_t SBBreakpointLocation::GetThreadIndex() const { 34204eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 3430b57cec5SDimitry Andric 3440b57cec5SDimitry Andric uint32_t thread_idx = UINT32_MAX; 3450b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 3460b57cec5SDimitry Andric if (loc_sp) { 3470b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 3480b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 3490b57cec5SDimitry Andric return loc_sp->GetThreadIndex(); 3500b57cec5SDimitry Andric } 3510b57cec5SDimitry Andric return thread_idx; 3520b57cec5SDimitry Andric } 3530b57cec5SDimitry Andric 3540b57cec5SDimitry Andric void SBBreakpointLocation::SetThreadName(const char *thread_name) { 35504eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, thread_name); 3560b57cec5SDimitry Andric 3570b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 3580b57cec5SDimitry Andric if (loc_sp) { 3590b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 3600b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 3610b57cec5SDimitry Andric loc_sp->SetThreadName(thread_name); 3620b57cec5SDimitry Andric } 3630b57cec5SDimitry Andric } 3640b57cec5SDimitry Andric 3650b57cec5SDimitry Andric const char *SBBreakpointLocation::GetThreadName() const { 36604eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 3670b57cec5SDimitry Andric 3680b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 369*fe013be4SDimitry Andric if (!loc_sp) 370*fe013be4SDimitry Andric return nullptr; 371*fe013be4SDimitry Andric 3720b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 3730b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 374*fe013be4SDimitry Andric return ConstString(loc_sp->GetThreadName()).GetCString(); 3750b57cec5SDimitry Andric } 3760b57cec5SDimitry Andric 3770b57cec5SDimitry Andric void SBBreakpointLocation::SetQueueName(const char *queue_name) { 37804eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, queue_name); 3790b57cec5SDimitry Andric 3800b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 3810b57cec5SDimitry Andric if (loc_sp) { 3820b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 3830b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 3840b57cec5SDimitry Andric loc_sp->SetQueueName(queue_name); 3850b57cec5SDimitry Andric } 3860b57cec5SDimitry Andric } 3870b57cec5SDimitry Andric 3880b57cec5SDimitry Andric const char *SBBreakpointLocation::GetQueueName() const { 38904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 3900b57cec5SDimitry Andric 3910b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 392*fe013be4SDimitry Andric if (!loc_sp) 393*fe013be4SDimitry Andric return nullptr; 394*fe013be4SDimitry Andric 3950b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 3960b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 397*fe013be4SDimitry Andric return ConstString(loc_sp->GetQueueName()).GetCString(); 3980b57cec5SDimitry Andric } 3990b57cec5SDimitry Andric 4000b57cec5SDimitry Andric bool SBBreakpointLocation::IsResolved() { 40104eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 4020b57cec5SDimitry Andric 4030b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 4040b57cec5SDimitry Andric if (loc_sp) { 4050b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 4060b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 4070b57cec5SDimitry Andric return loc_sp->IsResolved(); 4080b57cec5SDimitry Andric } 4090b57cec5SDimitry Andric return false; 4100b57cec5SDimitry Andric } 4110b57cec5SDimitry Andric 4120b57cec5SDimitry Andric void SBBreakpointLocation::SetLocation( 4130b57cec5SDimitry Andric const lldb::BreakpointLocationSP &break_loc_sp) { 4140b57cec5SDimitry Andric // Uninstall the callbacks? 4150b57cec5SDimitry Andric m_opaque_wp = break_loc_sp; 4160b57cec5SDimitry Andric } 4170b57cec5SDimitry Andric 4180b57cec5SDimitry Andric bool SBBreakpointLocation::GetDescription(SBStream &description, 4190b57cec5SDimitry Andric DescriptionLevel level) { 42004eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this, description, level); 4210b57cec5SDimitry Andric 4220b57cec5SDimitry Andric Stream &strm = description.ref(); 4230b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 4240b57cec5SDimitry Andric 4250b57cec5SDimitry Andric if (loc_sp) { 4260b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 4270b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 4280b57cec5SDimitry Andric loc_sp->GetDescription(&strm, level); 4290b57cec5SDimitry Andric strm.EOL(); 4300b57cec5SDimitry Andric } else 4310b57cec5SDimitry Andric strm.PutCString("No value"); 4320b57cec5SDimitry Andric 4330b57cec5SDimitry Andric return true; 4340b57cec5SDimitry Andric } 4350b57cec5SDimitry Andric 4360b57cec5SDimitry Andric break_id_t SBBreakpointLocation::GetID() { 43704eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 4380b57cec5SDimitry Andric 4390b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 4400b57cec5SDimitry Andric if (loc_sp) { 4410b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 4420b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 4430b57cec5SDimitry Andric return loc_sp->GetID(); 4440b57cec5SDimitry Andric } else 4450b57cec5SDimitry Andric return LLDB_INVALID_BREAK_ID; 4460b57cec5SDimitry Andric } 4470b57cec5SDimitry Andric 4480b57cec5SDimitry Andric SBBreakpoint SBBreakpointLocation::GetBreakpoint() { 44904eeddc0SDimitry Andric LLDB_INSTRUMENT_VA(this); 4500b57cec5SDimitry Andric 4510b57cec5SDimitry Andric BreakpointLocationSP loc_sp = GetSP(); 4520b57cec5SDimitry Andric 4530b57cec5SDimitry Andric SBBreakpoint sb_bp; 4540b57cec5SDimitry Andric if (loc_sp) { 4550b57cec5SDimitry Andric std::lock_guard<std::recursive_mutex> guard( 4560b57cec5SDimitry Andric loc_sp->GetTarget().GetAPIMutex()); 4570b57cec5SDimitry Andric sb_bp = loc_sp->GetBreakpoint().shared_from_this(); 4580b57cec5SDimitry Andric } 4590b57cec5SDimitry Andric 46004eeddc0SDimitry Andric return sb_bp; 4610b57cec5SDimitry Andric } 462