LLDB mainline
SBThread.cpp
Go to the documentation of this file.
1//===-- SBThread.cpp ------------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/API/SBThread.h"
10#include "Utils.h"
11#include "lldb/API/SBAddress.h"
12#include "lldb/API/SBDebugger.h"
13#include "lldb/API/SBEvent.h"
14#include "lldb/API/SBFileSpec.h"
15#include "lldb/API/SBFormat.h"
16#include "lldb/API/SBFrame.h"
17#include "lldb/API/SBProcess.h"
18#include "lldb/API/SBStream.h"
23#include "lldb/API/SBValue.h"
25#include "lldb/Core/Debugger.h"
31#include "lldb/Target/Process.h"
32#include "lldb/Target/Queue.h"
35#include "lldb/Target/Target.h"
36#include "lldb/Target/Thread.h"
43#include "lldb/Utility/State.h"
44#include "lldb/Utility/Stream.h"
47
48#include <memory>
49
50using namespace lldb;
51using namespace lldb_private;
52
55
57}
58
59// Constructors
62}
63
64SBThread::SBThread(const ThreadSP &lldb_object_sp)
65 : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
66 LLDB_INSTRUMENT_VA(this, lldb_object_sp);
67}
68
70 LLDB_INSTRUMENT_VA(this, rhs);
71
73}
74
75// Assignment operator
76
78 LLDB_INSTRUMENT_VA(this, rhs);
79
80 if (this != &rhs)
82 return *this;
83}
84
85// Destructor
86SBThread::~SBThread() = default;
87
90
91 SBQueue sb_queue;
92 QueueSP queue_sp;
93 std::unique_lock<std::recursive_mutex> lock;
94 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
95
96 if (exe_ctx.HasThreadScope()) {
97 Process::StopLocker stop_locker;
98 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
99 queue_sp = exe_ctx.GetThreadPtr()->GetQueue();
100 if (queue_sp) {
101 sb_queue.SetQueue(queue_sp);
102 }
103 }
104 }
105
106 return sb_queue;
107}
108
109bool SBThread::IsValid() const {
110 LLDB_INSTRUMENT_VA(this);
111 return this->operator bool();
112}
113SBThread::operator bool() const {
114 LLDB_INSTRUMENT_VA(this);
115
116 std::unique_lock<std::recursive_mutex> lock;
117 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
118
119 Target *target = exe_ctx.GetTargetPtr();
120 Process *process = exe_ctx.GetProcessPtr();
121 if (target && process) {
122 Process::StopLocker stop_locker;
123 if (stop_locker.TryLock(&process->GetRunLock()))
124 return m_opaque_sp->GetThreadSP().get() != nullptr;
125 }
126 // Without a valid target & process, this thread can't be valid.
127 return false;
128}
129
131 LLDB_INSTRUMENT_VA(this);
132
133 m_opaque_sp->Clear();
134}
135
137 LLDB_INSTRUMENT_VA(this);
138
140 std::unique_lock<std::recursive_mutex> lock;
141 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
142
143 if (exe_ctx.HasThreadScope()) {
144 Process::StopLocker stop_locker;
145 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
146 return exe_ctx.GetThreadPtr()->GetStopReason();
147 }
148 }
149
150 return reason;
151}
152
154 LLDB_INSTRUMENT_VA(this);
155
156 std::unique_lock<std::recursive_mutex> lock;
157 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
158
159 if (exe_ctx.HasThreadScope()) {
160 Process::StopLocker stop_locker;
161 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
162 StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
163 if (stop_info_sp) {
164 StopReason reason = stop_info_sp->GetStopReason();
165 switch (reason) {
167 case eStopReasonNone:
168 case eStopReasonTrace:
169 case eStopReasonExec:
175 // There is no data for these stop reasons.
176 return 0;
177
179 break_id_t site_id = stop_info_sp->GetValue();
180 lldb::BreakpointSiteSP bp_site_sp(
182 site_id));
183 if (bp_site_sp)
184 return bp_site_sp->GetNumberOfConstituents() * 2;
185 else
186 return 0; // Breakpoint must have cleared itself...
187 } break;
188
190 return 1;
191
193 return 1;
194
196 return 1;
197
199 return 1;
200
201 case eStopReasonFork:
202 return 1;
203
204 case eStopReasonVFork:
205 return 1;
206 }
207 }
208 }
209 }
210 return 0;
211}
212
214 LLDB_INSTRUMENT_VA(this, idx);
215
216 std::unique_lock<std::recursive_mutex> lock;
217 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
218
219 if (exe_ctx.HasThreadScope()) {
220 Process::StopLocker stop_locker;
221 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
222 Thread *thread = exe_ctx.GetThreadPtr();
223 StopInfoSP stop_info_sp = thread->GetStopInfo();
224 if (stop_info_sp) {
225 StopReason reason = stop_info_sp->GetStopReason();
226 switch (reason) {
228 case eStopReasonNone:
229 case eStopReasonTrace:
230 case eStopReasonExec:
236 // There is no data for these stop reasons.
237 return 0;
238
240 break_id_t site_id = stop_info_sp->GetValue();
241 lldb::BreakpointSiteSP bp_site_sp(
243 site_id));
244 if (bp_site_sp) {
245 uint32_t bp_index = idx / 2;
246 BreakpointLocationSP bp_loc_sp(
247 bp_site_sp->GetConstituentAtIndex(bp_index));
248 if (bp_loc_sp) {
249 if (idx & 1) {
250 // Odd idx, return the breakpoint location ID
251 return bp_loc_sp->GetID();
252 } else {
253 // Even idx, return the breakpoint ID
254 return bp_loc_sp->GetBreakpoint().GetID();
255 }
256 }
257 }
259 } break;
260
262 return stop_info_sp->GetValue();
263
265 return stop_info_sp->GetValue();
266
268 return stop_info_sp->GetValue();
269
271 return stop_info_sp->GetValue();
272
273 case eStopReasonFork:
274 return stop_info_sp->GetValue();
275
276 case eStopReasonVFork:
277 return stop_info_sp->GetValue();
278 }
279 }
280 }
281 }
282 return 0;
283}
284
286 LLDB_INSTRUMENT_VA(this, stream);
287
288 Stream &strm = stream.ref();
289
290 std::unique_lock<std::recursive_mutex> lock;
291 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
292
293 if (!exe_ctx.HasThreadScope())
294 return false;
295
296 StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
297 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
298 if (!info)
299 return false;
300
301 info->Dump(strm);
302
303 return true;
304}
305
308 LLDB_INSTRUMENT_VA(this, type);
309
310 SBThreadCollection threads;
311
312 std::unique_lock<std::recursive_mutex> lock;
313 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
314
315 if (!exe_ctx.HasThreadScope())
316 return SBThreadCollection();
317
318 ProcessSP process_sp = exe_ctx.GetProcessSP();
319
320 StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
321 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
322 if (!info)
323 return threads;
324
325 threads = process_sp->GetInstrumentationRuntime(type)
326 ->GetBacktracesFromExtendedStopInfo(info);
327 return threads;
328}
329
330size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
331 LLDB_INSTRUMENT_VA(this, dst, dst_len);
332
333 std::unique_lock<std::recursive_mutex> lock;
334 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
335
336 if (dst)
337 *dst = 0;
338
339 if (!exe_ctx.HasThreadScope())
340 return 0;
341
342 Process::StopLocker stop_locker;
343 if (!stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
344 return 0;
345
346 std::string thread_stop_desc = exe_ctx.GetThreadPtr()->GetStopDescription();
347 if (thread_stop_desc.empty())
348 return 0;
349
350 if (dst)
351 return ::snprintf(dst, dst_len, "%s", thread_stop_desc.c_str()) + 1;
352
353 // NULL dst passed in, return the length needed to contain the
354 // description.
355 return thread_stop_desc.size() + 1; // Include the NULL byte for size
356}
357
359 LLDB_INSTRUMENT_VA(this);
360
361 ValueObjectSP return_valobj_sp;
362 std::unique_lock<std::recursive_mutex> lock;
363 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
364
365 if (exe_ctx.HasThreadScope()) {
366 Process::StopLocker stop_locker;
367 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
368 StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
369 if (stop_info_sp) {
370 return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
371 }
372 }
373 }
374
375 return SBValue(return_valobj_sp);
376}
377
378void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
379 m_opaque_sp->SetThreadSP(lldb_object_sp);
380}
381
383 LLDB_INSTRUMENT_VA(this);
384
385 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
386 if (thread_sp)
387 return thread_sp->GetID();
389}
390
391uint32_t SBThread::GetIndexID() const {
392 LLDB_INSTRUMENT_VA(this);
393
394 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
395 if (thread_sp)
396 return thread_sp->GetIndexID();
398}
399
400const char *SBThread::GetName() const {
401 LLDB_INSTRUMENT_VA(this);
402
403 std::unique_lock<std::recursive_mutex> lock;
404 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
405
406 if (!exe_ctx.HasThreadScope())
407 return nullptr;
408
409 Process::StopLocker stop_locker;
410 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
411 return ConstString(exe_ctx.GetThreadPtr()->GetName()).GetCString();
412
413 return nullptr;
414}
415
416const char *SBThread::GetQueueName() const {
417 LLDB_INSTRUMENT_VA(this);
418
419 std::unique_lock<std::recursive_mutex> lock;
420 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
421
422 if (!exe_ctx.HasThreadScope())
423 return nullptr;
424
425 Process::StopLocker stop_locker;
426 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
427 return ConstString(exe_ctx.GetThreadPtr()->GetQueueName()).GetCString();
428
429 return nullptr;
430}
431
433 LLDB_INSTRUMENT_VA(this);
434
436 std::unique_lock<std::recursive_mutex> lock;
437 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
438
439 if (exe_ctx.HasThreadScope()) {
440 Process::StopLocker stop_locker;
441 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
442 id = exe_ctx.GetThreadPtr()->GetQueueID();
443 }
444 }
445
446 return id;
447}
448
449bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
450 LLDB_INSTRUMENT_VA(this, path, strm);
451
452 bool success = false;
453 std::unique_lock<std::recursive_mutex> lock;
454 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
455
456 if (exe_ctx.HasThreadScope()) {
457 Process::StopLocker stop_locker;
458 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
459 Thread *thread = exe_ctx.GetThreadPtr();
460 StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
461 if (info_root_sp) {
463 info_root_sp->GetObjectForDotSeparatedPath(path);
464 if (node) {
465 if (node->GetType() == eStructuredDataTypeString) {
466 strm.ref() << node->GetAsString()->GetValue();
467 success = true;
468 }
469 if (node->GetType() == eStructuredDataTypeInteger) {
470 strm.Printf("0x%" PRIx64, node->GetUnsignedIntegerValue());
471 success = true;
472 }
473 if (node->GetType() == eStructuredDataTypeFloat) {
474 strm.Printf("0x%f", node->GetAsFloat()->GetValue());
475 success = true;
476 }
477 if (node->GetType() == eStructuredDataTypeBoolean) {
478 if (node->GetAsBoolean()->GetValue())
479 strm.Printf("true");
480 else
481 strm.Printf("false");
482 success = true;
483 }
484 if (node->GetType() == eStructuredDataTypeNull) {
485 strm.Printf("null");
486 success = true;
487 }
488 }
489 }
490 }
491 }
492
493 return success;
494}
495
497 ThreadPlan *new_plan) {
498 SBError sb_error;
499
500 Process *process = exe_ctx.GetProcessPtr();
501 if (!process) {
502 sb_error.SetErrorString("No process in SBThread::ResumeNewPlan");
503 return sb_error;
504 }
505
506 Thread *thread = exe_ctx.GetThreadPtr();
507 if (!thread) {
508 sb_error.SetErrorString("No thread in SBThread::ResumeNewPlan");
509 return sb_error;
510 }
511
512 // User level plans should be Controlling Plans so they can be interrupted,
513 // other plans executed, and then a "continue" will resume the plan.
514 if (new_plan != nullptr) {
515 new_plan->SetIsControllingPlan(true);
516 new_plan->SetOkayToDiscard(false);
517 }
518
519 // Why do we need to set the current thread by ID here???
520 process->GetThreadList().SetSelectedThreadByID(thread->GetID());
521
522 if (process->GetTarget().GetDebugger().GetAsyncExecution())
523 sb_error.ref() = process->Resume();
524 else
525 sb_error.ref() = process->ResumeSynchronous(nullptr);
526
527 return sb_error;
528}
529
530void SBThread::StepOver(lldb::RunMode stop_other_threads) {
531 LLDB_INSTRUMENT_VA(this, stop_other_threads);
532
533 SBError error; // Ignored
534 StepOver(stop_other_threads, error);
535}
536
537void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
538 LLDB_INSTRUMENT_VA(this, stop_other_threads, error);
539
540 std::unique_lock<std::recursive_mutex> lock;
541 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
542
543 if (!exe_ctx.HasThreadScope()) {
544 error.SetErrorString("this SBThread object is invalid");
545 return;
546 }
547
548 Thread *thread = exe_ctx.GetThreadPtr();
549 bool abort_other_plans = false;
550 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
551
552 Status new_plan_status;
553 ThreadPlanSP new_plan_sp;
554 if (frame_sp) {
555 if (frame_sp->HasDebugInformation()) {
556 const LazyBool avoid_no_debug = eLazyBoolCalculate;
557 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
558 new_plan_sp = thread->QueueThreadPlanForStepOverRange(
559 abort_other_plans, sc.line_entry, sc, stop_other_threads,
560 new_plan_status, avoid_no_debug);
561 } else {
562 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
563 true, abort_other_plans, stop_other_threads, new_plan_status);
564 }
565 }
566 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
567}
568
569void SBThread::StepInto(lldb::RunMode stop_other_threads) {
570 LLDB_INSTRUMENT_VA(this, stop_other_threads);
571
572 StepInto(nullptr, stop_other_threads);
573}
574
575void SBThread::StepInto(const char *target_name,
576 lldb::RunMode stop_other_threads) {
577 LLDB_INSTRUMENT_VA(this, target_name, stop_other_threads);
578
579 SBError error; // Ignored
580 StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
581}
582
583void SBThread::StepInto(const char *target_name, uint32_t end_line,
584 SBError &error, lldb::RunMode stop_other_threads) {
585 LLDB_INSTRUMENT_VA(this, target_name, end_line, error, stop_other_threads);
586
587 std::unique_lock<std::recursive_mutex> lock;
588 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
589
590 if (!exe_ctx.HasThreadScope()) {
591 error.SetErrorString("this SBThread object is invalid");
592 return;
593 }
594
595 bool abort_other_plans = false;
596
597 Thread *thread = exe_ctx.GetThreadPtr();
598 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
599 ThreadPlanSP new_plan_sp;
600 Status new_plan_status;
601
602 if (frame_sp && frame_sp->HasDebugInformation()) {
603 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
604 AddressRange range;
605 if (end_line == LLDB_INVALID_LINE_NUMBER)
606 range = sc.line_entry.range;
607 else {
608 if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
609 return;
610 }
611
612 const LazyBool step_out_avoids_code_without_debug_info =
614 const LazyBool step_in_avoids_code_without_debug_info =
616 new_plan_sp = thread->QueueThreadPlanForStepInRange(
617 abort_other_plans, range, sc, target_name, stop_other_threads,
618 new_plan_status, step_in_avoids_code_without_debug_info,
619 step_out_avoids_code_without_debug_info);
620 } else {
621 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
622 false, abort_other_plans, stop_other_threads, new_plan_status);
623 }
624
625 if (new_plan_status.Success())
626 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
627 else
628 error.SetErrorString(new_plan_status.AsCString());
629}
630
632 LLDB_INSTRUMENT_VA(this);
633
634 SBError error; // Ignored
635 StepOut(error);
636}
637
640
641 std::unique_lock<std::recursive_mutex> lock;
642 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
643
644 if (!exe_ctx.HasThreadScope()) {
645 error.SetErrorString("this SBThread object is invalid");
646 return;
647 }
648
649 bool abort_other_plans = false;
650 bool stop_other_threads = false;
651
652 Thread *thread = exe_ctx.GetThreadPtr();
653
654 const LazyBool avoid_no_debug = eLazyBoolCalculate;
655 Status new_plan_status;
656 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
657 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
658 eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
659
660 if (new_plan_status.Success())
661 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
662 else
663 error.SetErrorString(new_plan_status.AsCString());
664}
665
667 LLDB_INSTRUMENT_VA(this, sb_frame);
668
669 SBError error; // Ignored
670 StepOutOfFrame(sb_frame, error);
671}
672
674 LLDB_INSTRUMENT_VA(this, sb_frame, error);
675
676 std::unique_lock<std::recursive_mutex> lock;
677 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
678
679 if (!sb_frame.IsValid()) {
680 error.SetErrorString("passed invalid SBFrame object");
681 return;
682 }
683
684 StackFrameSP frame_sp(sb_frame.GetFrameSP());
685
686 if (!exe_ctx.HasThreadScope()) {
687 error.SetErrorString("this SBThread object is invalid");
688 return;
689 }
690
691 bool abort_other_plans = false;
692 bool stop_other_threads = false;
693 Thread *thread = exe_ctx.GetThreadPtr();
694 if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
695 error.SetErrorString("passed a frame from another thread");
696 return;
697 }
698
699 Status new_plan_status;
700 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
701 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
702 eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
703
704 if (new_plan_status.Success())
705 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
706 else
707 error.SetErrorString(new_plan_status.AsCString());
708}
709
710void SBThread::StepInstruction(bool step_over) {
711 LLDB_INSTRUMENT_VA(this, step_over);
712
713 SBError error; // Ignored
714 StepInstruction(step_over, error);
715}
716
718 LLDB_INSTRUMENT_VA(this, step_over, error);
719
720 std::unique_lock<std::recursive_mutex> lock;
721 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
722
723 if (!exe_ctx.HasThreadScope()) {
724 error.SetErrorString("this SBThread object is invalid");
725 return;
726 }
727
728 Thread *thread = exe_ctx.GetThreadPtr();
729 Status new_plan_status;
731 step_over, false, true, new_plan_status));
732
733 if (new_plan_status.Success())
734 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
735 else
736 error.SetErrorString(new_plan_status.AsCString());
737}
738
740 LLDB_INSTRUMENT_VA(this, addr);
741
742 SBError error; // Ignored
743 RunToAddress(addr, error);
744}
745
747 LLDB_INSTRUMENT_VA(this, addr, error);
748
749 std::unique_lock<std::recursive_mutex> lock;
750 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
751
752 if (!exe_ctx.HasThreadScope()) {
753 error.SetErrorString("this SBThread object is invalid");
754 return;
755 }
756
757 bool abort_other_plans = false;
758 bool stop_other_threads = true;
759
760 Address target_addr(addr);
761
762 Thread *thread = exe_ctx.GetThreadPtr();
763
764 Status new_plan_status;
766 abort_other_plans, target_addr, stop_other_threads, new_plan_status));
767
768 if (new_plan_status.Success())
769 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
770 else
771 error.SetErrorString(new_plan_status.AsCString());
772}
773
775 lldb::SBFileSpec &sb_file_spec, uint32_t line) {
776 LLDB_INSTRUMENT_VA(this, sb_frame, sb_file_spec, line);
777
778 SBError sb_error;
779 char path[PATH_MAX];
780
781 std::unique_lock<std::recursive_mutex> lock;
782 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
783
784 StackFrameSP frame_sp(sb_frame.GetFrameSP());
785
786 if (exe_ctx.HasThreadScope()) {
787 Target *target = exe_ctx.GetTargetPtr();
788 Thread *thread = exe_ctx.GetThreadPtr();
789
790 if (line == 0) {
791 sb_error.SetErrorString("invalid line argument");
792 return sb_error;
793 }
794
795 if (!frame_sp) {
796 // We don't want to run SelectMostRelevantFrame here, for instance if
797 // you called a sequence of StepOverUntil's you wouldn't want the
798 // frame changed out from under you because you stepped into a
799 // recognized frame.
801 if (!frame_sp)
802 frame_sp = thread->GetStackFrameAtIndex(0);
803 }
804
805 SymbolContext frame_sc;
806 if (!frame_sp) {
807 sb_error.SetErrorString("no valid frames in thread to step");
808 return sb_error;
809 }
810
811 // If we have a frame, get its line
812 frame_sc = frame_sp->GetSymbolContext(
813 eSymbolContextCompUnit | eSymbolContextFunction |
814 eSymbolContextLineEntry | eSymbolContextSymbol);
815
816 if (frame_sc.comp_unit == nullptr) {
817 sb_error.SetErrorStringWithFormat(
818 "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
819 return sb_error;
820 }
821
822 FileSpec step_file_spec;
823 if (sb_file_spec.IsValid()) {
824 // The file spec passed in was valid, so use it
825 step_file_spec = sb_file_spec.ref();
826 } else {
827 if (frame_sc.line_entry.IsValid())
828 step_file_spec = frame_sc.line_entry.GetFile();
829 else {
830 sb_error.SetErrorString("invalid file argument or no file for frame");
831 return sb_error;
832 }
833 }
834
835 // Grab the current function, then we will make sure the "until" address is
836 // within the function. We discard addresses that are out of the current
837 // function, and then if there are no addresses remaining, give an
838 // appropriate error message.
839
840 bool all_in_function = true;
841 AddressRange fun_range = frame_sc.function->GetAddressRange();
842
843 std::vector<addr_t> step_over_until_addrs;
844 const bool abort_other_plans = false;
845 const bool stop_other_threads = false;
846 // TODO: Handle SourceLocationSpec column information
847 SourceLocationSpec location_spec(
848 step_file_spec, line, /*column=*/std::nullopt, /*check_inlines=*/true,
849 /*exact_match=*/false);
850
851 SymbolContextList sc_list;
852 frame_sc.comp_unit->ResolveSymbolContext(location_spec,
853 eSymbolContextLineEntry, sc_list);
854 for (const SymbolContext &sc : sc_list) {
855 addr_t step_addr =
856 sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
857 if (step_addr != LLDB_INVALID_ADDRESS) {
858 if (fun_range.ContainsLoadAddress(step_addr, target))
859 step_over_until_addrs.push_back(step_addr);
860 else
861 all_in_function = false;
862 }
863 }
864
865 if (step_over_until_addrs.empty()) {
866 if (all_in_function) {
867 step_file_spec.GetPath(path, sizeof(path));
868 sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path,
869 line);
870 } else
871 sb_error.SetErrorString("step until target not in current function");
872 } else {
873 Status new_plan_status;
874 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
875 abort_other_plans, &step_over_until_addrs[0],
876 step_over_until_addrs.size(), stop_other_threads,
877 frame_sp->GetFrameIndex(), new_plan_status));
878
879 if (new_plan_status.Success())
880 sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
881 else
882 sb_error.SetErrorString(new_plan_status.AsCString());
883 }
884 } else {
885 sb_error.SetErrorString("this SBThread object is invalid");
886 }
887 return sb_error;
888}
889
890SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
891 LLDB_INSTRUMENT_VA(this, script_class_name);
892
893 return StepUsingScriptedThreadPlan(script_class_name, true);
894}
895
896SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
897 bool resume_immediately) {
898 LLDB_INSTRUMENT_VA(this, script_class_name, resume_immediately);
899
901 return StepUsingScriptedThreadPlan(script_class_name, no_data,
902 resume_immediately);
903}
904
905SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
906 SBStructuredData &args_data,
907 bool resume_immediately) {
908 LLDB_INSTRUMENT_VA(this, script_class_name, args_data, resume_immediately);
909
911
912 std::unique_lock<std::recursive_mutex> lock;
913 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
914
915 if (!exe_ctx.HasThreadScope()) {
916 error.SetErrorString("this SBThread object is invalid");
917 return error;
918 }
919
920 Thread *thread = exe_ctx.GetThreadPtr();
921 Status new_plan_status;
922 StructuredData::ObjectSP obj_sp = args_data.m_impl_up->GetObjectSP();
923
924 ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
925 false, script_class_name, obj_sp, false, new_plan_status);
926
927 if (new_plan_status.Fail()) {
928 error.SetErrorString(new_plan_status.AsCString());
929 return error;
930 }
931
932 if (!resume_immediately)
933 return error;
934
935 if (new_plan_status.Success())
936 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
937 else
938 error.SetErrorString(new_plan_status.AsCString());
939
940 return error;
941}
942
944 LLDB_INSTRUMENT_VA(this, file_spec, line);
945
946 SBError sb_error;
947
948 std::unique_lock<std::recursive_mutex> lock;
949 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
950
951 if (!exe_ctx.HasThreadScope()) {
952 sb_error.SetErrorString("this SBThread object is invalid");
953 return sb_error;
954 }
955
956 Thread *thread = exe_ctx.GetThreadPtr();
957
958 Status err = thread->JumpToLine(file_spec.ref(), line, true);
959 sb_error.SetError(err);
960 return sb_error;
961}
962
964 LLDB_INSTRUMENT_VA(this, frame, return_value);
965
966 SBError sb_error;
967
968 std::unique_lock<std::recursive_mutex> lock;
969 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
970
971 if (exe_ctx.HasThreadScope()) {
972 Thread *thread = exe_ctx.GetThreadPtr();
973 sb_error.SetError(
974 thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
975 }
976
977 return sb_error;
978}
979
981 LLDB_INSTRUMENT_VA(this);
982
983 SBError sb_error;
984
985 std::unique_lock<std::recursive_mutex> lock;
986 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
987
988 if (exe_ctx.HasThreadScope()) {
989 Thread *thread = exe_ctx.GetThreadPtr();
990 sb_error.SetError(thread->UnwindInnermostExpression());
991 if (sb_error.Success())
992 thread->SetSelectedFrameByIndex(0, false);
993 }
994
995 return sb_error;
996}
997
999 LLDB_INSTRUMENT_VA(this);
1000
1001 SBError error; // Ignored
1002 return Suspend(error);
1003}
1004
1007
1008 std::unique_lock<std::recursive_mutex> lock;
1009 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1010
1011 bool result = false;
1012 if (exe_ctx.HasThreadScope()) {
1013 Process::StopLocker stop_locker;
1014 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1016 result = true;
1017 } else {
1018 error.SetErrorString("process is running");
1019 }
1020 } else
1021 error.SetErrorString("this SBThread object is invalid");
1022 return result;
1023}
1024
1026 LLDB_INSTRUMENT_VA(this);
1027
1028 SBError error; // Ignored
1029 return Resume(error);
1030}
1031
1034
1035 std::unique_lock<std::recursive_mutex> lock;
1036 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1037
1038 bool result = false;
1039 if (exe_ctx.HasThreadScope()) {
1040 Process::StopLocker stop_locker;
1041 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1042 const bool override_suspend = true;
1043 exe_ctx.GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
1044 result = true;
1045 } else {
1046 error.SetErrorString("process is running");
1047 }
1048 } else
1049 error.SetErrorString("this SBThread object is invalid");
1050 return result;
1051}
1052
1054 LLDB_INSTRUMENT_VA(this);
1055
1056 std::unique_lock<std::recursive_mutex> lock;
1057 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1058
1059 if (exe_ctx.HasThreadScope())
1060 return exe_ctx.GetThreadPtr()->GetResumeState() == eStateSuspended;
1061 return false;
1062}
1063
1065 LLDB_INSTRUMENT_VA(this);
1066
1067 std::unique_lock<std::recursive_mutex> lock;
1068 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1069
1070 if (exe_ctx.HasThreadScope())
1071 return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
1072 return false;
1073}
1074
1076 LLDB_INSTRUMENT_VA(this);
1077
1078 SBProcess sb_process;
1079 std::unique_lock<std::recursive_mutex> lock;
1080 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1081
1082 if (exe_ctx.HasThreadScope()) {
1083 // Have to go up to the target so we can get a shared pointer to our
1084 // process...
1085 sb_process.SetSP(exe_ctx.GetProcessSP());
1086 }
1087
1088 return sb_process;
1089}
1090
1092 LLDB_INSTRUMENT_VA(this);
1093
1094 uint32_t num_frames = 0;
1095 std::unique_lock<std::recursive_mutex> lock;
1096 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1097
1098 if (exe_ctx.HasThreadScope()) {
1099 Process::StopLocker stop_locker;
1100 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1101 num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
1102 }
1103 }
1104
1105 return num_frames;
1106}
1107
1109 LLDB_INSTRUMENT_VA(this, idx);
1110
1111 SBFrame sb_frame;
1112 StackFrameSP frame_sp;
1113 std::unique_lock<std::recursive_mutex> lock;
1114 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1115
1116 if (exe_ctx.HasThreadScope()) {
1117 Process::StopLocker stop_locker;
1118 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1119 frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx);
1120 sb_frame.SetFrameSP(frame_sp);
1121 }
1122 }
1123
1124 return sb_frame;
1125}
1126
1128 LLDB_INSTRUMENT_VA(this);
1129
1130 SBFrame sb_frame;
1131 StackFrameSP frame_sp;
1132 std::unique_lock<std::recursive_mutex> lock;
1133 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1134
1135 if (exe_ctx.HasThreadScope()) {
1136 Process::StopLocker stop_locker;
1137 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1138 frame_sp =
1140 sb_frame.SetFrameSP(frame_sp);
1141 }
1142 }
1143
1144 return sb_frame;
1145}
1146
1148 LLDB_INSTRUMENT_VA(this, idx);
1149
1150 SBFrame sb_frame;
1151 StackFrameSP frame_sp;
1152 std::unique_lock<std::recursive_mutex> lock;
1153 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1154
1155 if (exe_ctx.HasThreadScope()) {
1156 Process::StopLocker stop_locker;
1157 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1158 Thread *thread = exe_ctx.GetThreadPtr();
1159 frame_sp = thread->GetStackFrameAtIndex(idx);
1160 if (frame_sp) {
1161 thread->SetSelectedFrame(frame_sp.get());
1162 sb_frame.SetFrameSP(frame_sp);
1163 }
1164 }
1165 }
1166
1167 return sb_frame;
1168}
1169
1171 LLDB_INSTRUMENT_VA(event);
1172
1173 return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr;
1174}
1175
1177 LLDB_INSTRUMENT_VA(event);
1178
1180}
1181
1183 LLDB_INSTRUMENT_VA(event);
1184
1186}
1187
1188bool SBThread::operator==(const SBThread &rhs) const {
1189 LLDB_INSTRUMENT_VA(this, rhs);
1190
1191 return m_opaque_sp->GetThreadSP().get() ==
1192 rhs.m_opaque_sp->GetThreadSP().get();
1193}
1194
1195bool SBThread::operator!=(const SBThread &rhs) const {
1196 LLDB_INSTRUMENT_VA(this, rhs);
1197
1198 return m_opaque_sp->GetThreadSP().get() !=
1199 rhs.m_opaque_sp->GetThreadSP().get();
1200}
1201
1202bool SBThread::GetStatus(SBStream &status) const {
1203 LLDB_INSTRUMENT_VA(this, status);
1204
1205 Stream &strm = status.ref();
1206
1207 std::unique_lock<std::recursive_mutex> lock;
1208 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1209
1210 if (exe_ctx.HasThreadScope()) {
1211 exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true,
1212 /*show_hidden=*/true);
1213 } else
1214 strm.PutCString("No status");
1215
1216 return true;
1217}
1218
1219bool SBThread::GetDescription(SBStream &description) const {
1220 LLDB_INSTRUMENT_VA(this, description);
1221
1222 return GetDescription(description, false);
1223}
1224
1225bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
1226 LLDB_INSTRUMENT_VA(this, description, stop_format);
1227
1228 Stream &strm = description.ref();
1229
1230 std::unique_lock<std::recursive_mutex> lock;
1231 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1232
1233 if (exe_ctx.HasThreadScope()) {
1235 strm, LLDB_INVALID_THREAD_ID, stop_format);
1236 } else
1237 strm.PutCString("No value");
1238
1239 return true;
1240}
1241
1243 SBStream &output) {
1244 Stream &strm = output.ref();
1245
1246 SBError error;
1247 if (!format) {
1248 error.SetErrorString("The provided SBFormat object is invalid");
1249 return error;
1250 }
1251
1252 std::unique_lock<std::recursive_mutex> lock;
1253 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1254
1255 if (exe_ctx.HasThreadScope()) {
1256 if (exe_ctx.GetThreadPtr()->DumpUsingFormat(
1257 strm, LLDB_INVALID_THREAD_ID, format.GetFormatEntrySP().get())) {
1258 return error;
1259 }
1260 }
1261
1262 error.SetErrorStringWithFormat(
1263 "It was not possible to generate a thread description with the given "
1264 "format string '%s'",
1265 format.GetFormatEntrySP()->string.c_str());
1266 return error;
1267}
1268
1270 LLDB_INSTRUMENT_VA(this, type);
1271
1272 std::unique_lock<std::recursive_mutex> lock;
1273 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1274 SBThread sb_origin_thread;
1275
1276 Process::StopLocker stop_locker;
1277 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1278 if (exe_ctx.HasThreadScope()) {
1279 ThreadSP real_thread(exe_ctx.GetThreadSP());
1280 if (real_thread) {
1281 ConstString type_const(type);
1282 Process *process = exe_ctx.GetProcessPtr();
1283 if (process) {
1284 SystemRuntime *runtime = process->GetSystemRuntime();
1285 if (runtime) {
1286 ThreadSP new_thread_sp(
1287 runtime->GetExtendedBacktraceThread(real_thread, type_const));
1288 if (new_thread_sp) {
1289 // Save this in the Process' ExtendedThreadList so a strong
1290 // pointer retains the object.
1291 process->GetExtendedThreadList().AddThread(new_thread_sp);
1292 sb_origin_thread.SetThread(new_thread_sp);
1293 }
1294 }
1295 }
1296 }
1297 }
1298 }
1299
1300 return sb_origin_thread;
1301}
1302
1304 LLDB_INSTRUMENT_VA(this);
1305
1306 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1307 if (thread_sp)
1308 return thread_sp->GetExtendedBacktraceOriginatingIndexID();
1309 return LLDB_INVALID_INDEX32;
1310}
1311
1313 LLDB_INSTRUMENT_VA(this);
1314
1315 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1316 if (!thread_sp)
1317 return SBValue();
1318
1319 return SBValue(thread_sp->GetCurrentException());
1320}
1321
1323 LLDB_INSTRUMENT_VA(this);
1324
1325 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1326 if (!thread_sp)
1327 return SBThread();
1328
1329 return SBThread(thread_sp->GetCurrentExceptionBacktrace());
1330}
1331
1333 LLDB_INSTRUMENT_VA(this);
1334
1335 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1336 if (thread_sp)
1337 return thread_sp->SafeToCallFunctions();
1338 return true;
1339}
1340
1341lldb::ThreadSP SBThread::GetSP() const { return m_opaque_sp->GetThreadSP(); }
1342
1344 return get();
1345}
1346
1348 return m_opaque_sp->GetThreadSP().get();
1349}
1350
1352 LLDB_INSTRUMENT_VA(this);
1353
1354 ThreadSP thread_sp = m_opaque_sp->GetThreadSP();
1355 if (!thread_sp)
1356 return SBValue();
1357 return thread_sp->GetSiginfoValue();
1358}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT()
#define LLDB_INSTRUMENT_VA(...)
bool Success() const
Definition: SBError.cpp:75
void SetErrorString(const char *err_str)
Definition: SBError.cpp:132
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:106
lldb_private::Status & ref()
Definition: SBError.cpp:167
lldb_private::Event * get() const
Definition: SBEvent.cpp:134
bool IsValid() const
Definition: SBFileSpec.cpp:76
const lldb_private::FileSpec & ref() const
Definition: SBFileSpec.cpp:162
Class that represents a format string that can be used to generate descriptions of objects like frame...
Definition: SBFormat.h:28
lldb::FormatEntrySP GetFormatEntrySP() const
Definition: SBFormat.cpp:44
bool IsValid() const
Definition: SBFrame.cpp:93
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition: SBFrame.cpp:89
lldb::SBThread GetThread() const
Definition: SBFrame.cpp:697
lldb::StackFrameSP GetFrameSP() const
Definition: SBFrame.cpp:85
void SetSP(const lldb::ProcessSP &process_sp)
Definition: SBProcess.cpp:108
void SetQueue(const lldb::QueueSP &queue_sp)
Definition: SBQueue.cpp:254
lldb_private::Stream & ref()
Definition: SBStream.cpp:177
StructuredDataImplUP m_impl_up
size_t GetStopDescription(char *dst_or_null, size_t dst_len)
Definition: SBThread.cpp:330
static const char * GetBroadcasterClassName()
Definition: SBThread.cpp:53
void StepInto(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition: SBThread.cpp:569
bool Suspend()
LLDB currently supports process centric debugging which means when any thread in a process stops,...
Definition: SBThread.cpp:998
const char * GetName() const
Definition: SBThread.cpp:400
const lldb::SBThread & operator=(const lldb::SBThread &rhs)
Definition: SBThread.cpp:77
lldb::SBFrame SetSelectedFrame(uint32_t frame_idx)
Definition: SBThread.cpp:1147
SBError UnwindInnermostExpression()
Definition: SBThread.cpp:980
SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx, lldb_private::ThreadPlan *new_plan)
Definition: SBThread.cpp:496
friend class SBThreadCollection
Definition: SBThread.h:244
bool IsValid() const
Definition: SBThread.cpp:109
uint32_t GetNumFrames()
Definition: SBThread.cpp:1091
const char * GetQueueName() const
Definition: SBThread.cpp:416
SBValue GetSiginfo()
Definition: SBThread.cpp:1351
void StepOut()
Definition: SBThread.cpp:631
uint32_t GetIndexID() const
Definition: SBThread.cpp:391
bool GetDescription(lldb::SBStream &description) const
Definition: SBThread.cpp:1219
static bool EventIsThreadEvent(const SBEvent &event)
Definition: SBThread.cpp:1170
lldb_private::Thread * operator->()
Definition: SBThread.cpp:1343
lldb_private::Thread * get()
Definition: SBThread.cpp:1347
void StepOutOfFrame(SBFrame &frame)
Definition: SBThread.cpp:666
bool GetStatus(lldb::SBStream &status) const
Definition: SBThread.cpp:1202
bool IsSuspended()
Definition: SBThread.cpp:1053
friend class SBValue
Definition: SBThread.h:241
static SBFrame GetStackFrameFromEvent(const SBEvent &event)
Definition: SBThread.cpp:1176
lldb::queue_id_t GetQueueID() const
Definition: SBThread.cpp:432
bool GetInfoItemByPathAsString(const char *path, SBStream &strm)
Definition: SBThread.cpp:449
lldb::SBFrame GetSelectedFrame()
Definition: SBThread.cpp:1127
bool operator!=(const lldb::SBThread &rhs) const
Definition: SBThread.cpp:1195
SBError StepUsingScriptedThreadPlan(const char *script_class_name)
Definition: SBThread.cpp:890
lldb::tid_t GetThreadID() const
Definition: SBThread.cpp:382
lldb::SBFrame GetFrameAtIndex(uint32_t idx)
Definition: SBThread.cpp:1108
uint32_t GetExtendedBacktraceOriginatingIndexID()
Definition: SBThread.cpp:1303
lldb::SBQueue GetQueue() const
Definition: SBThread.cpp:88
bool SafeToCallFunctions()
Definition: SBThread.cpp:1332
lldb::SBProcess GetProcess()
Definition: SBThread.cpp:1075
size_t GetStopReasonDataCount()
Get the number of words associated with the stop reason.
Definition: SBThread.cpp:153
void StepInstruction(bool step_over)
Definition: SBThread.cpp:710
SBThread GetCurrentExceptionBacktrace()
Definition: SBThread.cpp:1322
static SBThread GetThreadFromEvent(const SBEvent &event)
Definition: SBThread.cpp:1182
bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream)
Definition: SBThread.cpp:285
lldb::StopReason GetStopReason()
Definition: SBThread.cpp:136
SBValue GetStopReturnValue()
Definition: SBThread.cpp:358
void StepOver(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition: SBThread.cpp:530
bool IsStopped()
Definition: SBThread.cpp:1064
SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line)
Definition: SBThread.cpp:943
SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output)
Similar to GetDescription() but the format of the description can be configured via the format parame...
Definition: SBThread.cpp:1242
SBThreadCollection GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type)
Definition: SBThread.cpp:307
SBValue GetCurrentException()
Definition: SBThread.cpp:1312
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition: SBThread.cpp:378
lldb::ThreadSP GetSP() const
Definition: SBThread.cpp:1341
SBThread GetExtendedBacktraceThread(const char *type)
Definition: SBThread.cpp:1269
lldb::ExecutionContextRefSP m_opaque_sp
Definition: SBThread.h:259
void RunToAddress(lldb::addr_t addr)
Definition: SBThread.cpp:739
uint64_t GetStopReasonDataAtIndex(uint32_t idx)
Get information associated with a stop reason.
Definition: SBThread.cpp:213
SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value)
Definition: SBThread.cpp:963
bool operator==(const lldb::SBThread &rhs) const
Definition: SBThread.cpp:1188
SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec, uint32_t line)
Definition: SBThread.cpp:774
lldb::ValueObjectSP GetSP() const
Same as the protected version of GetSP that takes a locker, except that we make the locker locally in...
Definition: SBValue.cpp:1088
A section + offset based address range class.
Definition: AddressRange.h:25
bool ContainsLoadAddress(const Address &so_addr, Target *target) const
Check if a section offset so_addr when represented as a load address is contained within this object'...
A section + offset based address class.
Definition: Address.h:62
void ResolveSymbolContext(const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list, RealpathPrefixes *realpath_prefixes=nullptr)
Resolve symbol contexts by file and line.
A uniqued constant string class.
Definition: ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:188
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
Execution context objects refer to objects in the execution of the program that is being debugged.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool HasThreadScope() const
Returns true the ExecutionContext object contains a valid target, process, and thread.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
Target * GetTargetPtr() const
Returns a pointer to the target object.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
A file utility class.
Definition: FileSpec.h:56
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:367
const AddressRange & GetAddressRange()
Definition: Function.h:447
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
StopPointSiteList< lldb_private::BreakpointSite > & GetBreakpointSiteList()
Definition: Process.cpp:1610
ThreadList & GetThreadList()
Definition: Process.h:2227
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: Process.cpp:1382
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
Definition: Process.cpp:2870
ThreadList & GetExtendedThreadList()
Definition: Process.h:2238
Status ResumeSynchronous(Stream *stream)
Resume a process, and wait for it to stop.
Definition: Process.cpp:1399
ProcessRunLock & GetRunLock()
Definition: Process.cpp:5873
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1285
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
An error handling class.
Definition: Status.h:44
bool Fail() const
Test for error condition.
Definition: Status.cpp:180
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:129
bool Success() const
Test for success condition.
Definition: Status.cpp:278
static lldb::ValueObjectSP GetReturnValueObject(lldb::StopInfoSP &stop_info_sp)
Definition: StopInfo.cpp:1463
StopPointSiteSP FindByID(typename StopPointSite::SiteID site_id)
Returns a shared pointer to the site with id site_id.
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
std::shared_ptr< Object > ObjectSP
Defines a list of symbol context objects.
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
Function * function
The Function for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
LineEntry line_entry
The LineEntry for a given query.
bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error)
A plug-in interface definition class for system runtimes.
Definition: SystemRuntime.h:43
virtual lldb::ThreadSP GetExtendedBacktraceThread(lldb::ThreadSP thread, ConstString type)
Return a Thread which shows the origin of this thread's creation.
Debugger & GetDebugger()
Definition: Target.h:1069
void AddThread(const lldb::ThreadSP &thread_sp)
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
Definition: ThreadList.cpp:695
void SetOkayToDiscard(bool value)
Definition: ThreadPlan.h:412
bool SetIsControllingPlan(bool value)
Definition: ThreadPlan.h:404
static const ThreadEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: Thread.cpp:172
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
Definition: Thread.cpp:182
static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr)
Definition: Thread.cpp:199
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queue the plan used to step out of the function at the current PC of thread.
Definition: Thread.cpp:1321
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack.
Definition: Thread.cpp:1238
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Definition: Thread.h:408
virtual const char * GetQueueName()
Retrieve the Queue name for the queue currently using this Thread.
Definition: Thread.h:335
virtual lldb::ThreadPlanSP QueueThreadPlanForStepUntil(bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses, bool stop_others, uint32_t frame_idx, Status &status)
Definition: Thread.cpp:1377
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition: Thread.cpp:1472
StructuredData::ObjectSP GetExtendedInfo()
Retrieve a dictionary of information about this thread.
Definition: Thread.h:275
virtual lldb::ThreadPlanSP QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr, bool stop_other_threads, Status &status)
Gets the plan used to continue from the current PC.
Definition: Thread.cpp:1366
void SetResumeState(lldb::StateType state, bool override_suspend=false)
Sets the USER resume state for this thread.
Definition: Thread.h:187
lldb::StackFrameSP GetSelectedFrame(SelectMostRelevant select_most_relevant)
Definition: Thread.cpp:271
virtual const char * GetName()
Definition: Thread.h:283
static llvm::StringRef GetStaticBroadcasterClass()
Definition: Thread.cpp:214
virtual lldb::QueueSP GetQueue()
Retrieve the Queue for this thread, if any.
Definition: Thread.h:361
lldb::StateType GetResumeState() const
Gets the USER resume state for this thread.
Definition: Thread.h:201
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
Definition: Thread.cpp:279
void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format)
Definition: Thread.cpp:1640
virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, const char *step_in_target, lldb::RunMode stop_other_threads, Status &status, LazyBool step_in_avoids_code_without_debug_info=eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queues the plan used to step through an address range, stepping into functions.
Definition: Thread.cpp:1291
lldb::StateType GetState() const
Definition: Thread.cpp:565
virtual lldb::ThreadPlanSP QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, StructuredData::ObjectSP extra_args_sp, bool stop_other_threads, Status &status)
Definition: Thread.cpp:1387
bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast=false)
Definition: Thread.cpp:288
lldb::StopReason GetStopReason()
Definition: Thread.cpp:441
virtual lldb::ThreadPlanSP QueueThreadPlanForStepSingleInstruction(bool step_over, bool abort_other_plans, bool stop_other_threads, Status &status)
Queues the plan used to step one instruction from the current PC of thread.
Definition: Thread.cpp:1255
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
Definition: Thread.cpp:1562
bool DumpUsingFormat(Stream &strm, uint32_t frame_idx, const FormatEntity::Entry *format)
Print a description of this thread using the provided thread format.
Definition: Thread.cpp:1619
virtual lldb::queue_id_t GetQueueID()
Retrieve the Queue ID for the queue currently using this Thread.
Definition: Thread.h:323
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queues the plan used to step through an address range, stepping over function calls.
Definition: Thread.cpp:1264
std::string GetStopDescription()
Definition: Thread.cpp:576
lldb::StopInfoSP GetStopInfo()
Definition: Thread.cpp:347
virtual uint32_t GetStackFrameCount()
GetStackFrameCount can be expensive.
Definition: Thread.h:404
size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format, bool show_hidden, bool only_stacks=false)
Definition: Thread.cpp:1749
#define LLDB_INVALID_QUEUE_ID
Definition: lldb-defines.h:96
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:37
#define LLDB_INVALID_LINE_NUMBER
Definition: lldb-defines.h:94
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:90
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:83
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
@ DoNoSelectMostRelevantFrame
@ SelectMostRelevantFrame
A class that represents a running process on the host machine.
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
Definition: State.cpp:89
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
Definition: lldb-forward.h:449
std::shared_ptr< lldb_private::Queue > QueueSP
Definition: lldb-forward.h:396
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:420
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
Definition: lldb-forward.h:321
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
Definition: lldb-forward.h:322
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:446
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:480
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
int32_t break_id_t
Definition: lldb-types.h:86
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:387
InstrumentationRuntimeType
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
Definition: lldb-forward.h:427
uint64_t addr_t
Definition: lldb-types.h:80
StopReason
Thread stop reasons.
@ eStopReasonInstrumentation
@ eStopReasonPlanComplete
@ eStopReasonTrace
@ eStopReasonBreakpoint
@ eStopReasonExec
Program was re-exec'ed.
@ eStopReasonVForkDone
@ eStopReasonInterrupt
Thread requested interrupt.
@ eStopReasonProcessorTrace
@ eStopReasonThreadExiting
@ eStopReasonException
@ eStopReasonInvalid
@ eStopReasonWatchpoint
@ eStopReasonVFork
@ eStopReasonSignal
@ eStructuredDataTypeFloat
@ eStructuredDataTypeInteger
@ eStructuredDataTypeNull
@ eStructuredDataTypeBoolean
@ eStructuredDataTypeString
RunMode
Thread Run Modes.
uint64_t tid_t
Definition: lldb-types.h:84
uint64_t queue_id_t
Definition: lldb-types.h:90
bool IsValid() const
Check if a line entry object is valid.
Definition: LineEntry.cpp:35
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:137
const FileSpec & GetFile() const
Helper to access the file.
Definition: LineEntry.h:134
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
#define PATH_MAX