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"
18#include "lldb/API/SBProcess.h"
19#include "lldb/API/SBStream.h"
24#include "lldb/API/SBValue.h"
26#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"
48
49#include <memory>
50
51using namespace lldb;
52using namespace lldb_private;
53
59
60// Constructors
64
65SBThread::SBThread(const ThreadSP &lldb_object_sp)
66 : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
67 LLDB_INSTRUMENT_VA(this, lldb_object_sp);
68}
69
71 LLDB_INSTRUMENT_VA(this, rhs);
72
74}
75
76// Assignment operator
77
79 LLDB_INSTRUMENT_VA(this, rhs);
80
81 if (this != &rhs)
83 return *this;
84}
85
86// Destructor
87SBThread::~SBThread() = default;
88
91
92 SBQueue sb_queue;
93 QueueSP queue_sp;
94 llvm::Expected<StoppedExecutionContext> exe_ctx =
96 if (!exe_ctx) {
97 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
98 return SBQueue();
99 }
100
101 if (exe_ctx->HasThreadScope()) {
102 queue_sp = exe_ctx->GetThreadPtr()->GetQueue();
103 if (queue_sp) {
104 sb_queue.SetQueue(queue_sp);
105 }
106 }
107
108 return sb_queue;
109}
110
111bool SBThread::IsValid() const {
112 LLDB_INSTRUMENT_VA(this);
113 return this->operator bool();
114}
115SBThread::operator bool() const {
116 LLDB_INSTRUMENT_VA(this);
117 if (!m_opaque_sp)
118 return false;
119
120 llvm::Expected<StoppedExecutionContext> exe_ctx =
122 if (!exe_ctx) {
123 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
124 return false;
125 }
126
127 return m_opaque_sp->GetThreadSP().get() != nullptr;
128}
129
131 LLDB_INSTRUMENT_VA(this);
132
133 m_opaque_sp->Clear();
134}
135
137 LLDB_INSTRUMENT_VA(this);
138
140 llvm::Expected<StoppedExecutionContext> exe_ctx =
142 if (!exe_ctx) {
143 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
144 return reason;
145 }
146
147 if (exe_ctx->HasThreadScope())
148 return exe_ctx->GetThreadPtr()->GetStopReason();
149
150 return reason;
151}
152
154 LLDB_INSTRUMENT_VA(this);
155
156 llvm::Expected<StoppedExecutionContext> exe_ctx =
158 if (exe_ctx) {
159 if (exe_ctx->HasThreadScope()) {
160 StopInfoSP stop_info_sp = exe_ctx->GetThreadPtr()->GetStopInfo();
161 if (stop_info_sp)
162 return stop_info_sp->GetStopReasonDataCount();
163 }
164 } else {
165 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
166 return 0;
167 }
168 return 0;
169}
170
172 LLDB_INSTRUMENT_VA(this, idx);
173
174 llvm::Expected<StoppedExecutionContext> exe_ctx =
176 if (exe_ctx) {
177 if (exe_ctx->HasThreadScope()) {
178 Thread *thread = exe_ctx->GetThreadPtr();
179 StopInfoSP stop_info_sp = thread->GetStopInfo();
180 if (stop_info_sp)
181 return stop_info_sp->GetStopReasonDataAtIndex(idx);
182 }
183 } else {
184 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
185 return 0;
186 }
187 return 0;
188}
189
191 LLDB_INSTRUMENT_VA(this, stream);
192
193 Stream &strm = stream.ref();
194
195 llvm::Expected<StoppedExecutionContext> exe_ctx =
197 if (!exe_ctx) {
198 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
199 return false;
200 }
201
202 if (!exe_ctx->HasThreadScope())
203 return false;
204
205 StopInfoSP stop_info = exe_ctx->GetThreadPtr()->GetStopInfo();
206 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
207 if (!info)
208 return false;
209
210 info->Dump(strm);
211
212 return true;
213}
214
217 LLDB_INSTRUMENT_VA(this, type);
218
219 SBThreadCollection threads;
220
221 llvm::Expected<StoppedExecutionContext> exe_ctx =
223 if (!exe_ctx) {
224 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
225 return SBThreadCollection();
226 }
227
228 if (!exe_ctx->HasThreadScope())
229 return SBThreadCollection();
230
231 ProcessSP process_sp = exe_ctx->GetProcessSP();
232
233 StopInfoSP stop_info = exe_ctx->GetThreadPtr()->GetStopInfo();
234 StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
235 if (!info)
236 return threads;
237
238 threads = process_sp->GetInstrumentationRuntime(type)
239 ->GetBacktracesFromExtendedStopInfo(info);
240 return threads;
241}
242
244 LLDB_INSTRUMENT_VA(this, stream);
245
246 if (!m_opaque_sp)
247 return false;
248
249 llvm::Expected<StoppedExecutionContext> exe_ctx =
251 if (!exe_ctx) {
252 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
253 return false;
254 }
255
256 if (!exe_ctx->HasThreadScope())
257 return false;
258
259 Stream &strm = stream.ref();
260 const std::string stop_desc = exe_ctx->GetThreadPtr()->GetStopDescription();
261 strm.PutCString(stop_desc);
262
263 return true;
264}
265
266size_t SBThread::GetStopDescription(char *dst_or_null, size_t dst_len) {
267 LLDB_INSTRUMENT_VA(this, dst_or_null, dst_len);
268
269 if (dst_or_null)
270 *dst_or_null = 0;
271
272 llvm::Expected<StoppedExecutionContext> exe_ctx =
274 if (!exe_ctx) {
275 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
276 return 0;
277 }
278
279 if (!exe_ctx->HasThreadScope())
280 return 0;
281
282 std::string thread_stop_desc = exe_ctx->GetThreadPtr()->GetStopDescription();
283 if (thread_stop_desc.empty())
284 return 0;
285
286 if (dst_or_null)
287 return ::snprintf(dst_or_null, dst_len, "%s", thread_stop_desc.c_str()) + 1;
288
289 // NULL dst passed in, return the length needed to contain the
290 // description.
291 return thread_stop_desc.size() + 1; // Include the NULL byte for size
292}
293
295 LLDB_INSTRUMENT_VA(this);
296
297 ValueObjectSP return_valobj_sp;
298 llvm::Expected<StoppedExecutionContext> exe_ctx =
300 if (!exe_ctx) {
301 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
302 return SBValue();
303 }
304
305 if (exe_ctx->HasThreadScope()) {
306 StopInfoSP stop_info_sp = exe_ctx->GetThreadPtr()->GetStopInfo();
307 if (stop_info_sp) {
308 return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
309 }
310 }
311
312 return SBValue(return_valobj_sp);
313}
314
315void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
316 m_opaque_sp->SetThreadSP(lldb_object_sp);
317}
318
320 LLDB_INSTRUMENT_VA(this);
321
322 llvm::Expected<StoppedExecutionContext> exe_ctx =
324 if (!exe_ctx) {
325 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
327 }
328
329 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
330 if (thread_sp)
331 return thread_sp->GetID();
333}
334
335uint32_t SBThread::GetIndexID() const {
336 LLDB_INSTRUMENT_VA(this);
337
338 llvm::Expected<StoppedExecutionContext> exe_ctx =
340 if (!exe_ctx) {
341 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
343 }
344
345 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
346 if (thread_sp)
347 return thread_sp->GetIndexID();
349}
350
351const char *SBThread::GetName() const {
352 LLDB_INSTRUMENT_VA(this);
353
354 llvm::Expected<StoppedExecutionContext> exe_ctx =
356 if (!exe_ctx) {
357 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
358 return nullptr;
359 }
360
361 if (!exe_ctx->HasThreadScope())
362 return nullptr;
363
364 return ConstString(exe_ctx->GetThreadPtr()->GetName()).GetCString();
365}
366
367const char *SBThread::GetQueueName() const {
368 LLDB_INSTRUMENT_VA(this);
369
370 llvm::Expected<StoppedExecutionContext> exe_ctx =
372 if (!exe_ctx) {
373 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
374 return nullptr;
375 }
376
377 if (!exe_ctx->HasThreadScope())
378 return nullptr;
379
380 return ConstString(exe_ctx->GetThreadPtr()->GetQueueName()).GetCString();
381}
382
384 LLDB_INSTRUMENT_VA(this);
385
387 llvm::Expected<StoppedExecutionContext> exe_ctx =
389 if (!exe_ctx) {
390 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
391 return id;
392 }
393
394 if (exe_ctx->HasThreadScope()) {
395 id = exe_ctx->GetThreadPtr()->GetQueueID();
396 }
397
398 return id;
399}
400
401bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
402 LLDB_INSTRUMENT_VA(this, path, strm);
403
404 bool success = false;
405 llvm::Expected<StoppedExecutionContext> exe_ctx =
407 if (exe_ctx) {
408 if (exe_ctx->HasThreadScope()) {
409 Thread *thread = exe_ctx->GetThreadPtr();
410 StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
411 if (info_root_sp) {
413 info_root_sp->GetObjectForDotSeparatedPath(path);
414 if (node) {
415 if (node->GetType() == eStructuredDataTypeString) {
416 strm.ref() << node->GetAsString()->GetValue();
417 success = true;
418 }
419 if (node->GetType() == eStructuredDataTypeInteger) {
420 strm.Printf("0x%" PRIx64, node->GetUnsignedIntegerValue());
421 success = true;
422 }
423 if (node->GetType() == eStructuredDataTypeFloat) {
424 strm.Printf("0x%f", node->GetAsFloat()->GetValue());
425 success = true;
426 }
427 if (node->GetType() == eStructuredDataTypeBoolean) {
428 if (node->GetAsBoolean()->GetValue())
429 strm.Printf("true");
430 else
431 strm.Printf("false");
432 success = true;
433 }
434 if (node->GetType() == eStructuredDataTypeNull) {
435 strm.Printf("null");
436 success = true;
437 }
438 }
439 }
440 }
441 } else {
442 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
443 return success;
444 }
445
446 return success;
447}
448
450 ThreadPlan *new_plan) {
451 Thread *thread = exe_ctx.GetThreadPtr();
452 if (!thread)
453 return Status::FromErrorString("No thread in SBThread::ResumeNewPlan");
454
455 // User level plans should be Controlling Plans so they can be interrupted,
456 // other plans executed, and then a "continue" will resume the plan.
457 if (new_plan != nullptr) {
458 new_plan->SetIsControllingPlan(true);
459 new_plan->SetOkayToDiscard(false);
460 }
461
462 // Why do we need to set the current thread by ID here???
463 Process *process = exe_ctx.GetProcessPtr();
464 process->GetThreadList().SetSelectedThreadByID(thread->GetID());
465
466 // Release the run lock but keep the API lock.
467 std::unique_lock<std::recursive_mutex> api_lock = exe_ctx.AllowResume();
468 if (process->GetTarget().GetDebugger().GetAsyncExecution())
469 return process->Resume();
470 return process->ResumeSynchronous(nullptr);
471}
472
473void SBThread::StepOver(lldb::RunMode stop_other_threads) {
474 LLDB_INSTRUMENT_VA(this, stop_other_threads);
475
476 SBError error; // Ignored
477 StepOver(stop_other_threads, error);
478}
479
480void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
481 LLDB_INSTRUMENT_VA(this, stop_other_threads, error);
482
483 llvm::Expected<StoppedExecutionContext> exe_ctx =
485 if (!exe_ctx) {
486 error = Status::FromError(exe_ctx.takeError());
487 return;
488 }
489
490 if (!exe_ctx->HasThreadScope()) {
491 error = Status::FromErrorString("this SBThread object is invalid");
492 return;
493 }
494
495 Thread *thread = exe_ctx->GetThreadPtr();
496 bool abort_other_plans = false;
497 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
498
499 Status new_plan_status;
500 ThreadPlanSP new_plan_sp;
501 if (frame_sp) {
502 if (frame_sp->HasDebugInformation()) {
503 const LazyBool avoid_no_debug = eLazyBoolCalculate;
504 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
505 new_plan_sp = thread->QueueThreadPlanForStepOverRange(
506 abort_other_plans, sc.line_entry, sc, stop_other_threads,
507 new_plan_status, avoid_no_debug);
508 } else {
509 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
510 true, abort_other_plans, stop_other_threads, new_plan_status);
511 }
512 }
513 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
514}
515
516void SBThread::StepInto(lldb::RunMode stop_other_threads) {
517 LLDB_INSTRUMENT_VA(this, stop_other_threads);
518
519 StepInto(nullptr, stop_other_threads);
520}
521
522void SBThread::StepInto(const char *target_name,
523 lldb::RunMode stop_other_threads) {
524 LLDB_INSTRUMENT_VA(this, target_name, stop_other_threads);
525
526 SBError error; // Ignored
527 StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
528}
529
530void SBThread::StepInto(const char *target_name, uint32_t end_line,
531 SBError &error, lldb::RunMode stop_other_threads) {
532 LLDB_INSTRUMENT_VA(this, target_name, end_line, error, stop_other_threads);
533
534 llvm::Expected<StoppedExecutionContext> exe_ctx =
536 if (!exe_ctx) {
537 error = Status::FromError(exe_ctx.takeError());
538 return;
539 }
540
541 if (!exe_ctx->HasThreadScope()) {
542 error = Status::FromErrorString("this SBThread object is invalid");
543 return;
544 }
545
546 bool abort_other_plans = false;
547
548 Thread *thread = exe_ctx->GetThreadPtr();
549 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
550 ThreadPlanSP new_plan_sp;
551 Status new_plan_status;
552
553 if (frame_sp && frame_sp->HasDebugInformation()) {
554 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
555 AddressRange range;
556 if (end_line == LLDB_INVALID_LINE_NUMBER)
557 range = sc.line_entry.range;
558 else {
559 llvm::Error err = sc.GetAddressRangeFromHereToEndLine(end_line, range);
560 if (err) {
561 error = Status::FromErrorString(llvm::toString(std::move(err)).c_str());
562 return;
563 }
564 }
565
566 const LazyBool step_out_avoids_code_without_debug_info =
568 const LazyBool step_in_avoids_code_without_debug_info =
570 new_plan_sp = thread->QueueThreadPlanForStepInRange(
571 abort_other_plans, range, sc, target_name, stop_other_threads,
572 new_plan_status, step_in_avoids_code_without_debug_info,
573 step_out_avoids_code_without_debug_info);
574 } else {
575 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
576 false, abort_other_plans, stop_other_threads, new_plan_status);
577 }
578
579 if (new_plan_status.Success())
580 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
581 else
582 error = Status::FromErrorString(new_plan_status.AsCString());
583}
584
586 LLDB_INSTRUMENT_VA(this);
587
588 SBError error; // Ignored
589 StepOut(error);
590}
591
594
595 llvm::Expected<StoppedExecutionContext> exe_ctx =
597 if (!exe_ctx) {
598 error = Status::FromError(exe_ctx.takeError());
599 return;
600 }
601
602 if (!exe_ctx->HasThreadScope()) {
603 error = Status::FromErrorString("this SBThread object is invalid");
604 return;
605 }
606
607 bool abort_other_plans = false;
608 bool stop_other_threads = false;
609
610 Thread *thread = exe_ctx->GetThreadPtr();
611
612 const LazyBool avoid_no_debug = eLazyBoolCalculate;
613 Status new_plan_status;
614 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
615 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
616 eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
617
618 if (new_plan_status.Success())
619 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
620 else
621 error = Status::FromErrorString(new_plan_status.AsCString());
622}
623
625 LLDB_INSTRUMENT_VA(this, sb_frame);
626
627 SBError error; // Ignored
628 StepOutOfFrame(sb_frame, error);
629}
630
632 LLDB_INSTRUMENT_VA(this, sb_frame, error);
633
634 llvm::Expected<StoppedExecutionContext> exe_ctx =
636 if (!exe_ctx) {
637 error = Status::FromError(exe_ctx.takeError());
638 return;
639 }
640
641 if (!sb_frame.IsValid()) {
642 error = Status::FromErrorString("passed invalid SBFrame object");
643 return;
644 }
645
646 StackFrameSP frame_sp(sb_frame.GetFrameSP());
647
648 if (!exe_ctx->HasThreadScope()) {
649 error = Status::FromErrorString("this SBThread object is invalid");
650 return;
651 }
652
653 bool abort_other_plans = false;
654 bool stop_other_threads = false;
655 Thread *thread = exe_ctx->GetThreadPtr();
656 if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
657 error = Status::FromErrorString("passed a frame from another thread");
658 return;
659 }
660
661 Status new_plan_status;
662 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
663 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
664 eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
665
666 if (new_plan_status.Success())
667 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
668 else
669 error = Status::FromErrorString(new_plan_status.AsCString());
670}
671
672void SBThread::StepInstruction(bool step_over) {
673 LLDB_INSTRUMENT_VA(this, step_over);
674
675 SBError error; // Ignored
676 StepInstruction(step_over, error);
677}
678
680 LLDB_INSTRUMENT_VA(this, step_over, error);
681
682 llvm::Expected<StoppedExecutionContext> exe_ctx =
684 if (!exe_ctx) {
685 error = Status::FromError(exe_ctx.takeError());
686 return;
687 }
688
689 if (!exe_ctx->HasThreadScope()) {
690 error = Status::FromErrorString("this SBThread object is invalid");
691 return;
692 }
693
694 Thread *thread = exe_ctx->GetThreadPtr();
695 Status new_plan_status;
696 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepSingleInstruction(
697 step_over, false, true, new_plan_status));
698
699 if (new_plan_status.Success())
700 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
701 else
702 error = Status::FromErrorString(new_plan_status.AsCString());
703}
704
706 LLDB_INSTRUMENT_VA(this, addr);
707
708 SBError error; // Ignored
709 RunToAddress(addr, error);
710}
711
713 LLDB_INSTRUMENT_VA(this, addr, error);
714
715 llvm::Expected<StoppedExecutionContext> exe_ctx =
717 if (!exe_ctx) {
718 error = Status::FromError(exe_ctx.takeError());
719 return;
720 }
721
722 if (!exe_ctx->HasThreadScope()) {
723 error = Status::FromErrorString("this SBThread object is invalid");
724 return;
725 }
726
727 bool abort_other_plans = false;
728 bool stop_other_threads = true;
729
730 Address target_addr(addr);
731
732 Thread *thread = exe_ctx->GetThreadPtr();
733
734 Status new_plan_status;
735 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
736 abort_other_plans, target_addr, stop_other_threads, new_plan_status));
737
738 if (new_plan_status.Success())
739 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
740 else
741 error = Status::FromErrorString(new_plan_status.AsCString());
742}
743
745 lldb::SBFileSpec &sb_file_spec, uint32_t line) {
746 LLDB_INSTRUMENT_VA(this, sb_frame, sb_file_spec, line);
747
748 SBError sb_error;
749 char path[PATH_MAX];
750
751 llvm::Expected<StoppedExecutionContext> exe_ctx =
753 if (!exe_ctx)
754 return Status::FromError(exe_ctx.takeError());
755
756 StackFrameSP frame_sp(sb_frame.GetFrameSP());
757
758 if (exe_ctx->HasThreadScope()) {
759 Target *target = exe_ctx->GetTargetPtr();
760 Thread *thread = exe_ctx->GetThreadPtr();
761
762 if (line == 0) {
763 sb_error = Status::FromErrorString("invalid line argument");
764 return sb_error;
765 }
766
767 if (!frame_sp) {
768 // We don't want to run SelectMostRelevantFrame here, for instance if
769 // you called a sequence of StepOverUntil's you wouldn't want the
770 // frame changed out from under you because you stepped into a
771 // recognized frame.
772 frame_sp = thread->GetSelectedFrame(DoNoSelectMostRelevantFrame);
773 if (!frame_sp)
774 frame_sp = thread->GetStackFrameAtIndex(0);
775 }
776
777 SymbolContext frame_sc;
778 if (!frame_sp) {
779 sb_error = Status::FromErrorString("no valid frames in thread to step");
780 return sb_error;
781 }
782
783 // If we have a frame, get its line
784 frame_sc = frame_sp->GetSymbolContext(
785 eSymbolContextCompUnit | eSymbolContextFunction |
786 eSymbolContextLineEntry | eSymbolContextSymbol);
787
788 if (frame_sc.comp_unit == nullptr) {
790 "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
791 return sb_error;
792 }
793
794 FileSpec step_file_spec;
795 if (sb_file_spec.IsValid()) {
796 // The file spec passed in was valid, so use it
797 step_file_spec = sb_file_spec.ref();
798 } else {
799 if (frame_sc.line_entry.IsValid())
800 step_file_spec = frame_sc.line_entry.GetFile();
801 else {
802 sb_error = Status::FromErrorString(
803 "invalid file argument or no file for frame");
804 return sb_error;
805 }
806 }
807
808 // Grab the current function, then we will make sure the "until" address is
809 // within the function. We discard addresses that are out of the current
810 // function, and then if there are no addresses remaining, give an
811 // appropriate error message.
812
813 bool all_in_function = true;
814
815 std::vector<addr_t> step_over_until_addrs;
816 const bool abort_other_plans = false;
817 const bool stop_other_threads = false;
818 // TODO: Handle SourceLocationSpec column information
819 SourceLocationSpec location_spec(
820 step_file_spec, line, /*column=*/std::nullopt, /*check_inlines=*/true,
821 /*exact_match=*/false);
822
823 SymbolContextList sc_list;
824 frame_sc.comp_unit->ResolveSymbolContext(location_spec,
825 eSymbolContextLineEntry, sc_list);
826 for (const SymbolContext &sc : sc_list) {
827 addr_t step_addr =
828 sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
829 if (step_addr != LLDB_INVALID_ADDRESS) {
830 AddressRange unused_range;
831 if (frame_sc.function->GetRangeContainingLoadAddress(step_addr, *target,
832 unused_range))
833 step_over_until_addrs.push_back(step_addr);
834 else
835 all_in_function = false;
836 }
837 }
838
839 if (step_over_until_addrs.empty()) {
840 if (all_in_function) {
841 step_file_spec.GetPath(path, sizeof(path));
843 "No line entries for %s:%u", path, line);
844 } else
845 sb_error = Status::FromErrorString(
846 "step until target not in current function");
847 } else {
848 Status new_plan_status;
849 ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepUntil(
850 abort_other_plans, step_over_until_addrs, stop_other_threads,
851 frame_sp->GetFrameIndex(), new_plan_status);
852
853 if (new_plan_status.Success())
854 sb_error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
855 else
856 sb_error = Status::FromErrorString(new_plan_status.AsCString());
857 }
858 } else {
859 sb_error = Status::FromErrorString("this SBThread object is invalid");
860 }
861 return sb_error;
862}
863
864SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
865 LLDB_INSTRUMENT_VA(this, script_class_name);
866
867 return StepUsingScriptedThreadPlan(script_class_name, true);
868}
869
870SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
871 bool resume_immediately) {
872 LLDB_INSTRUMENT_VA(this, script_class_name, resume_immediately);
873
875 return StepUsingScriptedThreadPlan(script_class_name, no_data,
876 resume_immediately);
877}
878
879SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
880 SBStructuredData &args_data,
881 bool resume_immediately) {
882 LLDB_INSTRUMENT_VA(this, script_class_name, args_data, resume_immediately);
883
885
886 llvm::Expected<StoppedExecutionContext> exe_ctx =
888 if (!exe_ctx)
889 return Status::FromError(exe_ctx.takeError());
890
891 if (!exe_ctx->HasThreadScope()) {
892 error = Status::FromErrorString("this SBThread object is invalid");
893 return error;
894 }
895
896 Thread *thread = exe_ctx->GetThreadPtr();
897 Status new_plan_status;
898 StructuredData::ObjectSP obj_sp = args_data.m_impl_up->GetObjectSP();
899
900 StructuredData::DictionarySP args_dict_sp;
901 if (obj_sp && obj_sp->GetType() == lldb::eStructuredDataTypeDictionary)
902 args_dict_sp = std::static_pointer_cast<StructuredData::Dictionary>(obj_sp);
903
904 ScriptedMetadata scripted_metadata(script_class_name, args_dict_sp);
905 ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
906 false, scripted_metadata, false, new_plan_status);
907
908 if (new_plan_status.Fail()) {
909 error = Status::FromErrorString(new_plan_status.AsCString());
910 return error;
911 }
912
913 if (!resume_immediately)
914 return error;
915
916 if (new_plan_status.Success())
917 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
918 else
919 error = Status::FromErrorString(new_plan_status.AsCString());
920
921 return error;
922}
923
925 LLDB_INSTRUMENT_VA(this, file_spec, line);
926
927 SBError sb_error;
928
929 llvm::Expected<StoppedExecutionContext> exe_ctx =
931 if (!exe_ctx)
932 return Status::FromError(exe_ctx.takeError());
933
934 if (!exe_ctx->HasThreadScope()) {
935 sb_error = Status::FromErrorString("this SBThread object is invalid");
936 return sb_error;
937 }
938
939 Thread *thread = exe_ctx->GetThreadPtr();
940
941 Status err = thread->JumpToLine(file_spec.ref(), line, true);
942 sb_error.SetError(std::move(err));
943 return sb_error;
944}
945
947 LLDB_INSTRUMENT_VA(this, frame, return_value);
948
949 SBError sb_error;
950
951 llvm::Expected<StoppedExecutionContext> exe_ctx =
953 if (!exe_ctx)
954 return Status::FromError(exe_ctx.takeError());
955
956 if (exe_ctx->HasThreadScope()) {
957 Thread *thread = exe_ctx->GetThreadPtr();
958 sb_error.SetError(
959 thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
960 }
961
962 return sb_error;
963}
964
966 LLDB_INSTRUMENT_VA(this);
967
968 SBError sb_error;
969
970 llvm::Expected<StoppedExecutionContext> exe_ctx =
972 if (!exe_ctx)
973 return Status::FromError(exe_ctx.takeError());
974
975 if (exe_ctx->HasThreadScope()) {
976 Thread *thread = exe_ctx->GetThreadPtr();
977 sb_error.SetError(thread->UnwindInnermostExpression());
978 if (sb_error.Success())
979 thread->SetSelectedFrameByIndex(0, false);
980 }
981
982 return sb_error;
983}
984
986 LLDB_INSTRUMENT_VA(this);
987
988 SBError error; // Ignored
989 return Suspend(error);
990}
991
994
995 llvm::Expected<StoppedExecutionContext> exe_ctx =
997 if (!exe_ctx) {
998 error = Status::FromError(exe_ctx.takeError());
999 return false;
1000 }
1001
1002 bool result = false;
1003 if (exe_ctx->HasThreadScope()) {
1004 exe_ctx->GetThreadPtr()->SetResumeState(eStateSuspended);
1005 result = true;
1006 } else
1007 error = Status::FromErrorString("this SBThread object is invalid");
1008 return result;
1009}
1010
1012 LLDB_INSTRUMENT_VA(this);
1013
1014 SBError error; // Ignored
1015 return Resume(error);
1016}
1017
1020
1021 llvm::Expected<StoppedExecutionContext> exe_ctx =
1023 if (!exe_ctx) {
1024 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1025 error = Status::FromErrorString("process is running");
1026 return false;
1027 }
1028
1029 bool result = false;
1030 if (exe_ctx->HasThreadScope()) {
1031 const bool override_suspend = true;
1032 exe_ctx->GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
1033 result = true;
1034 } else
1035 error = Status::FromErrorString("this SBThread object is invalid");
1036 return result;
1037}
1038
1040 LLDB_INSTRUMENT_VA(this);
1041
1042 llvm::Expected<StoppedExecutionContext> exe_ctx =
1044 if (!exe_ctx) {
1045 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1046 return false;
1047 }
1048
1049 if (exe_ctx->HasThreadScope())
1050 return exe_ctx->GetThreadPtr()->GetResumeState() == eStateSuspended;
1051 return false;
1052}
1053
1055 LLDB_INSTRUMENT_VA(this);
1056
1057 llvm::Expected<StoppedExecutionContext> exe_ctx =
1059 if (!exe_ctx) {
1060 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1061 return false;
1062 }
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 llvm::Expected<StoppedExecutionContext> exe_ctx =
1075 if (!exe_ctx) {
1076 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1077 return SBProcess();
1078 }
1079
1080 if (exe_ctx->HasThreadScope()) {
1081 // Have to go up to the target so we can get a shared pointer to our
1082 // process...
1083 sb_process.SetSP(exe_ctx->GetProcessSP());
1084 }
1085
1086 return sb_process;
1087}
1088
1090 LLDB_INSTRUMENT_VA(this);
1091
1092 llvm::Expected<StoppedExecutionContext> exe_ctx =
1094 if (!exe_ctx) {
1095 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1096 return 0;
1097 }
1098
1099 if (exe_ctx->HasThreadScope())
1100 return exe_ctx->GetThreadPtr()->GetStackFrameCount();
1101
1102 return 0;
1103}
1104
1106 LLDB_INSTRUMENT_VA(this, idx);
1107
1108 SBFrame sb_frame;
1109 llvm::Expected<StoppedExecutionContext> exe_ctx =
1111 if (!exe_ctx) {
1112 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1113 return SBFrame();
1114 }
1115
1116 if (exe_ctx->HasThreadScope()) {
1117 StackFrameSP frame_sp = exe_ctx->GetThreadPtr()->GetStackFrameAtIndex(idx);
1118 sb_frame.SetFrameSP(frame_sp);
1119 }
1120
1121 return sb_frame;
1122}
1123
1125 LLDB_INSTRUMENT_VA(this);
1126
1127 SBFrameList sb_frame_list;
1128 llvm::Expected<StoppedExecutionContext> exe_ctx =
1130 if (!exe_ctx) {
1131 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1132 return SBFrameList();
1133 }
1134
1135 if (exe_ctx->HasThreadScope()) {
1136 StackFrameListSP frame_list_sp =
1137 exe_ctx->GetThreadPtr()->GetStackFrameList();
1138 sb_frame_list.SetFrameList(frame_list_sp);
1139 }
1140
1141 return sb_frame_list;
1142}
1143
1145 LLDB_INSTRUMENT_VA(this);
1146
1147 SBFrame sb_frame;
1148 llvm::Expected<StoppedExecutionContext> exe_ctx =
1150 if (!exe_ctx) {
1151 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1152 return SBFrame();
1153 }
1154
1155 if (exe_ctx->HasThreadScope()) {
1156 StackFrameSP frame_sp =
1157 exe_ctx->GetThreadPtr()->GetSelectedFrame(SelectMostRelevantFrame);
1158 sb_frame.SetFrameSP(frame_sp);
1159 }
1160
1161 return sb_frame;
1162}
1163
1165 LLDB_INSTRUMENT_VA(this, idx);
1166
1167 SBFrame sb_frame;
1168 StackFrameSP frame_sp;
1169 llvm::Expected<StoppedExecutionContext> exe_ctx =
1171 if (!exe_ctx) {
1172 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1173 return SBFrame();
1174 }
1175
1176 if (exe_ctx->HasThreadScope()) {
1177 Thread *thread = exe_ctx->GetThreadPtr();
1178 frame_sp = thread->GetStackFrameAtIndex(idx);
1179 if (frame_sp) {
1180 thread->SetSelectedFrame(frame_sp.get());
1181 sb_frame.SetFrameSP(frame_sp);
1182 }
1183 }
1184
1185 return sb_frame;
1186}
1187
1189 LLDB_INSTRUMENT_VA(event);
1190
1191 return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr;
1192}
1193
1199
1205
1206bool SBThread::operator==(const SBThread &rhs) const {
1207 LLDB_INSTRUMENT_VA(this, rhs);
1208
1209 return m_opaque_sp->GetThreadSP().get() ==
1210 rhs.m_opaque_sp->GetThreadSP().get();
1211}
1212
1213bool SBThread::operator!=(const SBThread &rhs) const {
1214 LLDB_INSTRUMENT_VA(this, rhs);
1215
1216 return m_opaque_sp->GetThreadSP().get() !=
1217 rhs.m_opaque_sp->GetThreadSP().get();
1218}
1219
1220bool SBThread::GetStatus(SBStream &status) const {
1221 LLDB_INSTRUMENT_VA(this, status);
1222
1223 Stream &strm = status.ref();
1224
1225 llvm::Expected<StoppedExecutionContext> exe_ctx =
1227 if (!exe_ctx) {
1228 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1229 return false;
1230 }
1231
1232 if (exe_ctx->HasThreadScope()) {
1233 exe_ctx->GetThreadPtr()->GetStatus(strm, 0, 1, 1, true,
1234 /*show_hidden=*/true);
1235 } else
1236 strm.PutCString("No status");
1237
1238 return true;
1239}
1240
1241bool SBThread::GetDescription(SBStream &description) const {
1242 LLDB_INSTRUMENT_VA(this, description);
1243
1244 return GetDescription(description, false);
1245}
1246
1247bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
1248 LLDB_INSTRUMENT_VA(this, description, stop_format);
1249
1250 Stream &strm = description.ref();
1251
1252 llvm::Expected<StoppedExecutionContext> exe_ctx =
1254 if (!exe_ctx) {
1255 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1256 return false;
1257 }
1258
1259 if (exe_ctx->HasThreadScope()) {
1260 exe_ctx->GetThreadPtr()->DumpUsingSettingsFormat(
1261 strm, LLDB_INVALID_THREAD_ID, stop_format);
1262 } else
1263 strm.PutCString("No value");
1264
1265 return true;
1266}
1267
1269 SBStream &output) {
1270 Stream &strm = output.ref();
1271
1272 SBError error;
1273 if (!format) {
1274 error = Status::FromErrorString("The provided SBFormat object is invalid");
1275 return error;
1276 }
1277
1278 llvm::Expected<StoppedExecutionContext> exe_ctx =
1280 if (!exe_ctx) {
1281 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1282 return error;
1283 }
1284
1285 if (exe_ctx->HasThreadScope()) {
1286 if (exe_ctx->GetThreadPtr()->DumpUsingFormat(
1287 strm, LLDB_INVALID_THREAD_ID, format.GetFormatEntrySP().get())) {
1288 return error;
1289 }
1290 }
1291
1293 "It was not possible to generate a thread description with the given "
1294 "format string '%s'",
1295 format.GetFormatEntrySP()->string.c_str());
1296 return error;
1297}
1298
1300 LLDB_INSTRUMENT_VA(this, type);
1301
1302 llvm::Expected<StoppedExecutionContext> exe_ctx =
1304 SBThread sb_origin_thread;
1305 if (exe_ctx) {
1306 if (exe_ctx->HasThreadScope()) {
1307 ThreadSP real_thread(exe_ctx->GetThreadSP());
1308 if (real_thread) {
1309 ConstString type_const(type);
1310 Process *process = exe_ctx->GetProcessPtr();
1311 if (process) {
1312 SystemRuntime *runtime = process->GetSystemRuntime();
1313 if (runtime) {
1314 ThreadSP new_thread_sp(
1315 runtime->GetExtendedBacktraceThread(real_thread, type_const));
1316 if (new_thread_sp) {
1317 // Save this in the Process' ExtendedThreadList so a strong
1318 // pointer retains the object.
1319 process->GetExtendedThreadList().AddThread(new_thread_sp);
1320 sb_origin_thread.SetThread(new_thread_sp);
1321 }
1322 }
1323 }
1324 }
1325 }
1326 } else {
1327 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1328 }
1329
1330 return sb_origin_thread;
1331}
1332
1334 LLDB_INSTRUMENT_VA(this);
1335
1336 llvm::Expected<StoppedExecutionContext> exe_ctx =
1338 if (!exe_ctx) {
1339 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1340 return LLDB_INVALID_INDEX32;
1341 }
1342
1343 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1344 if (thread_sp)
1345 return thread_sp->GetExtendedBacktraceOriginatingIndexID();
1346 return LLDB_INVALID_INDEX32;
1347}
1348
1350 LLDB_INSTRUMENT_VA(this);
1351
1352 llvm::Expected<StoppedExecutionContext> exe_ctx =
1354 if (!exe_ctx) {
1355 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1356 return SBValue();
1357 }
1358
1359 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1360 if (!thread_sp)
1361 return SBValue();
1362
1363 return SBValue(thread_sp->GetCurrentException());
1364}
1365
1367 LLDB_INSTRUMENT_VA(this);
1368
1369 llvm::Expected<StoppedExecutionContext> exe_ctx =
1371 if (!exe_ctx) {
1372 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1373 return SBThread();
1374 }
1375
1376 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1377 if (!thread_sp)
1378 return SBThread();
1379
1380 return SBThread(thread_sp->GetCurrentExceptionBacktrace());
1381}
1382
1384 LLDB_INSTRUMENT_VA(this);
1385
1386 llvm::Expected<StoppedExecutionContext> exe_ctx =
1388 if (!exe_ctx) {
1389 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1390 return false;
1391 }
1392
1393 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1394 if (thread_sp)
1395 return thread_sp->SafeToCallFunctions();
1396 return true;
1397}
1398
1399lldb::ThreadSP SBThread::GetSP() const { return m_opaque_sp->GetThreadSP(); }
1400
1404
1406 return m_opaque_sp->GetThreadSP().get();
1407}
1408
1410 LLDB_INSTRUMENT_VA(this);
1411
1412 llvm::Expected<StoppedExecutionContext> exe_ctx =
1414 if (!exe_ctx) {
1415 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1416 return SBValue();
1417 }
1418
1419 ThreadSP thread_sp = m_opaque_sp->GetThreadSP();
1420 if (!thread_sp)
1421 return SBValue();
1422 return thread_sp->GetSiginfoValue();
1423}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT()
#define LLDB_INSTRUMENT_VA(...)
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:394
static Status ResumeNewPlan(StoppedExecutionContext exe_ctx, ThreadPlan *new_plan)
Definition SBThread.cpp:449
bool Success() const
Definition SBError.cpp:81
void SetError(uint32_t err, lldb::ErrorType type)
Definition SBError.cpp:124
lldb_private::Event * get() const
Definition SBEvent.cpp:134
bool IsValid() const
const lldb_private::FileSpec & ref() const
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
Represents a list of SBFrame objects.
Definition SBFrameList.h:31
void SetFrameList(const lldb::StackFrameListSP &frame_list_sp)
bool IsValid() const
Definition SBFrame.cpp:96
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition SBFrame.cpp:92
lldb::SBThread GetThread() const
Definition SBFrame.cpp:608
lldb::StackFrameSP GetFrameSP() const
Definition SBFrame.cpp:88
void SetSP(const lldb::ProcessSP &process_sp)
void SetQueue(const lldb::QueueSP &queue_sp)
Definition SBQueue.cpp:254
lldb_private::Stream & ref()
Definition SBStream.cpp:178
StructuredDataImplUP m_impl_up
static const char * GetBroadcasterClassName()
Definition SBThread.cpp:54
void StepInto(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition SBThread.cpp:516
bool Suspend()
LLDB currently supports process centric debugging which means when any thread in a process stops,...
Definition SBThread.cpp:985
const char * GetName() const
Definition SBThread.cpp:351
bool GetStopDescription(lldb::SBStream &stream) const
Gets a human-readable description of why the thread stopped.
Definition SBThread.cpp:243
const lldb::SBThread & operator=(const lldb::SBThread &rhs)
Definition SBThread.cpp:78
lldb::SBFrame SetSelectedFrame(uint32_t frame_idx)
SBError UnwindInnermostExpression()
Definition SBThread.cpp:965
friend class SBThreadCollection
Definition SBThread.h:255
bool IsValid() const
Definition SBThread.cpp:111
uint32_t GetNumFrames()
friend class SBProcess
Definition SBThread.h:250
const char * GetQueueName() const
Definition SBThread.cpp:367
SBValue GetSiginfo()
uint32_t GetIndexID() const
Definition SBThread.cpp:335
bool GetDescription(lldb::SBStream &description) const
static bool EventIsThreadEvent(const SBEvent &event)
lldb_private::Thread * operator->()
lldb_private::Thread * get()
void StepOutOfFrame(SBFrame &frame)
Definition SBThread.cpp:624
bool GetStatus(lldb::SBStream &status) const
friend class SBValue
Definition SBThread.h:252
static SBFrame GetStackFrameFromEvent(const SBEvent &event)
lldb::queue_id_t GetQueueID() const
Definition SBThread.cpp:383
lldb::SBFrameList GetFrames() const
bool GetInfoItemByPathAsString(const char *path, SBStream &strm)
Definition SBThread.cpp:401
lldb::SBFrame GetSelectedFrame()
friend class SBFrameList
Definition SBThread.h:249
bool operator!=(const lldb::SBThread &rhs) const
SBError StepUsingScriptedThreadPlan(const char *script_class_name)
Definition SBThread.cpp:864
lldb::tid_t GetThreadID() const
Definition SBThread.cpp:319
lldb::SBFrame GetFrameAtIndex(uint32_t idx)
uint32_t GetExtendedBacktraceOriginatingIndexID()
lldb::SBQueue GetQueue() const
Definition SBThread.cpp:89
bool SafeToCallFunctions()
lldb::SBProcess GetProcess()
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:672
SBThread GetCurrentExceptionBacktrace()
friend class SBFrame
Definition SBThread.h:248
static SBThread GetThreadFromEvent(const SBEvent &event)
bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream)
Definition SBThread.cpp:190
lldb::StopReason GetStopReason()
Definition SBThread.cpp:136
SBValue GetStopReturnValue()
Definition SBThread.cpp:294
void StepOver(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition SBThread.cpp:473
SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line)
Definition SBThread.cpp:924
SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output)
Similar to GetDescription() but the format of the description can be configured via the format parame...
SBThreadCollection GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type)
Definition SBThread.cpp:216
SBValue GetCurrentException()
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition SBThread.cpp:315
lldb::ThreadSP GetSP() const
SBThread GetExtendedBacktraceThread(const char *type)
lldb::ExecutionContextRefSP m_opaque_sp
Definition SBThread.h:268
void RunToAddress(lldb::addr_t addr)
Definition SBThread.cpp:705
uint64_t GetStopReasonDataAtIndex(uint32_t idx)
Get information associated with a stop reason.
Definition SBThread.cpp:171
SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value)
Definition SBThread.cpp:946
bool operator==(const lldb::SBThread &rhs) const
SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec, uint32_t line)
Definition SBThread.cpp:744
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:973
A section + offset based address range class.
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 * GetCString() const
Get the string value as a C string.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
Execution context objects refer to objects in the execution of the program that is being debugged.
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:57
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
bool GetRangeContainingLoadAddress(lldb::addr_t load_addr, Target &target, AddressRange &range)
Definition Function.h:447
A plug-in interface definition class for debugging a process.
Definition Process.h:357
ThreadList & GetThreadList()
Definition Process.h:2380
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
Definition Process.cpp:1332
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
Definition Process.cpp:3114
ThreadList & GetExtendedThreadList()
Definition Process.h:2391
Status ResumeSynchronous(Stream *stream)
Resume a process, and wait for it to stop.
Definition Process.cpp:1349
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1255
"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:293
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition Status.cpp:194
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:136
bool Success() const
Test for success condition.
Definition Status.cpp:303
static lldb::ValueObjectSP GetReturnValueObject(lldb::StopInfoSP &stop_info_sp)
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:63
std::shared_ptr< Dictionary > DictionarySP
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.
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.
virtual lldb::ThreadSP GetExtendedBacktraceThread(lldb::ThreadSP thread, ConstString type)
Return a Thread which shows the origin of this thread's creation.
Debugger & GetDebugger() const
Definition Target.h:1324
void AddThread(const lldb::ThreadSP &thread_sp)
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
void SetOkayToDiscard(bool value)
Definition ThreadPlan.h:427
bool SetIsControllingPlan(bool value)
Definition ThreadPlan.h:419
static const ThreadEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition Thread.cpp:179
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
Definition Thread.cpp:189
static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr)
Definition Thread.cpp:206
static llvm::StringRef GetStaticBroadcasterClass()
Definition Thread.cpp:221
#define LLDB_INVALID_QUEUE_ID
#define LLDB_INVALID_LINE_NUMBER
#define LLDB_INVALID_THREAD_ID
#define LLDB_INVALID_INDEX32
#define LLDB_INVALID_ADDRESS
@ DoNoSelectMostRelevantFrame
@ SelectMostRelevantFrame
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:327
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
llvm::Expected< StoppedExecutionContext > GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr)
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::Queue > QueueSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
@ 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.
std::shared_ptr< lldb_private::Process > ProcessSP
InstrumentationRuntimeType
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
uint64_t addr_t
Definition lldb-types.h:80
StopReason
Thread stop reasons.
@ eStructuredDataTypeFloat
@ eStructuredDataTypeDictionary
@ eStructuredDataTypeInteger
@ eStructuredDataTypeNull
@ eStructuredDataTypeBoolean
@ eStructuredDataTypeString
class LLDB_API SBQueue
Definition SBDefines.h:101
RunMode
Thread Run Modes.
uint64_t tid_t
Definition lldb-types.h:84
uint64_t queue_id_t
Definition lldb-types.h:91
std::shared_ptr< lldb_private::StackFrameList > StackFrameListSP
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
A wrapper class representing an execution context with non-null Target and Process pointers,...
std::unique_lock< std::recursive_mutex > AllowResume()
Clears this context, unlocking the ProcessRunLock and returning the locked API lock,...
#define PATH_MAX