[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
|
|
|
//===-- Watchpoint.cpp ----------------------------------------------------===//
|
2010-06-09 00:52:24 +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
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-10-31 02:50:12 +08:00
|
|
|
#include "lldb/Breakpoint/Watchpoint.h"
|
|
|
|
|
2011-10-18 02:58:00 +08:00
|
|
|
#include "lldb/Breakpoint/StoppointCallbackContext.h"
|
2012-10-23 15:20:06 +08:00
|
|
|
#include "lldb/Core/Value.h"
|
|
|
|
#include "lldb/Core/ValueObject.h"
|
|
|
|
#include "lldb/Core/ValueObjectMemory.h"
|
2015-09-16 05:13:50 +08:00
|
|
|
#include "lldb/Expression/UserExpression.h"
|
2019-07-19 04:58:24 +08:00
|
|
|
#include "lldb/Symbol/TypeSystem.h"
|
2011-10-18 02:58:00 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
2019-07-31 06:12:34 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2015-08-12 06:53:00 +08:00
|
|
|
Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
|
|
|
|
const CompilerType *type, bool hardware)
|
2020-07-23 23:41:14 +08:00
|
|
|
: StoppointSite(0, addr, size, hardware), m_target(target),
|
2012-08-14 05:09:54 +08:00
|
|
|
m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
|
2012-08-22 07:17:04 +08:00
|
|
|
m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
|
2012-02-25 14:44:30 +08:00
|
|
|
m_ignore_count(0), m_false_alarms(0), m_decl_str(), m_watch_spec_str(),
|
2012-12-18 10:03:49 +08:00
|
|
|
m_type(), m_error(), m_options(), m_being_created(true) {
|
2019-07-31 06:12:34 +08:00
|
|
|
|
2012-10-23 15:20:06 +08:00
|
|
|
if (type && type->IsValid())
|
|
|
|
m_type = *type;
|
|
|
|
else {
|
|
|
|
// If we don't have a known type, then we force it to unsigned int of the
|
|
|
|
// right size.
|
2019-07-31 06:12:34 +08:00
|
|
|
auto type_system_or_err =
|
|
|
|
target.GetScratchTypeSystemForLanguage(eLanguageTypeC);
|
|
|
|
if (auto err = type_system_or_err.takeError()) {
|
|
|
|
LLDB_LOG_ERROR(
|
|
|
|
lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS),
|
|
|
|
std::move(err), "Failed to set type.");
|
|
|
|
} else {
|
|
|
|
m_type = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
|
|
|
|
eEncodingUint, 8 * size);
|
|
|
|
}
|
2012-10-23 15:20:06 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-23 15:20:06 +08:00
|
|
|
// Set the initial value of the watched variable:
|
|
|
|
if (m_target.GetProcessSP()) {
|
|
|
|
ExecutionContext exe_ctx;
|
|
|
|
m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
|
|
|
|
CaptureWatchedValue(exe_ctx);
|
|
|
|
}
|
2012-12-18 10:03:49 +08:00
|
|
|
m_being_created = false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2015-10-31 02:50:12 +08:00
|
|
|
Watchpoint::~Watchpoint() = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-08-10 07:09:42 +08:00
|
|
|
// This function is used when "baton" doesn't need to be freed
|
|
|
|
void Watchpoint::SetCallback(WatchpointHitCallback callback, void *baton,
|
|
|
|
bool is_synchronous) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// The default "Baton" class will keep a copy of "baton" and won't free or
|
|
|
|
// delete it when it goes goes out of scope.
|
2016-09-14 01:53:38 +08:00
|
|
|
m_options.SetCallback(callback, std::make_shared<UntypedBaton>(baton),
|
|
|
|
is_synchronous);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-12-18 10:03:49 +08:00
|
|
|
SendWatchpointChangedEvent(eWatchpointEventTypeCommandChanged);
|
2012-08-10 07:09:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// This function is used when a baton needs to be freed and therefore is
|
|
|
|
// contained in a "Baton" subclass.
|
|
|
|
void Watchpoint::SetCallback(WatchpointHitCallback callback,
|
|
|
|
const BatonSP &callback_baton_sp,
|
|
|
|
bool is_synchronous) {
|
|
|
|
m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
|
2012-12-18 10:03:49 +08:00
|
|
|
SendWatchpointChangedEvent(eWatchpointEventTypeCommandChanged);
|
2012-08-10 07:09:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Watchpoint::ClearCallback() {
|
|
|
|
m_options.ClearCallback();
|
2012-12-18 10:03:49 +08:00
|
|
|
SendWatchpointChangedEvent(eWatchpointEventTypeCommandChanged);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-08-14 05:09:54 +08:00
|
|
|
void Watchpoint::SetDeclInfo(const std::string &str) { m_decl_str = str; }
|
2011-09-17 05:41:42 +08:00
|
|
|
|
2012-08-14 05:09:54 +08:00
|
|
|
std::string Watchpoint::GetWatchSpec() { return m_watch_spec_str; }
|
|
|
|
|
|
|
|
void Watchpoint::SetWatchSpec(const std::string &str) {
|
2012-02-25 14:44:30 +08:00
|
|
|
m_watch_spec_str = str;
|
|
|
|
}
|
|
|
|
|
2020-07-22 02:04:36 +08:00
|
|
|
bool Watchpoint::IsHardware() const {
|
|
|
|
lldbassert(m_is_hardware || !HardwareRequired());
|
|
|
|
return m_is_hardware;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-08-14 05:09:54 +08:00
|
|
|
bool Watchpoint::IsWatchVariable() const { return m_is_watch_variable; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-08-14 05:09:54 +08:00
|
|
|
void Watchpoint::SetWatchVariable(bool val) { m_is_watch_variable = val; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-23 15:20:06 +08:00
|
|
|
bool Watchpoint::CaptureWatchedValue(const ExecutionContext &exe_ctx) {
|
|
|
|
ConstString watch_name("$__lldb__watch_value");
|
|
|
|
m_old_value_sp = m_new_value_sp;
|
|
|
|
Address watch_address(GetLoadAddress());
|
2012-10-24 05:09:09 +08:00
|
|
|
if (!m_type.IsValid()) {
|
|
|
|
// Don't know how to report new & old values, since we couldn't make a
|
2018-05-01 00:49:04 +08:00
|
|
|
// scalar type for this watchpoint. This works around an assert in
|
|
|
|
// ValueObjectMemory::Create.
|
2012-10-24 05:09:09 +08:00
|
|
|
// FIXME: This should not happen, but if it does in some case we care about,
|
|
|
|
// we can go grab the value raw and print it as unsigned.
|
|
|
|
return false;
|
|
|
|
}
|
2016-11-13 02:17:36 +08:00
|
|
|
m_new_value_sp = ValueObjectMemory::Create(
|
|
|
|
exe_ctx.GetBestExecutionContextScope(), watch_name.GetStringRef(),
|
|
|
|
watch_address, m_type);
|
2012-10-23 15:20:06 +08:00
|
|
|
m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name);
|
2015-10-31 02:50:12 +08:00
|
|
|
return (m_new_value_sp && m_new_value_sp->GetError().Success());
|
2012-10-23 15:20:06 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-08-15 04:56:37 +08:00
|
|
|
void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() {
|
|
|
|
++m_false_alarms;
|
|
|
|
if (m_false_alarms) {
|
2020-07-23 23:41:14 +08:00
|
|
|
if (m_hit_counter.GetValue() >= m_false_alarms) {
|
|
|
|
m_hit_counter.Decrement(m_false_alarms);
|
2012-08-15 04:56:37 +08:00
|
|
|
m_false_alarms = 0;
|
|
|
|
} else {
|
2020-07-23 23:41:14 +08:00
|
|
|
m_false_alarms -= m_hit_counter.GetValue();
|
|
|
|
m_hit_counter.Reset();
|
2012-08-15 04:56:37 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-08-15 04:56:37 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// RETURNS - true if we should stop at this breakpoint, false if we
|
|
|
|
// should continue.
|
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
bool Watchpoint::ShouldStop(StoppointCallbackContext *context) {
|
2020-07-23 23:41:14 +08:00
|
|
|
m_hit_counter.Increment();
|
2011-09-23 02:04:58 +08:00
|
|
|
|
2018-12-15 08:15:33 +08:00
|
|
|
return IsEnabled();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
void Watchpoint::GetDescription(Stream *s, lldb::DescriptionLevel level) {
|
2011-09-17 05:41:42 +08:00
|
|
|
DumpWithLevel(s, level);
|
2011-09-13 07:38:44 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
void Watchpoint::Dump(Stream *s) const {
|
2011-09-17 05:41:42 +08:00
|
|
|
DumpWithLevel(s, lldb::eDescriptionLevelBrief);
|
|
|
|
}
|
|
|
|
|
2015-10-31 02:50:12 +08:00
|
|
|
// If prefix is nullptr, we display the watch id and ignore the prefix
|
|
|
|
// altogether.
|
2012-08-14 07:27:50 +08:00
|
|
|
void Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const {
|
|
|
|
if (!prefix) {
|
|
|
|
s->Printf("\nWatchpoint %u hit:", GetID());
|
|
|
|
prefix = "";
|
|
|
|
}
|
2015-10-09 23:13:20 +08:00
|
|
|
|
2012-10-23 15:20:06 +08:00
|
|
|
if (m_old_value_sp) {
|
2015-10-09 23:13:20 +08:00
|
|
|
const char *old_value_cstr = m_old_value_sp->GetValueAsCString();
|
|
|
|
if (old_value_cstr && old_value_cstr[0])
|
|
|
|
s->Printf("\n%sold value: %s", prefix, old_value_cstr);
|
|
|
|
else {
|
|
|
|
const char *old_summary_cstr = m_old_value_sp->GetSummaryAsCString();
|
|
|
|
if (old_summary_cstr && old_summary_cstr[0])
|
|
|
|
s->Printf("\n%sold value: %s", prefix, old_summary_cstr);
|
2012-08-14 05:09:54 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-10-23 15:20:06 +08:00
|
|
|
if (m_new_value_sp) {
|
2015-10-09 23:13:20 +08:00
|
|
|
const char *new_value_cstr = m_new_value_sp->GetValueAsCString();
|
|
|
|
if (new_value_cstr && new_value_cstr[0])
|
|
|
|
s->Printf("\n%snew value: %s", prefix, new_value_cstr);
|
|
|
|
else {
|
|
|
|
const char *new_summary_cstr = m_new_value_sp->GetSummaryAsCString();
|
|
|
|
if (new_summary_cstr && new_summary_cstr[0])
|
|
|
|
s->Printf("\n%snew value: %s", prefix, new_summary_cstr);
|
2012-08-14 05:09:54 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-08-14 05:09:54 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
void Watchpoint::DumpWithLevel(Stream *s,
|
|
|
|
lldb::DescriptionLevel description_level) const {
|
2011-10-18 02:58:00 +08:00
|
|
|
if (s == nullptr)
|
|
|
|
return;
|
2011-09-17 05:41:42 +08:00
|
|
|
|
|
|
|
assert(description_level >= lldb::eDescriptionLevelBrief &&
|
|
|
|
description_level <= lldb::eDescriptionLevelVerbose);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
s->Printf("Watchpoint %u: addr = 0x%8.8" PRIx64
|
|
|
|
" size = %u state = %s type = %s%s",
|
2012-01-24 08:11:02 +08:00
|
|
|
GetID(), GetLoadAddress(), m_byte_size,
|
2011-10-14 08:42:25 +08:00
|
|
|
IsEnabled() ? "enabled" : "disabled", m_watch_read ? "r" : "",
|
2010-06-09 00:52:24 +08:00
|
|
|
m_watch_write ? "w" : "");
|
|
|
|
|
2012-08-22 07:17:04 +08:00
|
|
|
if (description_level >= lldb::eDescriptionLevelFull) {
|
|
|
|
if (!m_decl_str.empty())
|
|
|
|
s->Printf("\n declare @ '%s'", m_decl_str.c_str());
|
|
|
|
if (!m_watch_spec_str.empty())
|
|
|
|
s->Printf("\n watchpoint spec = '%s'", m_watch_spec_str.c_str());
|
|
|
|
|
|
|
|
// Dump the snapshots we have taken.
|
|
|
|
DumpSnapshots(s, " ");
|
|
|
|
|
|
|
|
if (GetConditionText())
|
2012-08-24 06:28:26 +08:00
|
|
|
s->Printf("\n condition = '%s'", GetConditionText());
|
|
|
|
m_options.GetCallbackDescription(s, description_level);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (description_level >= lldb::eDescriptionLevelVerbose) {
|
|
|
|
s->Printf("\n hw_index = %i hit_count = %-4u ignore_count = %-4u",
|
|
|
|
GetHardwareIndex(), GetHitCount(), GetIgnoreCount());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-08-22 07:17:04 +08:00
|
|
|
}
|
|
|
|
|
2012-12-18 10:03:49 +08:00
|
|
|
bool Watchpoint::IsEnabled() const { return m_enabled; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-12-18 10:03:49 +08:00
|
|
|
// Within StopInfo.cpp, we purposely turn on the ephemeral mode right before
|
2018-05-01 00:49:04 +08:00
|
|
|
// temporarily disable the watchpoint in order to perform possible watchpoint
|
|
|
|
// actions without triggering further watchpoint events. After the temporary
|
|
|
|
// disabled watchpoint is enabled, we then turn off the ephemeral mode.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-12-18 10:03:49 +08:00
|
|
|
void Watchpoint::TurnOnEphemeralMode() { m_is_ephemeral = true; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
void Watchpoint::TurnOffEphemeralMode() {
|
2012-08-22 07:17:04 +08:00
|
|
|
m_is_ephemeral = false;
|
2011-10-14 08:42:25 +08:00
|
|
|
// Leaving ephemeral mode, reset the m_disabled_count!
|
2010-06-09 00:52:24 +08:00
|
|
|
m_disabled_count = 0;
|
|
|
|
}
|
2015-10-31 02:50:12 +08:00
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
bool Watchpoint::IsDisabledDuringEphemeralMode() {
|
2016-10-26 04:34:32 +08:00
|
|
|
return m_disabled_count > 1 && m_is_ephemeral;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2015-10-31 02:50:12 +08:00
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
void Watchpoint::SetEnabled(bool enabled, bool notify) {
|
2010-06-09 00:52:24 +08:00
|
|
|
if (!enabled) {
|
2012-08-22 07:17:04 +08:00
|
|
|
if (!m_is_ephemeral)
|
2010-06-09 00:52:24 +08:00
|
|
|
SetHardwareIndex(LLDB_INVALID_INDEX32);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
++m_disabled_count;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// Don't clear the snapshots for now.
|
|
|
|
// Within StopInfo.cpp, we purposely do disable/enable watchpoint while
|
2012-08-22 06:06:34 +08:00
|
|
|
// performing watchpoint actions.
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-12-18 10:03:49 +08:00
|
|
|
bool changed = enabled != m_enabled;
|
2010-06-09 00:52:24 +08:00
|
|
|
m_enabled = enabled;
|
2012-12-18 10:03:49 +08:00
|
|
|
if (notify && !m_is_ephemeral && changed)
|
|
|
|
SendWatchpointChangedEvent(enabled ? eWatchpointEventTypeEnabled
|
|
|
|
: eWatchpointEventTypeDisabled);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 08:42:25 +08:00
|
|
|
void Watchpoint::SetWatchpointType(uint32_t type, bool notify) {
|
|
|
|
int old_watch_read = m_watch_read;
|
2012-12-18 10:03:49 +08:00
|
|
|
int old_watch_write = m_watch_write;
|
|
|
|
m_watch_read = (type & LLDB_WATCH_TYPE_READ) != 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
m_watch_write = (type & LLDB_WATCH_TYPE_WRITE) != 0;
|
2012-12-18 10:03:49 +08:00
|
|
|
if (notify &&
|
|
|
|
(old_watch_read != m_watch_read || old_watch_write != m_watch_write))
|
|
|
|
SendWatchpointChangedEvent(eWatchpointEventTypeTypeChanged);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-10-18 02:58:00 +08:00
|
|
|
|
|
|
|
bool Watchpoint::WatchpointRead() const { return m_watch_read != 0; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-18 02:58:00 +08:00
|
|
|
bool Watchpoint::WatchpointWrite() const { return m_watch_write != 0; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-18 02:58:00 +08:00
|
|
|
uint32_t Watchpoint::GetIgnoreCount() const { return m_ignore_count; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-18 02:58:00 +08:00
|
|
|
void Watchpoint::SetIgnoreCount(uint32_t n) {
|
2012-12-18 10:03:49 +08:00
|
|
|
bool changed = m_ignore_count != n;
|
2012-08-10 07:09:42 +08:00
|
|
|
m_ignore_count = n;
|
|
|
|
if (changed)
|
|
|
|
SendWatchpointChangedEvent(eWatchpointEventTypeIgnoreChanged);
|
2011-10-18 02:58:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Watchpoint::InvokeCallback(StoppointCallbackContext *context) {
|
2015-10-31 02:50:12 +08:00
|
|
|
return m_options.InvokeCallback(context, GetID());
|
2011-10-18 02:58:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Watchpoint::SetCondition(const char *condition) {
|
|
|
|
if (condition == nullptr || condition[0] == '\0') {
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_condition_up)
|
|
|
|
m_condition_up.reset();
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2015-10-31 02:50:12 +08:00
|
|
|
// Pass nullptr for expr_prefix (no translation-unit level definitions).
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2019-02-13 14:25:41 +08:00
|
|
|
m_condition_up.reset(m_target.GetUserExpressionForLanguage(
|
2016-11-08 12:52:16 +08:00
|
|
|
condition, llvm::StringRef(), lldb::eLanguageTypeUnknown,
|
2019-02-13 14:25:41 +08:00
|
|
|
UserExpression::eResultTypeAny, EvaluateExpressionOptions(), nullptr,
|
|
|
|
error));
|
2015-09-16 05:13:50 +08:00
|
|
|
if (error.Fail()) {
|
|
|
|
// FIXME: Log something...
|
2019-02-13 14:25:41 +08:00
|
|
|
m_condition_up.reset();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
2012-12-18 10:03:49 +08:00
|
|
|
SendWatchpointChangedEvent(eWatchpointEventTypeConditionChanged);
|
2011-10-18 02:58:00 +08:00
|
|
|
}
|
|
|
|
|
2012-12-18 10:03:49 +08:00
|
|
|
const char *Watchpoint::GetConditionText() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_condition_up)
|
|
|
|
return m_condition_up->GetUserText();
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2012-12-18 10:03:49 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Watchpoint::SendWatchpointChangedEvent(
|
|
|
|
lldb::WatchpointEventType eventKind) {
|
|
|
|
if (!m_being_created &&
|
|
|
|
GetTarget().EventTypeHasListeners(
|
|
|
|
Target::eBroadcastBitWatchpointChanged)) {
|
|
|
|
WatchpointEventData *data =
|
|
|
|
new Watchpoint::WatchpointEventData(eventKind, shared_from_this());
|
|
|
|
GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged, data);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-12-18 10:03:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Watchpoint::SendWatchpointChangedEvent(WatchpointEventData *data) {
|
|
|
|
if (data == nullptr)
|
2016-09-07 04:57:50 +08:00
|
|
|
return;
|
|
|
|
|
2012-12-18 10:03:49 +08:00
|
|
|
if (!m_being_created &&
|
|
|
|
GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
|
|
|
|
GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged, data);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2012-12-18 10:03:49 +08:00
|
|
|
delete data;
|
|
|
|
}
|
|
|
|
|
2015-10-31 02:50:12 +08:00
|
|
|
Watchpoint::WatchpointEventData::WatchpointEventData(
|
2012-12-18 10:03:49 +08:00
|
|
|
WatchpointEventType sub_type, const WatchpointSP &new_watchpoint_sp)
|
|
|
|
: EventData(), m_watchpoint_event(sub_type),
|
|
|
|
m_new_watchpoint_sp(new_watchpoint_sp) {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-31 02:50:12 +08:00
|
|
|
Watchpoint::WatchpointEventData::~WatchpointEventData() = default;
|
2012-12-18 10:03:49 +08:00
|
|
|
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString Watchpoint::WatchpointEventData::GetFlavorString() {
|
2012-12-18 10:03:49 +08:00
|
|
|
static ConstString g_flavor("Watchpoint::WatchpointEventData");
|
|
|
|
return g_flavor;
|
|
|
|
}
|
|
|
|
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString Watchpoint::WatchpointEventData::GetFlavor() const {
|
2012-12-18 10:03:49 +08:00
|
|
|
return WatchpointEventData::GetFlavorString();
|
|
|
|
}
|
|
|
|
|
|
|
|
WatchpointSP &Watchpoint::WatchpointEventData::GetWatchpoint() {
|
|
|
|
return m_new_watchpoint_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
WatchpointEventType
|
|
|
|
Watchpoint::WatchpointEventData::GetWatchpointEventType() const {
|
|
|
|
return m_watchpoint_event;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Watchpoint::WatchpointEventData::Dump(Stream *s) const {}
|
|
|
|
|
|
|
|
const Watchpoint::WatchpointEventData *
|
|
|
|
Watchpoint::WatchpointEventData::GetEventDataFromEvent(const Event *event) {
|
|
|
|
if (event) {
|
|
|
|
const EventData *event_data = event->GetData();
|
|
|
|
if (event_data &&
|
|
|
|
event_data->GetFlavor() == WatchpointEventData::GetFlavorString())
|
|
|
|
return static_cast<const WatchpointEventData *>(event->GetData());
|
|
|
|
}
|
2015-10-31 02:50:12 +08:00
|
|
|
return nullptr;
|
2012-12-18 10:03:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
WatchpointEventType
|
|
|
|
Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent(
|
|
|
|
const EventSP &event_sp) {
|
|
|
|
const WatchpointEventData *data = GetEventDataFromEvent(event_sp.get());
|
|
|
|
|
2015-10-31 02:50:12 +08:00
|
|
|
if (data == nullptr)
|
2012-12-18 10:03:49 +08:00
|
|
|
return eWatchpointEventTypeInvalidType;
|
|
|
|
else
|
|
|
|
return data->GetWatchpointEventType();
|
|
|
|
}
|
|
|
|
|
|
|
|
WatchpointSP Watchpoint::WatchpointEventData::GetWatchpointFromEvent(
|
|
|
|
const EventSP &event_sp) {
|
|
|
|
WatchpointSP wp_sp;
|
|
|
|
|
|
|
|
const WatchpointEventData *data = GetEventDataFromEvent(event_sp.get());
|
|
|
|
if (data)
|
|
|
|
wp_sp = data->m_new_watchpoint_sp;
|
|
|
|
|
|
|
|
return wp_sp;
|
|
|
|
}
|