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