summaryrefslogtreecommitdiffstats
path: root/lldb/source/API
diff options
context:
space:
mode:
authorJoseph Tremoulet <jotrem@microsoft.com>2019-11-22 12:59:46 -0500
committerJoseph Tremoulet <jotrem@microsoft.com>2019-12-04 09:57:15 -0500
commit95b2e516bd3e4587953e44bf062054ff84f2b057 (patch)
tree8a6b3beccc334c879cac7cbda5fc98e2003baecf /lldb/source/API
parent82f6ae5433cac1ba0d02e8df253da3d3b3ce68e1 (diff)
downloadbcm5719-llvm-95b2e516bd3e4587953e44bf062054ff84f2b057.tar.gz
bcm5719-llvm-95b2e516bd3e4587953e44bf062054ff84f2b057.zip
Change Target::FindBreakpointsByName to return Expected<vector>
Summary: Using a BreakpointList corrupts the breakpoints' IDs because BreakpointList::Add sets the ID, so use a vector instead, and update the signature to return the vector wrapped in an llvm::Expected which can propagate any error from the inner call to StringIsBreakpointName. Note that, despite the similar name, SBTarget::FindBreakpointsByName doesn't suffer the same problem, because it uses a SBBreakpointList, which is more like a BreakpointIDList than a BreakpointList under the covers. Add a check to TestBreakpointNames that, without this fix, notices the ID getting mutated and fails. Reviewers: jingham, JDevlieghere Reviewed By: JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70907
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBTarget.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 7013e2b45e5..312e4df7586 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1176,12 +1176,15 @@ bool SBTarget::FindBreakpointsByName(const char *name,
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- BreakpointList bkpt_list(false);
- bool is_valid =
- target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list);
- if (!is_valid)
+ llvm::Expected<std::vector<BreakpointSP>> expected_vector =
+ target_sp->GetBreakpointList().FindBreakpointsByName(name);
+ if (!expected_vector) {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS),
+ "invalid breakpoint name: {}",
+ llvm::toString(expected_vector.takeError()));
return false;
- for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) {
+ }
+ for (BreakpointSP bkpt_sp : *expected_vector) {
bkpts.AppendByID(bkpt_sp->GetID());
}
}
OpenPOWER on IntegriCloud