1 //===-- SBThread.cpp --------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBThread.h"
10 #include "SBReproducerPrivate.h"
12 #include "lldb/API/SBAddress.h"
13 #include "lldb/API/SBDebugger.h"
14 #include "lldb/API/SBEvent.h"
15 #include "lldb/API/SBFileSpec.h"
16 #include "lldb/API/SBFrame.h"
17 #include "lldb/API/SBProcess.h"
18 #include "lldb/API/SBStream.h"
19 #include "lldb/API/SBSymbolContext.h"
20 #include "lldb/API/SBThreadCollection.h"
21 #include "lldb/API/SBThreadPlan.h"
22 #include "lldb/API/SBValue.h"
23 #include "lldb/Breakpoint/BreakpointLocation.h"
24 #include "lldb/Core/Debugger.h"
25 #include "lldb/Core/StreamFile.h"
26 #include "lldb/Core/ValueObject.h"
27 #include "lldb/Interpreter/CommandInterpreter.h"
28 #include "lldb/Symbol/CompileUnit.h"
29 #include "lldb/Symbol/SymbolContext.h"
30 #include "lldb/Target/Process.h"
31 #include "lldb/Target/Queue.h"
32 #include "lldb/Target/StopInfo.h"
33 #include "lldb/Target/SystemRuntime.h"
34 #include "lldb/Target/Target.h"
35 #include "lldb/Target/Thread.h"
36 #include "lldb/Target/ThreadPlan.h"
37 #include "lldb/Target/ThreadPlanStepInRange.h"
38 #include "lldb/Target/ThreadPlanStepInstruction.h"
39 #include "lldb/Target/ThreadPlanStepOut.h"
40 #include "lldb/Target/ThreadPlanStepRange.h"
41 #include "lldb/Target/UnixSignals.h"
42 #include "lldb/Utility/State.h"
43 #include "lldb/Utility/Stream.h"
44 #include "lldb/Utility/StructuredData.h"
45 #include "lldb/lldb-enumerations.h"
50 using namespace lldb_private;
52 const char *SBThread::GetBroadcasterClassName() {
53 LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBThread,
54 GetBroadcasterClassName);
56 return Thread::GetStaticBroadcasterClass().AsCString();
60 SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) {
61 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThread);
64 SBThread::SBThread(const ThreadSP &lldb_object_sp)
65 : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
66 LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &), lldb_object_sp);
69 SBThread::SBThread(const SBThread &rhs) : m_opaque_sp() {
70 LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::SBThread &), rhs);
72 m_opaque_sp = clone(rhs.m_opaque_sp);
75 // Assignment operator
77 const lldb::SBThread &SBThread::operator=(const SBThread &rhs) {
78 LLDB_RECORD_METHOD(const lldb::SBThread &,
79 SBThread, operator=,(const lldb::SBThread &), rhs);
82 m_opaque_sp = clone(rhs.m_opaque_sp);
83 return LLDB_RECORD_RESULT(*this);
87 SBThread::~SBThread() {}
89 lldb::SBQueue SBThread::GetQueue() const {
90 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBQueue, SBThread, GetQueue);
94 std::unique_lock<std::recursive_mutex> lock;
95 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
97 if (exe_ctx.HasThreadScope()) {
98 Process::StopLocker stop_locker;
99 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
100 queue_sp = exe_ctx.GetThreadPtr()->GetQueue();
102 sb_queue.SetQueue(queue_sp);
107 return LLDB_RECORD_RESULT(sb_queue);
110 bool SBThread::IsValid() const {
111 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, IsValid);
112 return this->operator bool();
114 SBThread::operator bool() const {
115 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, operator bool);
117 std::unique_lock<std::recursive_mutex> lock;
118 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
120 Target *target = exe_ctx.GetTargetPtr();
121 Process *process = exe_ctx.GetProcessPtr();
122 if (target && process) {
123 Process::StopLocker stop_locker;
124 if (stop_locker.TryLock(&process->GetRunLock()))
125 return m_opaque_sp->GetThreadSP().get() != nullptr;
127 // Without a valid target & process, this thread can't be valid.
131 void SBThread::Clear() {
132 LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, Clear);
134 m_opaque_sp->Clear();
137 StopReason SBThread::GetStopReason() {
138 LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThread, GetStopReason);
140 StopReason reason = eStopReasonInvalid;
141 std::unique_lock<std::recursive_mutex> lock;
142 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
144 if (exe_ctx.HasThreadScope()) {
145 Process::StopLocker stop_locker;
146 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
147 return exe_ctx.GetThreadPtr()->GetStopReason();
154 size_t SBThread::GetStopReasonDataCount() {
155 LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThread, GetStopReasonDataCount);
157 std::unique_lock<std::recursive_mutex> lock;
158 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
160 if (exe_ctx.HasThreadScope()) {
161 Process::StopLocker stop_locker;
162 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
163 StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
165 StopReason reason = stop_info_sp->GetStopReason();
167 case eStopReasonInvalid:
168 case eStopReasonNone:
169 case eStopReasonTrace:
170 case eStopReasonExec:
171 case eStopReasonPlanComplete:
172 case eStopReasonThreadExiting:
173 case eStopReasonInstrumentation:
174 // There is no data for these stop reasons.
177 case eStopReasonBreakpoint: {
178 break_id_t site_id = stop_info_sp->GetValue();
179 lldb::BreakpointSiteSP bp_site_sp(
180 exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID(
183 return bp_site_sp->GetNumberOfOwners() * 2;
185 return 0; // Breakpoint must have cleared itself...
188 case eStopReasonWatchpoint:
191 case eStopReasonSignal:
194 case eStopReasonException:
203 uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) {
204 LLDB_RECORD_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex, (uint32_t),
207 std::unique_lock<std::recursive_mutex> lock;
208 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
210 if (exe_ctx.HasThreadScope()) {
211 Process::StopLocker stop_locker;
212 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
213 Thread *thread = exe_ctx.GetThreadPtr();
214 StopInfoSP stop_info_sp = thread->GetStopInfo();
216 StopReason reason = stop_info_sp->GetStopReason();
218 case eStopReasonInvalid:
219 case eStopReasonNone:
220 case eStopReasonTrace:
221 case eStopReasonExec:
222 case eStopReasonPlanComplete:
223 case eStopReasonThreadExiting:
224 case eStopReasonInstrumentation:
225 // There is no data for these stop reasons.
228 case eStopReasonBreakpoint: {
229 break_id_t site_id = stop_info_sp->GetValue();
230 lldb::BreakpointSiteSP bp_site_sp(
231 exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID(
234 uint32_t bp_index = idx / 2;
235 BreakpointLocationSP bp_loc_sp(
236 bp_site_sp->GetOwnerAtIndex(bp_index));
239 // Odd idx, return the breakpoint location ID
240 return bp_loc_sp->GetID();
242 // Even idx, return the breakpoint ID
243 return bp_loc_sp->GetBreakpoint().GetID();
247 return LLDB_INVALID_BREAK_ID;
250 case eStopReasonWatchpoint:
251 return stop_info_sp->GetValue();
253 case eStopReasonSignal:
254 return stop_info_sp->GetValue();
256 case eStopReasonException:
257 return stop_info_sp->GetValue();
265 bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) {
266 LLDB_RECORD_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON,
267 (lldb::SBStream &), stream);
269 Stream &strm = stream.ref();
271 std::unique_lock<std::recursive_mutex> lock;
272 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
274 if (!exe_ctx.HasThreadScope())
277 StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
278 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
288 SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
289 LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBThread,
290 GetStopReasonExtendedBacktraces,
291 (lldb::InstrumentationRuntimeType), type);
293 ThreadCollectionSP threads;
294 threads = std::make_shared<ThreadCollection>();
296 std::unique_lock<std::recursive_mutex> lock;
297 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
299 if (!exe_ctx.HasThreadScope())
300 return LLDB_RECORD_RESULT(threads);
302 ProcessSP process_sp = exe_ctx.GetProcessSP();
304 StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
305 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
307 return LLDB_RECORD_RESULT(threads);
309 return LLDB_RECORD_RESULT(process_sp->GetInstrumentationRuntime(type)
310 ->GetBacktracesFromExtendedStopInfo(info));
313 size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
314 LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t),
317 std::unique_lock<std::recursive_mutex> lock;
318 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
320 if (exe_ctx.HasThreadScope()) {
321 Process::StopLocker stop_locker;
322 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
324 StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
326 const char *stop_desc = stop_info_sp->GetDescription();
329 return ::snprintf(dst, dst_len, "%s", stop_desc);
331 // NULL dst passed in, return the length needed to contain the
333 return ::strlen(stop_desc) + 1; // Include the NULL byte for size
336 size_t stop_desc_len = 0;
337 switch (stop_info_sp->GetStopReason()) {
338 case eStopReasonTrace:
339 case eStopReasonPlanComplete: {
340 static char trace_desc[] = "step";
341 stop_desc = trace_desc;
343 sizeof(trace_desc); // Include the NULL byte for size
346 case eStopReasonBreakpoint: {
347 static char bp_desc[] = "breakpoint hit";
349 stop_desc_len = sizeof(bp_desc); // Include the NULL byte for size
352 case eStopReasonWatchpoint: {
353 static char wp_desc[] = "watchpoint hit";
355 stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size
358 case eStopReasonSignal: {
360 exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
361 stop_info_sp->GetValue());
362 if (stop_desc == nullptr || stop_desc[0] == '\0') {
363 static char signal_desc[] = "signal";
364 stop_desc = signal_desc;
366 sizeof(signal_desc); // Include the NULL byte for size
370 case eStopReasonException: {
371 char exc_desc[] = "exception";
372 stop_desc = exc_desc;
373 stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
376 case eStopReasonExec: {
377 char exc_desc[] = "exec";
378 stop_desc = exc_desc;
379 stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
382 case eStopReasonThreadExiting: {
383 char limbo_desc[] = "thread exiting";
384 stop_desc = limbo_desc;
385 stop_desc_len = sizeof(limbo_desc);
391 if (stop_desc && stop_desc[0]) {
393 return ::snprintf(dst, dst_len, "%s", stop_desc) +
394 1; // Include the NULL byte
396 if (stop_desc_len == 0)
397 stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte
399 return stop_desc_len;
410 SBValue SBThread::GetStopReturnValue() {
411 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetStopReturnValue);
413 ValueObjectSP return_valobj_sp;
414 std::unique_lock<std::recursive_mutex> lock;
415 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
417 if (exe_ctx.HasThreadScope()) {
418 Process::StopLocker stop_locker;
419 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
420 StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
422 return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
427 return LLDB_RECORD_RESULT(SBValue(return_valobj_sp));
430 void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
431 m_opaque_sp->SetThreadSP(lldb_object_sp);
434 lldb::tid_t SBThread::GetThreadID() const {
435 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::tid_t, SBThread, GetThreadID);
437 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
439 return thread_sp->GetID();
440 return LLDB_INVALID_THREAD_ID;
443 uint32_t SBThread::GetIndexID() const {
444 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBThread, GetIndexID);
446 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
448 return thread_sp->GetIndexID();
449 return LLDB_INVALID_INDEX32;
452 const char *SBThread::GetName() const {
453 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetName);
455 const char *name = nullptr;
456 std::unique_lock<std::recursive_mutex> lock;
457 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
459 if (exe_ctx.HasThreadScope()) {
460 Process::StopLocker stop_locker;
461 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
462 name = exe_ctx.GetThreadPtr()->GetName();
469 const char *SBThread::GetQueueName() const {
470 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetQueueName);
472 const char *name = nullptr;
473 std::unique_lock<std::recursive_mutex> lock;
474 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
476 if (exe_ctx.HasThreadScope()) {
477 Process::StopLocker stop_locker;
478 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
479 name = exe_ctx.GetThreadPtr()->GetQueueName();
486 lldb::queue_id_t SBThread::GetQueueID() const {
487 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::queue_id_t, SBThread, GetQueueID);
489 queue_id_t id = LLDB_INVALID_QUEUE_ID;
490 std::unique_lock<std::recursive_mutex> lock;
491 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
493 if (exe_ctx.HasThreadScope()) {
494 Process::StopLocker stop_locker;
495 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
496 id = exe_ctx.GetThreadPtr()->GetQueueID();
503 bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
504 LLDB_RECORD_METHOD(bool, SBThread, GetInfoItemByPathAsString,
505 (const char *, lldb::SBStream &), path, strm);
507 bool success = false;
508 std::unique_lock<std::recursive_mutex> lock;
509 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
511 if (exe_ctx.HasThreadScope()) {
512 Process::StopLocker stop_locker;
513 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
514 Thread *thread = exe_ctx.GetThreadPtr();
515 StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
517 StructuredData::ObjectSP node =
518 info_root_sp->GetObjectForDotSeparatedPath(path);
520 if (node->GetType() == eStructuredDataTypeString) {
521 strm.Printf("%s", node->GetAsString()->GetValue().str().c_str());
524 if (node->GetType() == eStructuredDataTypeInteger) {
525 strm.Printf("0x%" PRIx64, node->GetAsInteger()->GetValue());
528 if (node->GetType() == eStructuredDataTypeFloat) {
529 strm.Printf("0x%f", node->GetAsFloat()->GetValue());
532 if (node->GetType() == eStructuredDataTypeBoolean) {
533 if (node->GetAsBoolean()->GetValue())
536 strm.Printf("false");
539 if (node->GetType() == eStructuredDataTypeNull) {
551 SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
552 ThreadPlan *new_plan) {
555 Process *process = exe_ctx.GetProcessPtr();
557 sb_error.SetErrorString("No process in SBThread::ResumeNewPlan");
561 Thread *thread = exe_ctx.GetThreadPtr();
563 sb_error.SetErrorString("No thread in SBThread::ResumeNewPlan");
567 // User level plans should be Master Plans so they can be interrupted, other
568 // plans executed, and then a "continue" will resume the plan.
569 if (new_plan != nullptr) {
570 new_plan->SetIsMasterPlan(true);
571 new_plan->SetOkayToDiscard(false);
574 // Why do we need to set the current thread by ID here???
575 process->GetThreadList().SetSelectedThreadByID(thread->GetID());
577 if (process->GetTarget().GetDebugger().GetAsyncExecution())
578 sb_error.ref() = process->Resume();
580 sb_error.ref() = process->ResumeSynchronous(nullptr);
585 void SBThread::StepOver(lldb::RunMode stop_other_threads) {
586 LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode),
589 SBError error; // Ignored
590 StepOver(stop_other_threads, error);
593 void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
594 LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode, lldb::SBError &),
595 stop_other_threads, error);
597 std::unique_lock<std::recursive_mutex> lock;
598 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
600 if (!exe_ctx.HasThreadScope()) {
601 error.SetErrorString("this SBThread object is invalid");
605 Thread *thread = exe_ctx.GetThreadPtr();
606 bool abort_other_plans = false;
607 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
609 Status new_plan_status;
610 ThreadPlanSP new_plan_sp;
612 if (frame_sp->HasDebugInformation()) {
613 const LazyBool avoid_no_debug = eLazyBoolCalculate;
614 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
615 new_plan_sp = thread->QueueThreadPlanForStepOverRange(
616 abort_other_plans, sc.line_entry, sc, stop_other_threads,
617 new_plan_status, avoid_no_debug);
619 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
620 true, abort_other_plans, stop_other_threads, new_plan_status);
623 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
626 void SBThread::StepInto(lldb::RunMode stop_other_threads) {
627 LLDB_RECORD_METHOD(void, SBThread, StepInto, (lldb::RunMode),
630 StepInto(nullptr, stop_other_threads);
633 void SBThread::StepInto(const char *target_name,
634 lldb::RunMode stop_other_threads) {
635 LLDB_RECORD_METHOD(void, SBThread, StepInto, (const char *, lldb::RunMode),
636 target_name, stop_other_threads);
638 SBError error; // Ignored
639 StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
642 void SBThread::StepInto(const char *target_name, uint32_t end_line,
643 SBError &error, lldb::RunMode stop_other_threads) {
644 LLDB_RECORD_METHOD(void, SBThread, StepInto,
645 (const char *, uint32_t, lldb::SBError &, lldb::RunMode),
646 target_name, end_line, error, stop_other_threads);
649 std::unique_lock<std::recursive_mutex> lock;
650 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
652 if (!exe_ctx.HasThreadScope()) {
653 error.SetErrorString("this SBThread object is invalid");
657 bool abort_other_plans = false;
659 Thread *thread = exe_ctx.GetThreadPtr();
660 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
661 ThreadPlanSP new_plan_sp;
662 Status new_plan_status;
664 if (frame_sp && frame_sp->HasDebugInformation()) {
665 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
667 if (end_line == LLDB_INVALID_LINE_NUMBER)
668 range = sc.line_entry.range;
670 if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
674 const LazyBool step_out_avoids_code_without_debug_info =
676 const LazyBool step_in_avoids_code_without_debug_info =
678 new_plan_sp = thread->QueueThreadPlanForStepInRange(
679 abort_other_plans, range, sc, target_name, stop_other_threads,
680 new_plan_status, step_in_avoids_code_without_debug_info,
681 step_out_avoids_code_without_debug_info);
683 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
684 false, abort_other_plans, stop_other_threads, new_plan_status);
687 if (new_plan_status.Success())
688 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
690 error.SetErrorString(new_plan_status.AsCString());
693 void SBThread::StepOut() {
694 LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, StepOut);
696 SBError error; // Ignored
700 void SBThread::StepOut(SBError &error) {
701 LLDB_RECORD_METHOD(void, SBThread, StepOut, (lldb::SBError &), error);
703 std::unique_lock<std::recursive_mutex> lock;
704 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
706 if (!exe_ctx.HasThreadScope()) {
707 error.SetErrorString("this SBThread object is invalid");
711 bool abort_other_plans = false;
712 bool stop_other_threads = false;
714 Thread *thread = exe_ctx.GetThreadPtr();
716 const LazyBool avoid_no_debug = eLazyBoolCalculate;
717 Status new_plan_status;
718 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
719 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
720 eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
722 if (new_plan_status.Success())
723 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
725 error.SetErrorString(new_plan_status.AsCString());
728 void SBThread::StepOutOfFrame(SBFrame &sb_frame) {
729 LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &),
732 SBError error; // Ignored
733 StepOutOfFrame(sb_frame, error);
736 void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
737 LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame,
738 (lldb::SBFrame &, lldb::SBError &), sb_frame, error);
741 std::unique_lock<std::recursive_mutex> lock;
742 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
744 if (!sb_frame.IsValid()) {
745 error.SetErrorString("passed invalid SBFrame object");
749 StackFrameSP frame_sp(sb_frame.GetFrameSP());
751 if (!exe_ctx.HasThreadScope()) {
752 error.SetErrorString("this SBThread object is invalid");
756 bool abort_other_plans = false;
757 bool stop_other_threads = false;
758 Thread *thread = exe_ctx.GetThreadPtr();
759 if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
760 error.SetErrorString("passed a frame from another thread");
764 Status new_plan_status;
765 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
766 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
767 eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
769 if (new_plan_status.Success())
770 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
772 error.SetErrorString(new_plan_status.AsCString());
775 void SBThread::StepInstruction(bool step_over) {
776 LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool), step_over);
778 SBError error; // Ignored
779 StepInstruction(step_over, error);
782 void SBThread::StepInstruction(bool step_over, SBError &error) {
783 LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool, lldb::SBError &),
786 std::unique_lock<std::recursive_mutex> lock;
787 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
789 if (!exe_ctx.HasThreadScope()) {
790 error.SetErrorString("this SBThread object is invalid");
794 Thread *thread = exe_ctx.GetThreadPtr();
795 Status new_plan_status;
796 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepSingleInstruction(
797 step_over, true, true, new_plan_status));
799 if (new_plan_status.Success())
800 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
802 error.SetErrorString(new_plan_status.AsCString());
805 void SBThread::RunToAddress(lldb::addr_t addr) {
806 LLDB_RECORD_METHOD(void, SBThread, RunToAddress, (lldb::addr_t), addr);
808 SBError error; // Ignored
809 RunToAddress(addr, error);
812 void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) {
813 LLDB_RECORD_METHOD(void, SBThread, RunToAddress,
814 (lldb::addr_t, lldb::SBError &), addr, error);
816 std::unique_lock<std::recursive_mutex> lock;
817 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
819 if (!exe_ctx.HasThreadScope()) {
820 error.SetErrorString("this SBThread object is invalid");
824 bool abort_other_plans = false;
825 bool stop_other_threads = true;
827 Address target_addr(addr);
829 Thread *thread = exe_ctx.GetThreadPtr();
831 Status new_plan_status;
832 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
833 abort_other_plans, target_addr, stop_other_threads, new_plan_status));
835 if (new_plan_status.Success())
836 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
838 error.SetErrorString(new_plan_status.AsCString());
841 SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
842 lldb::SBFileSpec &sb_file_spec, uint32_t line) {
843 LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepOverUntil,
844 (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t), sb_frame,
850 std::unique_lock<std::recursive_mutex> lock;
851 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
853 StackFrameSP frame_sp(sb_frame.GetFrameSP());
855 if (exe_ctx.HasThreadScope()) {
856 Target *target = exe_ctx.GetTargetPtr();
857 Thread *thread = exe_ctx.GetThreadPtr();
860 sb_error.SetErrorString("invalid line argument");
861 return LLDB_RECORD_RESULT(sb_error);
865 frame_sp = thread->GetSelectedFrame();
867 frame_sp = thread->GetStackFrameAtIndex(0);
870 SymbolContext frame_sc;
872 sb_error.SetErrorString("no valid frames in thread to step");
873 return LLDB_RECORD_RESULT(sb_error);
876 // If we have a frame, get its line
877 frame_sc = frame_sp->GetSymbolContext(
878 eSymbolContextCompUnit | eSymbolContextFunction |
879 eSymbolContextLineEntry | eSymbolContextSymbol);
881 if (frame_sc.comp_unit == nullptr) {
882 sb_error.SetErrorStringWithFormat(
883 "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
884 return LLDB_RECORD_RESULT(sb_error);
887 FileSpec step_file_spec;
888 if (sb_file_spec.IsValid()) {
889 // The file spec passed in was valid, so use it
890 step_file_spec = sb_file_spec.ref();
892 if (frame_sc.line_entry.IsValid())
893 step_file_spec = frame_sc.line_entry.file;
895 sb_error.SetErrorString("invalid file argument or no file for frame");
896 return LLDB_RECORD_RESULT(sb_error);
900 // Grab the current function, then we will make sure the "until" address is
901 // within the function. We discard addresses that are out of the current
902 // function, and then if there are no addresses remaining, give an
903 // appropriate error message.
905 bool all_in_function = true;
906 AddressRange fun_range = frame_sc.function->GetAddressRange();
908 std::vector<addr_t> step_over_until_addrs;
909 const bool abort_other_plans = false;
910 const bool stop_other_threads = false;
911 const bool check_inlines = true;
912 const bool exact = false;
914 SymbolContextList sc_list;
915 const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext(
916 step_file_spec, line, check_inlines, exact, eSymbolContextLineEntry,
918 if (num_matches > 0) {
920 for (uint32_t i = 0; i < num_matches; ++i) {
921 if (sc_list.GetContextAtIndex(i, sc)) {
923 sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
924 if (step_addr != LLDB_INVALID_ADDRESS) {
925 if (fun_range.ContainsLoadAddress(step_addr, target))
926 step_over_until_addrs.push_back(step_addr);
928 all_in_function = false;
934 if (step_over_until_addrs.empty()) {
935 if (all_in_function) {
936 step_file_spec.GetPath(path, sizeof(path));
937 sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path,
940 sb_error.SetErrorString("step until target not in current function");
942 Status new_plan_status;
943 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
944 abort_other_plans, &step_over_until_addrs[0],
945 step_over_until_addrs.size(), stop_other_threads,
946 frame_sp->GetFrameIndex(), new_plan_status));
948 if (new_plan_status.Success())
949 sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
951 sb_error.SetErrorString(new_plan_status.AsCString());
954 sb_error.SetErrorString("this SBThread object is invalid");
956 return LLDB_RECORD_RESULT(sb_error);
959 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
960 LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
961 (const char *), script_class_name);
963 return LLDB_RECORD_RESULT(
964 StepUsingScriptedThreadPlan(script_class_name, true));
967 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
968 bool resume_immediately) {
969 LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
970 (const char *, bool), script_class_name,
975 std::unique_lock<std::recursive_mutex> lock;
976 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
978 if (!exe_ctx.HasThreadScope()) {
979 error.SetErrorString("this SBThread object is invalid");
980 return LLDB_RECORD_RESULT(error);
983 Thread *thread = exe_ctx.GetThreadPtr();
984 Status new_plan_status;
985 ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
986 false, script_class_name, false, new_plan_status);
988 if (new_plan_status.Fail()) {
989 error.SetErrorString(new_plan_status.AsCString());
990 return LLDB_RECORD_RESULT(error);
993 if (!resume_immediately)
994 return LLDB_RECORD_RESULT(error);
996 if (new_plan_status.Success())
997 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
999 error.SetErrorString(new_plan_status.AsCString());
1001 return LLDB_RECORD_RESULT(error);
1004 SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) {
1005 LLDB_RECORD_METHOD(lldb::SBError, SBThread, JumpToLine,
1006 (lldb::SBFileSpec &, uint32_t), file_spec, line);
1010 std::unique_lock<std::recursive_mutex> lock;
1011 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1013 if (!exe_ctx.HasThreadScope()) {
1014 sb_error.SetErrorString("this SBThread object is invalid");
1015 return LLDB_RECORD_RESULT(sb_error);
1018 Thread *thread = exe_ctx.GetThreadPtr();
1020 Status err = thread->JumpToLine(file_spec.get(), line, true);
1021 sb_error.SetError(err);
1022 return LLDB_RECORD_RESULT(sb_error);
1025 SBError SBThread::ReturnFromFrame(SBFrame &frame, SBValue &return_value) {
1026 LLDB_RECORD_METHOD(lldb::SBError, SBThread, ReturnFromFrame,
1027 (lldb::SBFrame &, lldb::SBValue &), frame, return_value);
1031 std::unique_lock<std::recursive_mutex> lock;
1032 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1034 if (exe_ctx.HasThreadScope()) {
1035 Thread *thread = exe_ctx.GetThreadPtr();
1037 thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
1040 return LLDB_RECORD_RESULT(sb_error);
1043 SBError SBThread::UnwindInnermostExpression() {
1044 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBThread,
1045 UnwindInnermostExpression);
1049 std::unique_lock<std::recursive_mutex> lock;
1050 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1052 if (exe_ctx.HasThreadScope()) {
1053 Thread *thread = exe_ctx.GetThreadPtr();
1054 sb_error.SetError(thread->UnwindInnermostExpression());
1055 if (sb_error.Success())
1056 thread->SetSelectedFrameByIndex(0, false);
1059 return LLDB_RECORD_RESULT(sb_error);
1062 bool SBThread::Suspend() {
1063 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Suspend);
1065 SBError error; // Ignored
1066 return Suspend(error);
1069 bool SBThread::Suspend(SBError &error) {
1070 LLDB_RECORD_METHOD(bool, SBThread, Suspend, (lldb::SBError &), error);
1072 std::unique_lock<std::recursive_mutex> lock;
1073 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1075 bool result = false;
1076 if (exe_ctx.HasThreadScope()) {
1077 Process::StopLocker stop_locker;
1078 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1079 exe_ctx.GetThreadPtr()->SetResumeState(eStateSuspended);
1082 error.SetErrorString("process is running");
1085 error.SetErrorString("this SBThread object is invalid");
1089 bool SBThread::Resume() {
1090 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Resume);
1092 SBError error; // Ignored
1093 return Resume(error);
1096 bool SBThread::Resume(SBError &error) {
1097 LLDB_RECORD_METHOD(bool, SBThread, Resume, (lldb::SBError &), error);
1099 std::unique_lock<std::recursive_mutex> lock;
1100 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1102 bool result = false;
1103 if (exe_ctx.HasThreadScope()) {
1104 Process::StopLocker stop_locker;
1105 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1106 const bool override_suspend = true;
1107 exe_ctx.GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
1110 error.SetErrorString("process is running");
1113 error.SetErrorString("this SBThread object is invalid");
1117 bool SBThread::IsSuspended() {
1118 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsSuspended);
1120 std::unique_lock<std::recursive_mutex> lock;
1121 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1123 if (exe_ctx.HasThreadScope())
1124 return exe_ctx.GetThreadPtr()->GetResumeState() == eStateSuspended;
1128 bool SBThread::IsStopped() {
1129 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsStopped);
1131 std::unique_lock<std::recursive_mutex> lock;
1132 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1134 if (exe_ctx.HasThreadScope())
1135 return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
1139 SBProcess SBThread::GetProcess() {
1140 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBThread, GetProcess);
1142 SBProcess sb_process;
1143 std::unique_lock<std::recursive_mutex> lock;
1144 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1146 if (exe_ctx.HasThreadScope()) {
1147 // Have to go up to the target so we can get a shared pointer to our
1149 sb_process.SetSP(exe_ctx.GetProcessSP());
1152 return LLDB_RECORD_RESULT(sb_process);
1155 uint32_t SBThread::GetNumFrames() {
1156 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread, GetNumFrames);
1158 uint32_t num_frames = 0;
1159 std::unique_lock<std::recursive_mutex> lock;
1160 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1162 if (exe_ctx.HasThreadScope()) {
1163 Process::StopLocker stop_locker;
1164 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1165 num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
1172 SBFrame SBThread::GetFrameAtIndex(uint32_t idx) {
1173 LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t), idx);
1176 StackFrameSP frame_sp;
1177 std::unique_lock<std::recursive_mutex> lock;
1178 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1180 if (exe_ctx.HasThreadScope()) {
1181 Process::StopLocker stop_locker;
1182 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1183 frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx);
1184 sb_frame.SetFrameSP(frame_sp);
1188 return LLDB_RECORD_RESULT(sb_frame);
1191 lldb::SBFrame SBThread::GetSelectedFrame() {
1192 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBThread, GetSelectedFrame);
1195 StackFrameSP frame_sp;
1196 std::unique_lock<std::recursive_mutex> lock;
1197 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1199 if (exe_ctx.HasThreadScope()) {
1200 Process::StopLocker stop_locker;
1201 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1202 frame_sp = exe_ctx.GetThreadPtr()->GetSelectedFrame();
1203 sb_frame.SetFrameSP(frame_sp);
1207 return LLDB_RECORD_RESULT(sb_frame);
1210 lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) {
1211 LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t),
1215 StackFrameSP frame_sp;
1216 std::unique_lock<std::recursive_mutex> lock;
1217 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1219 if (exe_ctx.HasThreadScope()) {
1220 Process::StopLocker stop_locker;
1221 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1222 Thread *thread = exe_ctx.GetThreadPtr();
1223 frame_sp = thread->GetStackFrameAtIndex(idx);
1225 thread->SetSelectedFrame(frame_sp.get());
1226 sb_frame.SetFrameSP(frame_sp);
1231 return LLDB_RECORD_RESULT(sb_frame);
1234 bool SBThread::EventIsThreadEvent(const SBEvent &event) {
1235 LLDB_RECORD_STATIC_METHOD(bool, SBThread, EventIsThreadEvent,
1236 (const lldb::SBEvent &), event);
1238 return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr;
1241 SBFrame SBThread::GetStackFrameFromEvent(const SBEvent &event) {
1242 LLDB_RECORD_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent,
1243 (const lldb::SBEvent &), event);
1245 return LLDB_RECORD_RESULT(
1246 Thread::ThreadEventData::GetStackFrameFromEvent(event.get()));
1249 SBThread SBThread::GetThreadFromEvent(const SBEvent &event) {
1250 LLDB_RECORD_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent,
1251 (const lldb::SBEvent &), event);
1253 return LLDB_RECORD_RESULT(
1254 Thread::ThreadEventData::GetThreadFromEvent(event.get()));
1257 bool SBThread::operator==(const SBThread &rhs) const {
1258 LLDB_RECORD_METHOD_CONST(bool, SBThread, operator==,(const lldb::SBThread &),
1261 return m_opaque_sp->GetThreadSP().get() ==
1262 rhs.m_opaque_sp->GetThreadSP().get();
1265 bool SBThread::operator!=(const SBThread &rhs) const {
1266 LLDB_RECORD_METHOD_CONST(bool, SBThread, operator!=,(const lldb::SBThread &),
1269 return m_opaque_sp->GetThreadSP().get() !=
1270 rhs.m_opaque_sp->GetThreadSP().get();
1273 bool SBThread::GetStatus(SBStream &status) const {
1274 LLDB_RECORD_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &),
1277 Stream &strm = status.ref();
1279 std::unique_lock<std::recursive_mutex> lock;
1280 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1282 if (exe_ctx.HasThreadScope()) {
1283 exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true);
1285 strm.PutCString("No status");
1290 bool SBThread::GetDescription(SBStream &description) const {
1291 LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription, (lldb::SBStream &),
1294 return GetDescription(description, false);
1297 bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
1298 LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription,
1299 (lldb::SBStream &, bool), description, stop_format);
1301 Stream &strm = description.ref();
1303 std::unique_lock<std::recursive_mutex> lock;
1304 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1306 if (exe_ctx.HasThreadScope()) {
1307 exe_ctx.GetThreadPtr()->DumpUsingSettingsFormat(strm,
1308 LLDB_INVALID_THREAD_ID,
1310 // strm.Printf("SBThread: tid = 0x%4.4" PRIx64,
1311 // exe_ctx.GetThreadPtr()->GetID());
1313 strm.PutCString("No value");
1318 SBThread SBThread::GetExtendedBacktraceThread(const char *type) {
1319 LLDB_RECORD_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread,
1320 (const char *), type);
1322 std::unique_lock<std::recursive_mutex> lock;
1323 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1324 SBThread sb_origin_thread;
1326 Process::StopLocker stop_locker;
1327 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1328 if (exe_ctx.HasThreadScope()) {
1329 ThreadSP real_thread(exe_ctx.GetThreadSP());
1331 ConstString type_const(type);
1332 Process *process = exe_ctx.GetProcessPtr();
1334 SystemRuntime *runtime = process->GetSystemRuntime();
1336 ThreadSP new_thread_sp(
1337 runtime->GetExtendedBacktraceThread(real_thread, type_const));
1338 if (new_thread_sp) {
1339 // Save this in the Process' ExtendedThreadList so a strong
1340 // pointer retains the object.
1341 process->GetExtendedThreadList().AddThread(new_thread_sp);
1342 sb_origin_thread.SetThread(new_thread_sp);
1350 return LLDB_RECORD_RESULT(sb_origin_thread);
1353 uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() {
1354 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread,
1355 GetExtendedBacktraceOriginatingIndexID);
1357 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1359 return thread_sp->GetExtendedBacktraceOriginatingIndexID();
1360 return LLDB_INVALID_INDEX32;
1363 SBValue SBThread::GetCurrentException() {
1364 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetCurrentException);
1366 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1368 return LLDB_RECORD_RESULT(SBValue());
1370 return LLDB_RECORD_RESULT(SBValue(thread_sp->GetCurrentException()));
1373 SBThread SBThread::GetCurrentExceptionBacktrace() {
1374 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBThread,
1375 GetCurrentExceptionBacktrace);
1377 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1379 return LLDB_RECORD_RESULT(SBThread());
1381 return LLDB_RECORD_RESULT(
1382 SBThread(thread_sp->GetCurrentExceptionBacktrace()));
1385 bool SBThread::SafeToCallFunctions() {
1386 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, SafeToCallFunctions);
1388 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1390 return thread_sp->SafeToCallFunctions();
1394 lldb_private::Thread *SBThread::operator->() {
1398 lldb_private::Thread *SBThread::get() {
1399 return m_opaque_sp->GetThreadSP().get();
1402 namespace lldb_private {
1406 void RegisterMethods<SBThread>(Registry &R) {
1407 LLDB_REGISTER_STATIC_METHOD(const char *, SBThread, GetBroadcasterClassName,
1409 LLDB_REGISTER_CONSTRUCTOR(SBThread, ());
1410 LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &));
1411 LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::SBThread &));
1412 LLDB_REGISTER_METHOD(const lldb::SBThread &,
1413 SBThread, operator=,(const lldb::SBThread &));
1414 LLDB_REGISTER_METHOD_CONST(lldb::SBQueue, SBThread, GetQueue, ());
1415 LLDB_REGISTER_METHOD_CONST(bool, SBThread, IsValid, ());
1416 LLDB_REGISTER_METHOD_CONST(bool, SBThread, operator bool, ());
1417 LLDB_REGISTER_METHOD(void, SBThread, Clear, ());
1418 LLDB_REGISTER_METHOD(lldb::StopReason, SBThread, GetStopReason, ());
1419 LLDB_REGISTER_METHOD(size_t, SBThread, GetStopReasonDataCount, ());
1420 LLDB_REGISTER_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex,
1422 LLDB_REGISTER_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON,
1423 (lldb::SBStream &));
1424 LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBThread,
1425 GetStopReasonExtendedBacktraces,
1426 (lldb::InstrumentationRuntimeType));
1427 LLDB_REGISTER_METHOD(size_t, SBThread, GetStopDescription,
1429 LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetStopReturnValue, ());
1430 LLDB_REGISTER_METHOD_CONST(lldb::tid_t, SBThread, GetThreadID, ());
1431 LLDB_REGISTER_METHOD_CONST(uint32_t, SBThread, GetIndexID, ());
1432 LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetName, ());
1433 LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetQueueName, ());
1434 LLDB_REGISTER_METHOD_CONST(lldb::queue_id_t, SBThread, GetQueueID, ());
1435 LLDB_REGISTER_METHOD(bool, SBThread, GetInfoItemByPathAsString,
1436 (const char *, lldb::SBStream &));
1437 LLDB_REGISTER_METHOD(void, SBThread, StepOver, (lldb::RunMode));
1438 LLDB_REGISTER_METHOD(void, SBThread, StepOver,
1439 (lldb::RunMode, lldb::SBError &));
1440 LLDB_REGISTER_METHOD(void, SBThread, StepInto, (lldb::RunMode));
1441 LLDB_REGISTER_METHOD(void, SBThread, StepInto,
1442 (const char *, lldb::RunMode));
1443 LLDB_REGISTER_METHOD(
1444 void, SBThread, StepInto,
1445 (const char *, uint32_t, lldb::SBError &, lldb::RunMode));
1446 LLDB_REGISTER_METHOD(void, SBThread, StepOut, ());
1447 LLDB_REGISTER_METHOD(void, SBThread, StepOut, (lldb::SBError &));
1448 LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &));
1449 LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame,
1450 (lldb::SBFrame &, lldb::SBError &));
1451 LLDB_REGISTER_METHOD(void, SBThread, StepInstruction, (bool));
1452 LLDB_REGISTER_METHOD(void, SBThread, StepInstruction,
1453 (bool, lldb::SBError &));
1454 LLDB_REGISTER_METHOD(void, SBThread, RunToAddress, (lldb::addr_t));
1455 LLDB_REGISTER_METHOD(void, SBThread, RunToAddress,
1456 (lldb::addr_t, lldb::SBError &));
1457 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepOverUntil,
1458 (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t));
1459 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
1461 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
1462 (const char *, bool));
1463 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, JumpToLine,
1464 (lldb::SBFileSpec &, uint32_t));
1465 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, ReturnFromFrame,
1466 (lldb::SBFrame &, lldb::SBValue &));
1467 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, UnwindInnermostExpression,
1469 LLDB_REGISTER_METHOD(bool, SBThread, Suspend, ());
1470 LLDB_REGISTER_METHOD(bool, SBThread, Suspend, (lldb::SBError &));
1471 LLDB_REGISTER_METHOD(bool, SBThread, Resume, ());
1472 LLDB_REGISTER_METHOD(bool, SBThread, Resume, (lldb::SBError &));
1473 LLDB_REGISTER_METHOD(bool, SBThread, IsSuspended, ());
1474 LLDB_REGISTER_METHOD(bool, SBThread, IsStopped, ());
1475 LLDB_REGISTER_METHOD(lldb::SBProcess, SBThread, GetProcess, ());
1476 LLDB_REGISTER_METHOD(uint32_t, SBThread, GetNumFrames, ());
1477 LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t));
1478 LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetSelectedFrame, ());
1479 LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t));
1480 LLDB_REGISTER_STATIC_METHOD(bool, SBThread, EventIsThreadEvent,
1481 (const lldb::SBEvent &));
1482 LLDB_REGISTER_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent,
1483 (const lldb::SBEvent &));
1484 LLDB_REGISTER_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent,
1485 (const lldb::SBEvent &));
1486 LLDB_REGISTER_METHOD_CONST(bool,
1487 SBThread, operator==,(const lldb::SBThread &));
1488 LLDB_REGISTER_METHOD_CONST(bool,
1489 SBThread, operator!=,(const lldb::SBThread &));
1490 LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &));
1491 LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription,
1492 (lldb::SBStream &));
1493 LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription,
1494 (lldb::SBStream &, bool));
1495 LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread,
1497 LLDB_REGISTER_METHOD(uint32_t, SBThread,
1498 GetExtendedBacktraceOriginatingIndexID, ());
1499 LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetCurrentException, ());
1500 LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetCurrentExceptionBacktrace,
1502 LLDB_REGISTER_METHOD(bool, SBThread, SafeToCallFunctions, ());