Skip to content

Commit

Permalink
[lldb] Use Target references instead of pointers in CommandObject (NFC)
Browse files Browse the repository at this point in the history
The GetTarget helper returns a Target reference so there's reason to
convert it to a pointer and check its validity.
  • Loading branch information
JDevlieghere committed Aug 1, 2024
1 parent 1c5f6cf commit 5dbbc3b
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 167 deletions.
8 changes: 4 additions & 4 deletions lldb/source/Commands/CommandObjectBreakpointCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ class CommandObjectBreakpointCommandList : public CommandObjectParsed {

protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
Target *target = &GetTarget();
Target &target = GetTarget();

const BreakpointList &breakpoints = target->GetBreakpointList();
const BreakpointList &breakpoints = target.GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();

if (num_breakpoints == 0) {
Expand All @@ -566,7 +566,7 @@ class CommandObjectBreakpointCommandList : public CommandObjectParsed {

BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
command, target, result, &valid_bp_ids,
command, &target, result, &valid_bp_ids,
BreakpointName::Permissions::PermissionKinds::listPerm);

if (result.Succeeded()) {
Expand All @@ -575,7 +575,7 @@ class CommandObjectBreakpointCommandList : public CommandObjectParsed {
BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
Breakpoint *bp =
target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();

if (bp) {
BreakpointLocationSP bp_loc_sp;
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Commands/CommandObjectDisassemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,10 @@ CommandObjectDisassemble::GetRangesForSelectedMode(

void CommandObjectDisassemble::DoExecute(Args &command,
CommandReturnObject &result) {
Target *target = &GetTarget();
Target &target = GetTarget();

if (!m_options.arch.IsValid())
m_options.arch = target->GetArchitecture();
m_options.arch = target.GetArchitecture();

if (!m_options.arch.IsValid()) {
result.AppendError(
Expand Down Expand Up @@ -535,7 +535,7 @@ void CommandObjectDisassemble::DoExecute(Args &command,
} else {
result.AppendErrorWithFormat(
"Failed to disassemble memory at 0x%8.8" PRIx64 ".\n",
cur_range.GetBaseAddress().GetLoadAddress(target));
cur_range.GetBaseAddress().GetLoadAddress(&target));
}
}
if (print_sc_header)
Expand Down
Loading

0 comments on commit 5dbbc3b

Please sign in to comment.