Skip to content

[lldb][NFCI] Change BreakpointIDList::FindBreakpointID to BreakpointIDList::Contains #79517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lldb/include/lldb/Breakpoint/BreakpointID.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class BreakpointID {

virtual ~BreakpointID();

bool operator==(BreakpointID rhs) const {
return m_break_id == rhs.m_break_id && m_location_id == rhs.m_location_id;
}

lldb::break_id_t GetBreakpointID() const { return m_break_id; }

lldb::break_id_t GetLocationID() const { return m_location_id; }
Expand Down
3 changes: 1 addition & 2 deletions lldb/include/lldb/Breakpoint/BreakpointIDList.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class BreakpointIDList {

bool AddBreakpointID(BreakpointID bp_id);

// TODO: This should take a const BreakpointID.
bool FindBreakpointID(BreakpointID &bp_id, size_t *position) const;
bool Contains(BreakpointID bp_id) const;

// Returns a pair consisting of the beginning and end of a breakpoint
// ID range expression. If the input string is not a valid specification,
Expand Down
16 changes: 4 additions & 12 deletions lldb/source/Breakpoint/BreakpointIDList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "lldb/Utility/Args.h"
#include "lldb/Utility/StreamString.h"

#include "llvm/ADT/STLExtras.h"

using namespace lldb;
using namespace lldb_private;

Expand Down Expand Up @@ -48,18 +50,8 @@ bool BreakpointIDList::AddBreakpointID(BreakpointID bp_id) {
// return true.
}

bool BreakpointIDList::FindBreakpointID(BreakpointID &bp_id,
size_t *position) const {
for (size_t i = 0; i < m_breakpoint_ids.size(); ++i) {
BreakpointID tmp_id = m_breakpoint_ids[i];
if (tmp_id.GetBreakpointID() == bp_id.GetBreakpointID() &&
tmp_id.GetLocationID() == bp_id.GetLocationID()) {
*position = i;
return true;
}
}

return false;
bool BreakpointIDList::Contains(BreakpointID bp_id) const {
return llvm::is_contained(m_breakpoint_ids, bp_id);
}

// This function takes OLD_ARGS, which is usually the result of breaking the
Expand Down
5 changes: 2 additions & 3 deletions lldb/source/Commands/CommandObjectBreakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,9 +1485,8 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
for (auto breakpoint_sp : breakpoints.Breakpoints()) {
if (!breakpoint_sp->IsEnabled() && breakpoint_sp->AllowDelete()) {
BreakpointID bp_id(breakpoint_sp->GetID());
size_t pos = 0;
if (!excluded_bp_ids.FindBreakpointID(bp_id, &pos))
valid_bp_ids.AddBreakpointID(breakpoint_sp->GetID());
if (!excluded_bp_ids.Contains(bp_id))
valid_bp_ids.AddBreakpointID(bp_id);
}
}
if (valid_bp_ids.GetSize() == 0) {
Expand Down
4 changes: 1 addition & 3 deletions lldb/source/Commands/CommandObjectProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,7 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
for (size_t loc_idx = 0; loc_idx < num_locations; loc_idx++) {
BreakpointLocationSP loc_sp = bp_sp->GetLocationAtIndex(loc_idx);
tmp_id.SetBreakpointLocationID(loc_idx);
size_t position = 0;
if (!with_locs.FindBreakpointID(tmp_id, &position)
&& loc_sp->IsEnabled()) {
if (!with_locs.Contains(tmp_id) && loc_sp->IsEnabled()) {
locs_disabled.push_back(tmp_id);
loc_sp->SetEnabled(false);
}
Expand Down