Revert "[lldb] Add 'modify' type watchpoints, make it default (#66308)"

TestStepOverWatchpoint.py and TestUnalignedWatchpoint.py are failing
on the ubuntu and debian bots
https://lab.llvm.org/buildbot/#/builders/68/builds/60204
https://lab.llvm.org/buildbot/#/builders/96/builds/45623

and the newly added test TestModifyWatchpoint.py does not
work on windows bot
https://lab.llvm.org/buildbot/#/builders/219/builds/5708

I will debug tomorrow morning and reland.

This reverts commit 3692267ca8f9c51cb55e4387283762d921fe2ae2.
This commit is contained in:
Jason Molenda 2023-09-18 22:48:46 -07:00
parent af935cf0ee
commit 44532a9dd4
31 changed files with 57 additions and 386 deletions

View File

@ -77,5 +77,4 @@
#include "lldb/API/SBValueList.h"
#include "lldb/API/SBVariablesOptions.h"
#include "lldb/API/SBWatchpoint.h"
#include "lldb/API/SBWatchpointOptions.h"
%}

View File

@ -1,12 +0,0 @@
%feature("docstring",
"A container for options to use when creating watchpoints."
) lldb::SBWatchpointOptions;
%feature("docstring", "Sets whether the watchpoint should stop on read accesses."
) lldb::SBWatchpointOptions::SetWatchpointTypeRead;
%feature("docstring", "Gets whether the watchpoint should stop on read accesses."
) lldb::SBWatchpointOptions::GetWatchpointTypeRead;
%feature("docstring", "Sets whether the watchpoint should stop on write accesses. eWatchpointWriteTypeOnModify is the most commonly useful mode, where lldb will stop when the watched value has changed. eWatchpointWriteTypeAlways will stop on any write to the watched region, even if it's the value is the same."
) lldb::SBWatchpointOptions::SetWatchpointTypeWrite;
%feature("docstring", "Gets whether the watchpoint should stop on write accesses, returning WatchpointWriteType to indicate the type of write watching that is enabled, or eWatchpointWriteTypeDisabled."
) lldb::SBWatchpointOptions::GetWatchpointTypeWrite;

View File

@ -80,7 +80,6 @@
%include "./interface/SBValueListDocstrings.i"
%include "./interface/SBVariablesOptionsDocstrings.i"
%include "./interface/SBWatchpointDocstrings.i"
%include "./interface/SBWatchpointOptionsDocstrings.i"
/* API headers */
%include "lldb/API/SBAddress.h"
@ -153,7 +152,6 @@
%include "lldb/API/SBValueList.h"
%include "lldb/API/SBVariablesOptions.h"
%include "lldb/API/SBWatchpoint.h"
%include "lldb/API/SBWatchpointOptions.h"
/* Extensions for SB classes */
%include "./interface/SBAddressExtensions.i"

View File

@ -21,7 +21,6 @@
#include "lldb/API/SBType.h"
#include "lldb/API/SBValue.h"
#include "lldb/API/SBWatchpoint.h"
#include "lldb/API/SBWatchpointOptions.h"
namespace lldb_private {
namespace python {
@ -829,13 +828,8 @@ public:
lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id);
LLDB_DEPRECATED("WatchAddress deprecated, use WatchpointCreateByAddress")
lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read,
bool modify, SBError &error);
lldb::SBWatchpoint
WatchpointCreateByAddress(lldb::addr_t addr, size_t size,
lldb::SBWatchpointOptions options, SBError &error);
bool write, SBError &error);
bool EnableAllWatchpoints();

View File

@ -1,43 +0,0 @@
//===-- SBWatchpointOptions.h -----------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_API_SBWATCHPOINTOPTIONS_H
#define LLDB_API_SBWATCHPOINTOPTIONS_H
#include "lldb/API/SBDefines.h"
class WatchpointOptionsImpl;
namespace lldb {
class LLDB_API SBWatchpointOptions {
public:
SBWatchpointOptions();
SBWatchpointOptions(const lldb::SBWatchpointOptions &rhs);
~SBWatchpointOptions();
const SBWatchpointOptions &operator=(const lldb::SBWatchpointOptions &rhs);
/// Stop when the watched memory region is read.
void SetWatchpointTypeRead(bool read);
bool GetWatchpointTypeRead() const;
/// Stop when the watched memory region is written to/modified
void SetWatchpointTypeWrite(lldb::WatchpointWriteType write_type);
lldb::WatchpointWriteType GetWatchpointTypeWrite() const;
private:
// This auto_pointer is made in the constructor and is always valid.
mutable std::unique_ptr<WatchpointOptionsImpl> m_opaque_up;
};
} // namespace lldb
#endif // LLDB_API_SBWATCHPOINTOPTIONS_H

View File

@ -76,14 +76,12 @@ public:
bool WatchpointRead() const;
bool WatchpointWrite() const;
bool WatchpointModify() const;
uint32_t GetIgnoreCount() const;
void SetIgnoreCount(uint32_t n);
void SetWatchpointType(uint32_t type, bool notify = true);
void SetDeclInfo(const std::string &str);
std::string GetWatchSpec();
void SetWatchSpec(const std::string &str);
bool WatchedValueReportable(const ExecutionContext &exe_ctx);
// Snapshot management interface.
bool IsWatchVariable() const;
@ -214,8 +212,7 @@ private:
// again, we check the count, if it is more than 1, it means the user-
// supplied actions actually want the watchpoint to be disabled!
uint32_t m_watch_read : 1, // 1 if we stop when the watched data is read from
m_watch_write : 1, // 1 if we stop when the watched data is written to
m_watch_modify : 1; // 1 if we stop when the watched data is changed
m_watch_write : 1; // 1 if we stop when the watched data is written to
uint32_t m_ignore_count; // Number of times to ignore this watchpoint
std::string m_decl_str; // Declaration information, if any.
std::string m_watch_spec_str; // Spec for the watchpoint.

View File

@ -30,15 +30,13 @@ public:
void OptionParsingStarting(ExecutionContext *execution_context) override;
/// eWatchRead == LLDB_WATCH_TYPE_READ
/// eWatchWrite == LLDB_WATCH_TYPE_WRITE
/// eWatchModify == LLDB_WATCH_TYPE_MODIFY
/// eWatchReadWrite == LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE
// Note:
// eWatchRead == LLDB_WATCH_TYPE_READ; and
// eWatchWrite == LLDB_WATCH_TYPE_WRITE
enum WatchType {
eWatchInvalid = 0,
eWatchRead,
eWatchWrite,
eWatchModify,
eWatchReadWrite
};

View File

@ -44,10 +44,8 @@
#define LLDB_WATCH_ID_IS_VALID(uid) ((uid) != (LLDB_INVALID_WATCH_ID))
#define LLDB_WATCH_TYPE_READ (1u << 0)
#define LLDB_WATCH_TYPE_WRITE (1u << 1)
#define LLDB_WATCH_TYPE_MODIFY (1u << 2)
#define LLDB_WATCH_TYPE_IS_VALID(type) \
((type & LLDB_WATCH_TYPE_READ) || (type & LLDB_WATCH_TYPE_WRITE) || \
(type & LLDB_WATCH_TYPE_MODIFY))
((type & LLDB_WATCH_TYPE_READ) || (type & LLDB_WATCH_TYPE_WRITE))
// Generic Register Numbers
#define LLDB_REGNUM_GENERIC_PC 0 // Program Counter

View File

@ -431,21 +431,6 @@ FLAGS_ENUM(WatchpointEventType){
eWatchpointEventTypeThreadChanged = (1u << 11),
eWatchpointEventTypeTypeChanged = (1u << 12)};
enum WatchpointWriteType {
/// Don't stop when the watched memory region is written to.
eWatchpointWriteTypeDisabled,
/// Stop on any write access to the memory region, even if
/// the value doesn't change. On some architectures, a write
/// near the memory region may be falsely reported as a match,
/// and notify this spurious stop as a watchpoint trap.
eWatchpointWriteTypeAlways,
/// Stop on a write to the memory region that changes its value.
/// This is most likely the behavior a user expects, and is the
/// behavior in gdb. lldb can silently ignore writes near the
/// watched memory region that are reported as accesses to lldb.
eWatchpointWriteTypeOnModify
};
/// Programming language type.
///
/// These enumerations use the same language enumerations as the DWARF

View File

@ -284,7 +284,6 @@ class VariableList;
class Watchpoint;
class WatchpointList;
class WatchpointOptions;
class WatchpointSetOptions;
struct CompilerContext;
struct LineEntry;
struct PropertyDefinition;

View File

@ -91,7 +91,6 @@ add_lldb_library(liblldb SHARED ${option_framework}
SBValueList.cpp
SBVariablesOptions.cpp
SBWatchpoint.cpp
SBWatchpointOptions.cpp
SBUnixSignals.cpp
SystemInitializerFull.cpp
${lldb_python_wrapper}

View File

@ -1322,39 +1322,27 @@ SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) {
}
lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
bool read, bool modify,
bool read, bool write,
SBError &error) {
LLDB_INSTRUMENT_VA(this, addr, size, read, write, error);
SBWatchpointOptions options;
options.SetWatchpointTypeRead(read);
options.SetWatchpointTypeWrite(eWatchpointWriteTypeOnModify);
return WatchpointCreateByAddress(addr, size, options, error);
}
lldb::SBWatchpoint
SBTarget::WatchpointCreateByAddress(lldb::addr_t addr, size_t size,
SBWatchpointOptions options,
SBError &error) {
LLDB_INSTRUMENT_VA(this, addr, size, options, error);
SBWatchpoint sb_watchpoint;
lldb::WatchpointSP watchpoint_sp;
TargetSP target_sp(GetSP());
if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
size > 0) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
uint32_t watch_type = 0;
if (options.GetWatchpointTypeRead())
if (read)
watch_type |= LLDB_WATCH_TYPE_READ;
if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeAlways)
if (write)
watch_type |= LLDB_WATCH_TYPE_WRITE;
if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeOnModify)
watch_type |= LLDB_WATCH_TYPE_MODIFY;
if (watch_type == 0) {
error.SetErrorString("Can't create a watchpoint that is neither read nor "
"write nor modify.");
error.SetErrorString(
"Can't create a watchpoint that is neither read nor write.");
return sb_watchpoint;
}
if (target_sp && addr != LLDB_INVALID_ADDRESS && size > 0) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
// Target::CreateWatchpoint() is thread safe.
Status cw_error;
// This API doesn't take in a type, so we can't figure out what it is.

View File

@ -1433,17 +1433,10 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
return sb_watchpoint;
uint32_t watch_type = 0;
if (read) {
if (read)
watch_type |= LLDB_WATCH_TYPE_READ;
// read + write, the most likely intention
// is to catch all writes to this, not just
// value modifications.
if (write)
watch_type |= LLDB_WATCH_TYPE_WRITE;
} else {
if (write)
watch_type |= LLDB_WATCH_TYPE_MODIFY;
}
Status rc;
CompilerType type(value_sp->GetCompilerType());

View File

@ -354,8 +354,7 @@ bool SBWatchpoint::IsWatchingWrites() {
std::lock_guard<std::recursive_mutex> guard(
watchpoint_sp->GetTarget().GetAPIMutex());
return watchpoint_sp->WatchpointWrite() ||
watchpoint_sp->WatchpointModify();
return watchpoint_sp->WatchpointWrite();
}
return false;

View File

@ -1,73 +0,0 @@
//===-- SBWatchpointOptions.cpp -------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBWatchpointOptions.h"
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Utility/Instrumentation.h"
#include "Utils.h"
using namespace lldb;
using namespace lldb_private;
class WatchpointOptionsImpl {
public:
bool m_read = false;
bool m_write = false;
bool m_modify = false;
};
SBWatchpointOptions::SBWatchpointOptions()
: m_opaque_up(new WatchpointOptionsImpl()) {
LLDB_INSTRUMENT_VA(this);
}
SBWatchpointOptions::SBWatchpointOptions(const SBWatchpointOptions &rhs) {
LLDB_INSTRUMENT_VA(this, rhs);
m_opaque_up = clone(rhs.m_opaque_up);
}
const SBWatchpointOptions &
SBWatchpointOptions::operator=(const SBWatchpointOptions &rhs) {
LLDB_INSTRUMENT_VA(this, rhs);
if (this != &rhs)
m_opaque_up = clone(rhs.m_opaque_up);
return *this;
}
SBWatchpointOptions::~SBWatchpointOptions() = default;
void SBWatchpointOptions::SetWatchpointTypeRead(bool read) {
m_opaque_up->m_read = read;
}
bool SBWatchpointOptions::GetWatchpointTypeRead() const {
return m_opaque_up->m_read;
}
void SBWatchpointOptions::SetWatchpointTypeWrite(
WatchpointWriteType write_type) {
if (write_type == eWatchpointWriteTypeOnModify) {
m_opaque_up->m_write = false;
m_opaque_up->m_modify = true;
} else if (write_type == eWatchpointWriteTypeAlways) {
m_opaque_up->m_write = true;
m_opaque_up->m_modify = false;
} else
m_opaque_up->m_write = m_opaque_up->m_modify = false;
}
WatchpointWriteType SBWatchpointOptions::GetWatchpointTypeWrite() const {
if (m_opaque_up->m_modify)
return eWatchpointWriteTypeOnModify;
if (m_opaque_up->m_write)
return eWatchpointWriteTypeAlways;
return eWatchpointWriteTypeDisabled;
}

View File

@ -29,8 +29,7 @@ Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
: StoppointSite(0, addr, size, hardware), m_target(target),
m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
m_watch_write(0), m_watch_modify(0), m_ignore_count(0),
m_being_created(true) {
m_watch_write(0), m_ignore_count(0), m_being_created(true) {
if (type && type->IsValid())
m_type = *type;
@ -194,7 +193,7 @@ bool Watchpoint::IsWatchVariable() const { return m_is_watch_variable; }
void Watchpoint::SetWatchVariable(bool val) { m_is_watch_variable = val; }
bool Watchpoint::CaptureWatchedValue(const ExecutionContext &exe_ctx) {
ConstString g_watch_name("$__lldb__watch_value");
ConstString watch_name("$__lldb__watch_value");
m_old_value_sp = m_new_value_sp;
Address watch_address(GetLoadAddress());
if (!m_type.IsValid()) {
@ -206,47 +205,12 @@ bool Watchpoint::CaptureWatchedValue(const ExecutionContext &exe_ctx) {
return false;
}
m_new_value_sp = ValueObjectMemory::Create(
exe_ctx.GetBestExecutionContextScope(), g_watch_name.GetStringRef(),
exe_ctx.GetBestExecutionContextScope(), watch_name.GetStringRef(),
watch_address, m_type);
m_new_value_sp = m_new_value_sp->CreateConstantValue(g_watch_name);
m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name);
return (m_new_value_sp && m_new_value_sp->GetError().Success());
}
bool Watchpoint::WatchedValueReportable(const ExecutionContext &exe_ctx) {
if (!m_watch_modify || m_watch_read)
return true;
if (!m_type.IsValid())
return true;
ConstString g_watch_name("$__lldb__watch_value");
Address watch_address(GetLoadAddress());
ValueObjectSP newest_valueobj_sp = ValueObjectMemory::Create(
exe_ctx.GetBestExecutionContextScope(), g_watch_name.GetStringRef(),
watch_address, m_type);
newest_valueobj_sp = newest_valueobj_sp->CreateConstantValue(g_watch_name);
Status error;
DataExtractor new_data;
DataExtractor old_data;
newest_valueobj_sp->GetData(new_data, error);
if (error.Fail())
return true;
m_new_value_sp->GetData(old_data, error);
if (error.Fail())
return true;
if (new_data.GetByteSize() != old_data.GetByteSize() ||
new_data.GetByteSize() == 0)
return true;
if (memcmp(new_data.GetDataStart(), old_data.GetDataStart(),
old_data.GetByteSize()) == 0)
return false; // Value has not changed, user requested modify watchpoint
return true;
}
// RETURNS - true if we should stop at this breakpoint, false if we
// should continue.
@ -304,10 +268,10 @@ void Watchpoint::DumpWithLevel(Stream *s,
description_level <= lldb::eDescriptionLevelVerbose);
s->Printf("Watchpoint %u: addr = 0x%8.8" PRIx64
" size = %u state = %s type = %s%s%s",
" size = %u state = %s type = %s%s",
GetID(), GetLoadAddress(), m_byte_size,
IsEnabled() ? "enabled" : "disabled", m_watch_read ? "r" : "",
m_watch_write ? "w" : "", m_watch_modify ? "m" : "");
m_watch_write ? "w" : "");
if (description_level >= lldb::eDescriptionLevelFull) {
if (!m_decl_str.empty())
@ -369,13 +333,10 @@ void Watchpoint::SetEnabled(bool enabled, bool notify) {
void Watchpoint::SetWatchpointType(uint32_t type, bool notify) {
int old_watch_read = m_watch_read;
int old_watch_write = m_watch_write;
int old_watch_modify = m_watch_modify;
m_watch_read = (type & LLDB_WATCH_TYPE_READ) != 0;
m_watch_write = (type & LLDB_WATCH_TYPE_WRITE) != 0;
m_watch_modify = (type & LLDB_WATCH_TYPE_MODIFY) != 0;
if (notify &&
(old_watch_read != m_watch_read || old_watch_write != m_watch_write ||
old_watch_modify != m_watch_modify))
(old_watch_read != m_watch_read || old_watch_write != m_watch_write))
SendWatchpointChangedEvent(eWatchpointEventTypeTypeChanged);
}
@ -383,8 +344,6 @@ bool Watchpoint::WatchpointRead() const { return m_watch_read != 0; }
bool Watchpoint::WatchpointWrite() const { return m_watch_write != 0; }
bool Watchpoint::WatchpointModify() const { return m_watch_modify != 0; }
uint32_t Watchpoint::GetIgnoreCount() const { return m_ignore_count; }
void Watchpoint::SetIgnoreCount(uint32_t n) {

View File

@ -803,7 +803,7 @@ public:
"Set a watchpoint on a variable. "
"Use the '-w' option to specify the type of watchpoint and "
"the '-s' option to specify the byte size to watch for. "
"If no '-w' option is specified, it defaults to modify. "
"If no '-w' option is specified, it defaults to write. "
"If no '-s' option is specified, it defaults to the variable's "
"byte size. "
"Note that there are limited hardware resources for watchpoints. "
@ -878,9 +878,9 @@ protected:
return false;
}
// If no '-w' is specified, default to '-w modify'.
// If no '-w' is specified, default to '-w write'.
if (!m_option_watchpoint.watch_type_specified) {
m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchModify;
m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchWrite;
}
// We passed the sanity check for the command. Proceed to set the
@ -947,23 +947,7 @@ protected:
}
// Now it's time to create the watchpoint.
uint32_t watch_type = 0;
switch (m_option_watchpoint.watch_type) {
case OptionGroupWatchpoint::eWatchModify:
watch_type |= LLDB_WATCH_TYPE_MODIFY;
break;
case OptionGroupWatchpoint::eWatchRead:
watch_type |= LLDB_WATCH_TYPE_READ;
break;
case OptionGroupWatchpoint::eWatchReadWrite:
watch_type |= LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE;
break;
case OptionGroupWatchpoint::eWatchWrite:
watch_type |= LLDB_WATCH_TYPE_WRITE;
break;
case OptionGroupWatchpoint::eWatchInvalid:
break;
};
uint32_t watch_type = m_option_watchpoint.watch_type;
error.Clear();
WatchpointSP watch_sp =
@ -1015,7 +999,7 @@ public:
"Use the '-l' option to specify the language of the expression. "
"Use the '-w' option to specify the type of watchpoint and "
"the '-s' option to specify the byte size to watch for. "
"If no '-w' option is specified, it defaults to modify. "
"If no '-w' option is specified, it defaults to write. "
"If no '-s' option is specified, it defaults to the target's "
"pointer byte size. "
"Note that there are limited hardware resources for watchpoints. "
@ -1029,7 +1013,7 @@ public:
R"(
Examples:
(lldb) watchpoint set expression -w modify -s 1 -- foo + 32
(lldb) watchpoint set expression -w write -s 1 -- foo + 32
Watches write access for the 1-byte region pointed to by the address 'foo + 32')");
@ -1089,7 +1073,7 @@ protected:
// If no '-w' is specified, default to '-w write'.
if (!m_option_watchpoint.watch_type_specified) {
m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchModify;
m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchWrite;
}
// We passed the sanity check for the command. Proceed to set the

View File

@ -27,11 +27,6 @@ static constexpr OptionEnumValueElement g_watch_type[] = {
"write",
"Watch for write",
},
{
OptionGroupWatchpoint::eWatchModify,
"modify",
"Watch for modifications",
},
{
OptionGroupWatchpoint::eWatchReadWrite,
"read_write",

View File

@ -3108,16 +3108,14 @@ static GDBStoppointType GetGDBStoppointType(Watchpoint *wp) {
assert(wp);
bool watch_read = wp->WatchpointRead();
bool watch_write = wp->WatchpointWrite();
bool watch_modify = wp->WatchpointModify();
// watch_read, watch_write, watch_modify cannot all be false.
assert((watch_read || watch_write || watch_modify) &&
"watch_read, watch_write, watch_modify cannot all be false.");
if (watch_read && (watch_write || watch_modify))
// watch_read and watch_write cannot both be false.
assert(watch_read || watch_write);
if (watch_read && watch_write)
return eWatchpointReadWrite;
else if (watch_read)
return eWatchpointRead;
else // Must be watch_write or watch_modify, then.
else // Must be watch_write, then.
return eWatchpointWrite;
}

View File

@ -982,12 +982,6 @@ protected:
m_should_stop = false;
}
}
// Don't stop if the watched region value is unmodified, and
// this is a Modify-type watchpoint.
if (m_should_stop && !wp_sp->WatchedValueReportable(exe_ctx))
m_should_stop = false;
// Finally, if we are going to stop, print out the new & old values:
if (m_should_stop) {
wp_sp->CaptureWatchedValue(exe_ctx);

View File

@ -860,8 +860,7 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
size_t old_size = matched_sp->GetByteSize();
uint32_t old_type =
(matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
(matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0) |
(matched_sp->WatchpointModify() ? LLDB_WATCH_TYPE_MODIFY : 0);
(matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
// Return the existing watchpoint if both size and type match.
if (size == old_size && kind == old_type) {
wp_sp = matched_sp;

View File

@ -1,6 +1,5 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
alignas(16) uint8_t buf[32];
// This uses inline assembly to generate an instruction that writes to a large
// block of memory. If it fails on your compiler/architecture, please add
@ -9,7 +8,6 @@ alignas(16) uint8_t buf[32];
// this test.
int main() {
memset(buf, UINT32_MAX, 8);
#if defined(__i386__) || defined(__x86_64__)
asm volatile ("movdqa %%xmm0, %0" : : "m"(buf));
#elif defined(__arm__)

View File

@ -5,7 +5,7 @@ int main() {
uint8_t buf[8];
uint64_t val;
} a;
a.val = UINT64_MAX; // break here
a.val = 0; // break here
for (int i = 0; i < 5; i++) {
a.val = i;
printf("a.val is %lu\n", a.val);

View File

@ -58,9 +58,7 @@ class TestNoWatchpointSupportInfo(GDBRemoteTestBase):
print(result.GetOutput())
err = lldb.SBError()
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
wp = target.WatchpointCreateByAddress(0x100, 8, wp_opts, err)
wp = target.WatchAddress(0x100, 8, False, True, err)
if self.TraceOn() and (err.Fail() or wp.IsValid == False):
strm = lldb.SBStream()
err.GetDescription(strm)

View File

@ -45,9 +45,7 @@ class UnalignedWatchpointTestCase(TestBase):
# to a 1024 byte boundary to begin with, force alignment.
wa_256_addr = (array_addr + 1024) & ~(1024 - 1)
err = lldb.SBError()
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
wp = target.WatchpointCreateByAddress(wa_256_addr, 1024, wp_opts, err)
wp = target.WatchAddress(wa_256_addr, 1024, False, True, err)
self.assertTrue(wp.IsValid())
self.assertSuccess(err)

View File

@ -1,3 +0,0 @@
C_SOURCES := main.c
include Makefile.rules

View File

@ -1,39 +0,0 @@
"""
Confirm that lldb modify watchpoints only stop
when the value being watched changes.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class ModifyWatchpointTestCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
def test_modify_watchpoint(self):
"""Test that a modify watchpoint only stops when the value changes."""
self.build()
self.main_source_file = lldb.SBFileSpec("main.c")
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
self, "break here", self.main_source_file
)
self.runCmd("watch set variable value")
process.Continue()
frame = process.GetSelectedThread().GetFrameAtIndex(0)
self.assertEqual(frame.locals["value"][0].GetValueAsUnsigned(), 10)
process.Continue()
frame = process.GetSelectedThread().GetFrameAtIndex(0)
self.assertEqual(frame.locals["value"][0].GetValueAsUnsigned(), 5)
process.Continue()
frame = process.GetSelectedThread().GetFrameAtIndex(0)
self.assertEqual(frame.locals["value"][0].GetValueAsUnsigned(), 7)
process.Continue()
frame = process.GetSelectedThread().GetFrameAtIndex(0)
self.assertEqual(frame.locals["value"][0].GetValueAsUnsigned(), 9)

View File

@ -1,20 +0,0 @@
#include <stdint.h>
int main() {
int value = 5;
value = 5; // break here
value = 5;
value = 5;
value = 5;
value = 5;
value = 5;
value = 10;
value = 10;
value = 10;
value = 10;
value = 5;
value = 7;
value = 9;
return value;
}

View File

@ -46,9 +46,7 @@ class UnalignedWatchpointTestCase(TestBase):
a_bytebuf_6 = frame.GetValueForVariablePath("a.bytebuf[6]")
a_bytebuf_6_addr = a_bytebuf_6.GetAddress().GetLoadAddress(target)
err = lldb.SBError()
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
wp = target.WatchpointCreateByAddress(a_bytebuf_6_addr, 4, wp_opts, err)
wp = target.WatchAddress(a_bytebuf_6_addr, 4, False, True, err)
self.assertTrue(err.Success())
self.assertTrue(wp.IsEnabled())
self.assertEqual(wp.GetWatchSize(), 4)

View File

@ -53,10 +53,7 @@ def fuzz_obj(obj):
obj.GetByteOrder()
obj.GetTriple()
error = lldb.SBError()
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeRead(True)
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
obj.WatchpointCreateByAddress(123, 8, wp_opts, error)
obj.WatchAddress(123, 8, True, True, error)
obj.GetBroadcaster()
obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief)
obj.Clear()

View File

@ -1,5 +1,5 @@
"""
Use lldb Python SBtarget.WatchpointCreateByAddress() API to create a watchpoint for write of '*g_char_ptr'.
Use lldb Python SBtarget.WatchAddress() API to create a watchpoint for write of '*g_char_ptr'.
"""
import lldb
@ -8,7 +8,7 @@ from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TargetWatchpointCreateByAddressPITestCase(TestBase):
class TargetWatchAddressAPITestCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
@ -22,7 +22,7 @@ class TargetWatchpointCreateByAddressPITestCase(TestBase):
self.violating_func = "do_bad_thing_with_location"
def test_watch_address(self):
"""Exercise SBTarget.WatchpointCreateByAddress() API to set a watchpoint."""
"""Exercise SBTarget.WatchAddress() API to set a watchpoint."""
self.build()
exe = self.getBuildArtifact("a.out")
@ -51,10 +51,8 @@ class TargetWatchpointCreateByAddressPITestCase(TestBase):
)
# Watch for write to *g_char_ptr.
error = lldb.SBError()
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
watchpoint = target.WatchpointCreateByAddress(
value.GetValueAsUnsigned(), 1, wp_opts, error
watchpoint = target.WatchAddress(
value.GetValueAsUnsigned(), 1, False, True, error
)
self.assertTrue(
value and watchpoint, "Successfully found the pointer and set a watchpoint"
@ -92,7 +90,7 @@ class TargetWatchpointCreateByAddressPITestCase(TestBase):
@skipIf(archs=["mips", "mipsel", "mips64", "mips64el"])
@skipIf(archs=["s390x"]) # Likewise on SystemZ
def test_watch_address_with_invalid_watch_size(self):
"""Exercise SBTarget.WatchpointCreateByAddress() API but pass an invalid watch_size."""
"""Exercise SBTarget.WatchAddress() API but pass an invalid watch_size."""
self.build()
exe = self.getBuildArtifact("a.out")
@ -126,10 +124,8 @@ class TargetWatchpointCreateByAddressPITestCase(TestBase):
if self.getArchitecture() not in ["arm64", "arm64e", "arm64_32"]:
# Watch for write to *g_char_ptr.
error = lldb.SBError()
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
watchpoint = target.WatchpointCreateByAddress(
value.GetValueAsUnsigned(), 365, wp_opts, error
watchpoint = target.WatchAddress(
value.GetValueAsUnsigned(), 365, False, True, error
)
self.assertFalse(watchpoint)
self.expect(