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"
30#include "lldb/Target/Process.h"
31#include "lldb/Target/Queue.h"
34#include "lldb/Target/Target.h"
35#include "lldb/Target/Thread.h"
42#include "lldb/Utility/State.h"
43#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 = Status::FromErrorString("No process in SBThread::ResumeNewPlan");
503 return sb_error;
504 }
505
506 Thread *thread = exe_ctx.GetThreadPtr();
507 if (!thread) {
508 sb_error = Status::FromErrorString("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 = Status::FromErrorString("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 = Status::FromErrorString("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 llvm::Error err = sc.GetAddressRangeFromHereToEndLine(end_line, range);
609 if (err) {
610 error = Status::FromErrorString(llvm::toString(std::move(err)).c_str());
611 return;
612 }
613 }
614
615 const LazyBool step_out_avoids_code_without_debug_info =
617 const LazyBool step_in_avoids_code_without_debug_info =
619 new_plan_sp = thread->QueueThreadPlanForStepInRange(
620 abort_other_plans, range, sc, target_name, stop_other_threads,
621 new_plan_status, step_in_avoids_code_without_debug_info,
622 step_out_avoids_code_without_debug_info);
623 } else {
624 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
625 false, abort_other_plans, stop_other_threads, new_plan_status);
626 }
627
628 if (new_plan_status.Success())
629 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
630 else
631 error = Status::FromErrorString(new_plan_status.AsCString());
632}
633
635 LLDB_INSTRUMENT_VA(this);
636
637 SBError error; // Ignored
638 StepOut(error);
639}
640
643
644 std::unique_lock<std::recursive_mutex> lock;
645 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
646
647 if (!exe_ctx.HasThreadScope()) {
648 error = Status::FromErrorString("this SBThread object is invalid");
649 return;
650 }
651
652 bool abort_other_plans = false;
653 bool stop_other_threads = false;
654
655 Thread *thread = exe_ctx.GetThreadPtr();
656
657 const LazyBool avoid_no_debug = eLazyBoolCalculate;
658 Status new_plan_status;
659 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
660 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
661 eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
662
663 if (new_plan_status.Success())
664 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
665 else
666 error = Status::FromErrorString(new_plan_status.AsCString());
667}
668
670 LLDB_INSTRUMENT_VA(this, sb_frame);
671
672 SBError error; // Ignored
673 StepOutOfFrame(sb_frame, error);
674}
675
677 LLDB_INSTRUMENT_VA(this, sb_frame, error);
678
679 std::unique_lock<std::recursive_mutex> lock;
680 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
681
682 if (!sb_frame.IsValid()) {
683 error = Status::FromErrorString("passed invalid SBFrame object");
684 return;
685 }
686
687 StackFrameSP frame_sp(sb_frame.GetFrameSP());
688
689 if (!exe_ctx.HasThreadScope()) {
690 error = Status::FromErrorString("this SBThread object is invalid");
691 return;
692 }
693
694 bool abort_other_plans = false;
695 bool stop_other_threads = false;
696 Thread *thread = exe_ctx.GetThreadPtr();
697 if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
698 error = Status::FromErrorString("passed a frame from another thread");
699 return;
700 }
701
702 Status new_plan_status;
703 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
704 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
705 eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
706
707 if (new_plan_status.Success())
708 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
709 else
710 error = Status::FromErrorString(new_plan_status.AsCString());
711}
712
713void SBThread::StepInstruction(bool step_over) {
714 LLDB_INSTRUMENT_VA(this, step_over);
715
716 SBError error; // Ignored
717 StepInstruction(step_over, error);
718}
719
721 LLDB_INSTRUMENT_VA(this, step_over, error);
722
723 std::unique_lock<std::recursive_mutex> lock;
724 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
725
726 if (!exe_ctx.HasThreadScope()) {
727 error = Status::FromErrorString("this SBThread object is invalid");
728 return;
729 }
730
731 Thread *thread = exe_ctx.GetThreadPtr();
732 Status new_plan_status;
734 step_over, false, true, new_plan_status));
735
736 if (new_plan_status.Success())
737 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
738 else
739 error = Status::FromErrorString(new_plan_status.AsCString());
740}
741
743 LLDB_INSTRUMENT_VA(this, addr);
744
745 SBError error; // Ignored
746 RunToAddress(addr, error);
747}
748
750 LLDB_INSTRUMENT_VA(this, addr, error);
751
752 std::unique_lock<std::recursive_mutex> lock;
753 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
754
755 if (!exe_ctx.HasThreadScope()) {
756 error = Status::FromErrorString("this SBThread object is invalid");
757 return;
758 }
759
760 bool abort_other_plans = false;
761 bool stop_other_threads = true;
762
763 Address target_addr(addr);
764
765 Thread *thread = exe_ctx.GetThreadPtr();
766
767 Status new_plan_status;
769 abort_other_plans, target_addr, stop_other_threads, new_plan_status));
770
771 if (new_plan_status.Success())
772 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
773 else
774 error = Status::FromErrorString(new_plan_status.AsCString());
775}
776
778 lldb::SBFileSpec &sb_file_spec, uint32_t line) {
779 LLDB_INSTRUMENT_VA(this, sb_frame, sb_file_spec, line);
780
781 SBError sb_error;
782 char path[PATH_MAX];
783
784 std::unique_lock<std::recursive_mutex> lock;
785 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
786
787 StackFrameSP frame_sp(sb_frame.GetFrameSP());
788
789 if (exe_ctx.HasThreadScope()) {
790 Target *target = exe_ctx.GetTargetPtr();
791 Thread *thread = exe_ctx.GetThreadPtr();
792
793 if (line == 0) {
794 sb_error = Status::FromErrorString("invalid line argument");
795 return sb_error;
796 }
797
798 if (!frame_sp) {
799 // We don't want to run SelectMostRelevantFrame here, for instance if
800 // you called a sequence of StepOverUntil's you wouldn't want the
801 // frame changed out from under you because you stepped into a
802 // recognized frame.
804 if (!frame_sp)
805 frame_sp = thread->GetStackFrameAtIndex(0);
806 }
807
808 SymbolContext frame_sc;
809 if (!frame_sp) {
810 sb_error = Status::FromErrorString("no valid frames in thread to step");
811 return sb_error;
812 }
813
814 // If we have a frame, get its line
815 frame_sc = frame_sp->GetSymbolContext(
816 eSymbolContextCompUnit | eSymbolContextFunction |
817 eSymbolContextLineEntry | eSymbolContextSymbol);
818
819 if (frame_sc.comp_unit == nullptr) {
821 "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
822 return sb_error;
823 }
824
825 FileSpec step_file_spec;
826 if (sb_file_spec.IsValid()) {
827 // The file spec passed in was valid, so use it
828 step_file_spec = sb_file_spec.ref();
829 } else {
830 if (frame_sc.line_entry.IsValid())
831 step_file_spec = frame_sc.line_entry.GetFile();
832 else {
833 sb_error = Status::FromErrorString(
834 "invalid file argument or no file for frame");
835 return sb_error;
836 }
837 }
838
839 // Grab the current function, then we will make sure the "until" address is
840 // within the function. We discard addresses that are out of the current
841 // function, and then if there are no addresses remaining, give an
842 // appropriate error message.
843
844 bool all_in_function = true;
845 AddressRange fun_range = frame_sc.function->GetAddressRange();
846
847 std::vector<addr_t> step_over_until_addrs;
848 const bool abort_other_plans = false;
849 const bool stop_other_threads = false;
850 // TODO: Handle SourceLocationSpec column information
851 SourceLocationSpec location_spec(
852 step_file_spec, line, /*column=*/std::nullopt, /*check_inlines=*/true,
853 /*exact_match=*/false);
854
855 SymbolContextList sc_list;
856 frame_sc.comp_unit->ResolveSymbolContext(location_spec,
857 eSymbolContextLineEntry, sc_list);
858 for (const SymbolContext &sc : sc_list) {
859 addr_t step_addr =
860 sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
861 if (step_addr != LLDB_INVALID_ADDRESS) {
862 if (fun_range.ContainsLoadAddress(step_addr, target))
863 step_over_until_addrs.push_back(step_addr);
864 else
865 all_in_function = false;
866 }
867 }
868
869 if (step_over_until_addrs.empty()) {
870 if (all_in_function) {
871 step_file_spec.GetPath(path, sizeof(path));
873 "No line entries for %s:%u", path, line);
874 } else
875 sb_error = Status::FromErrorString(
876 "step until target not in current function");
877 } else {
878 Status new_plan_status;
879 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
880 abort_other_plans, &step_over_until_addrs[0],
881 step_over_until_addrs.size(), stop_other_threads,
882 frame_sp->GetFrameIndex(), new_plan_status));
883
884 if (new_plan_status.Success())
885 sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
886 else
887 sb_error = Status::FromErrorString(new_plan_status.AsCString());
888 }
889 } else {
890 sb_error = Status::FromErrorString("this SBThread object is invalid");
891 }
892 return sb_error;
893}
894
895SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
896 LLDB_INSTRUMENT_VA(this, script_class_name);
897
898 return StepUsingScriptedThreadPlan(script_class_name, true);
899}
900
901SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
902 bool resume_immediately) {
903 LLDB_INSTRUMENT_VA(this, script_class_name, resume_immediately);
904
906 return StepUsingScriptedThreadPlan(script_class_name, no_data,
907 resume_immediately);
908}
909
910SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
911 SBStructuredData &args_data,
912 bool resume_immediately) {
913 LLDB_INSTRUMENT_VA(this, script_class_name, args_data, resume_immediately);
914
916
917 std::unique_lock<std::recursive_mutex> lock;
918 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
919
920 if (!exe_ctx.HasThreadScope()) {
921 error = Status::FromErrorString("this SBThread object is invalid");
922 return error;
923 }
924
925 Thread *thread = exe_ctx.GetThreadPtr();
926 Status new_plan_status;
927 StructuredData::ObjectSP obj_sp = args_data.m_impl_up->GetObjectSP();
928
929 ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
930 false, script_class_name, obj_sp, false, new_plan_status);
931
932 if (new_plan_status.Fail()) {
933 error = Status::FromErrorString(new_plan_status.AsCString());
934 return error;
935 }
936
937 if (!resume_immediately)
938 return error;
939
940 if (new_plan_status.Success())
941 error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
942 else
943 error = Status::FromErrorString(new_plan_status.AsCString());
944
945 return error;
946}
947
949 LLDB_INSTRUMENT_VA(this, file_spec, line);
950
951 SBError sb_error;
952
953 std::unique_lock<std::recursive_mutex> lock;
954 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
955
956 if (!exe_ctx.HasThreadScope()) {
957 sb_error = Status::FromErrorString("this SBThread object is invalid");
958 return sb_error;
959 }
960
961 Thread *thread = exe_ctx.GetThreadPtr();
962
963 Status err = thread->JumpToLine(file_spec.ref(), line, true);
964 sb_error.SetError(std::move(err));
965 return sb_error;
966}
967
969 LLDB_INSTRUMENT_VA(this, frame, return_value);
970
971 SBError sb_error;
972
973 std::unique_lock<std::recursive_mutex> lock;
974 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
975
976 if (exe_ctx.HasThreadScope()) {
977 Thread *thread = exe_ctx.GetThreadPtr();
978 sb_error.SetError(
979 thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
980 }
981
982 return sb_error;
983}
984
986 LLDB_INSTRUMENT_VA(this);
987
988 SBError sb_error;
989
990 std::unique_lock<std::recursive_mutex> lock;
991 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
992
993 if (exe_ctx.HasThreadScope()) {
994 Thread *thread = exe_ctx.GetThreadPtr();
995 sb_error.SetError(thread->UnwindInnermostExpression());
996 if (sb_error.Success())
997 thread->SetSelectedFrameByIndex(0, false);
998 }
999
1000 return sb_error;
1001}
1002
1004 LLDB_INSTRUMENT_VA(this);
1005
1006 SBError error; // Ignored
1007 return Suspend(error);
1008}
1009
1012
1013 std::unique_lock<std::recursive_mutex> lock;
1014 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1015
1016 bool result = false;
1017 if (exe_ctx.HasThreadScope()) {
1018 Process::StopLocker stop_locker;
1019 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1021 result = true;
1022 } else {
1023 error = Status::FromErrorString("process is running");
1024 }
1025 } else
1026 error = Status::FromErrorString("this SBThread object is invalid");
1027 return result;
1028}
1029
1031 LLDB_INSTRUMENT_VA(this);
1032
1033 SBError error; // Ignored
1034 return Resume(error);
1035}
1036
1039
1040 std::unique_lock<std::recursive_mutex> lock;
1041 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1042
1043 bool result = false;
1044 if (exe_ctx.HasThreadScope()) {
1045 Process::StopLocker stop_locker;
1046 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1047 const bool override_suspend = true;
1048 exe_ctx.GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
1049 result = true;
1050 } else {
1051 error = Status::FromErrorString("process is running");
1052 }
1053 } else
1054 error = Status::FromErrorString("this SBThread object is invalid");
1055 return result;
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 exe_ctx.GetThreadPtr()->GetResumeState() == eStateSuspended;
1066 return false;
1067}
1068
1070 LLDB_INSTRUMENT_VA(this);
1071
1072 std::unique_lock<std::recursive_mutex> lock;
1073 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1074
1075 if (exe_ctx.HasThreadScope())
1076 return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
1077 return false;
1078}
1079
1081 LLDB_INSTRUMENT_VA(this);
1082
1083 SBProcess sb_process;
1084 std::unique_lock<std::recursive_mutex> lock;
1085 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1086
1087 if (exe_ctx.HasThreadScope()) {
1088 // Have to go up to the target so we can get a shared pointer to our
1089 // process...
1090 sb_process.SetSP(exe_ctx.GetProcessSP());
1091 }
1092
1093 return sb_process;
1094}
1095
1097 LLDB_INSTRUMENT_VA(this);
1098
1099 uint32_t num_frames = 0;
1100 std::unique_lock<std::recursive_mutex> lock;
1101 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1102
1103 if (exe_ctx.HasThreadScope()) {
1104 Process::StopLocker stop_locker;
1105 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1106 num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
1107 }
1108 }
1109
1110 return num_frames;
1111}
1112
1114 LLDB_INSTRUMENT_VA(this, idx);
1115
1116 SBFrame sb_frame;
1117 StackFrameSP frame_sp;
1118 std::unique_lock<std::recursive_mutex> lock;
1119 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1120
1121 if (exe_ctx.HasThreadScope()) {
1122 Process::StopLocker stop_locker;
1123 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1124 frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx);
1125 sb_frame.SetFrameSP(frame_sp);
1126 }
1127 }
1128
1129 return sb_frame;
1130}
1131
1133 LLDB_INSTRUMENT_VA(this);
1134
1135 SBFrame sb_frame;
1136 StackFrameSP frame_sp;
1137 std::unique_lock<std::recursive_mutex> lock;
1138 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1139
1140 if (exe_ctx.HasThreadScope()) {
1141 Process::StopLocker stop_locker;
1142 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1143 frame_sp =
1145 sb_frame.SetFrameSP(frame_sp);
1146 }
1147 }
1148
1149 return sb_frame;
1150}
1151
1153 LLDB_INSTRUMENT_VA(this, idx);
1154
1155 SBFrame sb_frame;
1156 StackFrameSP frame_sp;
1157 std::unique_lock<std::recursive_mutex> lock;
1158 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1159
1160 if (exe_ctx.HasThreadScope()) {
1161 Process::StopLocker stop_locker;
1162 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1163 Thread *thread = exe_ctx.GetThreadPtr();
1164 frame_sp = thread->GetStackFrameAtIndex(idx);
1165 if (frame_sp) {
1166 thread->SetSelectedFrame(frame_sp.get());
1167 sb_frame.SetFrameSP(frame_sp);
1168 }
1169 }
1170 }
1171
1172 return sb_frame;
1173}
1174
1176 LLDB_INSTRUMENT_VA(event);
1177
1178 return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr;
1179}
1180
1182 LLDB_INSTRUMENT_VA(event);
1183
1185}
1186
1188 LLDB_INSTRUMENT_VA(event);
1189
1191}
1192
1193bool SBThread::operator==(const SBThread &rhs) const {
1194 LLDB_INSTRUMENT_VA(this, rhs);
1195
1196 return m_opaque_sp->GetThreadSP().get() ==
1197 rhs.m_opaque_sp->GetThreadSP().get();
1198}
1199
1200bool SBThread::operator!=(const SBThread &rhs) const {
1201 LLDB_INSTRUMENT_VA(this, rhs);
1202
1203 return m_opaque_sp->GetThreadSP().get() !=
1204 rhs.m_opaque_sp->GetThreadSP().get();
1205}
1206
1207bool SBThread::GetStatus(SBStream &status) const {
1208 LLDB_INSTRUMENT_VA(this, status);
1209
1210 Stream &strm = status.ref();
1211
1212 std::unique_lock<std::recursive_mutex> lock;
1213 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1214
1215 if (exe_ctx.HasThreadScope()) {
1216 exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true,
1217 /*show_hidden=*/true);
1218 } else
1219 strm.PutCString("No status");
1220
1221 return true;
1222}
1223
1224bool SBThread::GetDescription(SBStream &description) const {
1225 LLDB_INSTRUMENT_VA(this, description);
1226
1227 return GetDescription(description, false);
1228}
1229
1230bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
1231 LLDB_INSTRUMENT_VA(this, description, stop_format);
1232
1233 Stream &strm = description.ref();
1234
1235 std::unique_lock<std::recursive_mutex> lock;
1236 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1237
1238 if (exe_ctx.HasThreadScope()) {
1240 strm, LLDB_INVALID_THREAD_ID, stop_format);
1241 } else
1242 strm.PutCString("No value");
1243
1244 return true;
1245}
1246
1248 SBStream &output) {
1249 Stream &strm = output.ref();
1250
1251 SBError error;
1252 if (!format) {
1253 error = Status::FromErrorString("The provided SBFormat object is invalid");
1254 return error;
1255 }
1256
1257 std::unique_lock<std::recursive_mutex> lock;
1258 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1259
1260 if (exe_ctx.HasThreadScope()) {
1261 if (exe_ctx.GetThreadPtr()->DumpUsingFormat(
1262 strm, LLDB_INVALID_THREAD_ID, format.GetFormatEntrySP().get())) {
1263 return error;
1264 }
1265 }
1266
1268 "It was not possible to generate a thread description with the given "
1269 "format string '%s'",
1270 format.GetFormatEntrySP()->string.c_str());
1271 return error;
1272}
1273
1275 LLDB_INSTRUMENT_VA(this, type);
1276
1277 std::unique_lock<std::recursive_mutex> lock;
1278 ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1279 SBThread sb_origin_thread;
1280
1281 Process::StopLocker stop_locker;
1282 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
1283 if (exe_ctx.HasThreadScope()) {
1284 ThreadSP real_thread(exe_ctx.GetThreadSP());
1285 if (real_thread) {
1286 ConstString type_const(type);
1287 Process *process = exe_ctx.GetProcessPtr();
1288 if (process) {
1289 SystemRuntime *runtime = process->GetSystemRuntime();
1290 if (runtime) {
1291 ThreadSP new_thread_sp(
1292 runtime->GetExtendedBacktraceThread(real_thread, type_const));
1293 if (new_thread_sp) {
1294 // Save this in the Process' ExtendedThreadList so a strong
1295 // pointer retains the object.
1296 process->GetExtendedThreadList().AddThread(new_thread_sp);
1297 sb_origin_thread.SetThread(new_thread_sp);
1298 }
1299 }
1300 }
1301 }
1302 }
1303 }
1304
1305 return sb_origin_thread;
1306}
1307
1309 LLDB_INSTRUMENT_VA(this);
1310
1311 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1312 if (thread_sp)
1313 return thread_sp->GetExtendedBacktraceOriginatingIndexID();
1314 return LLDB_INVALID_INDEX32;
1315}
1316
1318 LLDB_INSTRUMENT_VA(this);
1319
1320 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1321 if (!thread_sp)
1322 return SBValue();
1323
1324 return SBValue(thread_sp->GetCurrentException());
1325}
1326
1328 LLDB_INSTRUMENT_VA(this);
1329
1330 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1331 if (!thread_sp)
1332 return SBThread();
1333
1334 return SBThread(thread_sp->GetCurrentExceptionBacktrace());
1335}
1336
1338 LLDB_INSTRUMENT_VA(this);
1339
1340 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1341 if (thread_sp)
1342 return thread_sp->SafeToCallFunctions();
1343 return true;
1344}
1345
1346lldb::ThreadSP SBThread::GetSP() const { return m_opaque_sp->GetThreadSP(); }
1347
1349 return get();
1350}
1351
1353 return m_opaque_sp->GetThreadSP().get();
1354}
1355
1357 LLDB_INSTRUMENT_VA(this);
1358
1359 ThreadSP thread_sp = m_opaque_sp->GetThreadSP();
1360 if (!thread_sp)
1361 return SBValue();
1362 return thread_sp->GetSiginfoValue();
1363}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT()
#define LLDB_INSTRUMENT_VA(...)
bool Success() const
Definition: SBError.cpp:81
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:124
lldb_private::Status & ref()
Definition: SBError.cpp:191
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:94
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition: SBFrame.cpp:90
lldb::SBThread GetThread() const
Definition: SBFrame.cpp:698
lldb::StackFrameSP GetFrameSP() const
Definition: SBFrame.cpp:86
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:1003
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:1152
SBError UnwindInnermostExpression()
Definition: SBThread.cpp:985
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:1096
const char * GetQueueName() const
Definition: SBThread.cpp:416
SBValue GetSiginfo()
Definition: SBThread.cpp:1356
void StepOut()
Definition: SBThread.cpp:634
uint32_t GetIndexID() const
Definition: SBThread.cpp:391
bool GetDescription(lldb::SBStream &description) const
Definition: SBThread.cpp:1224
static bool EventIsThreadEvent(const SBEvent &event)
Definition: SBThread.cpp:1175
lldb_private::Thread * operator->()
Definition: SBThread.cpp:1348
lldb_private::Thread * get()
Definition: SBThread.cpp:1352
void StepOutOfFrame(SBFrame &frame)
Definition: SBThread.cpp:669
bool GetStatus(lldb::SBStream &status) const
Definition: SBThread.cpp:1207
bool IsSuspended()
Definition: SBThread.cpp:1058
friend class SBValue
Definition: SBThread.h:241
static SBFrame GetStackFrameFromEvent(const SBEvent &event)
Definition: SBThread.cpp:1181
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:1132
bool operator!=(const lldb::SBThread &rhs) const
Definition: SBThread.cpp:1200
SBError StepUsingScriptedThreadPlan(const char *script_class_name)
Definition: SBThread.cpp:895
lldb::tid_t GetThreadID() const
Definition: SBThread.cpp:382
lldb::SBFrame GetFrameAtIndex(uint32_t idx)
Definition: SBThread.cpp:1113
uint32_t GetExtendedBacktraceOriginatingIndexID()
Definition: SBThread.cpp:1308
lldb::SBQueue GetQueue() const
Definition: SBThread.cpp:88
bool SafeToCallFunctions()
Definition: SBThread.cpp:1337
lldb::SBProcess GetProcess()
Definition: SBThread.cpp:1080
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:713
SBThread GetCurrentExceptionBacktrace()
Definition: SBThread.cpp:1327
static SBThread GetThreadFromEvent(const SBEvent &event)
Definition: SBThread.cpp:1187
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:1069
SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line)
Definition: SBThread.cpp:948
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:1247
SBThreadCollection GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type)
Definition: SBThread.cpp:307
SBValue GetCurrentException()
Definition: SBThread.cpp:1317
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition: SBThread.cpp:378
lldb::ThreadSP GetSP() const
Definition: SBThread.cpp:1346
SBThread GetExtendedBacktraceThread(const char *type)
Definition: SBThread.cpp:1274
lldb::ExecutionContextRefSP m_opaque_sp
Definition: SBThread.h:259
void RunToAddress(lldb::addr_t addr)
Definition: SBThread.cpp:742
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:968
bool operator==(const lldb::SBThread &rhs) const
Definition: SBThread.cpp:1193
SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec, uint32_t line)
Definition: SBThread.cpp:777
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:1106
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()
DEPRECATED: Use GetAddressRanges instead.
Definition: Function.h:448
A plug-in interface definition class for debugging a process.
Definition: Process.h:343
StopPointSiteList< lldb_private::BreakpointSite > & GetBreakpointSiteList()
Definition: Process.cpp:1583
ThreadList & GetThreadList()
Definition: Process.h:2182
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: Process.cpp:1355
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
Definition: Process.cpp:2854
ThreadList & GetExtendedThreadList()
Definition: Process.h:2193
Status ResumeSynchronous(Stream *stream)
Resume a process, and wait for it to stop.
Definition: Process.cpp:1372
ProcessRunLock & GetRunLock()
Definition: Process.cpp:5851
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1246
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
An error handling class.
Definition: Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition: Status.cpp:106
static Status FromErrorString(const char *str)
Definition: Status.h:141
bool Fail() const
Test for error condition.
Definition: Status.cpp:294
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:195
bool Success() const
Test for success condition.
Definition: Status.cpp:304
static lldb::ValueObjectSP GetReturnValueObject(lldb::StopInfoSP &stop_info_sp)
Definition: StopInfo.cpp:1520
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
llvm::Error GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range)
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.
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:1080
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:418
bool SetIsControllingPlan(bool value)
Definition: ThreadPlan.h:410
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:1328
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack.
Definition: Thread.cpp:1244
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:1384
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition: Thread.cpp:1479
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:1373
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:1652
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:1298
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:1394
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:1262
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
Definition: Thread.cpp:1571
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:1631
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:1271
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:1761
#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:453
std::shared_ptr< lldb_private::Queue > QueueSP
Definition: lldb-forward.h:398
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:424
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
Definition: lldb-forward.h:323
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
Definition: lldb-forward.h:324
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:450
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:484
@ 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:389
InstrumentationRuntimeType
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
Definition: lldb-forward.h:431
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