1 //===-- SBThread.cpp ------------------------------------------------------===//
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/SBStructuredData.h"
20 #include "lldb/API/SBSymbolContext.h"
21 #include "lldb/API/SBThreadCollection.h"
22 #include "lldb/API/SBThreadPlan.h"
23 #include "lldb/API/SBValue.h"
24 #include "lldb/Breakpoint/BreakpointLocation.h"
25 #include "lldb/Core/Debugger.h"
26 #include "lldb/Core/StreamFile.h"
27 #include "lldb/Core/StructuredDataImpl.h"
28 #include "lldb/Core/ValueObject.h"
29 #include "lldb/Interpreter/CommandInterpreter.h"
30 #include "lldb/Symbol/CompileUnit.h"
31 #include "lldb/Symbol/SymbolContext.h"
32 #include "lldb/Target/Process.h"
33 #include "lldb/Target/Queue.h"
34 #include "lldb/Target/StopInfo.h"
35 #include "lldb/Target/SystemRuntime.h"
36 #include "lldb/Target/Target.h"
37 #include "lldb/Target/Thread.h"
38 #include "lldb/Target/ThreadPlan.h"
39 #include "lldb/Target/ThreadPlanStepInRange.h"
40 #include "lldb/Target/ThreadPlanStepInstruction.h"
41 #include "lldb/Target/ThreadPlanStepOut.h"
42 #include "lldb/Target/ThreadPlanStepRange.h"
43 #include "lldb/Utility/State.h"
44 #include "lldb/Utility/Stream.h"
45 #include "lldb/Utility/StructuredData.h"
46 #include "lldb/lldb-enumerations.h"
51 using namespace lldb_private;
53 const char *SBThread::GetBroadcasterClassName() {
54 LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBThread,
55 GetBroadcasterClassName);
57 return Thread::GetStaticBroadcasterClass().AsCString();
61 SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) {
62 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThread);
65 SBThread::SBThread(const ThreadSP &lldb_object_sp)
66 : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
67 LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &), lldb_object_sp);
70 SBThread::SBThread(const SBThread &rhs) : m_opaque_sp() {
71 LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::SBThread &), rhs);
73 m_opaque_sp = clone(rhs.m_opaque_sp);
76 // Assignment operator
78 const lldb::SBThread &SBThread::operator=(const SBThread &rhs) {
79 LLDB_RECORD_METHOD(const lldb::SBThread &,
80 SBThread, operator=,(const lldb::SBThread &), rhs);
83 m_opaque_sp = clone(rhs.m_opaque_sp);
84 return LLDB_RECORD_RESULT(*this);
88 SBThread::~SBThread() = default;
90 lldb::SBQueue SBThread::GetQueue() const {
91 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBQueue, SBThread, GetQueue);
95 std::unique_lock<std::recursive_mutex> lock;
96 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
98 if (exe_ctx.HasThreadScope()) {
99 Process::StopLocker stop_locker;
100 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
101 queue_sp = exe_ctx.GetThreadPtr()->GetQueue();
103 sb_queue.SetQueue(queue_sp);
108 return LLDB_RECORD_RESULT(sb_queue);
111 bool SBThread::IsValid() const {
112 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, IsValid);
113 return this->operator bool();
115 SBThread::operator bool() const {
116 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, operator bool);
118 std::unique_lock<std::recursive_mutex> lock;
119 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
121 Target *target = exe_ctx.GetTargetPtr();
122 Process *process = exe_ctx.GetProcessPtr();
123 if (target && process) {
124 Process::StopLocker stop_locker;
125 if (stop_locker.TryLock(&process->GetRunLock()))
126 return m_opaque_sp->GetThreadSP().get() != nullptr;
128 // Without a valid target & process, this thread can't be valid.
132 void SBThread::Clear() {
133 LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, Clear);
135 m_opaque_sp->Clear();
138 StopReason SBThread::GetStopReason() {
139 LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThread, GetStopReason);
141 StopReason reason = eStopReasonInvalid;
142 std::unique_lock<std::recursive_mutex> lock;
143 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
145 if (exe_ctx.HasThreadScope()) {
146 Process::StopLocker stop_locker;
147 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
148 return exe_ctx.GetThreadPtr()->GetStopReason();
155 size_t SBThread::GetStopReasonDataCount() {
156 LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThread, GetStopReasonDataCount);
158 std::unique_lock<std::recursive_mutex> lock;
159 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
161 if (exe_ctx.HasThreadScope()) {
162 Process::StopLocker stop_locker;
163 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
164 StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
166 StopReason reason = stop_info_sp->GetStopReason();
168 case eStopReasonInvalid:
169 case eStopReasonNone:
170 case eStopReasonTrace:
171 case eStopReasonExec:
172 case eStopReasonPlanComplete:
173 case eStopReasonThreadExiting:
174 case eStopReasonInstrumentation:
175 // There is no data for these stop reasons.
178 case eStopReasonBreakpoint: {
179 break_id_t site_id = stop_info_sp->GetValue();
180 lldb::BreakpointSiteSP bp_site_sp(
181 exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID(
184 return bp_site_sp->GetNumberOfOwners() * 2;
186 return 0; // Breakpoint must have cleared itself...
189 case eStopReasonWatchpoint:
192 case eStopReasonSignal:
195 case eStopReasonException:
204 uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) {
205 LLDB_RECORD_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex, (uint32_t),
208 std::unique_lock<std::recursive_mutex> lock;
209 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
211 if (exe_ctx.HasThreadScope()) {
212 Process::StopLocker stop_locker;
213 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
214 Thread *thread = exe_ctx.GetThreadPtr();
215 StopInfoSP stop_info_sp = thread->GetStopInfo();
217 StopReason reason = stop_info_sp->GetStopReason();
219 case eStopReasonInvalid:
220 case eStopReasonNone:
221 case eStopReasonTrace:
222 case eStopReasonExec:
223 case eStopReasonPlanComplete:
224 case eStopReasonThreadExiting:
225 case eStopReasonInstrumentation:
226 // There is no data for these stop reasons.
229 case eStopReasonBreakpoint: {
230 break_id_t site_id = stop_info_sp->GetValue();
231 lldb::BreakpointSiteSP bp_site_sp(
232 exe_ctx.GetProcessPtr()->GetBreakpointSiteList().FindByID(
235 uint32_t bp_index = idx / 2;
236 BreakpointLocationSP bp_loc_sp(
237 bp_site_sp->GetOwnerAtIndex(bp_index));
240 // Odd idx, return the breakpoint location ID
241 return bp_loc_sp->GetID();
243 // Even idx, return the breakpoint ID
244 return bp_loc_sp->GetBreakpoint().GetID();
248 return LLDB_INVALID_BREAK_ID;
251 case eStopReasonWatchpoint:
252 return stop_info_sp->GetValue();
254 case eStopReasonSignal:
255 return stop_info_sp->GetValue();
257 case eStopReasonException:
258 return stop_info_sp->GetValue();
266 bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) {
267 LLDB_RECORD_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON,
268 (lldb::SBStream &), stream);
270 Stream &strm = stream.ref();
272 std::unique_lock<std::recursive_mutex> lock;
273 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
275 if (!exe_ctx.HasThreadScope())
278 StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
279 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
289 SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
290 LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBThread,
291 GetStopReasonExtendedBacktraces,
292 (lldb::InstrumentationRuntimeType), type);
294 SBThreadCollection threads;
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(SBThreadCollection());
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 threads = process_sp->GetInstrumentationRuntime(type)
310 ->GetBacktracesFromExtendedStopInfo(info);
311 return LLDB_RECORD_RESULT(threads);
314 size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
315 LLDB_RECORD_CHAR_PTR_METHOD(size_t, SBThread, GetStopDescription,
316 (char *, size_t), dst, "", dst_len);
318 std::unique_lock<std::recursive_mutex> lock;
319 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
324 if (!exe_ctx.HasThreadScope())
327 Process::StopLocker stop_locker;
328 if (!stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
331 std::string thread_stop_desc = exe_ctx.GetThreadPtr()->GetStopDescription();
332 if (thread_stop_desc.empty())
336 return ::snprintf(dst, dst_len, "%s", thread_stop_desc.c_str()) + 1;
338 // NULL dst passed in, return the length needed to contain the
340 return thread_stop_desc.size() + 1; // Include the NULL byte for size
343 SBValue SBThread::GetStopReturnValue() {
344 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetStopReturnValue);
346 ValueObjectSP return_valobj_sp;
347 std::unique_lock<std::recursive_mutex> lock;
348 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
350 if (exe_ctx.HasThreadScope()) {
351 Process::StopLocker stop_locker;
352 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
353 StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
355 return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
360 return LLDB_RECORD_RESULT(SBValue(return_valobj_sp));
363 void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
364 m_opaque_sp->SetThreadSP(lldb_object_sp);
367 lldb::tid_t SBThread::GetThreadID() const {
368 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::tid_t, SBThread, GetThreadID);
370 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
372 return thread_sp->GetID();
373 return LLDB_INVALID_THREAD_ID;
376 uint32_t SBThread::GetIndexID() const {
377 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBThread, GetIndexID);
379 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
381 return thread_sp->GetIndexID();
382 return LLDB_INVALID_INDEX32;
385 const char *SBThread::GetName() const {
386 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetName);
388 const char *name = nullptr;
389 std::unique_lock<std::recursive_mutex> lock;
390 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
392 if (exe_ctx.HasThreadScope()) {
393 Process::StopLocker stop_locker;
394 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
395 name = exe_ctx.GetThreadPtr()->GetName();
402 const char *SBThread::GetQueueName() const {
403 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetQueueName);
405 const char *name = nullptr;
406 std::unique_lock<std::recursive_mutex> lock;
407 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
409 if (exe_ctx.HasThreadScope()) {
410 Process::StopLocker stop_locker;
411 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
412 name = exe_ctx.GetThreadPtr()->GetQueueName();
419 lldb::queue_id_t SBThread::GetQueueID() const {
420 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::queue_id_t, SBThread, GetQueueID);
422 queue_id_t id = LLDB_INVALID_QUEUE_ID;
423 std::unique_lock<std::recursive_mutex> lock;
424 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
426 if (exe_ctx.HasThreadScope()) {
427 Process::StopLocker stop_locker;
428 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
429 id = exe_ctx.GetThreadPtr()->GetQueueID();
436 bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
437 LLDB_RECORD_METHOD(bool, SBThread, GetInfoItemByPathAsString,
438 (const char *, lldb::SBStream &), path, strm);
440 bool success = false;
441 std::unique_lock<std::recursive_mutex> lock;
442 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
444 if (exe_ctx.HasThreadScope()) {
445 Process::StopLocker stop_locker;
446 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
447 Thread *thread = exe_ctx.GetThreadPtr();
448 StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
450 StructuredData::ObjectSP node =
451 info_root_sp->GetObjectForDotSeparatedPath(path);
453 if (node->GetType() == eStructuredDataTypeString) {
454 strm.Printf("%s", node->GetAsString()->GetValue().str().c_str());
457 if (node->GetType() == eStructuredDataTypeInteger) {
458 strm.Printf("0x%" PRIx64, node->GetAsInteger()->GetValue());
461 if (node->GetType() == eStructuredDataTypeFloat) {
462 strm.Printf("0x%f", node->GetAsFloat()->GetValue());
465 if (node->GetType() == eStructuredDataTypeBoolean) {
466 if (node->GetAsBoolean()->GetValue())
469 strm.Printf("false");
472 if (node->GetType() == eStructuredDataTypeNull) {
484 SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
485 ThreadPlan *new_plan) {
488 Process *process = exe_ctx.GetProcessPtr();
490 sb_error.SetErrorString("No process in SBThread::ResumeNewPlan");
494 Thread *thread = exe_ctx.GetThreadPtr();
496 sb_error.SetErrorString("No thread in SBThread::ResumeNewPlan");
500 // User level plans should be Master Plans so they can be interrupted, other
501 // plans executed, and then a "continue" will resume the plan.
502 if (new_plan != nullptr) {
503 new_plan->SetIsMasterPlan(true);
504 new_plan->SetOkayToDiscard(false);
507 // Why do we need to set the current thread by ID here???
508 process->GetThreadList().SetSelectedThreadByID(thread->GetID());
510 if (process->GetTarget().GetDebugger().GetAsyncExecution())
511 sb_error.ref() = process->Resume();
513 sb_error.ref() = process->ResumeSynchronous(nullptr);
518 void SBThread::StepOver(lldb::RunMode stop_other_threads) {
519 LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode),
522 SBError error; // Ignored
523 StepOver(stop_other_threads, error);
526 void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
527 LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode, lldb::SBError &),
528 stop_other_threads, error);
530 std::unique_lock<std::recursive_mutex> lock;
531 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
533 if (!exe_ctx.HasThreadScope()) {
534 error.SetErrorString("this SBThread object is invalid");
538 Thread *thread = exe_ctx.GetThreadPtr();
539 bool abort_other_plans = false;
540 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
542 Status new_plan_status;
543 ThreadPlanSP new_plan_sp;
545 if (frame_sp->HasDebugInformation()) {
546 const LazyBool avoid_no_debug = eLazyBoolCalculate;
547 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
548 new_plan_sp = thread->QueueThreadPlanForStepOverRange(
549 abort_other_plans, sc.line_entry, sc, stop_other_threads,
550 new_plan_status, avoid_no_debug);
552 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
553 true, abort_other_plans, stop_other_threads, new_plan_status);
556 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
559 void SBThread::StepInto(lldb::RunMode stop_other_threads) {
560 LLDB_RECORD_METHOD(void, SBThread, StepInto, (lldb::RunMode),
563 StepInto(nullptr, stop_other_threads);
566 void SBThread::StepInto(const char *target_name,
567 lldb::RunMode stop_other_threads) {
568 LLDB_RECORD_METHOD(void, SBThread, StepInto, (const char *, lldb::RunMode),
569 target_name, stop_other_threads);
571 SBError error; // Ignored
572 StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
575 void SBThread::StepInto(const char *target_name, uint32_t end_line,
576 SBError &error, lldb::RunMode stop_other_threads) {
577 LLDB_RECORD_METHOD(void, SBThread, StepInto,
578 (const char *, uint32_t, lldb::SBError &, lldb::RunMode),
579 target_name, end_line, error, stop_other_threads);
582 std::unique_lock<std::recursive_mutex> lock;
583 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
585 if (!exe_ctx.HasThreadScope()) {
586 error.SetErrorString("this SBThread object is invalid");
590 bool abort_other_plans = false;
592 Thread *thread = exe_ctx.GetThreadPtr();
593 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
594 ThreadPlanSP new_plan_sp;
595 Status new_plan_status;
597 if (frame_sp && frame_sp->HasDebugInformation()) {
598 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
600 if (end_line == LLDB_INVALID_LINE_NUMBER)
601 range = sc.line_entry.range;
603 if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
607 const LazyBool step_out_avoids_code_without_debug_info =
609 const LazyBool step_in_avoids_code_without_debug_info =
611 new_plan_sp = thread->QueueThreadPlanForStepInRange(
612 abort_other_plans, range, sc, target_name, stop_other_threads,
613 new_plan_status, step_in_avoids_code_without_debug_info,
614 step_out_avoids_code_without_debug_info);
616 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
617 false, abort_other_plans, stop_other_threads, new_plan_status);
620 if (new_plan_status.Success())
621 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
623 error.SetErrorString(new_plan_status.AsCString());
626 void SBThread::StepOut() {
627 LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, StepOut);
629 SBError error; // Ignored
633 void SBThread::StepOut(SBError &error) {
634 LLDB_RECORD_METHOD(void, SBThread, StepOut, (lldb::SBError &), error);
636 std::unique_lock<std::recursive_mutex> lock;
637 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
639 if (!exe_ctx.HasThreadScope()) {
640 error.SetErrorString("this SBThread object is invalid");
644 bool abort_other_plans = false;
645 bool stop_other_threads = false;
647 Thread *thread = exe_ctx.GetThreadPtr();
649 const LazyBool avoid_no_debug = eLazyBoolCalculate;
650 Status new_plan_status;
651 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
652 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
653 eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
655 if (new_plan_status.Success())
656 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
658 error.SetErrorString(new_plan_status.AsCString());
661 void SBThread::StepOutOfFrame(SBFrame &sb_frame) {
662 LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &),
665 SBError error; // Ignored
666 StepOutOfFrame(sb_frame, error);
669 void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
670 LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame,
671 (lldb::SBFrame &, lldb::SBError &), sb_frame, error);
674 std::unique_lock<std::recursive_mutex> lock;
675 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
677 if (!sb_frame.IsValid()) {
678 error.SetErrorString("passed invalid SBFrame object");
682 StackFrameSP frame_sp(sb_frame.GetFrameSP());
684 if (!exe_ctx.HasThreadScope()) {
685 error.SetErrorString("this SBThread object is invalid");
689 bool abort_other_plans = false;
690 bool stop_other_threads = false;
691 Thread *thread = exe_ctx.GetThreadPtr();
692 if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
693 error.SetErrorString("passed a frame from another thread");
697 Status new_plan_status;
698 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
699 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
700 eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
702 if (new_plan_status.Success())
703 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
705 error.SetErrorString(new_plan_status.AsCString());
708 void SBThread::StepInstruction(bool step_over) {
709 LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool), step_over);
711 SBError error; // Ignored
712 StepInstruction(step_over, error);
715 void SBThread::StepInstruction(bool step_over, SBError &error) {
716 LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool, lldb::SBError &),
719 std::unique_lock<std::recursive_mutex> lock;
720 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
722 if (!exe_ctx.HasThreadScope()) {
723 error.SetErrorString("this SBThread object is invalid");
727 Thread *thread = exe_ctx.GetThreadPtr();
728 Status new_plan_status;
729 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepSingleInstruction(
730 step_over, true, true, new_plan_status));
732 if (new_plan_status.Success())
733 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
735 error.SetErrorString(new_plan_status.AsCString());
738 void SBThread::RunToAddress(lldb::addr_t addr) {
739 LLDB_RECORD_METHOD(void, SBThread, RunToAddress, (lldb::addr_t), addr);
741 SBError error; // Ignored
742 RunToAddress(addr, error);
745 void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) {
746 LLDB_RECORD_METHOD(void, SBThread, RunToAddress,
747 (lldb::addr_t, lldb::SBError &), addr, error);
749 std::unique_lock<std::recursive_mutex> lock;
750 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
752 if (!exe_ctx.HasThreadScope()) {
753 error.SetErrorString("this SBThread object is invalid");
757 bool abort_other_plans = false;
758 bool stop_other_threads = true;
760 Address target_addr(addr);
762 Thread *thread = exe_ctx.GetThreadPtr();
764 Status new_plan_status;
765 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
766 abort_other_plans, target_addr, stop_other_threads, new_plan_status));
768 if (new_plan_status.Success())
769 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
771 error.SetErrorString(new_plan_status.AsCString());
774 SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
775 lldb::SBFileSpec &sb_file_spec, uint32_t line) {
776 LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepOverUntil,
777 (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t), sb_frame,
783 std::unique_lock<std::recursive_mutex> lock;
784 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
786 StackFrameSP frame_sp(sb_frame.GetFrameSP());
788 if (exe_ctx.HasThreadScope()) {
789 Target *target = exe_ctx.GetTargetPtr();
790 Thread *thread = exe_ctx.GetThreadPtr();
793 sb_error.SetErrorString("invalid line argument");
794 return LLDB_RECORD_RESULT(sb_error);
798 frame_sp = thread->GetSelectedFrame();
800 frame_sp = thread->GetStackFrameAtIndex(0);
803 SymbolContext frame_sc;
805 sb_error.SetErrorString("no valid frames in thread to step");
806 return LLDB_RECORD_RESULT(sb_error);
809 // If we have a frame, get its line
810 frame_sc = frame_sp->GetSymbolContext(
811 eSymbolContextCompUnit | eSymbolContextFunction |
812 eSymbolContextLineEntry | eSymbolContextSymbol);
814 if (frame_sc.comp_unit == nullptr) {
815 sb_error.SetErrorStringWithFormat(
816 "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
817 return LLDB_RECORD_RESULT(sb_error);
820 FileSpec step_file_spec;
821 if (sb_file_spec.IsValid()) {
822 // The file spec passed in was valid, so use it
823 step_file_spec = sb_file_spec.ref();
825 if (frame_sc.line_entry.IsValid())
826 step_file_spec = frame_sc.line_entry.file;
828 sb_error.SetErrorString("invalid file argument or no file for frame");
829 return LLDB_RECORD_RESULT(sb_error);
833 // Grab the current function, then we will make sure the "until" address is
834 // within the function. We discard addresses that are out of the current
835 // function, and then if there are no addresses remaining, give an
836 // appropriate error message.
838 bool all_in_function = true;
839 AddressRange fun_range = frame_sc.function->GetAddressRange();
841 std::vector<addr_t> step_over_until_addrs;
842 const bool abort_other_plans = false;
843 const bool stop_other_threads = false;
844 const bool check_inlines = true;
845 const bool exact = false;
847 SymbolContextList sc_list;
848 frame_sc.comp_unit->ResolveSymbolContext(step_file_spec, line,
849 check_inlines, exact,
850 eSymbolContextLineEntry, sc_list);
851 const uint32_t num_matches = sc_list.GetSize();
852 if (num_matches > 0) {
854 for (uint32_t i = 0; i < num_matches; ++i) {
855 if (sc_list.GetContextAtIndex(i, sc)) {
857 sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
858 if (step_addr != LLDB_INVALID_ADDRESS) {
859 if (fun_range.ContainsLoadAddress(step_addr, target))
860 step_over_until_addrs.push_back(step_addr);
862 all_in_function = false;
868 if (step_over_until_addrs.empty()) {
869 if (all_in_function) {
870 step_file_spec.GetPath(path, sizeof(path));
871 sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path,
874 sb_error.SetErrorString("step until target not in current function");
876 Status new_plan_status;
877 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
878 abort_other_plans, &step_over_until_addrs[0],
879 step_over_until_addrs.size(), stop_other_threads,
880 frame_sp->GetFrameIndex(), new_plan_status));
882 if (new_plan_status.Success())
883 sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
885 sb_error.SetErrorString(new_plan_status.AsCString());
888 sb_error.SetErrorString("this SBThread object is invalid");
890 return LLDB_RECORD_RESULT(sb_error);
893 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
894 LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
895 (const char *), script_class_name);
897 return LLDB_RECORD_RESULT(
898 StepUsingScriptedThreadPlan(script_class_name, true));
901 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
902 bool resume_immediately) {
903 LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
904 (const char *, bool), script_class_name,
907 lldb::SBStructuredData no_data;
908 return LLDB_RECORD_RESULT(StepUsingScriptedThreadPlan(
909 script_class_name, no_data, resume_immediately));
912 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
913 SBStructuredData &args_data,
914 bool resume_immediately) {
915 LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
916 (const char *, lldb::SBStructuredData &, bool),
917 script_class_name, args_data, resume_immediately);
921 std::unique_lock<std::recursive_mutex> lock;
922 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
924 if (!exe_ctx.HasThreadScope()) {
925 error.SetErrorString("this SBThread object is invalid");
926 return LLDB_RECORD_RESULT(error);
929 Thread *thread = exe_ctx.GetThreadPtr();
930 Status new_plan_status;
931 StructuredData::ObjectSP obj_sp = args_data.m_impl_up->GetObjectSP();
933 ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
934 false, script_class_name, obj_sp, false, new_plan_status);
936 if (new_plan_status.Fail()) {
937 error.SetErrorString(new_plan_status.AsCString());
938 return LLDB_RECORD_RESULT(error);
941 if (!resume_immediately)
942 return LLDB_RECORD_RESULT(error);
944 if (new_plan_status.Success())
945 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
947 error.SetErrorString(new_plan_status.AsCString());
949 return LLDB_RECORD_RESULT(error);
952 SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) {
953 LLDB_RECORD_METHOD(lldb::SBError, SBThread, JumpToLine,
954 (lldb::SBFileSpec &, uint32_t), file_spec, line);
958 std::unique_lock<std::recursive_mutex> lock;
959 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
961 if (!exe_ctx.HasThreadScope()) {
962 sb_error.SetErrorString("this SBThread object is invalid");
963 return LLDB_RECORD_RESULT(sb_error);
966 Thread *thread = exe_ctx.GetThreadPtr();
968 Status err = thread->JumpToLine(file_spec.ref(), line, true);
969 sb_error.SetError(err);
970 return LLDB_RECORD_RESULT(sb_error);
973 SBError SBThread::ReturnFromFrame(SBFrame &frame, SBValue &return_value) {
974 LLDB_RECORD_METHOD(lldb::SBError, SBThread, ReturnFromFrame,
975 (lldb::SBFrame &, lldb::SBValue &), frame, return_value);
979 std::unique_lock<std::recursive_mutex> lock;
980 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
982 if (exe_ctx.HasThreadScope()) {
983 Thread *thread = exe_ctx.GetThreadPtr();
985 thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
988 return LLDB_RECORD_RESULT(sb_error);
991 SBError SBThread::UnwindInnermostExpression() {
992 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBThread,
993 UnwindInnermostExpression);
997 std::unique_lock<std::recursive_mutex> lock;
998 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1000 if (exe_ctx.HasThreadScope()) {
1001 Thread *thread = exe_ctx.GetThreadPtr();
1002 sb_error.SetError(thread->UnwindInnermostExpression());
1003 if (sb_error.Success())
1004 thread->SetSelectedFrameByIndex(0, false);
1007 return LLDB_RECORD_RESULT(sb_error);
1010 bool SBThread::Suspend() {
1011 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Suspend);
1013 SBError error; // Ignored
1014 return Suspend(error);
1017 bool SBThread::Suspend(SBError &error) {
1018 LLDB_RECORD_METHOD(bool, SBThread, Suspend, (lldb::SBError &), error);
1020 std::unique_lock<std::recursive_mutex> lock;
1021 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1023 bool result = false;
1024 if (exe_ctx.HasThreadScope()) {
1025 Process::StopLocker stop_locker;
1026 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1027 exe_ctx.GetThreadPtr()->SetResumeState(eStateSuspended);
1030 error.SetErrorString("process is running");
1033 error.SetErrorString("this SBThread object is invalid");
1037 bool SBThread::Resume() {
1038 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Resume);
1040 SBError error; // Ignored
1041 return Resume(error);
1044 bool SBThread::Resume(SBError &error) {
1045 LLDB_RECORD_METHOD(bool, SBThread, Resume, (lldb::SBError &), error);
1047 std::unique_lock<std::recursive_mutex> lock;
1048 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1050 bool result = false;
1051 if (exe_ctx.HasThreadScope()) {
1052 Process::StopLocker stop_locker;
1053 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1054 const bool override_suspend = true;
1055 exe_ctx.GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
1058 error.SetErrorString("process is running");
1061 error.SetErrorString("this SBThread object is invalid");
1065 bool SBThread::IsSuspended() {
1066 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsSuspended);
1068 std::unique_lock<std::recursive_mutex> lock;
1069 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1071 if (exe_ctx.HasThreadScope())
1072 return exe_ctx.GetThreadPtr()->GetResumeState() == eStateSuspended;
1076 bool SBThread::IsStopped() {
1077 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsStopped);
1079 std::unique_lock<std::recursive_mutex> lock;
1080 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1082 if (exe_ctx.HasThreadScope())
1083 return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
1087 SBProcess SBThread::GetProcess() {
1088 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBThread, GetProcess);
1090 SBProcess sb_process;
1091 std::unique_lock<std::recursive_mutex> lock;
1092 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1094 if (exe_ctx.HasThreadScope()) {
1095 // Have to go up to the target so we can get a shared pointer to our
1097 sb_process.SetSP(exe_ctx.GetProcessSP());
1100 return LLDB_RECORD_RESULT(sb_process);
1103 uint32_t SBThread::GetNumFrames() {
1104 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread, GetNumFrames);
1106 uint32_t num_frames = 0;
1107 std::unique_lock<std::recursive_mutex> lock;
1108 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1110 if (exe_ctx.HasThreadScope()) {
1111 Process::StopLocker stop_locker;
1112 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1113 num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
1120 SBFrame SBThread::GetFrameAtIndex(uint32_t idx) {
1121 LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t), idx);
1124 StackFrameSP frame_sp;
1125 std::unique_lock<std::recursive_mutex> lock;
1126 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1128 if (exe_ctx.HasThreadScope()) {
1129 Process::StopLocker stop_locker;
1130 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1131 frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx);
1132 sb_frame.SetFrameSP(frame_sp);
1136 return LLDB_RECORD_RESULT(sb_frame);
1139 lldb::SBFrame SBThread::GetSelectedFrame() {
1140 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBThread, GetSelectedFrame);
1143 StackFrameSP frame_sp;
1144 std::unique_lock<std::recursive_mutex> lock;
1145 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1147 if (exe_ctx.HasThreadScope()) {
1148 Process::StopLocker stop_locker;
1149 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1150 frame_sp = exe_ctx.GetThreadPtr()->GetSelectedFrame();
1151 sb_frame.SetFrameSP(frame_sp);
1155 return LLDB_RECORD_RESULT(sb_frame);
1158 lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) {
1159 LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t),
1163 StackFrameSP frame_sp;
1164 std::unique_lock<std::recursive_mutex> lock;
1165 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1167 if (exe_ctx.HasThreadScope()) {
1168 Process::StopLocker stop_locker;
1169 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1170 Thread *thread = exe_ctx.GetThreadPtr();
1171 frame_sp = thread->GetStackFrameAtIndex(idx);
1173 thread->SetSelectedFrame(frame_sp.get());
1174 sb_frame.SetFrameSP(frame_sp);
1179 return LLDB_RECORD_RESULT(sb_frame);
1182 bool SBThread::EventIsThreadEvent(const SBEvent &event) {
1183 LLDB_RECORD_STATIC_METHOD(bool, SBThread, EventIsThreadEvent,
1184 (const lldb::SBEvent &), event);
1186 return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr;
1189 SBFrame SBThread::GetStackFrameFromEvent(const SBEvent &event) {
1190 LLDB_RECORD_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent,
1191 (const lldb::SBEvent &), event);
1193 return LLDB_RECORD_RESULT(
1194 Thread::ThreadEventData::GetStackFrameFromEvent(event.get()));
1197 SBThread SBThread::GetThreadFromEvent(const SBEvent &event) {
1198 LLDB_RECORD_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent,
1199 (const lldb::SBEvent &), event);
1201 return LLDB_RECORD_RESULT(
1202 Thread::ThreadEventData::GetThreadFromEvent(event.get()));
1205 bool SBThread::operator==(const SBThread &rhs) const {
1206 LLDB_RECORD_METHOD_CONST(bool, SBThread, operator==,(const lldb::SBThread &),
1209 return m_opaque_sp->GetThreadSP().get() ==
1210 rhs.m_opaque_sp->GetThreadSP().get();
1213 bool SBThread::operator!=(const SBThread &rhs) const {
1214 LLDB_RECORD_METHOD_CONST(bool, SBThread, operator!=,(const lldb::SBThread &),
1217 return m_opaque_sp->GetThreadSP().get() !=
1218 rhs.m_opaque_sp->GetThreadSP().get();
1221 bool SBThread::GetStatus(SBStream &status) const {
1222 LLDB_RECORD_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &),
1225 Stream &strm = status.ref();
1227 std::unique_lock<std::recursive_mutex> lock;
1228 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1230 if (exe_ctx.HasThreadScope()) {
1231 exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true);
1233 strm.PutCString("No status");
1238 bool SBThread::GetDescription(SBStream &description) const {
1239 LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription, (lldb::SBStream &),
1242 return GetDescription(description, false);
1245 bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
1246 LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription,
1247 (lldb::SBStream &, bool), description, stop_format);
1249 Stream &strm = description.ref();
1251 std::unique_lock<std::recursive_mutex> lock;
1252 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1254 if (exe_ctx.HasThreadScope()) {
1255 exe_ctx.GetThreadPtr()->DumpUsingSettingsFormat(strm,
1256 LLDB_INVALID_THREAD_ID,
1258 // strm.Printf("SBThread: tid = 0x%4.4" PRIx64,
1259 // exe_ctx.GetThreadPtr()->GetID());
1261 strm.PutCString("No value");
1266 SBThread SBThread::GetExtendedBacktraceThread(const char *type) {
1267 LLDB_RECORD_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread,
1268 (const char *), type);
1270 std::unique_lock<std::recursive_mutex> lock;
1271 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1272 SBThread sb_origin_thread;
1274 Process::StopLocker stop_locker;
1275 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1276 if (exe_ctx.HasThreadScope()) {
1277 ThreadSP real_thread(exe_ctx.GetThreadSP());
1279 ConstString type_const(type);
1280 Process *process = exe_ctx.GetProcessPtr();
1282 SystemRuntime *runtime = process->GetSystemRuntime();
1284 ThreadSP new_thread_sp(
1285 runtime->GetExtendedBacktraceThread(real_thread, type_const));
1286 if (new_thread_sp) {
1287 // Save this in the Process' ExtendedThreadList so a strong
1288 // pointer retains the object.
1289 process->GetExtendedThreadList().AddThread(new_thread_sp);
1290 sb_origin_thread.SetThread(new_thread_sp);
1298 return LLDB_RECORD_RESULT(sb_origin_thread);
1301 uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() {
1302 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread,
1303 GetExtendedBacktraceOriginatingIndexID);
1305 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1307 return thread_sp->GetExtendedBacktraceOriginatingIndexID();
1308 return LLDB_INVALID_INDEX32;
1311 SBValue SBThread::GetCurrentException() {
1312 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetCurrentException);
1314 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1316 return LLDB_RECORD_RESULT(SBValue());
1318 return LLDB_RECORD_RESULT(SBValue(thread_sp->GetCurrentException()));
1321 SBThread SBThread::GetCurrentExceptionBacktrace() {
1322 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBThread,
1323 GetCurrentExceptionBacktrace);
1325 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1327 return LLDB_RECORD_RESULT(SBThread());
1329 return LLDB_RECORD_RESULT(
1330 SBThread(thread_sp->GetCurrentExceptionBacktrace()));
1333 bool SBThread::SafeToCallFunctions() {
1334 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, SafeToCallFunctions);
1336 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1338 return thread_sp->SafeToCallFunctions();
1342 lldb_private::Thread *SBThread::operator->() {
1346 lldb_private::Thread *SBThread::get() {
1347 return m_opaque_sp->GetThreadSP().get();
1350 namespace lldb_private {
1354 void RegisterMethods<SBThread>(Registry &R) {
1355 LLDB_REGISTER_STATIC_METHOD(const char *, SBThread, GetBroadcasterClassName,
1357 LLDB_REGISTER_CONSTRUCTOR(SBThread, ());
1358 LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &));
1359 LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::SBThread &));
1360 LLDB_REGISTER_METHOD(const lldb::SBThread &,
1361 SBThread, operator=,(const lldb::SBThread &));
1362 LLDB_REGISTER_METHOD_CONST(lldb::SBQueue, SBThread, GetQueue, ());
1363 LLDB_REGISTER_METHOD_CONST(bool, SBThread, IsValid, ());
1364 LLDB_REGISTER_METHOD_CONST(bool, SBThread, operator bool, ());
1365 LLDB_REGISTER_METHOD(void, SBThread, Clear, ());
1366 LLDB_REGISTER_METHOD(lldb::StopReason, SBThread, GetStopReason, ());
1367 LLDB_REGISTER_METHOD(size_t, SBThread, GetStopReasonDataCount, ());
1368 LLDB_REGISTER_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex,
1370 LLDB_REGISTER_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON,
1371 (lldb::SBStream &));
1372 LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBThread,
1373 GetStopReasonExtendedBacktraces,
1374 (lldb::InstrumentationRuntimeType));
1375 LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetStopReturnValue, ());
1376 LLDB_REGISTER_METHOD_CONST(lldb::tid_t, SBThread, GetThreadID, ());
1377 LLDB_REGISTER_METHOD_CONST(uint32_t, SBThread, GetIndexID, ());
1378 LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetName, ());
1379 LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetQueueName, ());
1380 LLDB_REGISTER_METHOD_CONST(lldb::queue_id_t, SBThread, GetQueueID, ());
1381 LLDB_REGISTER_METHOD(bool, SBThread, GetInfoItemByPathAsString,
1382 (const char *, lldb::SBStream &));
1383 LLDB_REGISTER_METHOD(void, SBThread, StepOver, (lldb::RunMode));
1384 LLDB_REGISTER_METHOD(void, SBThread, StepOver,
1385 (lldb::RunMode, lldb::SBError &));
1386 LLDB_REGISTER_METHOD(void, SBThread, StepInto, (lldb::RunMode));
1387 LLDB_REGISTER_METHOD(void, SBThread, StepInto,
1388 (const char *, lldb::RunMode));
1389 LLDB_REGISTER_METHOD(
1390 void, SBThread, StepInto,
1391 (const char *, uint32_t, lldb::SBError &, lldb::RunMode));
1392 LLDB_REGISTER_METHOD(void, SBThread, StepOut, ());
1393 LLDB_REGISTER_METHOD(void, SBThread, StepOut, (lldb::SBError &));
1394 LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &));
1395 LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame,
1396 (lldb::SBFrame &, lldb::SBError &));
1397 LLDB_REGISTER_METHOD(void, SBThread, StepInstruction, (bool));
1398 LLDB_REGISTER_METHOD(void, SBThread, StepInstruction,
1399 (bool, lldb::SBError &));
1400 LLDB_REGISTER_METHOD(void, SBThread, RunToAddress, (lldb::addr_t));
1401 LLDB_REGISTER_METHOD(void, SBThread, RunToAddress,
1402 (lldb::addr_t, lldb::SBError &));
1403 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepOverUntil,
1404 (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t));
1405 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
1407 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
1408 (const char *, bool));
1409 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
1410 (const char *, SBStructuredData &, bool));
1411 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, JumpToLine,
1412 (lldb::SBFileSpec &, uint32_t));
1413 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, ReturnFromFrame,
1414 (lldb::SBFrame &, lldb::SBValue &));
1415 LLDB_REGISTER_METHOD(lldb::SBError, SBThread, UnwindInnermostExpression,
1417 LLDB_REGISTER_METHOD(bool, SBThread, Suspend, ());
1418 LLDB_REGISTER_METHOD(bool, SBThread, Suspend, (lldb::SBError &));
1419 LLDB_REGISTER_METHOD(bool, SBThread, Resume, ());
1420 LLDB_REGISTER_METHOD(bool, SBThread, Resume, (lldb::SBError &));
1421 LLDB_REGISTER_METHOD(bool, SBThread, IsSuspended, ());
1422 LLDB_REGISTER_METHOD(bool, SBThread, IsStopped, ());
1423 LLDB_REGISTER_METHOD(lldb::SBProcess, SBThread, GetProcess, ());
1424 LLDB_REGISTER_METHOD(uint32_t, SBThread, GetNumFrames, ());
1425 LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t));
1426 LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetSelectedFrame, ());
1427 LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t));
1428 LLDB_REGISTER_STATIC_METHOD(bool, SBThread, EventIsThreadEvent,
1429 (const lldb::SBEvent &));
1430 LLDB_REGISTER_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent,
1431 (const lldb::SBEvent &));
1432 LLDB_REGISTER_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent,
1433 (const lldb::SBEvent &));
1434 LLDB_REGISTER_METHOD_CONST(bool,
1435 SBThread, operator==,(const lldb::SBThread &));
1436 LLDB_REGISTER_METHOD_CONST(bool,
1437 SBThread, operator!=,(const lldb::SBThread &));
1438 LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &));
1439 LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription,
1440 (lldb::SBStream &));
1441 LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription,
1442 (lldb::SBStream &, bool));
1443 LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread,
1445 LLDB_REGISTER_METHOD(uint32_t, SBThread,
1446 GetExtendedBacktraceOriginatingIndexID, ());
1447 LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetCurrentException, ());
1448 LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetCurrentExceptionBacktrace,
1450 LLDB_REGISTER_METHOD(bool, SBThread, SafeToCallFunctions, ());
1451 LLDB_REGISTER_CHAR_PTR_METHOD(size_t, SBThread, GetStopDescription);