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
198 case eStopReasonFork:
199 return 1;
200
201 case eStopReasonVFork:
202 return 1;
203 }
204 }
205 }
206 }
207 return 0;
208}
209
211 LLDB_INSTRUMENT_VA(this, idx);
212
213 std::unique_lock<std::recursive_mutex> lock;
214 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
215
216 if (exe_ctx.HasThreadScope()) {
217 Process::StopLocker stop_locker;
218 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
219 Thread *thread = exe_ctx.GetThreadPtr();
220 StopInfoSP stop_info_sp = thread->GetStopInfo();
221 if (stop_info_sp) {
222 StopReason reason = stop_info_sp->GetStopReason();
223 switch (reason) {
225 case eStopReasonNone:
226 case eStopReasonTrace:
227 case eStopReasonExec:
233 // There is no data for these stop reasons.
234 return 0;
235
237 break_id_t site_id = stop_info_sp->GetValue();
238 lldb::BreakpointSiteSP bp_site_sp(
240 site_id));
241 if (bp_site_sp) {
242 uint32_t bp_index = idx / 2;
243 BreakpointLocationSP bp_loc_sp(
244 bp_site_sp->GetConstituentAtIndex(bp_index));
245 if (bp_loc_sp) {
246 if (idx & 1) {
247 // Odd idx, return the breakpoint location ID
248 return bp_loc_sp->GetID();
249 } else {
250 // Even idx, return the breakpoint ID
251 return bp_loc_sp->GetBreakpoint().GetID();
252 }
253 }
254 }
256 } break;
257
259 return stop_info_sp->GetValue();
260
262 return stop_info_sp->GetValue();
263
265 return stop_info_sp->GetValue();
266
267 case eStopReasonFork:
268 return stop_info_sp->GetValue();
269
270 case eStopReasonVFork:
271 return stop_info_sp->GetValue();
272 }
273 }
274 }
275 }
276 return 0;
277}
278
280 LLDB_INSTRUMENT_VA(this, stream);
281
282 Stream &strm = stream.ref();
283
284 std::unique_lock<std::recursive_mutex> lock;
285 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
286
287 if (!exe_ctx.HasThreadScope())
288 return false;
289
290 StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
291 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
292 if (!info)
293 return false;
294
295 info->Dump(strm);
296
297 return true;
298}
299
302 LLDB_INSTRUMENT_VA(this, type);
303
304 SBThreadCollection threads;
305
306 std::unique_lock<std::recursive_mutex> lock;
307 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
308
309 if (!exe_ctx.HasThreadScope())
310 return SBThreadCollection();
311
312 ProcessSP process_sp = exe_ctx.GetProcessSP();
313
314 StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
315 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
316 if (!info)
317 return threads;
318
319 threads = process_sp->GetInstrumentationRuntime(type)
320 ->GetBacktracesFromExtendedStopInfo(info);
321 return threads;
322}
323
324size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
325 LLDB_INSTRUMENT_VA(this, dst, dst_len);
326
327 std::unique_lock<std::recursive_mutex> lock;
328 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
329
330 if (dst)
331 *dst = 0;
332
333 if (!exe_ctx.HasThreadScope())
334 return 0;
335
336 Process::StopLocker stop_locker;
337 if (!stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
338 return 0;
339
340 std::string thread_stop_desc = exe_ctx.GetThreadPtr()->GetStopDescription();
341 if (thread_stop_desc.empty())
342 return 0;
343
344 if (dst)
345 return ::snprintf(dst, dst_len, "%s", thread_stop_desc.c_str()) + 1;
346
347 // NULL dst passed in, return the length needed to contain the
348 // description.
349 return thread_stop_desc.size() + 1; // Include the NULL byte for size
350}
351
353 LLDB_INSTRUMENT_VA(this);
354
355 ValueObjectSP return_valobj_sp;
356 std::unique_lock<std::recursive_mutex> lock;
357 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
358
359 if (exe_ctx.HasThreadScope()) {
360 Process::StopLocker stop_locker;
361 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
362 StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
363 if (stop_info_sp) {
364 return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
365 }
366 }
367 }
368
369 return SBValue(return_valobj_sp);
370}
371
372void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
373 m_opaque_sp->SetThreadSP(lldb_object_sp);
374}
375
377 LLDB_INSTRUMENT_VA(this);
378
379 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
380 if (thread_sp)
381 return thread_sp->GetID();
383}
384
385uint32_t SBThread::GetIndexID() const {
386 LLDB_INSTRUMENT_VA(this);
387
388 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
389 if (thread_sp)
390 return thread_sp->GetIndexID();
392}
393
394const char *SBThread::GetName() const {
395 LLDB_INSTRUMENT_VA(this);
396
397 std::unique_lock<std::recursive_mutex> lock;
398 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
399
400 if (!exe_ctx.HasThreadScope())
401 return nullptr;
402
403 Process::StopLocker stop_locker;
404 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
405 return ConstString(exe_ctx.GetThreadPtr()->GetName()).GetCString();
406
407 return nullptr;
408}
409
410const char *SBThread::GetQueueName() const {
411 LLDB_INSTRUMENT_VA(this);
412
413 std::unique_lock<std::recursive_mutex> lock;
414 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
415
416 if (!exe_ctx.HasThreadScope())
417 return nullptr;
418
419 Process::StopLocker stop_locker;
420 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
421 return ConstString(exe_ctx.GetThreadPtr()->GetQueueName()).GetCString();
422
423 return nullptr;
424}
425
427 LLDB_INSTRUMENT_VA(this);
428
430 std::unique_lock<std::recursive_mutex> lock;
431 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
432
433 if (exe_ctx.HasThreadScope()) {
434 Process::StopLocker stop_locker;
435 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
436 id = exe_ctx.GetThreadPtr()->GetQueueID();
437 }
438 }
439
440 return id;
441}
442
443bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
444 LLDB_INSTRUMENT_VA(this, path, strm);
445
446 bool success = false;
447 std::unique_lock<std::recursive_mutex> lock;
448 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
449
450 if (exe_ctx.HasThreadScope()) {
451 Process::StopLocker stop_locker;
452 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
453 Thread *thread = exe_ctx.GetThreadPtr();
454 StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
455 if (info_root_sp) {
457 info_root_sp->GetObjectForDotSeparatedPath(path);
458 if (node) {
459 if (node->GetType() == eStructuredDataTypeString) {
460 strm.ref() << node->GetAsString()->GetValue();
461 success = true;
462 }
463 if (node->GetType() == eStructuredDataTypeInteger) {
464 strm.Printf("0x%" PRIx64, node->GetUnsignedIntegerValue());
465 success = true;
466 }
467 if (node->GetType() == eStructuredDataTypeFloat) {
468 strm.Printf("0x%f", node->GetAsFloat()->GetValue());
469 success = true;
470 }
471 if (node->GetType() == eStructuredDataTypeBoolean) {
472 if (node->GetAsBoolean()->GetValue())
473 strm.Printf("true");
474 else
475 strm.Printf("false");
476 success = true;
477 }
478 if (node->GetType() == eStructuredDataTypeNull) {
479 strm.Printf("null");
480 success = true;
481 }
482 }
483 }
484 }
485 }
486
487 return success;
488}
489
491 ThreadPlan *new_plan) {
492 SBError sb_error;
493
494 Process *process = exe_ctx.GetProcessPtr();
495 if (!process) {
496 sb_error.SetErrorString("No process in SBThread::ResumeNewPlan");
497 return sb_error;
498 }
499
500 Thread *thread = exe_ctx.GetThreadPtr();
501 if (!thread) {
502 sb_error.SetErrorString("No thread in SBThread::ResumeNewPlan");
503 return sb_error;
504 }
505
506 // User level plans should be Controlling Plans so they can be interrupted,
507 // other plans executed, and then a "continue" will resume the plan.
508 if (new_plan != nullptr) {
509 new_plan->SetIsControllingPlan(true);
510 new_plan->SetOkayToDiscard(false);
511 }
512
513 // Why do we need to set the current thread by ID here???
514 process->GetThreadList().SetSelectedThreadByID(thread->GetID());
515
516 if (process->GetTarget().GetDebugger().GetAsyncExecution())
517 sb_error.ref() = process->Resume();
518 else
519 sb_error.ref() = process->ResumeSynchronous(nullptr);
520
521 return sb_error;
522}
523
524void SBThread::StepOver(lldb::RunMode stop_other_threads) {
525 LLDB_INSTRUMENT_VA(this, stop_other_threads);
526
527 SBError error; // Ignored
528 StepOver(stop_other_threads, error);
529}
530
531void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
532 LLDB_INSTRUMENT_VA(this, stop_other_threads, error);
533
534 std::unique_lock<std::recursive_mutex> lock;
535 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
536
537 if (!exe_ctx.HasThreadScope()) {
538 error.SetErrorString("this SBThread object is invalid");
539 return;
540 }
541
542 Thread *thread = exe_ctx.GetThreadPtr();
543 bool abort_other_plans = false;
544 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
545
546 Status new_plan_status;
547 ThreadPlanSP new_plan_sp;
548 if (frame_sp) {
549 if (frame_sp->HasDebugInformation()) {
550 const LazyBool avoid_no_debug = eLazyBoolCalculate;
551 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
552 new_plan_sp = thread->QueueThreadPlanForStepOverRange(
553 abort_other_plans, sc.line_entry, sc, stop_other_threads,
554 new_plan_status, avoid_no_debug);
555 } else {
556 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
557 true, abort_other_plans, stop_other_threads, new_plan_status);
558 }
559 }
560 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
561}
562
563void SBThread::StepInto(lldb::RunMode stop_other_threads) {
564 LLDB_INSTRUMENT_VA(this, stop_other_threads);
565
566 StepInto(nullptr, stop_other_threads);
567}
568
569void SBThread::StepInto(const char *target_name,
570 lldb::RunMode stop_other_threads) {
571 LLDB_INSTRUMENT_VA(this, target_name, stop_other_threads);
572
573 SBError error; // Ignored
574 StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
575}
576
577void SBThread::StepInto(const char *target_name, uint32_t end_line,
578 SBError &error, lldb::RunMode stop_other_threads) {
579 LLDB_INSTRUMENT_VA(this, target_name, end_line, error, stop_other_threads);
580
581 std::unique_lock<std::recursive_mutex> lock;
582 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
583
584 if (!exe_ctx.HasThreadScope()) {
585 error.SetErrorString("this SBThread object is invalid");
586 return;
587 }
588
589 bool abort_other_plans = false;
590
591 Thread *thread = exe_ctx.GetThreadPtr();
592 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
593 ThreadPlanSP new_plan_sp;
594 Status new_plan_status;
595
596 if (frame_sp && frame_sp->HasDebugInformation()) {
597 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
598 AddressRange range;
599 if (end_line == LLDB_INVALID_LINE_NUMBER)
600 range = sc.line_entry.range;
601 else {
602 if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
603 return;
604 }
605
606 const LazyBool step_out_avoids_code_without_debug_info =
608 const LazyBool step_in_avoids_code_without_debug_info =
610 new_plan_sp = thread->QueueThreadPlanForStepInRange(
611 abort_other_plans, range, sc, target_name, stop_other_threads,
612 new_plan_status, step_in_avoids_code_without_debug_info,
613 step_out_avoids_code_without_debug_info);
614 } else {
615 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
616 false, abort_other_plans, stop_other_threads, new_plan_status);
617 }
618
619 if (new_plan_status.Success())
620 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
621 else
622 error.SetErrorString(new_plan_status.AsCString());
623}
624
626 LLDB_INSTRUMENT_VA(this);
627
628 SBError error; // Ignored
629 StepOut(error);
630}
631
634
635 std::unique_lock<std::recursive_mutex> lock;
636 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
637
638 if (!exe_ctx.HasThreadScope()) {
639 error.SetErrorString("this SBThread object is invalid");
640 return;
641 }
642
643 bool abort_other_plans = false;
644 bool stop_other_threads = false;
645
646 Thread *thread = exe_ctx.GetThreadPtr();
647
648 const LazyBool avoid_no_debug = eLazyBoolCalculate;
649 Status new_plan_status;
650 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
651 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
652 eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
653
654 if (new_plan_status.Success())
655 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
656 else
657 error.SetErrorString(new_plan_status.AsCString());
658}
659
661 LLDB_INSTRUMENT_VA(this, sb_frame);
662
663 SBError error; // Ignored
664 StepOutOfFrame(sb_frame, error);
665}
666
668 LLDB_INSTRUMENT_VA(this, sb_frame, error);
669
670 std::unique_lock<std::recursive_mutex> lock;
671 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
672
673 if (!sb_frame.IsValid()) {
674 error.SetErrorString("passed invalid SBFrame object");
675 return;
676 }
677
678 StackFrameSP frame_sp(sb_frame.GetFrameSP());
679
680 if (!exe_ctx.HasThreadScope()) {
681 error.SetErrorString("this SBThread object is invalid");
682 return;
683 }
684
685 bool abort_other_plans = false;
686 bool stop_other_threads = false;
687 Thread *thread = exe_ctx.GetThreadPtr();
688 if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
689 error.SetErrorString("passed a frame from another thread");
690 return;
691 }
692
693 Status new_plan_status;
694 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
695 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
696 eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
697
698 if (new_plan_status.Success())
699 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
700 else
701 error.SetErrorString(new_plan_status.AsCString());
702}
703
704void SBThread::StepInstruction(bool step_over) {
705 LLDB_INSTRUMENT_VA(this, step_over);
706
707 SBError error; // Ignored
708 StepInstruction(step_over, error);
709}
710
712 LLDB_INSTRUMENT_VA(this, step_over, error);
713
714 std::unique_lock<std::recursive_mutex> lock;
715 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
716
717 if (!exe_ctx.HasThreadScope()) {
718 error.SetErrorString("this SBThread object is invalid");
719 return;
720 }
721
722 Thread *thread = exe_ctx.GetThreadPtr();
723 Status new_plan_status;
725 step_over, true, true, new_plan_status));
726
727 if (new_plan_status.Success())
728 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
729 else
730 error.SetErrorString(new_plan_status.AsCString());
731}
732
734 LLDB_INSTRUMENT_VA(this, addr);
735
736 SBError error; // Ignored
737 RunToAddress(addr, error);
738}
739
741 LLDB_INSTRUMENT_VA(this, addr, error);
742
743 std::unique_lock<std::recursive_mutex> lock;
744 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
745
746 if (!exe_ctx.HasThreadScope()) {
747 error.SetErrorString("this SBThread object is invalid");
748 return;
749 }
750
751 bool abort_other_plans = false;
752 bool stop_other_threads = true;
753
754 Address target_addr(addr);
755
756 Thread *thread = exe_ctx.GetThreadPtr();
757
758 Status new_plan_status;
760 abort_other_plans, target_addr, stop_other_threads, new_plan_status));
761
762 if (new_plan_status.Success())
763 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
764 else
765 error.SetErrorString(new_plan_status.AsCString());
766}
767
769 lldb::SBFileSpec &sb_file_spec, uint32_t line) {
770 LLDB_INSTRUMENT_VA(this, sb_frame, sb_file_spec, line);
771
772 SBError sb_error;
773 char path[PATH_MAX];
774
775 std::unique_lock<std::recursive_mutex> lock;
776 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
777
778 StackFrameSP frame_sp(sb_frame.GetFrameSP());
779
780 if (exe_ctx.HasThreadScope()) {
781 Target *target = exe_ctx.GetTargetPtr();
782 Thread *thread = exe_ctx.GetThreadPtr();
783
784 if (line == 0) {
785 sb_error.SetErrorString("invalid line argument");
786 return sb_error;
787 }
788
789 if (!frame_sp) {
790 // We don't want to run SelectMostRelevantFrame here, for instance if
791 // you called a sequence of StepOverUntil's you wouldn't want the
792 // frame changed out from under you because you stepped into a
793 // recognized frame.
795 if (!frame_sp)
796 frame_sp = thread->GetStackFrameAtIndex(0);
797 }
798
799 SymbolContext frame_sc;
800 if (!frame_sp) {
801 sb_error.SetErrorString("no valid frames in thread to step");
802 return sb_error;
803 }
804
805 // If we have a frame, get its line
806 frame_sc = frame_sp->GetSymbolContext(
807 eSymbolContextCompUnit | eSymbolContextFunction |
808 eSymbolContextLineEntry | eSymbolContextSymbol);
809
810 if (frame_sc.comp_unit == nullptr) {
811 sb_error.SetErrorStringWithFormat(
812 "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
813 return sb_error;
814 }
815
816 FileSpec step_file_spec;
817 if (sb_file_spec.IsValid()) {
818 // The file spec passed in was valid, so use it
819 step_file_spec = sb_file_spec.ref();
820 } else {
821 if (frame_sc.line_entry.IsValid())
822 step_file_spec = frame_sc.line_entry.GetFile();
823 else {
824 sb_error.SetErrorString("invalid file argument or no file for frame");
825 return sb_error;
826 }
827 }
828
829 // Grab the current function, then we will make sure the "until" address is
830 // within the function. We discard addresses that are out of the current
831 // function, and then if there are no addresses remaining, give an
832 // appropriate error message.
833
834 bool all_in_function = true;
835 AddressRange fun_range = frame_sc.function->GetAddressRange();
836
837 std::vector<addr_t> step_over_until_addrs;
838 const bool abort_other_plans = false;
839 const bool stop_other_threads = false;
840 // TODO: Handle SourceLocationSpec column information
841 SourceLocationSpec location_spec(
842 step_file_spec, line, /*column=*/std::nullopt, /*check_inlines=*/true,
843 /*exact_match=*/false);
844
845 SymbolContextList sc_list;
846 frame_sc.comp_unit->ResolveSymbolContext(location_spec,
847 eSymbolContextLineEntry, sc_list);
848 for (const SymbolContext &sc : sc_list) {
849 addr_t step_addr =
850 sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
851 if (step_addr != LLDB_INVALID_ADDRESS) {
852 if (fun_range.ContainsLoadAddress(step_addr, target))
853 step_over_until_addrs.push_back(step_addr);
854 else
855 all_in_function = false;
856 }
857 }
858
859 if (step_over_until_addrs.empty()) {
860 if (all_in_function) {
861 step_file_spec.GetPath(path, sizeof(path));
862 sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path,
863 line);
864 } else
865 sb_error.SetErrorString("step until target not in current function");
866 } else {
867 Status new_plan_status;
868 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
869 abort_other_plans, &step_over_until_addrs[0],
870 step_over_until_addrs.size(), stop_other_threads,
871 frame_sp->GetFrameIndex(), new_plan_status));
872
873 if (new_plan_status.Success())
874 sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
875 else
876 sb_error.SetErrorString(new_plan_status.AsCString());
877 }
878 } else {
879 sb_error.SetErrorString("this SBThread object is invalid");
880 }
881 return sb_error;
882}
883
884SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
885 LLDB_INSTRUMENT_VA(this, script_class_name);
886
887 return StepUsingScriptedThreadPlan(script_class_name, true);
888}
889
890SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
891 bool resume_immediately) {
892 LLDB_INSTRUMENT_VA(this, script_class_name, resume_immediately);
893
895 return StepUsingScriptedThreadPlan(script_class_name, no_data,
896 resume_immediately);
897}
898
899SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
900 SBStructuredData &args_data,
901 bool resume_immediately) {
902 LLDB_INSTRUMENT_VA(this, script_class_name, args_data, resume_immediately);
903
905
906 std::unique_lock<std::recursive_mutex> lock;
907 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
908
909 if (!exe_ctx.HasThreadScope()) {
910 error.SetErrorString("this SBThread object is invalid");
911 return error;
912 }
913
914 Thread *thread = exe_ctx.GetThreadPtr();
915 Status new_plan_status;
916 StructuredData::ObjectSP obj_sp = args_data.m_impl_up->GetObjectSP();
917
918 ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
919 false, script_class_name, obj_sp, false, new_plan_status);
920
921 if (new_plan_status.Fail()) {
922 error.SetErrorString(new_plan_status.AsCString());
923 return error;
924 }
925
926 if (!resume_immediately)
927 return error;
928
929 if (new_plan_status.Success())
930 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
931 else
932 error.SetErrorString(new_plan_status.AsCString());
933
934 return error;
935}
936
938 LLDB_INSTRUMENT_VA(this, file_spec, line);
939
940 SBError sb_error;
941
942 std::unique_lock<std::recursive_mutex> lock;
943 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
944
945 if (!exe_ctx.HasThreadScope()) {
946 sb_error.SetErrorString("this SBThread object is invalid");
947 return sb_error;
948 }
949
950 Thread *thread = exe_ctx.GetThreadPtr();
951
952 Status err = thread->JumpToLine(file_spec.ref(), line, true);
953 sb_error.SetError(err);
954 return sb_error;
955}
956
958 LLDB_INSTRUMENT_VA(this, frame, return_value);
959
960 SBError sb_error;
961
962 std::unique_lock<std::recursive_mutex> lock;
963 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
964
965 if (exe_ctx.HasThreadScope()) {
966 Thread *thread = exe_ctx.GetThreadPtr();
967 sb_error.SetError(
968 thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
969 }
970
971 return sb_error;
972}
973
975 LLDB_INSTRUMENT_VA(this);
976
977 SBError sb_error;
978
979 std::unique_lock<std::recursive_mutex> lock;
980 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
981
982 if (exe_ctx.HasThreadScope()) {
983 Thread *thread = exe_ctx.GetThreadPtr();
984 sb_error.SetError(thread->UnwindInnermostExpression());
985 if (sb_error.Success())
986 thread->SetSelectedFrameByIndex(0, false);
987 }
988
989 return sb_error;
990}
991
993 LLDB_INSTRUMENT_VA(this);
994
995 SBError error; // Ignored
996 return Suspend(error);
997}
998
1001
1002 std::unique_lock<std::recursive_mutex> lock;
1003 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1004
1005 bool result = false;
1006 if (exe_ctx.HasThreadScope()) {
1007 Process::StopLocker stop_locker;
1008 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1010 result = true;
1011 } else {
1012 error.SetErrorString("process is running");
1013 }
1014 } else
1015 error.SetErrorString("this SBThread object is invalid");
1016 return result;
1017}
1018
1020 LLDB_INSTRUMENT_VA(this);
1021
1022 SBError error; // Ignored
1023 return Resume(error);
1024}
1025
1028
1029 std::unique_lock<std::recursive_mutex> lock;
1030 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1031
1032 bool result = false;
1033 if (exe_ctx.HasThreadScope()) {
1034 Process::StopLocker stop_locker;
1035 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1036 const bool override_suspend = true;
1037 exe_ctx.GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
1038 result = true;
1039 } else {
1040 error.SetErrorString("process is running");
1041 }
1042 } else
1043 error.SetErrorString("this SBThread object is invalid");
1044 return result;
1045}
1046
1048 LLDB_INSTRUMENT_VA(this);
1049
1050 std::unique_lock<std::recursive_mutex> lock;
1051 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1052
1053 if (exe_ctx.HasThreadScope())
1054 return exe_ctx.GetThreadPtr()->GetResumeState() == eStateSuspended;
1055 return false;
1056}
1057
1059 LLDB_INSTRUMENT_VA(this);
1060
1061 std::unique_lock<std::recursive_mutex> lock;
1062 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1063
1064 if (exe_ctx.HasThreadScope())
1065 return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
1066 return false;
1067}
1068
1070 LLDB_INSTRUMENT_VA(this);
1071
1072 SBProcess sb_process;
1073 std::unique_lock<std::recursive_mutex> lock;
1074 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1075
1076 if (exe_ctx.HasThreadScope()) {
1077 // Have to go up to the target so we can get a shared pointer to our
1078 // process...
1079 sb_process.SetSP(exe_ctx.GetProcessSP());
1080 }
1081
1082 return sb_process;
1083}
1084
1086 LLDB_INSTRUMENT_VA(this);
1087
1088 uint32_t num_frames = 0;
1089 std::unique_lock<std::recursive_mutex> lock;
1090 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1091
1092 if (exe_ctx.HasThreadScope()) {
1093 Process::StopLocker stop_locker;
1094 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1095 num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
1096 }
1097 }
1098
1099 return num_frames;
1100}
1101
1103 LLDB_INSTRUMENT_VA(this, idx);
1104
1105 SBFrame sb_frame;
1106 StackFrameSP frame_sp;
1107 std::unique_lock<std::recursive_mutex> lock;
1108 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1109
1110 if (exe_ctx.HasThreadScope()) {
1111 Process::StopLocker stop_locker;
1112 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1113 frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx);
1114 sb_frame.SetFrameSP(frame_sp);
1115 }
1116 }
1117
1118 return sb_frame;
1119}
1120
1122 LLDB_INSTRUMENT_VA(this);
1123
1124 SBFrame sb_frame;
1125 StackFrameSP frame_sp;
1126 std::unique_lock<std::recursive_mutex> lock;
1127 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1128
1129 if (exe_ctx.HasThreadScope()) {
1130 Process::StopLocker stop_locker;
1131 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1132 frame_sp =
1134 sb_frame.SetFrameSP(frame_sp);
1135 }
1136 }
1137
1138 return sb_frame;
1139}
1140
1142 LLDB_INSTRUMENT_VA(this, idx);
1143
1144 SBFrame sb_frame;
1145 StackFrameSP frame_sp;
1146 std::unique_lock<std::recursive_mutex> lock;
1147 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1148
1149 if (exe_ctx.HasThreadScope()) {
1150 Process::StopLocker stop_locker;
1151 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1152 Thread *thread = exe_ctx.GetThreadPtr();
1153 frame_sp = thread->GetStackFrameAtIndex(idx);
1154 if (frame_sp) {
1155 thread->SetSelectedFrame(frame_sp.get());
1156 sb_frame.SetFrameSP(frame_sp);
1157 }
1158 }
1159 }
1160
1161 return sb_frame;
1162}
1163
1165 LLDB_INSTRUMENT_VA(event);
1166
1167 return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr;
1168}
1169
1171 LLDB_INSTRUMENT_VA(event);
1172
1174}
1175
1177 LLDB_INSTRUMENT_VA(event);
1178
1180}
1181
1182bool SBThread::operator==(const SBThread &rhs) const {
1183 LLDB_INSTRUMENT_VA(this, rhs);
1184
1185 return m_opaque_sp->GetThreadSP().get() ==
1186 rhs.m_opaque_sp->GetThreadSP().get();
1187}
1188
1189bool SBThread::operator!=(const SBThread &rhs) const {
1190 LLDB_INSTRUMENT_VA(this, rhs);
1191
1192 return m_opaque_sp->GetThreadSP().get() !=
1193 rhs.m_opaque_sp->GetThreadSP().get();
1194}
1195
1196bool SBThread::GetStatus(SBStream &status) const {
1197 LLDB_INSTRUMENT_VA(this, status);
1198
1199 Stream &strm = status.ref();
1200
1201 std::unique_lock<std::recursive_mutex> lock;
1202 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1203
1204 if (exe_ctx.HasThreadScope()) {
1205 exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true);
1206 } else
1207 strm.PutCString("No status");
1208
1209 return true;
1210}
1211
1212bool SBThread::GetDescription(SBStream &description) const {
1213 LLDB_INSTRUMENT_VA(this, description);
1214
1215 return GetDescription(description, false);
1216}
1217
1218bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
1219 LLDB_INSTRUMENT_VA(this, description, stop_format);
1220
1221 Stream &strm = description.ref();
1222
1223 std::unique_lock<std::recursive_mutex> lock;
1224 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1225
1226 if (exe_ctx.HasThreadScope()) {
1228 strm, LLDB_INVALID_THREAD_ID, stop_format);
1229 } else
1230 strm.PutCString("No value");
1231
1232 return true;
1233}
1234
1236 SBStream &output) {
1237 Stream &strm = output.ref();
1238
1239 SBError error;
1240 if (!format) {
1241 error.SetErrorString("The provided SBFormat object is invalid");
1242 return error;
1243 }
1244
1245 std::unique_lock<std::recursive_mutex> lock;
1246 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1247
1248 if (exe_ctx.HasThreadScope()) {
1249 if (exe_ctx.GetThreadPtr()->DumpUsingFormat(
1250 strm, LLDB_INVALID_THREAD_ID, format.GetFormatEntrySP().get())) {
1251 return error;
1252 }
1253 }
1254
1255 error.SetErrorStringWithFormat(
1256 "It was not possible to generate a thread description with the given "
1257 "format string '%s'",
1258 format.GetFormatEntrySP()->string.c_str());
1259 return error;
1260}
1261
1263 LLDB_INSTRUMENT_VA(this, type);
1264
1265 std::unique_lock<std::recursive_mutex> lock;
1266 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1267 SBThread sb_origin_thread;
1268
1269 Process::StopLocker stop_locker;
1270 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1271 if (exe_ctx.HasThreadScope()) {
1272 ThreadSP real_thread(exe_ctx.GetThreadSP());
1273 if (real_thread) {
1274 ConstString type_const(type);
1275 Process *process = exe_ctx.GetProcessPtr();
1276 if (process) {
1277 SystemRuntime *runtime = process->GetSystemRuntime();
1278 if (runtime) {
1279 ThreadSP new_thread_sp(
1280 runtime->GetExtendedBacktraceThread(real_thread, type_const));
1281 if (new_thread_sp) {
1282 // Save this in the Process' ExtendedThreadList so a strong
1283 // pointer retains the object.
1284 process->GetExtendedThreadList().AddThread(new_thread_sp);
1285 sb_origin_thread.SetThread(new_thread_sp);
1286 }
1287 }
1288 }
1289 }
1290 }
1291 }
1292
1293 return sb_origin_thread;
1294}
1295
1297 LLDB_INSTRUMENT_VA(this);
1298
1299 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1300 if (thread_sp)
1301 return thread_sp->GetExtendedBacktraceOriginatingIndexID();
1302 return LLDB_INVALID_INDEX32;
1303}
1304
1306 LLDB_INSTRUMENT_VA(this);
1307
1308 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1309 if (!thread_sp)
1310 return SBValue();
1311
1312 return SBValue(thread_sp->GetCurrentException());
1313}
1314
1316 LLDB_INSTRUMENT_VA(this);
1317
1318 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1319 if (!thread_sp)
1320 return SBThread();
1321
1322 return SBThread(thread_sp->GetCurrentExceptionBacktrace());
1323}
1324
1326 LLDB_INSTRUMENT_VA(this);
1327
1328 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1329 if (thread_sp)
1330 return thread_sp->SafeToCallFunctions();
1331 return true;
1332}
1333
1335 return get();
1336}
1337
1339 return m_opaque_sp->GetThreadSP().get();
1340}
1341
1343 LLDB_INSTRUMENT_VA(this);
1344
1345 ThreadSP thread_sp = m_opaque_sp->GetThreadSP();
1346 if (!thread_sp)
1347 return SBValue();
1348 return thread_sp->GetSiginfoValue();
1349}
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:133
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:105
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:324
static const char * GetBroadcasterClassName()
Definition: SBThread.cpp:53
void StepInto(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition: SBThread.cpp:563
bool Suspend()
LLDB currently supports process centric debugging which means when any thread in a process stops,...
Definition: SBThread.cpp:992
const char * GetName() const
Definition: SBThread.cpp:394
const lldb::SBThread & operator=(const lldb::SBThread &rhs)
Definition: SBThread.cpp:77
lldb::SBFrame SetSelectedFrame(uint32_t frame_idx)
Definition: SBThread.cpp:1141
SBError UnwindInnermostExpression()
Definition: SBThread.cpp:974
SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx, lldb_private::ThreadPlan *new_plan)
Definition: SBThread.cpp:490
friend class SBThreadCollection
Definition: SBThread.h:243
bool IsValid() const
Definition: SBThread.cpp:109
uint32_t GetNumFrames()
Definition: SBThread.cpp:1085
const char * GetQueueName() const
Definition: SBThread.cpp:410
SBValue GetSiginfo()
Definition: SBThread.cpp:1342
void StepOut()
Definition: SBThread.cpp:625
uint32_t GetIndexID() const
Definition: SBThread.cpp:385
bool GetDescription(lldb::SBStream &description) const
Definition: SBThread.cpp:1212
static bool EventIsThreadEvent(const SBEvent &event)
Definition: SBThread.cpp:1164
lldb_private::Thread * operator->()
Definition: SBThread.cpp:1334
lldb_private::Thread * get()
Definition: SBThread.cpp:1338
void StepOutOfFrame(SBFrame &frame)
Definition: SBThread.cpp:660
bool GetStatus(lldb::SBStream &status) const
Definition: SBThread.cpp:1196
bool IsSuspended()
Definition: SBThread.cpp:1047
friend class SBValue
Definition: SBThread.h:240
static SBFrame GetStackFrameFromEvent(const SBEvent &event)
Definition: SBThread.cpp:1170
lldb::queue_id_t GetQueueID() const
Definition: SBThread.cpp:426
bool GetInfoItemByPathAsString(const char *path, SBStream &strm)
Definition: SBThread.cpp:443
lldb::SBFrame GetSelectedFrame()
Definition: SBThread.cpp:1121
bool operator!=(const lldb::SBThread &rhs) const
Definition: SBThread.cpp:1189
SBError StepUsingScriptedThreadPlan(const char *script_class_name)
Definition: SBThread.cpp:884
lldb::tid_t GetThreadID() const
Definition: SBThread.cpp:376
lldb::SBFrame GetFrameAtIndex(uint32_t idx)
Definition: SBThread.cpp:1102
uint32_t GetExtendedBacktraceOriginatingIndexID()
Definition: SBThread.cpp:1296
lldb::SBQueue GetQueue() const
Definition: SBThread.cpp:88
bool SafeToCallFunctions()
Definition: SBThread.cpp:1325
lldb::SBProcess GetProcess()
Definition: SBThread.cpp:1069
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:704
SBThread GetCurrentExceptionBacktrace()
Definition: SBThread.cpp:1315
static SBThread GetThreadFromEvent(const SBEvent &event)
Definition: SBThread.cpp:1176
bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream)
Definition: SBThread.cpp:279
lldb::StopReason GetStopReason()
Definition: SBThread.cpp:136
SBValue GetStopReturnValue()
Definition: SBThread.cpp:352
void StepOver(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition: SBThread.cpp:524
bool IsStopped()
Definition: SBThread.cpp:1058
SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line)
Definition: SBThread.cpp:937
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:1235
SBThreadCollection GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type)
Definition: SBThread.cpp:301
SBValue GetCurrentException()
Definition: SBThread.cpp:1305
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition: SBThread.cpp:372
SBThread GetExtendedBacktraceThread(const char *type)
Definition: SBThread.cpp:1262
lldb::ExecutionContextRefSP m_opaque_sp
Definition: SBThread.h:256
void RunToAddress(lldb::addr_t addr)
Definition: SBThread.cpp:733
uint64_t GetStopReasonDataAtIndex(uint32_t idx)
Get information associated with a stop reason.
Definition: SBThread.cpp:210
SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value)
Definition: SBThread.cpp:957
bool operator==(const lldb::SBThread &rhs) const
Definition: SBThread.cpp:1182
SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec, uint32_t line)
Definition: SBThread.cpp:768
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:1051
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)
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:214
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:1576
ThreadList & GetThreadList()
Definition: Process.h:2213
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: Process.cpp:1348
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
Definition: Process.cpp:2705
ThreadList & GetExtendedThreadList()
Definition: Process.h:2224
Status ResumeSynchronous(Stream *stream)
Resume a process, and wait for it to stop.
Definition: Process.cpp:1365
ProcessRunLock & GetRunLock()
Definition: Process.cpp:5663
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1277
"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:181
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
bool Success() const
Test for success condition.
Definition: Status.cpp:279
static lldb::ValueObjectSP GetReturnValueObject(lldb::StopInfoSP &stop_info_sp)
Definition: StopInfo.cpp:1435
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:1055
void AddThread(const lldb::ThreadSP &thread_sp)
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
Definition: ThreadList.cpp:696
void SetOkayToDiscard(bool value)
Definition: ThreadPlan.h:406
bool SetIsControllingPlan(bool value)
Definition: ThreadPlan.h:398
static const ThreadEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: Thread.cpp:166
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
Definition: Thread.cpp:176
static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr)
Definition: Thread.cpp:193
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:1310
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack.
Definition: Thread.cpp:1227
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Definition: Thread.h:405
virtual const char * GetQueueName()
Retrieve the Queue name for the queue currently using this Thread.
Definition: Thread.h:332
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:1366
static ConstString & GetStaticBroadcasterClass()
Definition: Thread.cpp:208
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition: Thread.cpp:1461
StructuredData::ObjectSP GetExtendedInfo()
Retrieve a dictionary of information about this thread.
Definition: Thread.h:272
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:1355
void SetResumeState(lldb::StateType state, bool override_suspend=false)
Sets the USER resume state for this thread.
Definition: Thread.h:184
lldb::StackFrameSP GetSelectedFrame(SelectMostRelevant select_most_relevant)
Definition: Thread.cpp:265
virtual const char * GetName()
Definition: Thread.h:280
virtual lldb::QueueSP GetQueue()
Retrieve the Queue for this thread, if any.
Definition: Thread.h:358
lldb::StateType GetResumeState() const
Gets the USER resume state for this thread.
Definition: Thread.h:198
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
Definition: Thread.cpp:273
void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format)
Definition: Thread.cpp:1629
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:1280
lldb::StateType GetState() const
Definition: Thread.cpp:559
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:1376
bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast=false)
Definition: Thread.cpp:282
lldb::StopReason GetStopReason()
Definition: Thread.cpp:435
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:1244
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
Definition: Thread.cpp:1551
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:1608
virtual lldb::queue_id_t GetQueueID()
Retrieve the Queue ID for the queue currently using this Thread.
Definition: Thread.h:320
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:1253
std::string GetStopDescription()
Definition: Thread.cpp:570
lldb::StopInfoSP GetStopInfo()
Definition: Thread.cpp:341
size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format, bool only_stacks=false)
Definition: Thread.cpp:1736
virtual uint32_t GetStackFrameCount()
GetStackFrameCount can be expensive.
Definition: Thread.h:401
#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.
Definition: SBAttachInfo.h:14
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:441
std::shared_ptr< lldb_private::Queue > QueueSP
Definition: lldb-forward.h:390
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:412
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
Definition: lldb-forward.h:315
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
Definition: lldb-forward.h:316
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:438
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472
@ 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:84
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:381
InstrumentationRuntimeType
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
Definition: lldb-forward.h:419
uint64_t addr_t
Definition: lldb-types.h:79
StopReason
Thread stop reasons.
@ eStopReasonInstrumentation
@ eStopReasonPlanComplete
@ eStopReasonTrace
@ eStopReasonBreakpoint
@ eStopReasonExec
Program was re-exec'ed.
@ eStopReasonVForkDone
@ eStopReasonProcessorTrace
@ eStopReasonThreadExiting
@ eStopReasonException
@ eStopReasonInvalid
@ eStopReasonWatchpoint
@ eStopReasonVFork
@ eStopReasonSignal
@ eStructuredDataTypeFloat
@ eStructuredDataTypeInteger
@ eStructuredDataTypeNull
@ eStructuredDataTypeBoolean
@ eStructuredDataTypeString
RunMode
Thread Run Modes.
uint64_t tid_t
Definition: lldb-types.h:82
uint64_t queue_id_t
Definition: lldb-types.h:88
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