Skip to content

Commit 849daa4

Browse files
[lldb][NFC] Move SBThread::ResumeNewPlan out of the header (#151988)
This *private* method is only defined as a member class of SBThread so that it may be declared a `friend` of SBError and access a private constructor of SBError that takes a `Status`, which is an `lldb_private` object. In other words, the method does not use anything about the class is belongs to, so it has no business being a member method. A subsequent patch will need to add a new argument to this class, a `Process::StopLocker`, which is also another `lldb_private` object. This is another strong suggestion that this method does not belong on the header file of a public API, even if at the private visibility level. We can't forward declare nested types like `Process:StopLocker`, so this problem is not easily solvable. This commit moves the method out of the header and into an anon namespace of the cpp file. It is also made to return a Status instead, and the private `SBError` constructor is accessed by the SBThread methods that call it.
1 parent 80bd72b commit 849daa4

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

lldb/include/lldb/API/SBThread.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,6 @@ class LLDB_API SBThread {
251251

252252
void SetThread(const lldb::ThreadSP &lldb_object_sp);
253253

254-
SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx,
255-
lldb_private::ThreadPlan *new_plan);
256-
257254
lldb::ThreadSP GetSP() const;
258255

259256
lldb::ExecutionContextRefSP m_opaque_sp;

lldb/source/API/SBThread.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -495,21 +495,14 @@ bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
495495
return success;
496496
}
497497

498-
SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
499-
ThreadPlan *new_plan) {
500-
SBError sb_error;
501-
498+
static Status ResumeNewPlan(ExecutionContext &exe_ctx, ThreadPlan *new_plan) {
502499
Process *process = exe_ctx.GetProcessPtr();
503-
if (!process) {
504-
sb_error = Status::FromErrorString("No process in SBThread::ResumeNewPlan");
505-
return sb_error;
506-
}
500+
if (!process)
501+
return Status::FromErrorString("No process in SBThread::ResumeNewPlan");
507502

508503
Thread *thread = exe_ctx.GetThreadPtr();
509-
if (!thread) {
510-
sb_error = Status::FromErrorString("No thread in SBThread::ResumeNewPlan");
511-
return sb_error;
512-
}
504+
if (!thread)
505+
return Status::FromErrorString("No thread in SBThread::ResumeNewPlan");
513506

514507
// User level plans should be Controlling Plans so they can be interrupted,
515508
// other plans executed, and then a "continue" will resume the plan.
@@ -522,11 +515,8 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
522515
process->GetThreadList().SetSelectedThreadByID(thread->GetID());
523516

524517
if (process->GetTarget().GetDebugger().GetAsyncExecution())
525-
sb_error.ref() = process->Resume();
526-
else
527-
sb_error.ref() = process->ResumeSynchronous(nullptr);
528-
529-
return sb_error;
518+
return process->Resume();
519+
return process->ResumeSynchronous(nullptr);
530520
}
531521

532522
void SBThread::StepOver(lldb::RunMode stop_other_threads) {

0 commit comments

Comments
 (0)