aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Target/StopInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/lldb/source/Target/StopInfo.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Target/StopInfo.cpp83
1 files changed, 47 insertions, 36 deletions
diff --git a/contrib/llvm-project/lldb/source/Target/StopInfo.cpp b/contrib/llvm-project/lldb/source/Target/StopInfo.cpp
index efc8fd269ac2..3b65d661c1ab 100644
--- a/contrib/llvm-project/lldb/source/Target/StopInfo.cpp
+++ b/contrib/llvm-project/lldb/source/Target/StopInfo.cpp
@@ -12,6 +12,7 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Breakpoint/Watchpoint.h"
+#include "lldb/Breakpoint/WatchpointResource.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/UserExpression.h"
@@ -109,9 +110,9 @@ public:
BreakpointSiteSP bp_site_sp(
thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(m_value));
if (bp_site_sp) {
- uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
- if (num_owners == 1) {
- BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(0);
+ uint32_t num_constituents = bp_site_sp->GetNumberOfConstituents();
+ if (num_constituents == 1) {
+ BreakpointLocationSP bp_loc_sp = bp_site_sp->GetConstituentAtIndex(0);
if (bp_loc_sp) {
Breakpoint & bkpt = bp_loc_sp->GetBreakpoint();
m_break_id = bkpt.GetID();
@@ -120,8 +121,10 @@ public:
}
} else {
m_was_all_internal = true;
- for (uint32_t i = 0; i < num_owners; i++) {
- if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal()) {
+ for (uint32_t i = 0; i < num_constituents; i++) {
+ if (!bp_site_sp->GetConstituentAtIndex(i)
+ ->GetBreakpoint()
+ .IsInternal()) {
m_was_all_internal = false;
break;
}
@@ -189,9 +192,9 @@ public:
// If we have just hit an internal breakpoint, and it has a kind
// description, print that instead of the full breakpoint printing:
if (bp_site_sp->IsInternal()) {
- size_t num_owners = bp_site_sp->GetNumberOfOwners();
- for (size_t idx = 0; idx < num_owners; idx++) {
- const char *kind = bp_site_sp->GetOwnerAtIndex(idx)
+ size_t num_constituents = bp_site_sp->GetNumberOfConstituents();
+ for (size_t idx = 0; idx < num_constituents; idx++) {
+ const char *kind = bp_site_sp->GetConstituentAtIndex(idx)
->GetBreakpoint()
.GetBreakpointKind();
if (kind != nullptr) {
@@ -284,13 +287,14 @@ protected:
// Use this variable to tell us if that is true.
bool actually_hit_any_locations = false;
if (bp_site_sp) {
- // Let's copy the owners list out of the site and store them in a local
- // list. That way if one of the breakpoint actions changes the site,
- // then we won't be operating on a bad list.
+ // Let's copy the constituents list out of the site and store them in a
+ // local list. That way if one of the breakpoint actions changes the
+ // site, then we won't be operating on a bad list.
BreakpointLocationCollection site_locations;
- size_t num_owners = bp_site_sp->CopyOwnersList(site_locations);
+ size_t num_constituents =
+ bp_site_sp->CopyConstituentsList(site_locations);
- if (num_owners == 0) {
+ if (num_constituents == 0) {
m_should_stop = true;
actually_hit_any_locations = true; // We're going to stop, don't
// change the stop info.
@@ -382,20 +386,21 @@ protected:
StoppointCallbackContext context(event_ptr, exe_ctx, false);
// For safety's sake let's also grab an extra reference to the
- // breakpoint owners of the locations we're going to examine, since
- // the locations are going to have to get back to their breakpoints,
- // and the locations don't keep their owners alive. I'm just
- // sticking the BreakpointSP's in a vector since I'm only using it to
- // locally increment their retain counts.
+ // breakpoint constituents of the locations we're going to examine,
+ // since the locations are going to have to get back to their
+ // breakpoints, and the locations don't keep their constituents alive.
+ // I'm just sticking the BreakpointSP's in a vector since I'm only
+ // using it to locally increment their retain counts.
- std::vector<lldb::BreakpointSP> location_owners;
+ std::vector<lldb::BreakpointSP> location_constituents;
- for (size_t j = 0; j < num_owners; j++) {
+ for (size_t j = 0; j < num_constituents; j++) {
BreakpointLocationSP loc(site_locations.GetByIndex(j));
- location_owners.push_back(loc->GetBreakpoint().shared_from_this());
+ location_constituents.push_back(
+ loc->GetBreakpoint().shared_from_this());
}
- for (size_t j = 0; j < num_owners; j++) {
+ for (size_t j = 0; j < num_constituents; j++) {
lldb::BreakpointLocationSP bp_loc_sp = site_locations.GetByIndex(j);
StreamString loc_desc;
if (log) {
@@ -631,7 +636,7 @@ public:
if (process_sp && watchpoint_sp) {
const bool notify = false;
watchpoint_sp->TurnOnEphemeralMode();
- process_sp->DisableWatchpoint(watchpoint_sp.get(), notify);
+ process_sp->DisableWatchpoint(watchpoint_sp, notify);
process_sp->AddPreResumeAction(SentryPreResumeAction, this);
}
}
@@ -642,9 +647,9 @@ public:
watchpoint_sp->TurnOffEphemeralMode();
const bool notify = false;
if (was_disabled) {
- process_sp->DisableWatchpoint(watchpoint_sp.get(), notify);
+ process_sp->DisableWatchpoint(watchpoint_sp, notify);
} else {
- process_sp->EnableWatchpoint(watchpoint_sp.get(), notify);
+ process_sp->EnableWatchpoint(watchpoint_sp, notify);
}
}
}
@@ -699,7 +704,6 @@ protected:
eVoteNoOpinion),
m_stop_info_sp(stop_info_sp), m_watch_sp(watch_sp) {
assert(watch_sp);
- m_watch_index = watch_sp->GetHardwareIndex();
}
bool DoWillResume(lldb::StateType resume_state,
@@ -708,7 +712,7 @@ protected:
return true;
if (!m_did_disable_wp) {
- GetThread().GetProcess()->DisableWatchpoint(m_watch_sp.get(), false);
+ GetThread().GetProcess()->DisableWatchpoint(m_watch_sp, false);
m_did_disable_wp = true;
}
return true;
@@ -752,14 +756,12 @@ protected:
if (!m_did_disable_wp)
return;
m_did_disable_wp = true;
- GetThread().GetProcess()->EnableWatchpoint(m_watch_sp.get(), true);
- m_watch_sp->SetHardwareIndex(m_watch_index);
+ GetThread().GetProcess()->EnableWatchpoint(m_watch_sp, true);
}
private:
StopInfoWatchpointSP m_stop_info_sp;
WatchpointSP m_watch_sp;
- uint32_t m_watch_index = LLDB_INVALID_INDEX32;
bool m_did_disable_wp = false;
};
@@ -982,15 +984,22 @@ 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);
Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
StreamSP output_sp = debugger.GetAsyncOutputStream();
- wp_sp->DumpSnapshots(output_sp.get());
- output_sp->EOL();
- output_sp->Flush();
+ if (wp_sp->DumpSnapshots(output_sp.get())) {
+ output_sp->EOL();
+ output_sp->Flush();
+ }
}
} else {
@@ -1067,9 +1076,9 @@ public:
thread_sp->GetProcess()->GetUnixSignals()->GetShouldNotify(m_value);
if (should_notify) {
StreamString strm;
- strm.Printf(
- "thread %d received signal: %s", thread_sp->GetIndexID(),
- thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsCString(
+ strm.Format(
+ "thread {0:d} received signal: {1}", thread_sp->GetIndexID(),
+ thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsStringRef(
m_value));
Process::ProcessEventData::AddRestartedReason(event_ptr,
strm.GetData());
@@ -1363,6 +1372,8 @@ StopInfoSP StopInfo::CreateStopReasonWithBreakpointSiteID(Thread &thread,
return StopInfoSP(new StopInfoBreakpoint(thread, break_id, should_stop));
}
+// LWP_TODO: We'll need a CreateStopReasonWithWatchpointResourceID akin
+// to CreateStopReasonWithBreakpointSiteID
StopInfoSP StopInfo::CreateStopReasonWithWatchpointID(Thread &thread,
break_id_t watch_id,
bool silently_continue) {