31 changes: 12 additions & 19 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,18 +892,6 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
if (ABISP abi = m_process_sp->GetABI())
addr = abi->FixDataAddress(addr);

// LWP_TODO this sequence is looking for an existing watchpoint
// at the exact same user-specified address, disables the new one
// if addr/size/type match. If type/size differ, disable old one.
// This isn't correct, we need both watchpoints to use a shared
// WatchpointResource in the target, and expand the WatchpointResource
// to handle the needs of both Watchpoints.
// Also, even if the addresses don't match, they may need to be
// supported by the same WatchpointResource, e.g. a watchpoint
// watching 1 byte at 0x102 and a watchpoint watching 1 byte at 0x103.
// They're in the same word and must be watched by a single hardware
// watchpoint register.

std::unique_lock<std::recursive_mutex> lock;
this->GetWatchpointList().GetListMutex(lock);
WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr);
Expand All @@ -919,7 +907,7 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
wp_sp->SetEnabled(false, notify);
} else {
// Nil the matched watchpoint; we will be creating a new one.
m_process_sp->DisableWatchpoint(matched_sp, notify);
m_process_sp->DisableWatchpoint(matched_sp.get(), notify);
m_watchpoint_list.Remove(matched_sp->GetID(), true);
}
}
Expand All @@ -930,7 +918,7 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
m_watchpoint_list.Add(wp_sp, true);
}

error = m_process_sp->EnableWatchpoint(wp_sp, notify);
error = m_process_sp->EnableWatchpoint(wp_sp.get(), notify);
LLDB_LOGF(log, "Target::%s (creation of watchpoint %s with id = %u)\n",
__FUNCTION__, error.Success() ? "succeeded" : "failed",
wp_sp->GetID());
Expand All @@ -939,6 +927,11 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
// Enabling the watchpoint on the device side failed. Remove the said
// watchpoint from the list maintained by the target instance.
m_watchpoint_list.Remove(wp_sp->GetID(), true);
// See if we could provide more helpful error message.
if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
error.SetErrorStringWithFormat(
"watch size of %" PRIu64 " is not supported", (uint64_t)size);

wp_sp.reset();
} else
m_last_created_watchpoint = wp_sp;
Expand Down Expand Up @@ -1238,7 +1231,7 @@ bool Target::RemoveAllWatchpoints(bool end_to_end) {
if (!wp_sp)
return false;

Status rc = m_process_sp->DisableWatchpoint(wp_sp);
Status rc = m_process_sp->DisableWatchpoint(wp_sp.get());
if (rc.Fail())
return false;
}
Expand Down Expand Up @@ -1267,7 +1260,7 @@ bool Target::DisableAllWatchpoints(bool end_to_end) {
if (!wp_sp)
return false;

Status rc = m_process_sp->DisableWatchpoint(wp_sp);
Status rc = m_process_sp->DisableWatchpoint(wp_sp.get());
if (rc.Fail())
return false;
}
Expand All @@ -1294,7 +1287,7 @@ bool Target::EnableAllWatchpoints(bool end_to_end) {
if (!wp_sp)
return false;

Status rc = m_process_sp->EnableWatchpoint(wp_sp);
Status rc = m_process_sp->EnableWatchpoint(wp_sp.get());
if (rc.Fail())
return false;
}
Expand Down Expand Up @@ -1357,7 +1350,7 @@ bool Target::DisableWatchpointByID(lldb::watch_id_t watch_id) {

WatchpointSP wp_sp = m_watchpoint_list.FindByID(watch_id);
if (wp_sp) {
Status rc = m_process_sp->DisableWatchpoint(wp_sp);
Status rc = m_process_sp->DisableWatchpoint(wp_sp.get());
if (rc.Success())
return true;

Expand All @@ -1376,7 +1369,7 @@ bool Target::EnableWatchpointByID(lldb::watch_id_t watch_id) {

WatchpointSP wp_sp = m_watchpoint_list.FindByID(watch_id);
if (wp_sp) {
Status rc = m_process_sp->EnableWatchpoint(wp_sp);
Status rc = m_process_sp->EnableWatchpoint(wp_sp.get());
if (rc.Success())
return true;

Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Target/ThreadPlanCallFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) {
BreakpointSiteSP bp_site_sp;
bp_site_sp = m_process.GetBreakpointSiteList().FindByID(break_site_id);
if (bp_site_sp) {
uint32_t num_owners = bp_site_sp->GetNumberOfConstituents();
uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
bool is_internal = true;
for (uint32_t i = 0; i < num_owners; i++) {
Breakpoint &bp = bp_site_sp->GetConstituentAtIndex(i)->GetBreakpoint();
Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
LLDB_LOGF(log,
"ThreadPlanCallFunction::PlanExplainsStop: hit "
"breakpoint %d while calling function",
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Target/ThreadPlanStepOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ bool ThreadPlanStepOut::DoPlanExplainsStop(Event *event_ptr) {
// important to report the user breakpoint than the step out
// completion.

if (site_sp->GetNumberOfConstituents() == 1)
if (site_sp->GetNumberOfOwners() == 1)
return true;
}
return false;
Expand Down
14 changes: 7 additions & 7 deletions lldb/source/Target/ThreadPlanStepRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,23 +400,23 @@ bool ThreadPlanStepRange::NextRangeBreakpointExplainsStop(
return false;
else {
// If we've hit the next branch breakpoint, then clear it.
size_t num_constituents = bp_site_sp->GetNumberOfConstituents();
size_t num_owners = bp_site_sp->GetNumberOfOwners();
bool explains_stop = true;
// If all the constituents are internal, then we are probably just stepping
// over this range from multiple threads, or multiple frames, so we want to
// If all the owners are internal, then we are probably just stepping over
// this range from multiple threads, or multiple frames, so we want to
// continue. If one is not internal, then we should not explain the stop,
// and let the user breakpoint handle the stop.
for (size_t i = 0; i < num_constituents; i++) {
if (!bp_site_sp->GetConstituentAtIndex(i)->GetBreakpoint().IsInternal()) {
for (size_t i = 0; i < num_owners; i++) {
if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal()) {
explains_stop = false;
break;
}
}
LLDB_LOGF(log,
"ThreadPlanStepRange::NextRangeBreakpointExplainsStop - Hit "
"next range breakpoint which has %" PRIu64
" constituents - explains stop: %u.",
(uint64_t)num_constituents, explains_stop);
" owners - explains stop: %u.",
(uint64_t)num_owners, explains_stop);
ClearNextBranchBreakpoint();
return explains_stop;
}
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Target/ThreadPlanStepUntil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void ThreadPlanStepUntil::AnalyzeStop() {
} else
m_should_stop = false;

if (this_site->GetNumberOfConstituents() == 1)
if (this_site->GetNumberOfOwners() == 1)
m_explains_stop = true;
else
m_explains_stop = false;
Expand Down Expand Up @@ -228,7 +228,7 @@ void ThreadPlanStepUntil::AnalyzeStop() {
// only breakpoint here, then we do explain the stop, and we'll
// continue. If not then we should let higher plans handle this
// stop.
if (this_site->GetNumberOfConstituents() == 1)
if (this_site->GetNumberOfOwners() == 1)
m_explains_stop = true;
else {
m_should_stop = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,5 @@ def test_watch_address_with_invalid_watch_size(self):
self.expect(
error.GetCString(),
exe=False,
substrs=["Setting one of the watchpoint resources failed"],
substrs=["watch size of %d is not supported" % 365],
)
3 changes: 0 additions & 3 deletions lldb/test/Shell/Watchpoint/Inputs/val.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
int main() {
int val = 0;
// Break here
val = 5;
val = 10;
val = 1;
val++;
val++;
return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# REQUIRES: system-darwin
# TODO: This test is breaking with my output
# reformatting done for Large Watchpoint support,
# but the lines being output by lldb are identical,
# by visual inspection.
# FileCheck is seeing some difference between them,
# which I need to get to the bottom of.
# UNSUPPORTED: system-darwin
# RUN: %clang_host -x c %S/Inputs/val.c -g -o %t
# RUN: %lldb -b -s %S/Inputs/watchpoint.in %t 2>&1 | FileCheck %S/Inputs/watchpoint.in
2 changes: 1 addition & 1 deletion lldb/test/Shell/Watchpoint/SetErrorCases.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ watchpoint set expression MyAggregateDataType
# CHECK: error: expression did not evaluate to an address

watchpoint set variable -s -128
# CHECK: error: invalid --size option value
# CHECK: error: invalid enumeration value