2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBBreakpoint.cpp ----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBBreakpoint.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBBreakpointLocation.h"
|
|
|
|
#include "lldb/API/SBDebugger.h"
|
2010-07-24 07:33:17 +08:00
|
|
|
#include "lldb/API/SBEvent.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2014-12-17 07:40:14 +08:00
|
|
|
#include "lldb/API/SBStringList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBThread.h"
|
|
|
|
|
|
|
|
#include "lldb/Breakpoint/Breakpoint.h"
|
2016-09-15 03:07:35 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointIDList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
2018-09-14 05:35:32 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointResolver.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointResolverScripted.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Breakpoint/StoppointCallbackContext.h"
|
|
|
|
#include "lldb/Core/Address.h"
|
2014-04-02 09:04:55 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/StreamFile.h"
|
2014-04-02 09:04:55 +08:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
#include "lldb/Interpreter/ScriptInterpreter.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2013-12-06 09:12:00 +08:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-18 09:47:08 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
#include "SBBreakpointOptionCommon.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/lldb-enumerations.h"
|
|
|
|
|
2016-09-14 01:53:38 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBBreakpoint::SBBreakpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpoint); }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_wp(rhs.m_opaque_wp) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &), rhs);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_wp(bp_sp) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &), bp_sp);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2015-10-31 09:22:59 +08:00
|
|
|
SBBreakpoint::~SBBreakpoint() = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBBreakpoint &,
|
|
|
|
SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
m_opaque_wp = rhs.m_opaque_wp;
|
2016-09-07 04:57:50 +08:00
|
|
|
return *this;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
bool, SBBreakpoint, operator==,(const lldb::SBBreakpoint &), rhs);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
return m_opaque_wp.lock() == rhs.m_opaque_wp.lock();
|
2010-12-13 03:25:26 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
bool, SBBreakpoint, operator!=,(const lldb::SBBreakpoint &), rhs);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
return m_opaque_wp.lock() != rhs.m_opaque_wp.lock();
|
2013-05-03 09:29:27 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
break_id_t SBBreakpoint::GetID() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::break_id_t, SBBreakpoint, GetID);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
break_id_t break_id = LLDB_INVALID_BREAK_ID;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp)
|
|
|
|
break_id = bkpt_sp->GetID();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return break_id;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::IsValid() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsValid);
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 21:58:46 +08:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBBreakpoint::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (!bkpt_sp)
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2017-02-27 19:05:34 +08:00
|
|
|
else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID()))
|
2016-09-07 04:57:50 +08:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBBreakpoint::ClearAllBreakpointSites() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpoint, ClearAllBreakpointSites);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->ClearAllBreakpointSites();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
|
|
|
|
FindLocationByAddress, (lldb::addr_t), vm_addr);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpointLocation sb_bp_location;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
if (vm_addr != LLDB_INVALID_ADDRESS) {
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2016-09-07 04:57:50 +08:00
|
|
|
Address address;
|
2017-02-27 19:05:34 +08:00
|
|
|
Target &target = bkpt_sp->GetTarget();
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
|
|
|
|
address.SetRawAddress(vm_addr);
|
|
|
|
}
|
2017-02-27 19:05:34 +08:00
|
|
|
sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp_location);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::break_id_t, SBBreakpoint, FindLocationIDByAddress,
|
|
|
|
(lldb::addr_t), vm_addr);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
break_id_t break_id = LLDB_INVALID_BREAK_ID;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2012-10-06 03:16:31 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp && vm_addr != LLDB_INVALID_ADDRESS) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2016-09-07 04:57:50 +08:00
|
|
|
Address address;
|
2017-02-27 19:05:34 +08:00
|
|
|
Target &target = bkpt_sp->GetTarget();
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
|
|
|
|
address.SetRawAddress(vm_addr);
|
2012-10-06 03:16:31 +08:00
|
|
|
}
|
2017-02-27 19:05:34 +08:00
|
|
|
break_id = bkpt_sp->FindLocationIDByAddress(address);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-10-06 03:16:31 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return break_id;
|
2012-09-26 07:55:19 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, FindLocationByID,
|
|
|
|
(lldb::break_id_t), bp_loc_id);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpointLocation sb_bp_location;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp_location);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
|
|
|
|
GetLocationAtIndex, (uint32_t), index);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpointLocation sb_bp_location;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2010-10-22 09:15:49 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-10-22 09:15:49 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_bp_location);
|
2010-07-24 07:33:17 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBBreakpoint::SetEnabled(bool enable) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetEnabled, (bool), enable);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->SetEnabled(enable);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::IsEnabled() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsEnabled);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
return bkpt_sp->IsEnabled();
|
2016-09-07 04:57:50 +08:00
|
|
|
} else
|
|
|
|
return false;
|
2010-06-18 09:47:08 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBBreakpoint::SetOneShot(bool one_shot) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetOneShot, (bool), one_shot);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2010-06-18 09:47:08 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->SetOneShot(one_shot);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::IsOneShot() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsOneShot);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
return bkpt_sp->IsOneShot();
|
2016-09-07 04:57:50 +08:00
|
|
|
} else
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::IsInternal() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsInternal);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
return bkpt_sp->IsInternal();
|
2016-09-07 04:57:50 +08:00
|
|
|
} else
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBBreakpoint::SetIgnoreCount(uint32_t count) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t), count);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->SetIgnoreCount(count);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpoint::SetCondition(const char *condition) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetCondition, (const char *),
|
|
|
|
condition);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->SetCondition(condition);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBBreakpoint::GetCondition() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpoint, GetCondition);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
return bkpt_sp->GetConditionText();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-08-04 02:13:24 +08:00
|
|
|
void SBBreakpoint::SetAutoContinue(bool auto_continue) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetAutoContinue, (bool),
|
|
|
|
auto_continue);
|
|
|
|
|
2017-08-04 02:13:24 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->SetAutoContinue(auto_continue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpoint::GetAutoContinue() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, GetAutoContinue);
|
|
|
|
|
2017-08-04 02:13:24 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
return bkpt_sp->IsAutoContinue();
|
|
|
|
}
|
2017-08-04 03:38:38 +08:00
|
|
|
return false;
|
2017-08-04 02:13:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t SBBreakpoint::GetHitCount() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetHitCount);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t count = 0;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
count = bkpt_sp->GetHitCount();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBBreakpoint::GetIgnoreCount() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetIgnoreCount);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t count = 0;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
count = bkpt_sp->GetIgnoreCount();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpoint::SetThreadID(tid_t tid) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t), tid);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->SetThreadID(tid);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tid_t SBBreakpoint::GetThreadID() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpoint, GetThreadID);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
tid_t tid = LLDB_INVALID_THREAD_ID;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
tid = bkpt_sp->GetThreadID();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return tid;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpoint::SetThreadIndex(uint32_t index) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t), index);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->GetOptions()->GetThreadSpec()->SetIndex(index);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBBreakpoint::GetThreadIndex() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetThreadIndex);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t thread_idx = UINT32_MAX;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2016-09-07 04:57:50 +08:00
|
|
|
const ThreadSpec *thread_spec =
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
|
2016-09-07 04:57:50 +08:00
|
|
|
if (thread_spec != nullptr)
|
|
|
|
thread_idx = thread_spec->GetIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
return thread_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpoint::SetThreadName(const char *thread_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadName, (const char *),
|
|
|
|
thread_name);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->GetOptions()->GetThreadSpec()->SetName(thread_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBBreakpoint::GetThreadName() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetThreadName);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *name = nullptr;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2016-09-07 04:57:50 +08:00
|
|
|
const ThreadSpec *thread_spec =
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
|
2016-09-07 04:57:50 +08:00
|
|
|
if (thread_spec != nullptr)
|
|
|
|
name = thread_spec->GetName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpoint::SetQueueName(const char *queue_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetQueueName, (const char *),
|
|
|
|
queue_name);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
bkpt_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBBreakpoint::GetQueueName() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetQueueName);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *name = nullptr;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2016-09-07 04:57:50 +08:00
|
|
|
const ThreadSpec *thread_spec =
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
|
2016-09-07 04:57:50 +08:00
|
|
|
if (thread_spec)
|
|
|
|
name = thread_spec->GetQueueName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SBBreakpoint::GetNumResolvedLocations() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint,
|
|
|
|
GetNumResolvedLocations);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
size_t num_resolved = 0;
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
num_resolved = bkpt_sp->GetNumResolvedLocations();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return num_resolved;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SBBreakpoint::GetNumLocations() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint, GetNumLocations);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2016-09-07 04:57:50 +08:00
|
|
|
size_t num_locs = 0;
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
num_locs = bkpt_sp->GetNumLocations();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return num_locs;
|
|
|
|
}
|
|
|
|
|
2016-09-21 06:54:49 +08:00
|
|
|
void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetCommandLineCommands,
|
|
|
|
(lldb::SBStringList &), commands);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (!bkpt_sp)
|
2016-09-21 06:54:49 +08:00
|
|
|
return;
|
|
|
|
if (commands.GetSize() == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2016-09-21 06:54:49 +08:00
|
|
|
std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
|
2016-09-27 03:47:37 +08:00
|
|
|
new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));
|
2016-09-21 06:54:49 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetOptions()->SetCommandDataCallback(cmd_data_up);
|
2016-09-21 06:54:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBBreakpoint, GetCommandLineCommands,
|
|
|
|
(lldb::SBStringList &), commands);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (!bkpt_sp)
|
2016-09-21 06:54:49 +08:00
|
|
|
return false;
|
|
|
|
StringList command_list;
|
|
|
|
bool has_commands =
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetOptions()->GetCommandLineCallbacks(command_list);
|
2016-09-21 06:54:49 +08:00
|
|
|
if (has_commands)
|
|
|
|
commands.AppendList(command_list);
|
|
|
|
return has_commands;
|
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::GetDescription(SBStream &s) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription, (lldb::SBStream &), s);
|
|
|
|
|
2016-09-16 09:41:27 +08:00
|
|
|
return GetDescription(s, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription,
|
|
|
|
(lldb::SBStream &, bool), s, include_locations);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
s.Printf("SBBreakpoint: id = %i, ", bkpt_sp->GetID());
|
|
|
|
bkpt_sp->GetResolverDescription(s.get());
|
|
|
|
bkpt_sp->GetFilterDescription(s.get());
|
2016-09-16 09:41:27 +08:00
|
|
|
if (include_locations) {
|
2017-02-27 19:05:34 +08:00
|
|
|
const size_t num_locations = bkpt_sp->GetNumLocations();
|
2016-09-16 09:41:27 +08:00
|
|
|
s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
s.Printf("No value");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBError SBBreakpoint::AddLocation(SBAddress &address) {
|
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, AddLocation,
|
|
|
|
(lldb::SBAddress &), address);
|
2018-09-14 05:35:32 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
SBError error;
|
|
|
|
|
|
|
|
if (!address.IsValid()) {
|
|
|
|
error.SetErrorString("Can't add an invalid address.");
|
|
|
|
return LLDB_RECORD_RESULT(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bkpt_sp) {
|
|
|
|
error.SetErrorString("No breakpoint to add a location to.");
|
|
|
|
return LLDB_RECORD_RESULT(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
|
|
|
|
error.SetErrorString("Only a scripted resolver can add locations.");
|
|
|
|
return LLDB_RECORD_RESULT(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref()))
|
|
|
|
bkpt_sp->AddLocation(address.ref());
|
|
|
|
else {
|
|
|
|
StreamString s;
|
|
|
|
address.get()->Dump(&s, &bkpt_sp->GetTarget(),
|
|
|
|
Address::DumpStyleModuleWithFileAddress);
|
|
|
|
error.SetErrorStringWithFormat("Address: %s didn't pass the filter.",
|
|
|
|
s.GetData());
|
|
|
|
}
|
|
|
|
return LLDB_RECORD_RESULT(error);
|
|
|
|
}
|
2018-09-14 05:35:32 +08:00
|
|
|
|
2019-03-09 03:09:27 +08:00
|
|
|
void SBBreakpoint ::SetCallback(SBBreakpointHitCallback callback, void *baton) {
|
|
|
|
LLDB_RECORD_DUMMY(void, SBBreakpoint, SetCallback,
|
|
|
|
(lldb::SBBreakpointHitCallback, void *), callback, baton);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2016-09-07 04:57:50 +08:00
|
|
|
BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
|
2017-09-15 04:22:49 +08:00
|
|
|
bkpt_sp->SetCallback(SBBreakpointCallbackBaton
|
|
|
|
::PrivateBreakpointHitCallback, baton_sp,
|
2017-02-27 19:05:34 +08:00
|
|
|
false);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpoint::SetScriptCallbackFunction(
|
|
|
|
const char *callback_function_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
|
|
|
|
(const char *), callback_function_name);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
BreakpointOptions *bp_options = bkpt_sp->GetOptions();
|
|
|
|
bkpt_sp->GetTarget()
|
2016-09-07 04:57:50 +08:00
|
|
|
.GetDebugger()
|
|
|
|
.GetCommandInterpreter()
|
|
|
|
.GetScriptInterpreter()
|
|
|
|
->SetBreakpointCommandCallbackFunction(bp_options,
|
|
|
|
callback_function_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
|
|
|
|
(const char *), callback_body_text);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
SBError sb_error;
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
BreakpointOptions *bp_options = bkpt_sp->GetOptions();
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error =
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget()
|
2016-09-07 04:57:50 +08:00
|
|
|
.GetDebugger()
|
|
|
|
.GetCommandInterpreter()
|
|
|
|
.GetScriptInterpreter()
|
|
|
|
->SetBreakpointCommandCallback(bp_options, callback_body_text);
|
|
|
|
sb_error.SetError(error);
|
|
|
|
} else
|
|
|
|
sb_error.SetErrorString("invalid breakpoint");
|
2014-04-02 09:04:55 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2014-04-02 09:04:55 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::AddName(const char *new_name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error; // Think I'm just going to swallow the error here, it's
|
|
|
|
// probably more annoying to have to provide it.
|
2017-09-15 04:22:49 +08:00
|
|
|
bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error);
|
|
|
|
if (error.Fail())
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
return true;
|
2014-04-02 09:04:55 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBBreakpoint::RemoveName(const char *name_to_remove) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, RemoveName, (const char *),
|
|
|
|
name_to_remove);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2014-12-17 07:40:14 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2019-03-08 06:47:13 +08:00
|
|
|
bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
|
|
|
|
ConstString(name_to_remove));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-12-17 07:40:14 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::MatchesName(const char *name) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBBreakpoint, MatchesName, (const char *), name);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2014-12-17 07:40:14 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
|
|
|
return bkpt_sp->MatchesName(name);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-12-17 07:40:14 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
|
|
|
}
|
2014-12-17 07:40:14 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBBreakpoint::GetNames(SBStringList &names) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &),
|
|
|
|
names);
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
2014-12-17 07:40:14 +08:00
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetTarget().GetAPIMutex());
|
2016-09-07 04:57:50 +08:00
|
|
|
std::vector<std::string> names_vec;
|
2017-02-27 19:05:34 +08:00
|
|
|
bkpt_sp->GetNames(names_vec);
|
2016-09-07 04:57:50 +08:00
|
|
|
for (std::string name : names_vec) {
|
|
|
|
names.AppendString(name.c_str());
|
2014-12-17 07:40:14 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-12-17 07:40:14 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent,
|
|
|
|
(const lldb::SBEvent &), event);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) !=
|
|
|
|
nullptr;
|
2012-02-08 13:23:15 +08:00
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
BreakpointEventType
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint,
|
|
|
|
GetBreakpointEventTypeFromEvent,
|
|
|
|
(const lldb::SBEvent &), event);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (event.IsValid())
|
|
|
|
return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent(
|
|
|
|
event.GetSP());
|
|
|
|
return eBreakpointEventTypeInvalidType;
|
2010-07-24 07:33:17 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint,
|
|
|
|
GetBreakpointFromEvent, (const lldb::SBEvent &),
|
|
|
|
event);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (event.IsValid())
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
SBBreakpoint(Breakpoint::BreakpointEventData::GetBreakpointFromEvent(
|
|
|
|
event.GetSP())));
|
|
|
|
return LLDB_RECORD_RESULT(SBBreakpoint());
|
2010-07-24 07:33:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpointLocation
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpoint::GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event,
|
|
|
|
uint32_t loc_idx) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
|
|
|
|
GetBreakpointLocationAtIndexFromEvent,
|
|
|
|
(const lldb::SBEvent &, uint32_t), event, loc_idx);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpointLocation sb_breakpoint_loc;
|
|
|
|
if (event.IsValid())
|
|
|
|
sb_breakpoint_loc.SetLocation(
|
|
|
|
Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent(
|
|
|
|
event.GetSP(), loc_idx));
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_breakpoint_loc);
|
2010-07-24 07:33:17 +08:00
|
|
|
}
|
|
|
|
|
2012-02-08 13:23:15 +08:00
|
|
|
uint32_t
|
2016-09-07 04:57:50 +08:00
|
|
|
SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_STATIC_METHOD(uint32_t, SBBreakpoint,
|
|
|
|
GetNumBreakpointLocationsFromEvent,
|
|
|
|
(const lldb::SBEvent &), event);
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t num_locations = 0;
|
|
|
|
if (event.IsValid())
|
|
|
|
num_locations =
|
|
|
|
(Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent(
|
|
|
|
event.GetSP()));
|
|
|
|
return num_locations;
|
2012-02-08 13:23:15 +08:00
|
|
|
}
|
2016-09-15 03:07:35 +08:00
|
|
|
|
2018-11-15 09:18:15 +08:00
|
|
|
bool SBBreakpoint::IsHardware() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsHardware);
|
|
|
|
|
2018-11-15 09:18:15 +08:00
|
|
|
BreakpointSP bkpt_sp = GetSP();
|
|
|
|
if (bkpt_sp)
|
|
|
|
return bkpt_sp->IsHardware();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); }
|
|
|
|
|
2016-09-15 03:07:35 +08:00
|
|
|
// This is simple collection of breakpoint id's and their target.
|
2016-11-12 05:06:40 +08:00
|
|
|
class SBBreakpointListImpl {
|
2016-09-15 03:07:35 +08:00
|
|
|
public:
|
2016-11-12 05:06:40 +08:00
|
|
|
SBBreakpointListImpl(lldb::TargetSP target_sp) : m_target_wp() {
|
|
|
|
if (target_sp && target_sp->IsValid())
|
|
|
|
m_target_wp = target_sp;
|
2016-09-15 03:07:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
~SBBreakpointListImpl() = default;
|
|
|
|
|
|
|
|
size_t GetSize() { return m_break_ids.size(); }
|
|
|
|
|
|
|
|
BreakpointSP GetBreakpointAtIndex(size_t idx) {
|
|
|
|
if (idx >= m_break_ids.size())
|
|
|
|
return BreakpointSP();
|
|
|
|
TargetSP target_sp = m_target_wp.lock();
|
|
|
|
if (!target_sp)
|
|
|
|
return BreakpointSP();
|
|
|
|
lldb::break_id_t bp_id = m_break_ids[idx];
|
|
|
|
return target_sp->GetBreakpointList().FindBreakpointByID(bp_id);
|
|
|
|
}
|
|
|
|
|
2016-09-16 09:41:27 +08:00
|
|
|
BreakpointSP FindBreakpointByID(lldb::break_id_t desired_id) {
|
|
|
|
TargetSP target_sp = m_target_wp.lock();
|
|
|
|
if (!target_sp)
|
|
|
|
return BreakpointSP();
|
|
|
|
|
|
|
|
for (lldb::break_id_t &break_id : m_break_ids) {
|
|
|
|
if (break_id == desired_id)
|
|
|
|
return target_sp->GetBreakpointList().FindBreakpointByID(break_id);
|
|
|
|
}
|
|
|
|
return BreakpointSP();
|
|
|
|
}
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
bool Append(BreakpointSP bkpt) {
|
2016-09-15 03:07:35 +08:00
|
|
|
TargetSP target_sp = m_target_wp.lock();
|
2017-02-27 19:05:34 +08:00
|
|
|
if (!target_sp || !bkpt)
|
2016-09-15 03:07:35 +08:00
|
|
|
return false;
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt->GetTargetSP() != target_sp)
|
2016-09-15 03:07:35 +08:00
|
|
|
return false;
|
2017-02-27 19:05:34 +08:00
|
|
|
m_break_ids.push_back(bkpt->GetID());
|
2016-09-15 03:07:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
bool AppendIfUnique(BreakpointSP bkpt) {
|
2016-09-15 03:07:35 +08:00
|
|
|
TargetSP target_sp = m_target_wp.lock();
|
2017-02-27 19:05:34 +08:00
|
|
|
if (!target_sp || !bkpt)
|
2016-09-15 03:07:35 +08:00
|
|
|
return false;
|
2017-02-27 19:05:34 +08:00
|
|
|
if (bkpt->GetTargetSP() != target_sp)
|
2016-09-15 03:07:35 +08:00
|
|
|
return false;
|
2017-02-27 19:05:34 +08:00
|
|
|
lldb::break_id_t bp_id = bkpt->GetID();
|
2016-09-15 03:07:35 +08:00
|
|
|
if (find(m_break_ids.begin(), m_break_ids.end(), bp_id) ==
|
|
|
|
m_break_ids.end())
|
|
|
|
return false;
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
m_break_ids.push_back(bkpt->GetID());
|
2016-09-15 03:07:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppendByID(lldb::break_id_t id) {
|
|
|
|
TargetSP target_sp = m_target_wp.lock();
|
|
|
|
if (!target_sp)
|
|
|
|
return false;
|
|
|
|
if (id == LLDB_INVALID_BREAK_ID)
|
|
|
|
return false;
|
|
|
|
m_break_ids.push_back(id);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear() { m_break_ids.clear(); }
|
|
|
|
|
|
|
|
void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_list) {
|
|
|
|
for (lldb::break_id_t id : m_break_ids) {
|
|
|
|
bp_list.AddBreakpointID(BreakpointID(id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetSP GetTarget() { return m_target_wp.lock(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<lldb::break_id_t> m_break_ids;
|
|
|
|
TargetWP m_target_wp;
|
|
|
|
};
|
|
|
|
|
|
|
|
SBBreakpointList::SBBreakpointList(SBTarget &target)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &), target);
|
|
|
|
}
|
2016-09-15 03:07:35 +08:00
|
|
|
|
|
|
|
SBBreakpointList::~SBBreakpointList() {}
|
|
|
|
|
|
|
|
size_t SBBreakpointList::GetSize() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpointList, GetSize);
|
|
|
|
|
2016-09-15 03:07:35 +08:00
|
|
|
if (!m_opaque_sp)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return m_opaque_sp->GetSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint SBBreakpointList::GetBreakpointAtIndex(size_t idx) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, GetBreakpointAtIndex,
|
|
|
|
(size_t), idx);
|
|
|
|
|
2016-09-15 03:07:35 +08:00
|
|
|
if (!m_opaque_sp)
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBBreakpoint());
|
2016-09-15 03:07:35 +08:00
|
|
|
|
|
|
|
BreakpointSP bkpt_sp = m_opaque_sp->GetBreakpointAtIndex(idx);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp));
|
2016-09-15 03:07:35 +08:00
|
|
|
}
|
|
|
|
|
2016-09-16 09:41:27 +08:00
|
|
|
SBBreakpoint SBBreakpointList::FindBreakpointByID(lldb::break_id_t id) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, FindBreakpointByID,
|
|
|
|
(lldb::break_id_t), id);
|
|
|
|
|
2016-09-16 09:41:27 +08:00
|
|
|
if (!m_opaque_sp)
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBBreakpoint());
|
2016-09-16 09:41:27 +08:00
|
|
|
BreakpointSP bkpt_sp = m_opaque_sp->FindBreakpointByID(id);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp));
|
2016-09-16 09:41:27 +08:00
|
|
|
}
|
|
|
|
|
2016-09-15 03:07:35 +08:00
|
|
|
void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpointList, Append,
|
|
|
|
(const lldb::SBBreakpoint &), sb_bkpt);
|
|
|
|
|
2016-09-15 03:07:35 +08:00
|
|
|
if (!sb_bkpt.IsValid())
|
|
|
|
return;
|
|
|
|
if (!m_opaque_sp)
|
|
|
|
return;
|
2017-02-27 19:05:34 +08:00
|
|
|
m_opaque_sp->Append(sb_bkpt.m_opaque_wp.lock());
|
2016-09-15 03:07:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointList::AppendByID(lldb::break_id_t id) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBBreakpointList, AppendByID, (lldb::break_id_t),
|
|
|
|
id);
|
|
|
|
|
2016-09-15 03:07:35 +08:00
|
|
|
if (!m_opaque_sp)
|
|
|
|
return;
|
|
|
|
m_opaque_sp->AppendByID(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBBreakpointList, AppendIfUnique,
|
|
|
|
(const lldb::SBBreakpoint &), sb_bkpt);
|
|
|
|
|
2016-09-15 03:07:35 +08:00
|
|
|
if (!sb_bkpt.IsValid())
|
|
|
|
return false;
|
|
|
|
if (!m_opaque_sp)
|
|
|
|
return false;
|
2017-02-27 19:05:34 +08:00
|
|
|
return m_opaque_sp->AppendIfUnique(sb_bkpt.GetSP());
|
2016-09-15 03:07:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointList::Clear() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpointList, Clear);
|
|
|
|
|
2016-09-15 03:07:35 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointList::CopyToBreakpointIDList(
|
|
|
|
lldb_private::BreakpointIDList &bp_id_list) {
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->CopyToBreakpointIDList(bp_id_list);
|
|
|
|
}
|