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