Skip to content

Commit

Permalink
Revert "[lldb] Add 'modify' type watchpoints, make it default (#66308)"
Browse files Browse the repository at this point in the history
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 3692267.
  • Loading branch information
jasonmolenda committed Sep 19, 2023
1 parent af935cf commit 44532a9
Show file tree
Hide file tree
Showing 31 changed files with 57 additions and 386 deletions.
1 change: 0 additions & 1 deletion lldb/bindings/headers.swig
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,4 @@
#include "lldb/API/SBValueList.h"
#include "lldb/API/SBVariablesOptions.h"
#include "lldb/API/SBWatchpoint.h"
#include "lldb/API/SBWatchpointOptions.h"
%}
12 changes: 0 additions & 12 deletions lldb/bindings/interface/SBWatchpointOptionsDocstrings.i

This file was deleted.

2 changes: 0 additions & 2 deletions lldb/bindings/interfaces.swig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 1 addition & 7 deletions lldb/include/lldb/API/SBTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -829,13 +828,8 @@ class LLDB_API SBTarget {

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();

Expand Down
43 changes: 0 additions & 43 deletions lldb/include/lldb/API/SBWatchpointOptions.h

This file was deleted.

5 changes: 1 addition & 4 deletions lldb/include/lldb/Breakpoint/Watchpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ class Watchpoint : public std::enable_shared_from_this<Watchpoint>,

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;
Expand Down Expand Up @@ -214,8 +212,7 @@ class Watchpoint : public std::enable_shared_from_this<Watchpoint>,
// 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.
Expand Down
8 changes: 3 additions & 5 deletions lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ class OptionGroupWatchpoint : public OptionGroup {

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
};

Expand Down
4 changes: 1 addition & 3 deletions lldb/include/lldb/lldb-defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions lldb/include/lldb/lldb-enumerations.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/lldb-forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ class VariableList;
class Watchpoint;
class WatchpointList;
class WatchpointOptions;
class WatchpointSetOptions;
struct CompilerContext;
struct LineEntry;
struct PropertyDefinition;
Expand Down
1 change: 0 additions & 1 deletion lldb/source/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
40 changes: 14 additions & 26 deletions lldb/source/API/SBTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 3 additions & 10 deletions lldb/source/API/SBValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 1 addition & 2 deletions lldb/source/API/SBWatchpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
73 changes: 0 additions & 73 deletions lldb/source/API/SBWatchpointOptions.cpp

This file was deleted.

Loading

0 comments on commit 44532a9

Please sign in to comment.