[lldb] Use ArrayRef instead of pointer+size (NFC) (#189186)

While here:
* Move the constructor to the public section. Almost all ThreadPlan
classes have public constructors.
* Use `std::make_shared()`. It is modern and more efficient.
This commit is contained in:
Sergei Barannikov 2026-03-30 19:27:51 +03:00 committed by GitHub
parent 55c149c076
commit acb3d81a93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 18 additions and 25 deletions

View File

@ -1005,7 +1005,7 @@ public:
bool stop_other_threads, Status &status);
virtual lldb::ThreadPlanSP QueueThreadPlanForStepUntil(
bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses,
bool abort_other_plans, llvm::ArrayRef<lldb::addr_t> address_list,
bool stop_others, uint32_t frame_idx, Status &status);
virtual lldb::ThreadPlanSP

View File

@ -16,6 +16,9 @@ namespace lldb_private {
class ThreadPlanStepUntil : public ThreadPlan {
public:
ThreadPlanStepUntil(Thread &thread, llvm::ArrayRef<lldb::addr_t> address_list,
bool stop_others, uint32_t frame_idx = 0);
~ThreadPlanStepUntil() override;
void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
@ -30,10 +33,6 @@ protected:
bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
bool DoPlanExplainsStop(Event *event_ptr) override;
ThreadPlanStepUntil(Thread &thread, lldb::addr_t *address_list,
size_t num_addresses, bool stop_others,
uint32_t frame_idx = 0);
void AnalyzeStop();
private:
@ -52,10 +51,6 @@ private:
void Clear();
friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepUntil(
bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses,
bool stop_others, uint32_t frame_idx, Status &status);
// Need an appropriate marker for the current stack so we can tell step out
// from step in.

View File

@ -846,10 +846,9 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
"step until target not in current function");
} else {
Status new_plan_status;
ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
abort_other_plans, &step_over_until_addrs[0],
step_over_until_addrs.size(), stop_other_threads,
frame_sp->GetFrameIndex(), new_plan_status));
ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepUntil(
abort_other_plans, step_over_until_addrs, stop_other_threads,
frame_sp->GetFrameIndex(), new_plan_status);
if (new_plan_status.Success())
sb_error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());

View File

@ -1025,8 +1025,8 @@ protected:
}
new_plan_sp = thread->QueueThreadPlanForStepUntil(
abort_other_plans, &address_list.front(), address_list.size(),
m_options.m_stop_others, m_options.m_frame_idx, new_plan_status);
abort_other_plans, address_list, m_options.m_stop_others,
m_options.m_frame_idx, new_plan_status);
if (new_plan_sp) {
// User level plans should be controlling plans so they can be
// interrupted

View File

@ -1415,10 +1415,10 @@ ThreadPlanSP Thread::QueueThreadPlanForRunToAddress(bool abort_other_plans,
}
ThreadPlanSP Thread::QueueThreadPlanForStepUntil(
bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses,
bool abort_other_plans, llvm::ArrayRef<addr_t> address_list,
bool stop_other_threads, uint32_t frame_idx, Status &status) {
ThreadPlanSP thread_plan_sp(new ThreadPlanStepUntil(
*this, address_list, num_addresses, stop_other_threads, frame_idx));
ThreadPlanSP thread_plan_sp = std::make_shared<ThreadPlanStepUntil>(
*this, address_list, stop_other_threads, frame_idx);
status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
return thread_plan_sp;

View File

@ -24,9 +24,8 @@ using namespace lldb_private;
// the current frame
ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
lldb::addr_t *address_list,
size_t num_addresses, bool stop_others,
uint32_t frame_idx)
llvm::ArrayRef<addr_t> address_list,
bool stop_others, uint32_t frame_idx)
: ThreadPlan(ThreadPlan::eKindStepUntil, "Step until", thread,
eVoteNoOpinion, eVoteNoOpinion),
m_step_from_insn(LLDB_INVALID_ADDRESS),
@ -63,15 +62,15 @@ ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
m_stack_id = frame_sp->GetStackID();
// Now set breakpoints on all our return addresses:
for (size_t i = 0; i < num_addresses; i++) {
for (addr_t address : address_list) {
Breakpoint *until_bp =
target_sp->CreateBreakpoint(address_list[i], true, false).get();
target_sp->CreateBreakpoint(address, true, false).get();
if (until_bp != nullptr) {
until_bp->SetThreadID(m_tid);
m_until_points[address_list[i]] = until_bp->GetID();
m_until_points[address] = until_bp->GetID();
until_bp->SetBreakpointKind("until-target");
} else {
m_until_points[address_list[i]] = LLDB_INVALID_BREAK_ID;
m_until_points[address] = LLDB_INVALID_BREAK_ID;
}
}
}