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
242size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
243 LLDB_INSTRUMENT_VA(this, dst, dst_len);
244
245 if (dst)
246 *dst = 0;
247
248 llvm::Expected<StoppedExecutionContext> exe_ctx =
250 if (!exe_ctx) {
251 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
252 return 0;
253 }
254
255 if (!exe_ctx->HasThreadScope())
256 return 0;
257
258 std::string thread_stop_desc = exe_ctx->GetThreadPtr()->GetStopDescription();
259 if (thread_stop_desc.empty())
260 return 0;
261
262 if (dst)
263 return ::snprintf(dst, dst_len, "%s", thread_stop_desc.c_str()) + 1;
264
265 // NULL dst passed in, return the length needed to contain the
266 // description.
267 return thread_stop_desc.size() + 1; // Include the NULL byte for size
268}
269
271 LLDB_INSTRUMENT_VA(this);
272
273 ValueObjectSP return_valobj_sp;
274 llvm::Expected<StoppedExecutionContext> exe_ctx =
276 if (!exe_ctx) {
277 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
278 return SBValue();
279 }
280
281 if (exe_ctx->HasThreadScope()) {
282 StopInfoSP stop_info_sp = exe_ctx->GetThreadPtr()->GetStopInfo();
283 if (stop_info_sp) {
284 return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
285 }
286 }
287
288 return SBValue(return_valobj_sp);
289}
290
291void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
292 m_opaque_sp->SetThreadSP(lldb_object_sp);
293}
294
296 LLDB_INSTRUMENT_VA(this);
297
298 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
299 if (thread_sp)
300 return thread_sp->GetID();
302}
303
304uint32_t SBThread::GetIndexID() const {
305 LLDB_INSTRUMENT_VA(this);
306
307 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
308 if (thread_sp)
309 return thread_sp->GetIndexID();
311}
312
313const char *SBThread::GetName() const {
314 LLDB_INSTRUMENT_VA(this);
315
316 llvm::Expected<StoppedExecutionContext> exe_ctx =
318 if (!exe_ctx) {
319 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
320 return nullptr;
321 }
322
323 if (!exe_ctx->HasThreadScope())
324 return nullptr;
325
326 return ConstString(exe_ctx->GetThreadPtr()->GetName()).GetCString();
327}
328
329const char *SBThread::GetQueueName() const {
330 LLDB_INSTRUMENT_VA(this);
331
332 llvm::Expected<StoppedExecutionContext> exe_ctx =
334 if (!exe_ctx) {
335 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
336 return nullptr;
337 }
338
339 if (!exe_ctx->HasThreadScope())
340 return nullptr;
341
342 return ConstString(exe_ctx->GetThreadPtr()->GetQueueName()).GetCString();
343}
344
346 LLDB_INSTRUMENT_VA(this);
347
349 llvm::Expected<StoppedExecutionContext> exe_ctx =
351 if (!exe_ctx) {
352 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
353 return id;
354 }
355
356 if (exe_ctx->HasThreadScope()) {
357 id = exe_ctx->GetThreadPtr()->GetQueueID();
358 }
359
360 return id;
361}
362
363bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
364 LLDB_INSTRUMENT_VA(this, path, strm);
365
366 bool success = false;
367 llvm::Expected<StoppedExecutionContext> exe_ctx =
369 if (exe_ctx) {
370 if (exe_ctx->HasThreadScope()) {
371 Thread *thread = exe_ctx->GetThreadPtr();
372 StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
373 if (info_root_sp) {
375 info_root_sp->GetObjectForDotSeparatedPath(path);
376 if (node) {
377 if (node->GetType() == eStructuredDataTypeString) {
378 strm.ref() << node->GetAsString()->GetValue();
379 success = true;
380 }
381 if (node->GetType() == eStructuredDataTypeInteger) {
382 strm.Printf("0x%" PRIx64, node->GetUnsignedIntegerValue());
383 success = true;
384 }
385 if (node->GetType() == eStructuredDataTypeFloat) {
386 strm.Printf("0x%f", node->GetAsFloat()->GetValue());
387 success = true;
388 }
389 if (node->GetType() == eStructuredDataTypeBoolean) {
390 if (node->GetAsBoolean()->GetValue())
391 strm.Printf("true");
392 else
393 strm.Printf("false");
394 success = true;
395 }
396 if (node->GetType() == eStructuredDataTypeNull) {
397 strm.Printf("null");
398 success = true;
399 }
400 }
401 }
402 }
403 } else {
404 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
405 return success;
406 }
407
408 return success;
409}
410
412 ThreadPlan *new_plan) {
413 Thread *thread = exe_ctx.GetThreadPtr();
414 if (!thread)
415 return Status::FromErrorString("No thread in SBThread::ResumeNewPlan");
416
417 // User level plans should be Controlling Plans so they can be interrupted,
418 // other plans executed, and then a "continue" will resume the plan.
419 if (new_plan != nullptr) {
420 new_plan->SetIsControllingPlan(true);
421 new_plan->SetOkayToDiscard(false);
422 }
423
424 // Why do we need to set the current thread by ID here???
425 Process *process = exe_ctx.GetProcessPtr();
426 process->GetThreadList().SetSelectedThreadByID(thread->GetID());
427
428 // Release the run lock but keep the API lock.
429 std::unique_lock<std::recursive_mutex> api_lock = exe_ctx.AllowResume();
430 if (process->GetTarget().GetDebugger().GetAsyncExecution())
431 return process->Resume();
432 return process->ResumeSynchronous(nullptr);
433}
434
435void SBThread::StepOver(lldb::RunMode stop_other_threads) {
436 LLDB_INSTRUMENT_VA(this, stop_other_threads);
437
438 SBError error; // Ignored
439 StepOver(stop_other_threads, error);
440}
441
442void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
443 LLDB_INSTRUMENT_VA(this, stop_other_threads, error);
444
445 llvm::Expected<StoppedExecutionContext> exe_ctx =
447 if (!exe_ctx) {
448 error = Status::FromError(exe_ctx.takeError());
449 return;
450 }
451
452 if (!exe_ctx->HasThreadScope()) {
453 error = Status::FromErrorString("this SBThread object is invalid");
454 return;
455 }
456
457 Thread *thread = exe_ctx->GetThreadPtr();
458 bool abort_other_plans = false;
459 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
460
461 Status new_plan_status;
462 ThreadPlanSP new_plan_sp;
463 if (frame_sp) {
464 if (frame_sp->HasDebugInformation()) {
465 const LazyBool avoid_no_debug = eLazyBoolCalculate;
466 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
467 new_plan_sp = thread->QueueThreadPlanForStepOverRange(
468 abort_other_plans, sc.line_entry, sc, stop_other_threads,
469 new_plan_status, avoid_no_debug);
470 } else {
471 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
472 true, abort_other_plans, stop_other_threads, new_plan_status);
473 }
474 }
475 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
476}
477
478void SBThread::StepInto(lldb::RunMode stop_other_threads) {
479 LLDB_INSTRUMENT_VA(this, stop_other_threads);
480
481 StepInto(nullptr, stop_other_threads);
482}
483
484void SBThread::StepInto(const char *target_name,
485 lldb::RunMode stop_other_threads) {
486 LLDB_INSTRUMENT_VA(this, target_name, stop_other_threads);
487
488 SBError error; // Ignored
489 StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
490}
491
492void SBThread::StepInto(const char *target_name, uint32_t end_line,
493 SBError &error, lldb::RunMode stop_other_threads) {
494 LLDB_INSTRUMENT_VA(this, target_name, end_line, error, stop_other_threads);
495
496 llvm::Expected<StoppedExecutionContext> exe_ctx =
498 if (!exe_ctx) {
499 error = Status::FromError(exe_ctx.takeError());
500 return;
501 }
502
503 if (!exe_ctx->HasThreadScope()) {
504 error = Status::FromErrorString("this SBThread object is invalid");
505 return;
506 }
507
508 bool abort_other_plans = false;
509
510 Thread *thread = exe_ctx->GetThreadPtr();
511 StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
512 ThreadPlanSP new_plan_sp;
513 Status new_plan_status;
514
515 if (frame_sp && frame_sp->HasDebugInformation()) {
516 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
517 AddressRange range;
518 if (end_line == LLDB_INVALID_LINE_NUMBER)
519 range = sc.line_entry.range;
520 else {
521 llvm::Error err = sc.GetAddressRangeFromHereToEndLine(end_line, range);
522 if (err) {
523 error = Status::FromErrorString(llvm::toString(std::move(err)).c_str());
524 return;
525 }
526 }
527
528 const LazyBool step_out_avoids_code_without_debug_info =
530 const LazyBool step_in_avoids_code_without_debug_info =
532 new_plan_sp = thread->QueueThreadPlanForStepInRange(
533 abort_other_plans, range, sc, target_name, stop_other_threads,
534 new_plan_status, step_in_avoids_code_without_debug_info,
535 step_out_avoids_code_without_debug_info);
536 } else {
537 new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
538 false, abort_other_plans, stop_other_threads, new_plan_status);
539 }
540
541 if (new_plan_status.Success())
542 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
543 else
544 error = Status::FromErrorString(new_plan_status.AsCString());
545}
546
548 LLDB_INSTRUMENT_VA(this);
549
550 SBError error; // Ignored
551 StepOut(error);
552}
553
556
557 llvm::Expected<StoppedExecutionContext> exe_ctx =
559 if (!exe_ctx) {
560 error = Status::FromError(exe_ctx.takeError());
561 return;
562 }
563
564 if (!exe_ctx->HasThreadScope()) {
565 error = Status::FromErrorString("this SBThread object is invalid");
566 return;
567 }
568
569 bool abort_other_plans = false;
570 bool stop_other_threads = false;
571
572 Thread *thread = exe_ctx->GetThreadPtr();
573
574 const LazyBool avoid_no_debug = eLazyBoolCalculate;
575 Status new_plan_status;
576 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
577 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
578 eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
579
580 if (new_plan_status.Success())
581 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
582 else
583 error = Status::FromErrorString(new_plan_status.AsCString());
584}
585
587 LLDB_INSTRUMENT_VA(this, sb_frame);
588
589 SBError error; // Ignored
590 StepOutOfFrame(sb_frame, error);
591}
592
594 LLDB_INSTRUMENT_VA(this, sb_frame, error);
595
596 llvm::Expected<StoppedExecutionContext> exe_ctx =
598 if (!exe_ctx) {
599 error = Status::FromError(exe_ctx.takeError());
600 return;
601 }
602
603 if (!sb_frame.IsValid()) {
604 error = Status::FromErrorString("passed invalid SBFrame object");
605 return;
606 }
607
608 StackFrameSP frame_sp(sb_frame.GetFrameSP());
609
610 if (!exe_ctx->HasThreadScope()) {
611 error = Status::FromErrorString("this SBThread object is invalid");
612 return;
613 }
614
615 bool abort_other_plans = false;
616 bool stop_other_threads = false;
617 Thread *thread = exe_ctx->GetThreadPtr();
618 if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
619 error = Status::FromErrorString("passed a frame from another thread");
620 return;
621 }
622
623 Status new_plan_status;
624 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
625 abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
626 eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
627
628 if (new_plan_status.Success())
629 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
630 else
631 error = Status::FromErrorString(new_plan_status.AsCString());
632}
633
634void SBThread::StepInstruction(bool step_over) {
635 LLDB_INSTRUMENT_VA(this, step_over);
636
637 SBError error; // Ignored
638 StepInstruction(step_over, error);
639}
640
642 LLDB_INSTRUMENT_VA(this, step_over, error);
643
644 llvm::Expected<StoppedExecutionContext> exe_ctx =
646 if (!exe_ctx) {
647 error = Status::FromError(exe_ctx.takeError());
648 return;
649 }
650
651 if (!exe_ctx->HasThreadScope()) {
652 error = Status::FromErrorString("this SBThread object is invalid");
653 return;
654 }
655
656 Thread *thread = exe_ctx->GetThreadPtr();
657 Status new_plan_status;
658 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepSingleInstruction(
659 step_over, false, true, new_plan_status));
660
661 if (new_plan_status.Success())
662 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
663 else
664 error = Status::FromErrorString(new_plan_status.AsCString());
665}
666
668 LLDB_INSTRUMENT_VA(this, addr);
669
670 SBError error; // Ignored
671 RunToAddress(addr, error);
672}
673
675 LLDB_INSTRUMENT_VA(this, addr, error);
676
677 llvm::Expected<StoppedExecutionContext> exe_ctx =
679 if (!exe_ctx) {
680 error = Status::FromError(exe_ctx.takeError());
681 return;
682 }
683
684 if (!exe_ctx->HasThreadScope()) {
685 error = Status::FromErrorString("this SBThread object is invalid");
686 return;
687 }
688
689 bool abort_other_plans = false;
690 bool stop_other_threads = true;
691
692 Address target_addr(addr);
693
694 Thread *thread = exe_ctx->GetThreadPtr();
695
696 Status new_plan_status;
697 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
698 abort_other_plans, target_addr, stop_other_threads, new_plan_status));
699
700 if (new_plan_status.Success())
701 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
702 else
703 error = Status::FromErrorString(new_plan_status.AsCString());
704}
705
707 lldb::SBFileSpec &sb_file_spec, uint32_t line) {
708 LLDB_INSTRUMENT_VA(this, sb_frame, sb_file_spec, line);
709
710 SBError sb_error;
711 char path[PATH_MAX];
712
713 llvm::Expected<StoppedExecutionContext> exe_ctx =
715 if (!exe_ctx)
716 return Status::FromError(exe_ctx.takeError());
717
718 StackFrameSP frame_sp(sb_frame.GetFrameSP());
719
720 if (exe_ctx->HasThreadScope()) {
721 Target *target = exe_ctx->GetTargetPtr();
722 Thread *thread = exe_ctx->GetThreadPtr();
723
724 if (line == 0) {
725 sb_error = Status::FromErrorString("invalid line argument");
726 return sb_error;
727 }
728
729 if (!frame_sp) {
730 // We don't want to run SelectMostRelevantFrame here, for instance if
731 // you called a sequence of StepOverUntil's you wouldn't want the
732 // frame changed out from under you because you stepped into a
733 // recognized frame.
734 frame_sp = thread->GetSelectedFrame(DoNoSelectMostRelevantFrame);
735 if (!frame_sp)
736 frame_sp = thread->GetStackFrameAtIndex(0);
737 }
738
739 SymbolContext frame_sc;
740 if (!frame_sp) {
741 sb_error = Status::FromErrorString("no valid frames in thread to step");
742 return sb_error;
743 }
744
745 // If we have a frame, get its line
746 frame_sc = frame_sp->GetSymbolContext(
747 eSymbolContextCompUnit | eSymbolContextFunction |
748 eSymbolContextLineEntry | eSymbolContextSymbol);
749
750 if (frame_sc.comp_unit == nullptr) {
752 "frame %u doesn't have debug information", frame_sp->GetFrameIndex());
753 return sb_error;
754 }
755
756 FileSpec step_file_spec;
757 if (sb_file_spec.IsValid()) {
758 // The file spec passed in was valid, so use it
759 step_file_spec = sb_file_spec.ref();
760 } else {
761 if (frame_sc.line_entry.IsValid())
762 step_file_spec = frame_sc.line_entry.GetFile();
763 else {
764 sb_error = Status::FromErrorString(
765 "invalid file argument or no file for frame");
766 return sb_error;
767 }
768 }
769
770 // Grab the current function, then we will make sure the "until" address is
771 // within the function. We discard addresses that are out of the current
772 // function, and then if there are no addresses remaining, give an
773 // appropriate error message.
774
775 bool all_in_function = true;
776
777 std::vector<addr_t> step_over_until_addrs;
778 const bool abort_other_plans = false;
779 const bool stop_other_threads = false;
780 // TODO: Handle SourceLocationSpec column information
781 SourceLocationSpec location_spec(
782 step_file_spec, line, /*column=*/std::nullopt, /*check_inlines=*/true,
783 /*exact_match=*/false);
784
785 SymbolContextList sc_list;
786 frame_sc.comp_unit->ResolveSymbolContext(location_spec,
787 eSymbolContextLineEntry, sc_list);
788 for (const SymbolContext &sc : sc_list) {
789 addr_t step_addr =
790 sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
791 if (step_addr != LLDB_INVALID_ADDRESS) {
792 AddressRange unused_range;
793 if (frame_sc.function->GetRangeContainingLoadAddress(step_addr, *target,
794 unused_range))
795 step_over_until_addrs.push_back(step_addr);
796 else
797 all_in_function = false;
798 }
799 }
800
801 if (step_over_until_addrs.empty()) {
802 if (all_in_function) {
803 step_file_spec.GetPath(path, sizeof(path));
805 "No line entries for %s:%u", path, line);
806 } else
807 sb_error = Status::FromErrorString(
808 "step until target not in current function");
809 } else {
810 Status new_plan_status;
811 ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil(
812 abort_other_plans, &step_over_until_addrs[0],
813 step_over_until_addrs.size(), stop_other_threads,
814 frame_sp->GetFrameIndex(), new_plan_status));
815
816 if (new_plan_status.Success())
817 sb_error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
818 else
819 sb_error = Status::FromErrorString(new_plan_status.AsCString());
820 }
821 } else {
822 sb_error = Status::FromErrorString("this SBThread object is invalid");
823 }
824 return sb_error;
825}
826
827SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
828 LLDB_INSTRUMENT_VA(this, script_class_name);
829
830 return StepUsingScriptedThreadPlan(script_class_name, true);
831}
832
833SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
834 bool resume_immediately) {
835 LLDB_INSTRUMENT_VA(this, script_class_name, resume_immediately);
836
838 return StepUsingScriptedThreadPlan(script_class_name, no_data,
839 resume_immediately);
840}
841
842SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
843 SBStructuredData &args_data,
844 bool resume_immediately) {
845 LLDB_INSTRUMENT_VA(this, script_class_name, args_data, resume_immediately);
846
848
849 llvm::Expected<StoppedExecutionContext> exe_ctx =
851 if (!exe_ctx)
852 return Status::FromError(exe_ctx.takeError());
853
854 if (!exe_ctx->HasThreadScope()) {
855 error = Status::FromErrorString("this SBThread object is invalid");
856 return error;
857 }
858
859 Thread *thread = exe_ctx->GetThreadPtr();
860 Status new_plan_status;
861 StructuredData::ObjectSP obj_sp = args_data.m_impl_up->GetObjectSP();
862
863 ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
864 false, script_class_name, obj_sp, false, new_plan_status);
865
866 if (new_plan_status.Fail()) {
867 error = Status::FromErrorString(new_plan_status.AsCString());
868 return error;
869 }
870
871 if (!resume_immediately)
872 return error;
873
874 if (new_plan_status.Success())
875 error = ResumeNewPlan(std::move(*exe_ctx), new_plan_sp.get());
876 else
877 error = Status::FromErrorString(new_plan_status.AsCString());
878
879 return error;
880}
881
883 LLDB_INSTRUMENT_VA(this, file_spec, line);
884
885 SBError sb_error;
886
887 llvm::Expected<StoppedExecutionContext> exe_ctx =
889 if (!exe_ctx)
890 return Status::FromError(exe_ctx.takeError());
891
892 if (!exe_ctx->HasThreadScope()) {
893 sb_error = Status::FromErrorString("this SBThread object is invalid");
894 return sb_error;
895 }
896
897 Thread *thread = exe_ctx->GetThreadPtr();
898
899 Status err = thread->JumpToLine(file_spec.ref(), line, true);
900 sb_error.SetError(std::move(err));
901 return sb_error;
902}
903
905 LLDB_INSTRUMENT_VA(this, frame, return_value);
906
907 SBError sb_error;
908
909 llvm::Expected<StoppedExecutionContext> exe_ctx =
911 if (!exe_ctx)
912 return Status::FromError(exe_ctx.takeError());
913
914 if (exe_ctx->HasThreadScope()) {
915 Thread *thread = exe_ctx->GetThreadPtr();
916 sb_error.SetError(
917 thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
918 }
919
920 return sb_error;
921}
922
924 LLDB_INSTRUMENT_VA(this);
925
926 SBError sb_error;
927
928 llvm::Expected<StoppedExecutionContext> exe_ctx =
930 if (!exe_ctx)
931 return Status::FromError(exe_ctx.takeError());
932
933 if (exe_ctx->HasThreadScope()) {
934 Thread *thread = exe_ctx->GetThreadPtr();
935 sb_error.SetError(thread->UnwindInnermostExpression());
936 if (sb_error.Success())
937 thread->SetSelectedFrameByIndex(0, false);
938 }
939
940 return sb_error;
941}
942
944 LLDB_INSTRUMENT_VA(this);
945
946 SBError error; // Ignored
947 return Suspend(error);
948}
949
952
953 llvm::Expected<StoppedExecutionContext> exe_ctx =
955 if (!exe_ctx) {
956 error = Status::FromError(exe_ctx.takeError());
957 return false;
958 }
959
960 bool result = false;
961 if (exe_ctx->HasThreadScope()) {
962 exe_ctx->GetThreadPtr()->SetResumeState(eStateSuspended);
963 result = true;
964 } else
965 error = Status::FromErrorString("this SBThread object is invalid");
966 return result;
967}
968
970 LLDB_INSTRUMENT_VA(this);
971
972 SBError error; // Ignored
973 return Resume(error);
974}
975
978
979 llvm::Expected<StoppedExecutionContext> exe_ctx =
981 if (!exe_ctx) {
982 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
983 error = Status::FromErrorString("process is running");
984 return false;
985 }
986
987 bool result = false;
988 if (exe_ctx->HasThreadScope()) {
989 const bool override_suspend = true;
990 exe_ctx->GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
991 result = true;
992 } else
993 error = Status::FromErrorString("this SBThread object is invalid");
994 return result;
995}
996
998 LLDB_INSTRUMENT_VA(this);
999
1000 llvm::Expected<StoppedExecutionContext> exe_ctx =
1002 if (!exe_ctx) {
1003 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1004 return false;
1005 }
1006
1007 if (exe_ctx->HasThreadScope())
1008 return exe_ctx->GetThreadPtr()->GetResumeState() == eStateSuspended;
1009 return false;
1010}
1011
1013 LLDB_INSTRUMENT_VA(this);
1014
1015 llvm::Expected<StoppedExecutionContext> exe_ctx =
1017 if (!exe_ctx) {
1018 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1019 return false;
1020 }
1021
1022 if (exe_ctx->HasThreadScope())
1023 return StateIsStoppedState(exe_ctx->GetThreadPtr()->GetState(), true);
1024 return false;
1025}
1026
1028 LLDB_INSTRUMENT_VA(this);
1029
1030 SBProcess sb_process;
1031 llvm::Expected<StoppedExecutionContext> exe_ctx =
1033 if (!exe_ctx) {
1034 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1035 return SBProcess();
1036 }
1037
1038 if (exe_ctx->HasThreadScope()) {
1039 // Have to go up to the target so we can get a shared pointer to our
1040 // process...
1041 sb_process.SetSP(exe_ctx->GetProcessSP());
1042 }
1043
1044 return sb_process;
1045}
1046
1048 LLDB_INSTRUMENT_VA(this);
1049
1050 llvm::Expected<StoppedExecutionContext> exe_ctx =
1052 if (!exe_ctx) {
1053 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1054 return 0;
1055 }
1056
1057 if (exe_ctx->HasThreadScope())
1058 return exe_ctx->GetThreadPtr()->GetStackFrameCount();
1059
1060 return 0;
1061}
1062
1064 LLDB_INSTRUMENT_VA(this, idx);
1065
1066 SBFrame sb_frame;
1067 llvm::Expected<StoppedExecutionContext> exe_ctx =
1069 if (!exe_ctx) {
1070 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1071 return SBFrame();
1072 }
1073
1074 if (exe_ctx->HasThreadScope()) {
1075 StackFrameSP frame_sp = exe_ctx->GetThreadPtr()->GetStackFrameAtIndex(idx);
1076 sb_frame.SetFrameSP(frame_sp);
1077 }
1078
1079 return sb_frame;
1080}
1081
1083 LLDB_INSTRUMENT_VA(this);
1084
1085 SBFrame sb_frame;
1086 llvm::Expected<StoppedExecutionContext> exe_ctx =
1088 if (!exe_ctx) {
1089 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1090 return SBFrame();
1091 }
1092
1093 if (exe_ctx->HasThreadScope()) {
1094 StackFrameSP frame_sp =
1095 exe_ctx->GetThreadPtr()->GetSelectedFrame(SelectMostRelevantFrame);
1096 sb_frame.SetFrameSP(frame_sp);
1097 }
1098
1099 return sb_frame;
1100}
1101
1103 LLDB_INSTRUMENT_VA(this, idx);
1104
1105 SBFrame sb_frame;
1106 StackFrameSP frame_sp;
1107 llvm::Expected<StoppedExecutionContext> exe_ctx =
1109 if (!exe_ctx) {
1110 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1111 return SBFrame();
1112 }
1113
1114 if (exe_ctx->HasThreadScope()) {
1115 Thread *thread = exe_ctx->GetThreadPtr();
1116 frame_sp = thread->GetStackFrameAtIndex(idx);
1117 if (frame_sp) {
1118 thread->SetSelectedFrame(frame_sp.get());
1119 sb_frame.SetFrameSP(frame_sp);
1120 }
1121 }
1122
1123 return sb_frame;
1124}
1125
1127 LLDB_INSTRUMENT_VA(event);
1128
1129 return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr;
1130}
1131
1137
1143
1144bool SBThread::operator==(const SBThread &rhs) const {
1145 LLDB_INSTRUMENT_VA(this, rhs);
1146
1147 return m_opaque_sp->GetThreadSP().get() ==
1148 rhs.m_opaque_sp->GetThreadSP().get();
1149}
1150
1151bool SBThread::operator!=(const SBThread &rhs) const {
1152 LLDB_INSTRUMENT_VA(this, rhs);
1153
1154 return m_opaque_sp->GetThreadSP().get() !=
1155 rhs.m_opaque_sp->GetThreadSP().get();
1156}
1157
1158bool SBThread::GetStatus(SBStream &status) const {
1159 LLDB_INSTRUMENT_VA(this, status);
1160
1161 Stream &strm = status.ref();
1162
1163 llvm::Expected<StoppedExecutionContext> exe_ctx =
1165 if (!exe_ctx) {
1166 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1167 return false;
1168 }
1169
1170 if (exe_ctx->HasThreadScope()) {
1171 exe_ctx->GetThreadPtr()->GetStatus(strm, 0, 1, 1, true,
1172 /*show_hidden=*/true);
1173 } else
1174 strm.PutCString("No status");
1175
1176 return true;
1177}
1178
1179bool SBThread::GetDescription(SBStream &description) const {
1180 LLDB_INSTRUMENT_VA(this, description);
1181
1182 return GetDescription(description, false);
1183}
1184
1185bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
1186 LLDB_INSTRUMENT_VA(this, description, stop_format);
1187
1188 Stream &strm = description.ref();
1189
1190 llvm::Expected<StoppedExecutionContext> exe_ctx =
1192 if (!exe_ctx) {
1193 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1194 return false;
1195 }
1196
1197 if (exe_ctx->HasThreadScope()) {
1198 exe_ctx->GetThreadPtr()->DumpUsingSettingsFormat(
1199 strm, LLDB_INVALID_THREAD_ID, stop_format);
1200 } else
1201 strm.PutCString("No value");
1202
1203 return true;
1204}
1205
1207 SBStream &output) {
1208 Stream &strm = output.ref();
1209
1210 SBError error;
1211 if (!format) {
1212 error = Status::FromErrorString("The provided SBFormat object is invalid");
1213 return error;
1214 }
1215
1216 llvm::Expected<StoppedExecutionContext> exe_ctx =
1218 if (!exe_ctx) {
1219 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1220 return error;
1221 }
1222
1223 if (exe_ctx->HasThreadScope()) {
1224 if (exe_ctx->GetThreadPtr()->DumpUsingFormat(
1225 strm, LLDB_INVALID_THREAD_ID, format.GetFormatEntrySP().get())) {
1226 return error;
1227 }
1228 }
1229
1231 "It was not possible to generate a thread description with the given "
1232 "format string '%s'",
1233 format.GetFormatEntrySP()->string.c_str());
1234 return error;
1235}
1236
1238 LLDB_INSTRUMENT_VA(this, type);
1239
1240 llvm::Expected<StoppedExecutionContext> exe_ctx =
1242 SBThread sb_origin_thread;
1243 if (exe_ctx) {
1244 if (exe_ctx->HasThreadScope()) {
1245 ThreadSP real_thread(exe_ctx->GetThreadSP());
1246 if (real_thread) {
1247 ConstString type_const(type);
1248 Process *process = exe_ctx->GetProcessPtr();
1249 if (process) {
1250 SystemRuntime *runtime = process->GetSystemRuntime();
1251 if (runtime) {
1252 ThreadSP new_thread_sp(
1253 runtime->GetExtendedBacktraceThread(real_thread, type_const));
1254 if (new_thread_sp) {
1255 // Save this in the Process' ExtendedThreadList so a strong
1256 // pointer retains the object.
1257 process->GetExtendedThreadList().AddThread(new_thread_sp);
1258 sb_origin_thread.SetThread(new_thread_sp);
1259 }
1260 }
1261 }
1262 }
1263 }
1264 } else {
1265 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1266 }
1267
1268 return sb_origin_thread;
1269}
1270
1272 LLDB_INSTRUMENT_VA(this);
1273
1274 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1275 if (thread_sp)
1276 return thread_sp->GetExtendedBacktraceOriginatingIndexID();
1277 return LLDB_INVALID_INDEX32;
1278}
1279
1281 LLDB_INSTRUMENT_VA(this);
1282
1283 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1284 if (!thread_sp)
1285 return SBValue();
1286
1287 return SBValue(thread_sp->GetCurrentException());
1288}
1289
1291 LLDB_INSTRUMENT_VA(this);
1292
1293 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1294 if (!thread_sp)
1295 return SBThread();
1296
1297 return SBThread(thread_sp->GetCurrentExceptionBacktrace());
1298}
1299
1301 LLDB_INSTRUMENT_VA(this);
1302
1303 ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
1304 if (thread_sp)
1305 return thread_sp->SafeToCallFunctions();
1306 return true;
1307}
1308
1309lldb::ThreadSP SBThread::GetSP() const { return m_opaque_sp->GetThreadSP(); }
1310
1314
1316 return m_opaque_sp->GetThreadSP().get();
1317}
1318
1320 LLDB_INSTRUMENT_VA(this);
1321
1322 ThreadSP thread_sp = m_opaque_sp->GetThreadSP();
1323 if (!thread_sp)
1324 return SBValue();
1325 return thread_sp->GetSiginfoValue();
1326}
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:411
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
size_t GetStopDescription(char *dst_or_null, size_t dst_len)
Definition SBThread.cpp:242
static const char * GetBroadcasterClassName()
Definition SBThread.cpp:53
void StepInto(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition SBThread.cpp:478
bool Suspend()
LLDB currently supports process centric debugging which means when any thread in a process stops,...
Definition SBThread.cpp:943
const char * GetName() const
Definition SBThread.cpp:313
const lldb::SBThread & operator=(const lldb::SBThread &rhs)
Definition SBThread.cpp:77
lldb::SBFrame SetSelectedFrame(uint32_t frame_idx)
SBError UnwindInnermostExpression()
Definition SBThread.cpp:923
friend class SBThreadCollection
Definition SBThread.h:244
bool IsValid() const
Definition SBThread.cpp:110
uint32_t GetNumFrames()
friend class SBProcess
Definition SBThread.h:239
const char * GetQueueName() const
Definition SBThread.cpp:329
SBValue GetSiginfo()
uint32_t GetIndexID() const
Definition SBThread.cpp:304
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:586
bool GetStatus(lldb::SBStream &status) const
bool IsSuspended()
Definition SBThread.cpp:997
friend class SBValue
Definition SBThread.h:241
static SBFrame GetStackFrameFromEvent(const SBEvent &event)
lldb::queue_id_t GetQueueID() const
Definition SBThread.cpp:345
bool GetInfoItemByPathAsString(const char *path, SBStream &strm)
Definition SBThread.cpp:363
lldb::SBFrame GetSelectedFrame()
bool operator!=(const lldb::SBThread &rhs) const
SBError StepUsingScriptedThreadPlan(const char *script_class_name)
Definition SBThread.cpp:827
lldb::tid_t GetThreadID() const
Definition SBThread.cpp:295
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:634
SBThread GetCurrentExceptionBacktrace()
friend class SBFrame
Definition SBThread.h:238
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:270
void StepOver(lldb::RunMode stop_other_threads=lldb::eOnlyDuringStepping)
Definition SBThread.cpp:435
SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line)
Definition SBThread.cpp:882
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:291
lldb::ThreadSP GetSP() const
SBThread GetExtendedBacktraceThread(const char *type)
lldb::ExecutionContextRefSP m_opaque_sp
Definition SBThread.h:256
void RunToAddress(lldb::addr_t addr)
Definition SBThread.cpp:667
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:904
bool operator==(const lldb::SBThread &rhs) const
SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec, uint32_t line)
Definition SBThread.cpp:706
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:357
ThreadList & GetThreadList()
Definition Process.h:2253
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:2848
ThreadList & GetExtendedThreadList()
Definition Process.h:2264
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:1270
"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:1097
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