Skip to content

Commit 1afad2b

Browse files
[lldb][NFC] Move SBThread::ResumeNewPlan out of the header (llvm#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. (cherry picked from commit 849daa4)
1 parent 1739951 commit 1afad2b

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
@@ -255,9 +255,6 @@ class LLDB_API SBThread {
255255

256256
void SetThread(const lldb::ThreadSP &lldb_object_sp);
257257

258-
SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx,
259-
lldb_private::ThreadPlan *new_plan);
260-
261258
lldb::ThreadSP GetSP() const;
262259

263260
lldb::ExecutionContextRefSP m_opaque_sp;

lldb/source/API/SBThread.cpp

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

525-
SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
526-
ThreadPlan *new_plan) {
527-
SBError sb_error;
528-
525+
static Status ResumeNewPlan(ExecutionContext &exe_ctx, ThreadPlan *new_plan) {
529526
Process *process = exe_ctx.GetProcessPtr();
530-
if (!process) {
531-
sb_error = Status::FromErrorString("No process in SBThread::ResumeNewPlan");
532-
return sb_error;
533-
}
527+
if (!process)
528+
return Status::FromErrorString("No process in SBThread::ResumeNewPlan");
534529

535530
Thread *thread = exe_ctx.GetThreadPtr();
536-
if (!thread) {
537-
sb_error = Status::FromErrorString("No thread in SBThread::ResumeNewPlan");
538-
return sb_error;
539-
}
531+
if (!thread)
532+
return Status::FromErrorString("No thread in SBThread::ResumeNewPlan");
540533

541534
// User level plans should be Controlling Plans so they can be interrupted,
542535
// other plans executed, and then a "continue" will resume the plan.
@@ -549,11 +542,8 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
549542
process->GetThreadList().SetSelectedThreadByID(thread->GetID());
550543

551544
if (process->GetTarget().GetDebugger().GetAsyncExecution())
552-
sb_error.ref() = process->Resume();
553-
else
554-
sb_error.ref() = process->ResumeSynchronous(nullptr);
555-
556-
return sb_error;
545+
return process->Resume();
546+
return process->ResumeSynchronous(nullptr);
557547
}
558548

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

0 commit comments

Comments
 (0)