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 3692267ca8.
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

@@ -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());
uint32_t watch_type = 0;
if (options.GetWatchpointTypeRead())
watch_type |= LLDB_WATCH_TYPE_READ;
if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeAlways)
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.");
return sb_watchpoint;
}
if (target_sp && addr != LLDB_INVALID_ADDRESS && size > 0) {
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 (read)
watch_type |= LLDB_WATCH_TYPE_READ;
if (write)
watch_type |= LLDB_WATCH_TYPE_WRITE;
if (watch_type == 0) {
error.SetErrorString(
"Can't create a watchpoint that is neither read nor write.");
return sb_watchpoint;
}
// 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;
}
if (write)
watch_type |= LLDB_WATCH_TYPE_WRITE;
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;
}