[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- SBBreakpointName.cpp ----------------------------------------------===//
|
2017-09-15 04:22:49 +08:00
|
|
|
//
|
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
|
2017-09-15 04:22:49 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBBreakpointName.h"
|
|
|
|
#include "lldb/API/SBDebugger.h"
|
|
|
|
#include "lldb/API/SBError.h"
|
|
|
|
#include "lldb/API/SBStream.h"
|
|
|
|
#include "lldb/API/SBStringList.h"
|
2019-10-26 05:05:07 +08:00
|
|
|
#include "lldb/API/SBStructuredData.h"
|
2017-09-15 04:22:49 +08:00
|
|
|
#include "lldb/API/SBTarget.h"
|
2022-01-20 03:38:26 +08:00
|
|
|
#include "lldb/Utility/Instrumentation.h"
|
2017-09-15 04:22:49 +08:00
|
|
|
|
|
|
|
#include "lldb/Breakpoint/BreakpointName.h"
|
|
|
|
#include "lldb/Breakpoint/StoppointCallbackContext.h"
|
|
|
|
#include "lldb/Core/Debugger.h"
|
2019-10-26 05:05:07 +08:00
|
|
|
#include "lldb/Core/StructuredDataImpl.h"
|
2017-09-15 04:22:49 +08:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
#include "lldb/Interpreter/ScriptInterpreter.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
|
|
|
#include "lldb/Utility/Stream.h"
|
|
|
|
|
|
|
|
#include "SBBreakpointOptionCommon.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
namespace lldb
|
|
|
|
{
|
|
|
|
class SBBreakpointNameImpl {
|
|
|
|
public:
|
2017-12-08 02:06:06 +08:00
|
|
|
SBBreakpointNameImpl(TargetSP target_sp, const char *name) {
|
2017-09-15 04:22:49 +08:00
|
|
|
if (!name || name[0] == '\0')
|
|
|
|
return;
|
|
|
|
m_name.assign(name);
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
if (!target_sp)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
m_target_wp = target_sp;
|
|
|
|
}
|
2017-12-08 02:06:06 +08:00
|
|
|
|
|
|
|
SBBreakpointNameImpl(SBTarget &sb_target, const char *name);
|
|
|
|
bool operator==(const SBBreakpointNameImpl &rhs);
|
|
|
|
bool operator!=(const SBBreakpointNameImpl &rhs);
|
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// For now we take a simple approach and only keep the name, and relook up
|
|
|
|
// the location when we need it.
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-16 01:54:37 +08:00
|
|
|
TargetSP GetTarget() const {
|
2017-09-15 04:22:49 +08:00
|
|
|
return m_target_wp.lock();
|
|
|
|
}
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-16 01:54:37 +08:00
|
|
|
const char *GetName() const {
|
2017-09-15 04:22:49 +08:00
|
|
|
return m_name.c_str();
|
|
|
|
}
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-16 01:54:37 +08:00
|
|
|
bool IsValid() const {
|
2017-09-15 04:22:49 +08:00
|
|
|
return !m_name.empty() && m_target_wp.lock();
|
|
|
|
}
|
2017-12-08 02:06:06 +08:00
|
|
|
|
|
|
|
lldb_private::BreakpointName *GetBreakpointName() const;
|
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
private:
|
|
|
|
TargetWP m_target_wp;
|
|
|
|
std::string m_name;
|
|
|
|
};
|
2017-12-08 02:06:06 +08:00
|
|
|
|
|
|
|
SBBreakpointNameImpl::SBBreakpointNameImpl(SBTarget &sb_target,
|
|
|
|
const char *name) {
|
|
|
|
if (!name || name[0] == '\0')
|
|
|
|
return;
|
|
|
|
m_name.assign(name);
|
|
|
|
|
|
|
|
if (!sb_target.IsValid())
|
|
|
|
return;
|
|
|
|
|
|
|
|
TargetSP target_sp = sb_target.GetSP();
|
|
|
|
if (!target_sp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_target_wp = target_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointNameImpl::operator==(const SBBreakpointNameImpl &rhs) {
|
|
|
|
return m_name == rhs.m_name && m_target_wp.lock() == rhs.m_target_wp.lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointNameImpl::operator!=(const SBBreakpointNameImpl &rhs) {
|
|
|
|
return m_name != rhs.m_name || m_target_wp.lock() != rhs.m_target_wp.lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::BreakpointName *SBBreakpointNameImpl::GetBreakpointName() const {
|
|
|
|
if (!IsValid())
|
|
|
|
return nullptr;
|
|
|
|
TargetSP target_sp = GetTarget();
|
|
|
|
if (!target_sp)
|
|
|
|
return nullptr;
|
|
|
|
Status error;
|
|
|
|
return target_sp->FindBreakpointName(ConstString(m_name), true, error);
|
|
|
|
}
|
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
} // namespace lldb
|
|
|
|
|
2022-01-20 03:38:26 +08:00
|
|
|
SBBreakpointName::SBBreakpointName() { LLDB_INSTRUMENT_VA(this); }
|
2019-03-06 08:06:00 +08:00
|
|
|
|
|
|
|
SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, sb_target, name);
|
2017-09-15 04:22:49 +08:00
|
|
|
|
2020-06-25 07:25:05 +08:00
|
|
|
m_impl_up = std::make_unique<SBBreakpointNameImpl>(sb_target, name);
|
2018-05-01 00:49:04 +08:00
|
|
|
// Call FindBreakpointName here to make sure the name is valid, reset if not:
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
m_impl_up.reset();
|
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, sb_bkpt, name);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
if (!sb_bkpt.IsValid()) {
|
|
|
|
m_impl_up.reset();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
BreakpointSP bkpt_sp = sb_bkpt.GetSP();
|
|
|
|
Target &target = bkpt_sp->GetTarget();
|
|
|
|
|
2020-06-25 07:25:05 +08:00
|
|
|
m_impl_up =
|
|
|
|
std::make_unique<SBBreakpointNameImpl>(target.shared_from_this(), name);
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Call FindBreakpointName here to make sure the name is valid, reset if not:
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name) {
|
|
|
|
m_impl_up.reset();
|
|
|
|
return;
|
|
|
|
}
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
// Now copy over the breakpoint's options:
|
2021-06-12 08:00:46 +08:00
|
|
|
target.ConfigureBreakpointName(*bp_name, bkpt_sp->GetOptions(),
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName::Permissions());
|
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, rhs);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
if (!rhs.m_impl_up)
|
|
|
|
return;
|
|
|
|
else
|
2020-06-25 07:25:05 +08:00
|
|
|
m_impl_up = std::make_unique<SBBreakpointNameImpl>(
|
|
|
|
rhs.m_impl_up->GetTarget(), rhs.m_impl_up->GetName());
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpointName::~SBBreakpointName() = default;
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
const SBBreakpointName &SBBreakpointName::
|
|
|
|
operator=(const SBBreakpointName &rhs) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, rhs);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
if (!rhs.m_impl_up) {
|
|
|
|
m_impl_up.reset();
|
2022-01-10 14:54:08 +08:00
|
|
|
return *this;
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2020-06-25 07:25:05 +08:00
|
|
|
m_impl_up = std::make_unique<SBBreakpointNameImpl>(rhs.m_impl_up->GetTarget(),
|
|
|
|
rhs.m_impl_up->GetName());
|
2022-01-10 14:54:08 +08:00
|
|
|
return *this;
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, rhs);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2018-12-21 05:02:55 +08:00
|
|
|
return *m_impl_up == *rhs.m_impl_up;
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointName::operator!=(const lldb::SBBreakpointName &rhs) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, rhs);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2018-12-21 05:02:55 +08:00
|
|
|
return *m_impl_up != *rhs.m_impl_up;
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointName::IsValid() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
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();
|
|
|
|
}
|
|
|
|
SBBreakpointName::operator bool() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
if (!m_impl_up)
|
|
|
|
return false;
|
|
|
|
return m_impl_up->IsValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBBreakpointName::GetName() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
if (!m_impl_up)
|
|
|
|
return "<Invalid Breakpoint Name Object>";
|
|
|
|
return m_impl_up->GetName();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetEnabled(bool enable) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, enable);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().SetEnabled(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::UpdateName(BreakpointName &bp_name) {
|
|
|
|
if (!IsValid())
|
|
|
|
return;
|
|
|
|
|
|
|
|
TargetSP target_sp = m_impl_up->GetTarget();
|
|
|
|
if (!target_sp)
|
|
|
|
return;
|
|
|
|
target_sp->ApplyNameToBreakpoints(bp_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointName::IsEnabled() {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return false;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().IsEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetOneShot(bool one_shot) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, one_shot);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().SetOneShot(one_shot);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointName::IsOneShot() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
const BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return false;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().IsOneShot();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetIgnoreCount(uint32_t count) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, count);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().SetIgnoreCount(count);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBBreakpointName::GetIgnoreCount() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return false;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().GetIgnoreCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetCondition(const char *condition) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, condition);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().SetCondition(condition);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBBreakpointName::GetCondition() {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return nullptr;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().GetConditionText();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetAutoContinue(bool auto_continue) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, auto_continue);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().SetAutoContinue(auto_continue);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointName::GetAutoContinue() {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
2017-09-16 01:54:37 +08:00
|
|
|
return false;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().IsAutoContinue();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetThreadID(tid_t tid) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, tid);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().SetThreadID(tid);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
tid_t SBBreakpointName::GetThreadID() {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return LLDB_INVALID_THREAD_ID;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().GetThreadSpec()->GetTID();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetThreadIndex(uint32_t index) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, index);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().GetThreadSpec()->SetIndex(index);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBBreakpointName::GetThreadIndex() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return LLDB_INVALID_THREAD_ID;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().GetThreadSpec()->GetIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetThreadName(const char *thread_name) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, thread_name);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().GetThreadSpec()->SetName(thread_name);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBBreakpointName::GetThreadName() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return nullptr;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().GetThreadSpec()->GetName();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetQueueName(const char *queue_name) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, queue_name);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
bp_name->GetOptions().GetThreadSpec()->SetQueueName(queue_name);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBBreakpointName::GetQueueName() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return nullptr;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
return bp_name->GetOptions().GetThreadSpec()->GetQueueName();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, commands);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
|
|
|
if (commands.GetSize() == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
|
|
|
|
new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));
|
|
|
|
|
|
|
|
bp_name->GetOptions().SetCommandDataCallback(cmd_data_up);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBBreakpointName::GetCommandLineCommands(SBStringList &commands) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, commands);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return false;
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
StringList command_list;
|
|
|
|
bool has_commands =
|
|
|
|
bp_name->GetOptions().GetCommandLineCallbacks(command_list);
|
|
|
|
if (has_commands)
|
|
|
|
commands.AppendList(command_list);
|
|
|
|
return has_commands;
|
|
|
|
}
|
|
|
|
|
2017-09-15 08:52:35 +08:00
|
|
|
const char *SBBreakpointName::GetHelpString() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 08:52:35 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return "";
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 08:52:35 +08:00
|
|
|
return bp_name->GetHelp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetHelpString(const char *help_string) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, help_string);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 08:52:35 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
bp_name->SetHelp(help_string);
|
|
|
|
}
|
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
bool SBBreakpointName::GetDescription(SBStream &s) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, s);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
{
|
|
|
|
s.Printf("No value");
|
|
|
|
return false;
|
|
|
|
}
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
bp_name->GetDescription(s.get(), eDescriptionLevelFull);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback,
|
|
|
|
void *baton) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, callback, baton);
|
2019-03-09 03:09:27 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
|
|
|
|
bp_name->GetOptions().SetCallback(SBBreakpointCallbackBaton
|
|
|
|
::PrivateBreakpointHitCallback,
|
|
|
|
baton_sp,
|
|
|
|
false);
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBBreakpointName::SetScriptCallbackFunction(
|
2019-10-26 05:05:07 +08:00
|
|
|
const char *callback_function_name) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, callback_function_name);
|
2019-10-26 05:05:07 +08:00
|
|
|
SBStructuredData empty_args;
|
|
|
|
SetScriptCallbackFunction(callback_function_name, empty_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError SBBreakpointName::SetScriptCallbackFunction(
|
|
|
|
const char *callback_function_name,
|
|
|
|
SBStructuredData &extra_args) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, callback_function_name, extra_args);
|
2019-10-26 05:05:07 +08:00
|
|
|
SBError sb_error;
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
2019-10-26 05:05:07 +08:00
|
|
|
if (!bp_name) {
|
|
|
|
sb_error.SetErrorString("unrecognized breakpoint name");
|
2022-01-10 14:54:08 +08:00
|
|
|
return sb_error;
|
2019-10-26 05:05:07 +08:00
|
|
|
}
|
2019-03-08 06:47:13 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
BreakpointOptions &bp_options = bp_name->GetOptions();
|
2019-10-26 05:05:07 +08:00
|
|
|
Status error;
|
|
|
|
error = m_impl_up->GetTarget()
|
2021-06-12 08:00:46 +08:00
|
|
|
->GetDebugger()
|
|
|
|
.GetScriptInterpreter()
|
|
|
|
->SetBreakpointCommandCallbackFunction(
|
|
|
|
bp_options, callback_function_name,
|
|
|
|
extra_args.m_impl_up->GetObjectSP());
|
2019-10-26 05:05:07 +08:00
|
|
|
sb_error.SetError(error);
|
2017-09-15 04:22:49 +08:00
|
|
|
UpdateName(*bp_name);
|
2022-01-10 14:54:08 +08:00
|
|
|
return sb_error;
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBError
|
|
|
|
SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, callback_body_text);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
SBError sb_error;
|
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
2022-01-10 14:54:08 +08:00
|
|
|
return sb_error;
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
m_impl_up->GetTarget()->GetAPIMutex());
|
|
|
|
|
|
|
|
BreakpointOptions &bp_options = bp_name->GetOptions();
|
|
|
|
Status error =
|
|
|
|
m_impl_up->GetTarget()
|
|
|
|
->GetDebugger()
|
|
|
|
.GetScriptInterpreter()
|
2021-06-12 08:00:46 +08:00
|
|
|
->SetBreakpointCommandCallback(bp_options, callback_body_text);
|
2017-09-15 04:22:49 +08:00
|
|
|
sb_error.SetError(error);
|
|
|
|
if (!sb_error.Fail())
|
|
|
|
UpdateName(*bp_name);
|
|
|
|
|
2022-01-10 14:54:08 +08:00
|
|
|
return sb_error;
|
2017-09-15 04:22:49 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
bool SBBreakpointName::GetAllowList() const {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return false;
|
|
|
|
return bp_name->GetPermissions().GetAllowList();
|
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBBreakpointName::SetAllowList(bool value) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, value);
|
2017-09-15 04:22:49 +08:00
|
|
|
|
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
|
|
|
bp_name->GetPermissions().SetAllowList(value);
|
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
|
|
|
|
bool SBBreakpointName::GetAllowDelete() {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return false;
|
|
|
|
return bp_name->GetPermissions().GetAllowDelete();
|
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBBreakpointName::SetAllowDelete(bool value) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, value);
|
2017-09-15 04:22:49 +08:00
|
|
|
|
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
|
|
|
bp_name->GetPermissions().SetAllowDelete(value);
|
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
|
|
|
|
bool SBBreakpointName::GetAllowDisable() {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return false;
|
|
|
|
return bp_name->GetPermissions().GetAllowDisable();
|
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBBreakpointName::SetAllowDisable(bool value) {
|
2022-01-20 03:38:26 +08:00
|
|
|
LLDB_INSTRUMENT_VA(this, value);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2017-09-15 04:22:49 +08:00
|
|
|
BreakpointName *bp_name = GetBreakpointName();
|
|
|
|
if (!bp_name)
|
|
|
|
return;
|
|
|
|
bp_name->GetPermissions().SetAllowDisable(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::BreakpointName *SBBreakpointName::GetBreakpointName() const
|
|
|
|
{
|
|
|
|
if (!IsValid())
|
|
|
|
return nullptr;
|
|
|
|
return m_impl_up->GetBreakpointName();
|
|
|
|
}
|