diff options
| author | Joseph Tremoulet <jotrem@microsoft.com> | 2019-11-22 12:59:46 -0500 |
|---|---|---|
| committer | Joseph Tremoulet <jotrem@microsoft.com> | 2019-12-04 09:57:15 -0500 |
| commit | 95b2e516bd3e4587953e44bf062054ff84f2b057 (patch) | |
| tree | 8a6b3beccc334c879cac7cbda5fc98e2003baecf /lldb/source/Breakpoint/BreakpointList.cpp | |
| parent | 82f6ae5433cac1ba0d02e8df253da3d3b3ce68e1 (diff) | |
| download | bcm5719-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/Breakpoint/BreakpointList.cpp')
| -rw-r--r-- | lldb/source/Breakpoint/BreakpointList.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lldb/source/Breakpoint/BreakpointList.cpp b/lldb/source/Breakpoint/BreakpointList.cpp index c80fb917b49..5b23c633d14 100644 --- a/lldb/source/Breakpoint/BreakpointList.cpp +++ b/lldb/source/Breakpoint/BreakpointList.cpp @@ -10,6 +10,8 @@ #include "lldb/Target/Target.h" +#include "llvm/Support/Errc.h" + using namespace lldb; using namespace lldb_private; @@ -128,22 +130,24 @@ BreakpointSP BreakpointList::FindBreakpointByID(break_id_t break_id) const { return {}; } -bool BreakpointList::FindBreakpointsByName(const char *name, - BreakpointList &matching_bps) { - Status error; +llvm::Expected<std::vector<lldb::BreakpointSP>> +BreakpointList::FindBreakpointsByName(const char *name) { if (!name) - return false; + return llvm::createStringError(llvm::errc::invalid_argument, + "FindBreakpointsByName requires a name"); + Status error; if (!BreakpointID::StringIsBreakpointName(llvm::StringRef(name), error)) - return false; + return error.ToError(); + std::vector<lldb::BreakpointSP> matching_bps; for (BreakpointSP bkpt_sp : Breakpoints()) { if (bkpt_sp->MatchesName(name)) { - matching_bps.Add(bkpt_sp, false); + matching_bps.push_back(bkpt_sp); } } - return true; + return matching_bps; } void BreakpointList::Dump(Stream *s) const { |

