LLDB mainline
Thread.cpp
Go to the documentation of this file.
1//===-- Thread.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
11#include "lldb/Core/Debugger.h"
13#include "lldb/Core/Module.h"
17#include "lldb/Host/Host.h"
22#include "lldb/Target/ABI.h"
26#include "lldb/Target/Process.h"
32#include "lldb/Target/Target.h"
48#include "lldb/Utility/Log.h"
50#include "lldb/Utility/State.h"
51#include "lldb/Utility/Stream.h"
54
55#include <memory>
56#include <optional>
57
58using namespace lldb;
59using namespace lldb_private;
60
62 // NOTE: intentional leak so we don't crash if global destructor chain gets
63 // called as other threads still use the result of this function
64 static ThreadProperties *g_settings_ptr = new ThreadProperties(true);
65 return *g_settings_ptr;
66}
67
68#define LLDB_PROPERTIES_thread
69#include "TargetProperties.inc"
70
71enum {
72#define LLDB_PROPERTIES_thread
73#include "TargetPropertiesEnum.inc"
74};
75
77 : public Cloneable<ThreadOptionValueProperties, OptionValueProperties> {
78public:
79 ThreadOptionValueProperties(llvm::StringRef name) : Cloneable(name) {}
80
81 const Property *
83 const ExecutionContext *exe_ctx) const override {
84 // When getting the value for a key from the thread options, we will always
85 // try and grab the setting from the current thread if there is one. Else
86 // we just use the one from this instance.
87 if (exe_ctx) {
88 Thread *thread = exe_ctx->GetThreadPtr();
89 if (thread) {
90 ThreadOptionValueProperties *instance_properties =
91 static_cast<ThreadOptionValueProperties *>(
92 thread->GetValueProperties().get());
93 if (this != instance_properties)
94 return instance_properties->ProtectedGetPropertyAtIndex(idx);
95 }
96 }
97 return ProtectedGetPropertyAtIndex(idx);
98 }
99};
100
102 if (is_global) {
103 m_collection_sp = std::make_shared<ThreadOptionValueProperties>("thread");
104 m_collection_sp->Initialize(g_thread_properties);
105 } else
108}
109
111
113 const uint32_t idx = ePropertyStepAvoidRegex;
114 return GetPropertyAtIndexAs<const RegularExpression *>(idx);
115}
116
118 const uint32_t idx = ePropertyStepAvoidLibraries;
119 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
120}
121
123 const uint32_t idx = ePropertyEnableThreadTrace;
124 return GetPropertyAtIndexAs<bool>(
125 idx, g_thread_properties[idx].default_uint_value != 0);
126}
127
129 const uint32_t idx = ePropertyStepInAvoidsNoDebug;
130 return GetPropertyAtIndexAs<bool>(
131 idx, g_thread_properties[idx].default_uint_value != 0);
132}
133
135 const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
136 return GetPropertyAtIndexAs<bool>(
137 idx, g_thread_properties[idx].default_uint_value != 0);
138}
139
141 const uint32_t idx = ePropertyMaxBacktraceDepth;
142 return GetPropertyAtIndexAs<uint64_t>(
143 idx, g_thread_properties[idx].default_uint_value);
144}
145
147 const uint32_t idx = ePropertySingleThreadPlanTimeout;
148 return GetPropertyAtIndexAs<uint64_t>(
149 idx, g_thread_properties[idx].default_uint_value);
150}
151
152// Thread Event Data
153
155 return "Thread::ThreadEventData";
156}
157
159 : m_thread_sp(thread_sp), m_stack_id() {}
160
162 const StackID &stack_id)
163 : m_thread_sp(thread_sp), m_stack_id(stack_id) {}
164
165Thread::ThreadEventData::ThreadEventData() : m_thread_sp(), m_stack_id() {}
166
168
170
173 if (event_ptr) {
174 const EventData *event_data = event_ptr->GetData();
175 if (event_data &&
177 return static_cast<const ThreadEventData *>(event_ptr->GetData());
178 }
179 return nullptr;
180}
181
183 ThreadSP thread_sp;
184 const ThreadEventData *event_data = GetEventDataFromEvent(event_ptr);
185 if (event_data)
186 thread_sp = event_data->GetThread();
187 return thread_sp;
188}
189
191 StackID stack_id;
192 const ThreadEventData *event_data = GetEventDataFromEvent(event_ptr);
193 if (event_data)
194 stack_id = event_data->GetStackID();
195 return stack_id;
196}
197
200 const ThreadEventData *event_data = GetEventDataFromEvent(event_ptr);
201 StackFrameSP frame_sp;
202 if (event_data) {
203 ThreadSP thread_sp = event_data->GetThread();
204 if (thread_sp) {
205 frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID(
206 event_data->GetStackID());
207 }
208 }
209 return frame_sp;
210}
211
212// Thread class
213
215 static constexpr llvm::StringLiteral class_name("lldb.thread");
216 return class_name;
217}
218
219Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
220 : ThreadProperties(false), UserID(tid),
221 Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(),
223 m_process_wp(process.shared_from_this()), m_stop_info_sp(),
226 m_index_id(use_invalid_index_id ? LLDB_INVALID_INDEX32
227 : process.GetNextThreadIndexID(tid)),
235 Log *log = GetLog(LLDBLog::Object);
236 LLDB_LOGF(log, "%p Thread::Thread(tid = 0x%4.4" PRIx64 ")",
237 static_cast<void *>(this), GetID());
238
240}
241
243 Log *log = GetLog(LLDBLog::Object);
244 LLDB_LOGF(log, "%p Thread::~Thread(tid = 0x%4.4" PRIx64 ")",
245 static_cast<void *>(this), GetID());
246 /// If you hit this assert, it means your derived class forgot to call
247 /// DoDestroy in its destructor.
248 assert(m_destroy_called);
249}
250
252 m_destroy_called = true;
253 m_stop_info_sp.reset();
254 m_reg_context_sp.reset();
255 m_unwinder_up.reset();
256 std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
257 m_curr_frames_sp.reset();
258 m_prev_frames_sp.reset();
259 m_prev_framezero_pc.reset();
260}
261
264 auto data_sp =
265 std::make_shared<ThreadEventData>(shared_from_this(), new_frame_id);
267 }
268}
269
272 StackFrameListSP stack_frame_list_sp(GetStackFrameList());
273 StackFrameSP frame_sp = stack_frame_list_sp->GetFrameAtIndex(
274 stack_frame_list_sp->GetSelectedFrameIndex(select_most_relevant));
275 FrameSelectedCallback(frame_sp.get());
276 return frame_sp;
277}
278
280 bool broadcast) {
281 uint32_t ret_value = GetStackFrameList()->SetSelectedFrame(frame);
282 if (broadcast)
285 return ret_value;
286}
287
288bool Thread::SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast) {
289 StackFrameSP frame_sp(GetStackFrameList()->GetFrameAtIndex(frame_idx));
290 if (frame_sp) {
291 GetStackFrameList()->SetSelectedFrame(frame_sp.get());
292 if (broadcast)
293 BroadcastSelectedFrameChange(frame_sp->GetStackID());
294 FrameSelectedCallback(frame_sp.get());
295 return true;
296 } else
297 return false;
298}
299
301 Stream &output_stream) {
302 const bool broadcast = true;
303 bool success = SetSelectedFrameByIndex(frame_idx, broadcast);
304 if (success) {
306 if (frame_sp) {
307 bool already_shown = false;
308 SymbolContext frame_sc(
309 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
310 const Debugger &debugger = GetProcess()->GetTarget().GetDebugger();
311 if (debugger.GetUseExternalEditor() && frame_sc.line_entry.GetFile() &&
312 frame_sc.line_entry.line != 0) {
313 if (llvm::Error e = Host::OpenFileInExternalEditor(
314 debugger.GetExternalEditor(), frame_sc.line_entry.GetFile(),
315 frame_sc.line_entry.line)) {
316 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(e),
317 "OpenFileInExternalEditor failed: {0}");
318 } else {
319 already_shown = true;
320 }
321 }
322
323 bool show_frame_info = true;
324 bool show_source = !already_shown;
325 FrameSelectedCallback(frame_sp.get());
326 return frame_sp->GetStatus(output_stream, show_frame_info, show_source);
327 }
328 return false;
329 } else
330 return false;
331}
332
334 if (!frame)
335 return;
336
337 if (frame->HasDebugInformation() &&
338 (GetProcess()->GetWarningsOptimization() ||
339 GetProcess()->GetWarningsUnsupportedLanguage())) {
340 SymbolContext sc =
341 frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextModule);
342 GetProcess()->PrintWarningOptimization(sc);
343 GetProcess()->PrintWarningUnsupportedLanguage(sc);
344 }
345}
346
349 return m_stop_info_sp;
350
351 ThreadPlanSP completed_plan_sp(GetCompletedPlan());
352 ProcessSP process_sp(GetProcess());
353 const uint32_t stop_id = process_sp ? process_sp->GetStopID() : UINT32_MAX;
354
355 // Here we select the stop info according to priorirty: - m_stop_info_sp (if
356 // not trace) - preset value - completed plan stop info - new value with plan
357 // from completed plan stack - m_stop_info_sp (trace stop reason is OK now) -
358 // ask GetPrivateStopInfo to set stop info
359
360 bool have_valid_stop_info = m_stop_info_sp &&
361 m_stop_info_sp ->IsValid() &&
362 m_stop_info_stop_id == stop_id;
363 bool have_valid_completed_plan = completed_plan_sp && completed_plan_sp->PlanSucceeded();
364 bool plan_failed = completed_plan_sp && !completed_plan_sp->PlanSucceeded();
365 bool plan_overrides_trace =
366 have_valid_stop_info && have_valid_completed_plan
367 && (m_stop_info_sp->GetStopReason() == eStopReasonTrace);
368
369 if (have_valid_stop_info && !plan_overrides_trace && !plan_failed) {
370 return m_stop_info_sp;
371 } else if (completed_plan_sp) {
373 completed_plan_sp, GetReturnValueObject(), GetExpressionVariable());
374 } else {
376 return m_stop_info_sp;
377 }
378}
379
383}
384
386 if (!calculate)
387 return m_stop_info_sp;
388
390 return m_stop_info_sp;
391
392 ProcessSP process_sp(GetProcess());
393 if (process_sp) {
394 const uint32_t process_stop_id = process_sp->GetStopID();
395 if (m_stop_info_stop_id != process_stop_id) {
396 // We preserve the old stop info for a variety of reasons:
397 // 1) Someone has already updated it by the time we get here
398 // 2) We didn't get to execute the breakpoint instruction we stopped at
399 // 3) This is a virtual step so we didn't actually run
400 // 4) If this thread wasn't allowed to run the last time round.
401 if (m_stop_info_sp) {
402 if (m_stop_info_sp->IsValid() || IsStillAtLastBreakpointHit() ||
403 GetCurrentPlan()->IsVirtualStep()
406 else
407 m_stop_info_sp.reset();
408 }
409
410 if (!m_stop_info_sp) {
411 if (!CalculateStopInfo())
413 }
414 }
415
416 // The stop info can be manually set by calling Thread::SetStopInfo() prior
417 // to this function ever getting called, so we can't rely on
418 // "m_stop_info_stop_id != process_stop_id" as the condition for the if
419 // statement below, we must also check the stop info to see if we need to
420 // override it. See the header documentation in
421 // Architecture::OverrideStopInfo() for more information on the stop
422 // info override callback.
423 if (m_stop_info_override_stop_id != process_stop_id) {
424 m_stop_info_override_stop_id = process_stop_id;
425 if (m_stop_info_sp) {
426 if (const Architecture *arch =
427 process_sp->GetTarget().GetArchitecturePlugin())
428 arch->OverrideStopInfo(*this);
429 }
430 }
431 }
432
433 // If we were resuming the process and it was interrupted,
434 // return no stop reason. This thread would like to resume.
435 if (m_stop_info_sp && m_stop_info_sp->WasContinueInterrupted(*this))
436 return {};
437
438 return m_stop_info_sp;
439}
440
442 lldb::StopInfoSP stop_info_sp(GetStopInfo());
443 if (stop_info_sp)
444 return stop_info_sp->GetStopReason();
445 return eStopReasonNone;
446}
447
449 ProcessSP process_sp(GetProcess());
450 if (process_sp)
451 return m_stop_info_stop_id == process_sp->GetStopID();
452 else
453 return true; // Process is no longer around so stop info is always up to
454 // date...
455}
456
458 if (m_stop_info_sp) {
459 m_stop_info_sp.reset();
460 }
461}
462
463void Thread::SetStopInfo(const lldb::StopInfoSP &stop_info_sp) {
464 m_stop_info_sp = stop_info_sp;
465 if (m_stop_info_sp) {
466 m_stop_info_sp->MakeStopInfoValid();
467 // If we are overriding the ShouldReportStop, do that here:
469 m_stop_info_sp->OverrideShouldNotify(m_override_should_notify ==
471 }
472
473 ProcessSP process_sp(GetProcess());
474 if (process_sp)
475 m_stop_info_stop_id = process_sp->GetStopID();
476 else
478 Log *log = GetLog(LLDBLog::Thread);
479 LLDB_LOGF(log, "%p: tid = 0x%" PRIx64 ": stop info = %s (stop_id = %u)",
480 static_cast<void *>(this), GetID(),
481 stop_info_sp ? stop_info_sp->GetDescription() : "<NULL>",
483}
484
486 if (vote == eVoteNoOpinion)
487 return;
488 else {
490 if (m_stop_info_sp)
491 m_stop_info_sp->OverrideShouldNotify(m_override_should_notify ==
493 }
494}
495
497 // Note, we can't just NULL out the private reason, or the native thread
498 // implementation will try to go calculate it again. For now, just set it to
499 // a Unix Signal with an invalid signal number.
502}
503
505
507 saved_state.register_backup_sp.reset();
509 if (frame_sp) {
510 lldb::RegisterCheckpointSP reg_checkpoint_sp(
512 if (reg_checkpoint_sp) {
513 lldb::RegisterContextSP reg_ctx_sp(frame_sp->GetRegisterContext());
514 if (reg_ctx_sp && reg_ctx_sp->ReadAllRegisterValues(*reg_checkpoint_sp))
515 saved_state.register_backup_sp = reg_checkpoint_sp;
516 }
517 }
518 if (!saved_state.register_backup_sp)
519 return false;
520
521 saved_state.stop_info_sp = GetStopInfo();
522 ProcessSP process_sp(GetProcess());
523 if (process_sp)
524 saved_state.orig_stop_id = process_sp->GetStopID();
526 saved_state.m_completed_plan_checkpoint =
528
529 return true;
530}
531
533 ThreadStateCheckpoint &saved_state) {
534 if (saved_state.register_backup_sp) {
536 if (frame_sp) {
537 lldb::RegisterContextSP reg_ctx_sp(frame_sp->GetRegisterContext());
538 if (reg_ctx_sp) {
539 bool ret =
540 reg_ctx_sp->WriteAllRegisterValues(*saved_state.register_backup_sp);
541
542 // Clear out all stack frames as our world just changed.
544 reg_ctx_sp->InvalidateIfNeeded(true);
545 if (m_unwinder_up)
546 m_unwinder_up->Clear();
547 return ret;
548 }
549 }
550 }
551 return false;
552}
553
555 ThreadStateCheckpoint &saved_state) {
556 if (saved_state.stop_info_sp)
557 saved_state.stop_info_sp->MakeStopInfoValid();
558 SetStopInfo(saved_state.stop_info_sp);
559 GetStackFrameList()->SetCurrentInlinedDepth(
560 saved_state.current_inlined_depth);
562 saved_state.m_completed_plan_checkpoint);
563}
564
566 // If any other threads access this we will need a mutex for it
567 std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
568 return m_state;
569}
570
572 std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
573 m_state = state;
574}
575
578
579 if (!frame_sp)
580 return GetStopDescriptionRaw();
581
582 auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
583
584 if (!recognized_frame_sp)
585 return GetStopDescriptionRaw();
586
587 std::string recognized_stop_description =
588 recognized_frame_sp->GetStopDescription();
589
590 if (!recognized_stop_description.empty())
591 return recognized_stop_description;
592
593 return GetStopDescriptionRaw();
594}
595
597 StopInfoSP stop_info_sp = GetStopInfo();
598 std::string raw_stop_description;
599 if (stop_info_sp && stop_info_sp->IsValid()) {
600 raw_stop_description = stop_info_sp->GetDescription();
601 assert((!raw_stop_description.empty() ||
602 stop_info_sp->GetStopReason() == eStopReasonNone) &&
603 "StopInfo returned an empty description.");
604 }
605 return raw_stop_description;
606}
607
609 ThreadPlan *current_plan = GetCurrentPlan();
610
611 // FIXME: I may decide to disallow threads with no plans. In which
612 // case this should go to an assert.
613
614 if (!current_plan)
615 return;
616
617 current_plan->WillStop();
618}
619
622 // If we're at a breakpoint push the step-over breakpoint plan. Do this
623 // before telling the current plan it will resume, since we might change
624 // what the current plan is.
625
627 if (reg_ctx_sp) {
628 const addr_t thread_pc = reg_ctx_sp->GetPC();
629 BreakpointSiteSP bp_site_sp =
630 GetProcess()->GetBreakpointSiteList().FindByAddress(thread_pc);
631 if (bp_site_sp) {
632 // Note, don't assume there's a ThreadPlanStepOverBreakpoint, the
633 // target may not require anything special to step over a breakpoint.
634
635 ThreadPlan *cur_plan = GetCurrentPlan();
636
637 bool push_step_over_bp_plan = false;
638 if (cur_plan->GetKind() == ThreadPlan::eKindStepOverBreakpoint) {
641 if (bp_plan->GetBreakpointLoadAddress() != thread_pc)
642 push_step_over_bp_plan = true;
643 } else
644 push_step_over_bp_plan = true;
645
646 if (push_step_over_bp_plan) {
647 ThreadPlanSP step_bp_plan_sp(new ThreadPlanStepOverBreakpoint(*this));
648 if (step_bp_plan_sp) {
649 step_bp_plan_sp->SetPrivate(true);
650
651 if (GetCurrentPlan()->RunState() != eStateStepping) {
652 ThreadPlanStepOverBreakpoint *step_bp_plan =
653 static_cast<ThreadPlanStepOverBreakpoint *>(
654 step_bp_plan_sp.get());
655 step_bp_plan->SetAutoContinue(true);
656 }
657 QueueThreadPlan(step_bp_plan_sp, false);
658 }
659 }
660 }
661 }
662 }
663}
664
665bool Thread::ShouldResume(StateType resume_state) {
666 // At this point clear the completed plan stack.
669
670 StateType prev_resume_state = GetTemporaryResumeState();
671
672 SetTemporaryResumeState(resume_state);
673
674 lldb::ThreadSP backing_thread_sp(GetBackingThread());
675 if (backing_thread_sp)
676 backing_thread_sp->SetTemporaryResumeState(resume_state);
677
678 // Make sure m_stop_info_sp is valid. Don't do this for threads we suspended
679 // in the previous run.
680 if (prev_resume_state != eStateSuspended)
682
683 // This is a little dubious, but we are trying to limit how often we actually
684 // fetch stop info from the target, 'cause that slows down single stepping.
685 // So assume that if we got to the point where we're about to resume, and we
686 // haven't yet had to fetch the stop reason, then it doesn't need to know
687 // about the fact that we are resuming...
688 const uint32_t process_stop_id = GetProcess()->GetStopID();
689 if (m_stop_info_stop_id == process_stop_id &&
690 (m_stop_info_sp && m_stop_info_sp->IsValid())) {
691 StopInfo *stop_info = GetPrivateStopInfo().get();
692 if (stop_info)
693 stop_info->WillResume(resume_state);
694 }
695
696 // Tell all the plans that we are about to resume in case they need to clear
697 // any state. We distinguish between the plan on the top of the stack and the
698 // lower plans in case a plan needs to do any special business before it
699 // runs.
700
701 bool need_to_resume = false;
702 ThreadPlan *plan_ptr = GetCurrentPlan();
703 if (plan_ptr) {
704 need_to_resume = plan_ptr->WillResume(resume_state, true);
705
706 while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr) {
707 plan_ptr->WillResume(resume_state, false);
708 }
709
710 // If the WillResume for the plan says we are faking a resume, then it will
711 // have set an appropriate stop info. In that case, don't reset it here.
712
713 if (need_to_resume && resume_state != eStateSuspended) {
714 m_stop_info_sp.reset();
715 }
716 }
717
718 if (need_to_resume) {
720 // Let Thread subclasses do any special work they need to prior to resuming
721 WillResume(resume_state);
722 }
723
724 return need_to_resume;
725}
726
729 // This will get recomputed each time when we stop.
731}
732
734
735bool Thread::ShouldStop(Event *event_ptr) {
736 ThreadPlan *current_plan = GetCurrentPlan();
737
738 bool should_stop = true;
739
740 Log *log = GetLog(LLDBLog::Step);
741
743 LLDB_LOGF(log,
744 "Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
745 ", should_stop = 0 (ignore since thread was suspended)",
746 __FUNCTION__, GetID(), GetProtocolID());
747 return false;
748 }
749
751 LLDB_LOGF(log,
752 "Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
753 ", should_stop = 0 (ignore since thread was suspended)",
754 __FUNCTION__, GetID(), GetProtocolID());
755 return false;
756 }
757
758 // Based on the current thread plan and process stop info, check if this
759 // thread caused the process to stop. NOTE: this must take place before the
760 // plan is moved from the current plan stack to the completed plan stack.
762 LLDB_LOGF(log,
763 "Thread::%s for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
764 ", pc = 0x%16.16" PRIx64
765 ", should_stop = 0 (ignore since no stop reason)",
766 __FUNCTION__, GetID(), GetProtocolID(),
769 return false;
770 }
771
772 // Clear the "must run me before stop" if it was set:
774
775 if (log) {
776 LLDB_LOGF(log,
777 "Thread::%s(%p) for tid = 0x%4.4" PRIx64 " 0x%4.4" PRIx64
778 ", pc = 0x%16.16" PRIx64,
779 __FUNCTION__, static_cast<void *>(this), GetID(), GetProtocolID(),
782 LLDB_LOGF(log, "^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
783 StreamString s;
784 s.IndentMore();
785 GetProcess()->DumpThreadPlansForTID(
786 s, GetID(), eDescriptionLevelVerbose, true /* internal */,
787 false /* condense_trivial */, true /* skip_unreported */);
788 LLDB_LOGF(log, "Plan stack initial state:\n%s", s.GetData());
789 }
790
791 // The top most plan always gets to do the trace log...
792 current_plan->DoTraceLog();
793
794 // First query the stop info's ShouldStopSynchronous. This handles
795 // "synchronous" stop reasons, for example the breakpoint command on internal
796 // breakpoints. If a synchronous stop reason says we should not stop, then
797 // we don't have to do any more work on this stop.
798 StopInfoSP private_stop_info(GetPrivateStopInfo());
799 if (private_stop_info &&
800 !private_stop_info->ShouldStopSynchronous(event_ptr)) {
801 LLDB_LOGF(log, "StopInfo::ShouldStop async callback says we should not "
802 "stop, returning ShouldStop of false.");
803 return false;
804 }
805
806 // If we've already been restarted, don't query the plans since the state
807 // they would examine is not current.
809 return false;
810
811 // Before the plans see the state of the world, calculate the current inlined
812 // depth.
813 GetStackFrameList()->CalculateCurrentInlinedDepth();
814
815 // If the base plan doesn't understand why we stopped, then we have to find a
816 // plan that does. If that plan is still working, then we don't need to do
817 // any more work. If the plan that explains the stop is done, then we should
818 // pop all the plans below it, and pop it, and then let the plans above it
819 // decide whether they still need to do more work.
820
821 bool done_processing_current_plan = false;
822 if (!current_plan->PlanExplainsStop(event_ptr)) {
823 if (current_plan->TracerExplainsStop()) {
824 done_processing_current_plan = true;
825 should_stop = false;
826 } else {
827 // Leaf plan that does not explain the stop should be popped.
828 // The plan should be push itself later again before resuming to stay
829 // as leaf.
830 if (current_plan->IsLeafPlan())
831 PopPlan();
832
833 // If the current plan doesn't explain the stop, then find one that does
834 // and let it handle the situation.
835 ThreadPlan *plan_ptr = current_plan;
836 while ((plan_ptr = GetPreviousPlan(plan_ptr)) != nullptr) {
837 if (plan_ptr->PlanExplainsStop(event_ptr)) {
838 LLDB_LOGF(log, "Plan %s explains stop.", plan_ptr->GetName());
839
840 should_stop = plan_ptr->ShouldStop(event_ptr);
841
842 // plan_ptr explains the stop, next check whether plan_ptr is done,
843 // if so, then we should take it and all the plans below it off the
844 // stack.
845
846 if (plan_ptr->MischiefManaged()) {
847 // We're going to pop the plans up to and including the plan that
848 // explains the stop.
849 ThreadPlan *prev_plan_ptr = GetPreviousPlan(plan_ptr);
850
851 do {
852 if (should_stop)
853 current_plan->WillStop();
854 PopPlan();
855 } while ((current_plan = GetCurrentPlan()) != prev_plan_ptr);
856 // Now, if the responsible plan was not "Okay to discard" then
857 // we're done, otherwise we forward this to the next plan in the
858 // stack below.
859 done_processing_current_plan =
860 (plan_ptr->IsControllingPlan() && !plan_ptr->OkayToDiscard());
861 } else {
862 bool should_force_run = plan_ptr->ShouldRunBeforePublicStop();
863 if (should_force_run) {
865 should_stop = false;
866 }
867 done_processing_current_plan = true;
868 }
869 break;
870 }
871 }
872 }
873 }
874
875 if (!done_processing_current_plan) {
876 bool override_stop = false;
877
878 // We're starting from the base plan, so just let it decide;
879 if (current_plan->IsBasePlan()) {
880 should_stop = current_plan->ShouldStop(event_ptr);
881 LLDB_LOGF(log, "Base plan says should stop: %i.", should_stop);
882 } else {
883 // Otherwise, don't let the base plan override what the other plans say
884 // to do, since presumably if there were other plans they would know what
885 // to do...
886 while (true) {
887 if (current_plan->IsBasePlan())
888 break;
889
890 should_stop = current_plan->ShouldStop(event_ptr);
891 LLDB_LOGF(log, "Plan %s should stop: %d.", current_plan->GetName(),
892 should_stop);
893 if (current_plan->MischiefManaged()) {
894 if (should_stop)
895 current_plan->WillStop();
896
897 if (current_plan->ShouldAutoContinue(event_ptr)) {
898 override_stop = true;
899 LLDB_LOGF(log, "Plan %s auto-continue: true.",
900 current_plan->GetName());
901 }
902
903 // If a Controlling Plan wants to stop, we let it. Otherwise, see if
904 // the plan's parent wants to stop.
905
906 PopPlan();
907 if (should_stop && current_plan->IsControllingPlan() &&
908 !current_plan->OkayToDiscard()) {
909 break;
910 }
911
912 current_plan = GetCurrentPlan();
913 if (current_plan == nullptr) {
914 break;
915 }
916 } else {
917 break;
918 }
919 }
920 }
921
922 if (override_stop)
923 should_stop = false;
924 }
925
926 // One other potential problem is that we set up a controlling plan, then stop
927 // in before it is complete - for instance by hitting a breakpoint during a
928 // step-over - then do some step/finish/etc operations that wind up past the
929 // end point condition of the initial plan. We don't want to strand the
930 // original plan on the stack, This code clears stale plans off the stack.
931
932 if (should_stop) {
933 ThreadPlan *plan_ptr = GetCurrentPlan();
934
935 // Discard the stale plans and all plans below them in the stack, plus move
936 // the completed plans to the completed plan stack
937 while (!plan_ptr->IsBasePlan()) {
938 bool stale = plan_ptr->IsPlanStale();
939 ThreadPlan *examined_plan = plan_ptr;
940 plan_ptr = GetPreviousPlan(examined_plan);
941
942 if (stale) {
943 LLDB_LOGF(
944 log,
945 "Plan %s being discarded in cleanup, it says it is already done.",
946 examined_plan->GetName());
947 while (GetCurrentPlan() != examined_plan) {
948 DiscardPlan();
949 }
950 if (examined_plan->IsPlanComplete()) {
951 // plan is complete but does not explain the stop (example: step to a
952 // line with breakpoint), let us move the plan to
953 // completed_plan_stack anyway
954 PopPlan();
955 } else
956 DiscardPlan();
957 }
958 }
959 }
960
961 if (log) {
962 StreamString s;
963 s.IndentMore();
964 GetProcess()->DumpThreadPlansForTID(
965 s, GetID(), eDescriptionLevelVerbose, true /* internal */,
966 false /* condense_trivial */, true /* skip_unreported */);
967 LLDB_LOGF(log, "Plan stack final state:\n%s", s.GetData());
968 LLDB_LOGF(log, "vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
969 should_stop);
970 }
971 return should_stop;
972}
973
975 StateType thread_state = GetResumeState();
976 StateType temp_thread_state = GetTemporaryResumeState();
977
978 Log *log = GetLog(LLDBLog::Step);
979
980 if (thread_state == eStateSuspended || thread_state == eStateInvalid) {
981 LLDB_LOGF(log,
982 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
983 ": returning vote %i (state was suspended or invalid)",
985 return eVoteNoOpinion;
986 }
987
988 if (temp_thread_state == eStateSuspended ||
989 temp_thread_state == eStateInvalid) {
990 LLDB_LOGF(log,
991 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
992 ": returning vote %i (temporary state was suspended or invalid)",
994 return eVoteNoOpinion;
995 }
996
998 LLDB_LOGF(log,
999 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1000 ": returning vote %i (thread didn't stop for a reason.)",
1002 return eVoteNoOpinion;
1003 }
1004
1005 if (GetPlans().AnyCompletedPlans()) {
1006 // Pass skip_private = false to GetCompletedPlan, since we want to ask
1007 // the last plan, regardless of whether it is private or not.
1008 LLDB_LOGF(log,
1009 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1010 ": returning vote for complete stack's back plan",
1011 GetID());
1012 return GetPlans().GetCompletedPlan(false)->ShouldReportStop(event_ptr);
1013 } else {
1014 Vote thread_vote = eVoteNoOpinion;
1015 ThreadPlan *plan_ptr = GetCurrentPlan();
1016 while (true) {
1017 if (plan_ptr->PlanExplainsStop(event_ptr)) {
1018 thread_vote = plan_ptr->ShouldReportStop(event_ptr);
1019 break;
1020 }
1021 if (plan_ptr->IsBasePlan())
1022 break;
1023 else
1024 plan_ptr = GetPreviousPlan(plan_ptr);
1025 }
1026 LLDB_LOGF(log,
1027 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1028 ": returning vote %i for current plan",
1029 GetID(), thread_vote);
1030
1031 return thread_vote;
1032 }
1033}
1034
1036 StateType thread_state = GetResumeState();
1037
1038 if (thread_state == eStateSuspended || thread_state == eStateInvalid) {
1039 return eVoteNoOpinion;
1040 }
1041
1042 Log *log = GetLog(LLDBLog::Step);
1043 if (GetPlans().AnyCompletedPlans()) {
1044 // Pass skip_private = false to GetCompletedPlan, since we want to ask
1045 // the last plan, regardless of whether it is private or not.
1046 LLDB_LOGF(log,
1047 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1048 ", %s): %s being asked whether we should report run.",
1049 GetIndexID(), static_cast<void *>(this), GetID(),
1052
1053 return GetPlans().GetCompletedPlan(false)->ShouldReportRun(event_ptr);
1054 } else {
1055 LLDB_LOGF(log,
1056 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1057 ", %s): %s being asked whether we should report run.",
1058 GetIndexID(), static_cast<void *>(this), GetID(),
1060 GetCurrentPlan()->GetName());
1061
1062 return GetCurrentPlan()->ShouldReportRun(event_ptr);
1063 }
1064}
1065
1067 return (spec == nullptr) ? true : spec->ThreadPassesBasicTests(*this);
1068}
1069
1071 ThreadPlanStack *plans = GetProcess()->FindThreadPlans(GetID());
1072 if (plans)
1073 return *plans;
1074
1075 // History threads don't have a thread plan, but they do ask get asked to
1076 // describe themselves, which usually involves pulling out the stop reason.
1077 // That in turn will check for a completed plan on the ThreadPlanStack.
1078 // Instead of special-casing at that point, we return a Stack with a
1079 // ThreadPlanNull as its base plan. That will give the right answers to the
1080 // queries GetDescription makes, and only assert if you try to run the thread.
1082 m_null_plan_stack_up = std::make_unique<ThreadPlanStack>(*this, true);
1083 return *m_null_plan_stack_up;
1084}
1085
1086void Thread::PushPlan(ThreadPlanSP thread_plan_sp) {
1087 assert(thread_plan_sp && "Don't push an empty thread plan.");
1088
1089 Log *log = GetLog(LLDBLog::Step);
1090 if (log) {
1091 StreamString s;
1092 thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
1093 LLDB_LOGF(log, "Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
1094 static_cast<void *>(this), s.GetData(),
1095 thread_plan_sp->GetThread().GetID());
1096 }
1097
1098 GetPlans().PushPlan(std::move(thread_plan_sp));
1099}
1100
1102 Log *log = GetLog(LLDBLog::Step);
1103 ThreadPlanSP popped_plan_sp = GetPlans().PopPlan();
1104 if (log) {
1105 LLDB_LOGF(log, "Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
1106 popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID());
1107 }
1108}
1109
1111 Log *log = GetLog(LLDBLog::Step);
1112 ThreadPlanSP discarded_plan_sp = GetPlans().DiscardPlan();
1113
1114 LLDB_LOGF(log, "Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
1115 discarded_plan_sp->GetName(),
1116 discarded_plan_sp->GetThread().GetID());
1117}
1118
1120 const ThreadPlanStack &plans = GetPlans();
1121 if (!plans.AnyPlans())
1122 return;
1123
1124 // Iterate from the second plan (index: 1) to skip the base plan.
1125 ThreadPlanSP p;
1126 uint32_t i = 1;
1127 while ((p = plans.GetPlanByIndex(i, false))) {
1128 StreamString strm;
1129 p->GetDescription(&strm, eDescriptionLevelInitial);
1130 request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
1131 i++;
1132 }
1133}
1134
1136 return GetPlans().GetCurrentPlan().get();
1137}
1138
1140 return GetPlans().GetCompletedPlan();
1141}
1142
1144 return GetPlans().GetReturnValueObject();
1145}
1146
1149}
1150
1152 return GetPlans().IsPlanDone(plan);
1153}
1154
1156 return GetPlans().WasPlanDiscarded(plan);
1157}
1158
1160 return GetPlans().AnyCompletedPlans();
1161}
1162
1164 return GetPlans().GetPreviousPlan(current_plan);
1165}
1166
1168 bool abort_other_plans) {
1169 Status status;
1170 StreamString s;
1171 if (!thread_plan_sp->ValidatePlan(&s)) {
1172 DiscardThreadPlansUpToPlan(thread_plan_sp);
1173 thread_plan_sp.reset();
1174 status.SetErrorString(s.GetString());
1175 return status;
1176 }
1177
1178 if (abort_other_plans)
1179 DiscardThreadPlans(true);
1180
1181 PushPlan(thread_plan_sp);
1182
1183 // This seems a little funny, but I don't want to have to split up the
1184 // constructor and the DidPush in the scripted plan, that seems annoying.
1185 // That means the constructor has to be in DidPush. So I have to validate the
1186 // plan AFTER pushing it, and then take it off again...
1187 if (!thread_plan_sp->ValidatePlan(&s)) {
1188 DiscardThreadPlansUpToPlan(thread_plan_sp);
1189 thread_plan_sp.reset();
1190 status.SetErrorString(s.GetString());
1191 return status;
1192 }
1193
1194 return status;
1195}
1196
1198 // Count the user thread plans from the back end to get the number of the one
1199 // we want to discard:
1200
1201 ThreadPlan *up_to_plan_ptr = GetPlans().GetPlanByIndex(plan_index).get();
1202 if (up_to_plan_ptr == nullptr)
1203 return false;
1204
1205 DiscardThreadPlansUpToPlan(up_to_plan_ptr);
1206 return true;
1207}
1208
1210 DiscardThreadPlansUpToPlan(up_to_plan_sp.get());
1211}
1212
1214 Log *log = GetLog(LLDBLog::Step);
1215 LLDB_LOGF(log,
1216 "Discarding thread plans for thread tid = 0x%4.4" PRIx64
1217 ", up to %p",
1218 GetID(), static_cast<void *>(up_to_plan_ptr));
1219 GetPlans().DiscardPlansUpToPlan(up_to_plan_ptr);
1220}
1221
1223 Log *log = GetLog(LLDBLog::Step);
1224 if (log) {
1225 LLDB_LOGF(log,
1226 "Discarding thread plans for thread (tid = 0x%4.4" PRIx64
1227 ", force %d)",
1228 GetID(), force);
1229 }
1230
1231 if (force) {
1233 return;
1234 }
1236}
1237
1239 Status error;
1240 ThreadPlan *innermost_expr_plan = GetPlans().GetInnermostExpression();
1241 if (!innermost_expr_plan) {
1242 error.SetErrorString("No expressions currently active on this thread");
1243 return error;
1244 }
1245 DiscardThreadPlansUpToPlan(innermost_expr_plan);
1246 return error;
1247}
1248
1249ThreadPlanSP Thread::QueueBasePlan(bool abort_other_plans) {
1250 ThreadPlanSP thread_plan_sp(new ThreadPlanBase(*this));
1251 QueueThreadPlan(thread_plan_sp, abort_other_plans);
1252 return thread_plan_sp;
1253}
1254
1256 bool step_over, bool abort_other_plans, bool stop_other_threads,
1257 Status &status) {
1258 ThreadPlanSP thread_plan_sp(new ThreadPlanStepInstruction(
1259 *this, step_over, stop_other_threads, eVoteNoOpinion, eVoteNoOpinion));
1260 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1261 return thread_plan_sp;
1262}
1263
1265 bool abort_other_plans, const AddressRange &range,
1266 const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
1267 Status &status, LazyBool step_out_avoids_code_withoug_debug_info) {
1268 ThreadPlanSP thread_plan_sp;
1269 thread_plan_sp = std::make_shared<ThreadPlanStepOverRange>(
1270 *this, range, addr_context, stop_other_threads,
1271 step_out_avoids_code_withoug_debug_info);
1272
1273 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1274 return thread_plan_sp;
1275}
1276
1277// Call the QueueThreadPlanForStepOverRange method which takes an address
1278// range.
1280 bool abort_other_plans, const LineEntry &line_entry,
1281 const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
1282 Status &status, LazyBool step_out_avoids_code_withoug_debug_info) {
1283 const bool include_inlined_functions = true;
1284 auto address_range =
1285 line_entry.GetSameLineContiguousAddressRange(include_inlined_functions);
1287 abort_other_plans, address_range, addr_context, stop_other_threads,
1288 status, step_out_avoids_code_withoug_debug_info);
1289}
1290
1292 bool abort_other_plans, const AddressRange &range,
1293 const SymbolContext &addr_context, const char *step_in_target,
1294 lldb::RunMode stop_other_threads, Status &status,
1295 LazyBool step_in_avoids_code_without_debug_info,
1296 LazyBool step_out_avoids_code_without_debug_info) {
1297 ThreadPlanSP thread_plan_sp(new ThreadPlanStepInRange(
1298 *this, range, addr_context, step_in_target, stop_other_threads,
1299 step_in_avoids_code_without_debug_info,
1300 step_out_avoids_code_without_debug_info));
1301 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1302 return thread_plan_sp;
1303}
1304
1305// Call the QueueThreadPlanForStepInRange method which takes an address range.
1307 bool abort_other_plans, const LineEntry &line_entry,
1308 const SymbolContext &addr_context, const char *step_in_target,
1309 lldb::RunMode stop_other_threads, Status &status,
1310 LazyBool step_in_avoids_code_without_debug_info,
1311 LazyBool step_out_avoids_code_without_debug_info) {
1312 const bool include_inlined_functions = false;
1314 abort_other_plans,
1315 line_entry.GetSameLineContiguousAddressRange(include_inlined_functions),
1316 addr_context, step_in_target, stop_other_threads, status,
1317 step_in_avoids_code_without_debug_info,
1318 step_out_avoids_code_without_debug_info);
1319}
1320
1322 bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
1323 bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote,
1324 uint32_t frame_idx, Status &status,
1325 LazyBool step_out_avoids_code_without_debug_info) {
1326 ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut(
1327 *this, addr_context, first_insn, stop_other_threads, report_stop_vote,
1328 report_run_vote, frame_idx, step_out_avoids_code_without_debug_info));
1329
1330 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1331 return thread_plan_sp;
1332}
1333
1335 bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
1336 bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote,
1337 uint32_t frame_idx, Status &status, bool continue_to_next_branch) {
1338 const bool calculate_return_value =
1339 false; // No need to calculate the return value here.
1340 ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut(
1341 *this, addr_context, first_insn, stop_other_threads, report_stop_vote,
1342 report_run_vote, frame_idx, eLazyBoolNo, continue_to_next_branch,
1343 calculate_return_value));
1344
1345 ThreadPlanStepOut *new_plan =
1346 static_cast<ThreadPlanStepOut *>(thread_plan_sp.get());
1347 new_plan->ClearShouldStopHereCallbacks();
1348
1349 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1350 return thread_plan_sp;
1351}
1352
1354 bool abort_other_plans,
1355 bool stop_other_threads,
1356 Status &status) {
1357 ThreadPlanSP thread_plan_sp(
1358 new ThreadPlanStepThrough(*this, return_stack_id, stop_other_threads));
1359 if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(nullptr))
1360 return ThreadPlanSP();
1361
1362 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1363 return thread_plan_sp;
1364}
1365
1367 Address &target_addr,
1368 bool stop_other_threads,
1369 Status &status) {
1370 ThreadPlanSP thread_plan_sp(
1371 new ThreadPlanRunToAddress(*this, target_addr, stop_other_threads));
1372
1373 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1374 return thread_plan_sp;
1375}
1376
1378 bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses,
1379 bool stop_other_threads, uint32_t frame_idx, Status &status) {
1380 ThreadPlanSP thread_plan_sp(new ThreadPlanStepUntil(
1381 *this, address_list, num_addresses, stop_other_threads, frame_idx));
1382
1383 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1384 return thread_plan_sp;
1385}
1386
1388 bool abort_other_plans, const char *class_name,
1389 StructuredData::ObjectSP extra_args_sp, bool stop_other_threads,
1390 Status &status) {
1391
1392 ThreadPlanSP thread_plan_sp(new ScriptedThreadPlan(
1393 *this, class_name, StructuredDataImpl(extra_args_sp)));
1394 thread_plan_sp->SetStopOthers(stop_other_threads);
1395 status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
1396 return thread_plan_sp;
1397}
1398
1399uint32_t Thread::GetIndexID() const { return m_index_id; }
1400
1402 TargetSP target_sp;
1403 ProcessSP process_sp(GetProcess());
1404 if (process_sp)
1405 target_sp = process_sp->CalculateTarget();
1406 return target_sp;
1407}
1408
1410
1411ThreadSP Thread::CalculateThread() { return shared_from_this(); }
1412
1414
1416 exe_ctx.SetContext(shared_from_this());
1417}
1418
1420 std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
1421
1422 if (!m_curr_frames_sp)
1424 std::make_shared<StackFrameList>(*this, m_prev_frames_sp, true);
1425
1426 return m_curr_frames_sp;
1427}
1428
1429std::optional<addr_t> Thread::GetPreviousFrameZeroPC() {
1430 return m_prev_framezero_pc;
1431}
1432
1434 std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
1435
1436 GetUnwinder().Clear();
1437 m_prev_framezero_pc.reset();
1438 if (RegisterContextSP reg_ctx_sp = GetRegisterContext())
1439 m_prev_framezero_pc = reg_ctx_sp->GetPC();
1440
1441 // Only store away the old "reference" StackFrameList if we got all its
1442 // frames:
1443 // FIXME: At some point we can try to splice in the frames we have fetched
1444 // into the new frame as we make it, but let's not try that now.
1445 if (m_curr_frames_sp && m_curr_frames_sp->GetAllFramesFetched())
1447 m_curr_frames_sp.reset();
1448
1449 m_extended_info.reset();
1451}
1452
1454 return GetStackFrameList()->GetFrameWithConcreteFrameIndex(unwind_idx);
1455}
1456
1458 lldb::ValueObjectSP return_value_sp,
1459 bool broadcast) {
1460 StackFrameSP frame_sp = GetStackFrameAtIndex(frame_idx);
1461 Status return_error;
1462
1463 if (!frame_sp) {
1464 return_error.SetErrorStringWithFormat(
1465 "Could not find frame with index %d in thread 0x%" PRIx64 ".",
1466 frame_idx, GetID());
1467 }
1468
1469 return ReturnFromFrame(frame_sp, return_value_sp, broadcast);
1470}
1471
1473 lldb::ValueObjectSP return_value_sp,
1474 bool broadcast) {
1475 Status return_error;
1476
1477 if (!frame_sp) {
1478 return_error.SetErrorString("Can't return to a null frame.");
1479 return return_error;
1480 }
1481
1482 Thread *thread = frame_sp->GetThread().get();
1483 uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
1484 StackFrameSP older_frame_sp = thread->GetStackFrameAtIndex(older_frame_idx);
1485 if (!older_frame_sp) {
1486 return_error.SetErrorString("No older frame to return to.");
1487 return return_error;
1488 }
1489
1490 if (return_value_sp) {
1491 lldb::ABISP abi = thread->GetProcess()->GetABI();
1492 if (!abi) {
1493 return_error.SetErrorString("Could not find ABI to set return value.");
1494 return return_error;
1495 }
1496 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
1497
1498 // FIXME: ValueObject::Cast doesn't currently work correctly, at least not
1499 // for scalars.
1500 // Turn that back on when that works.
1501 if (/* DISABLES CODE */ (false) && sc.function != nullptr) {
1502 Type *function_type = sc.function->GetType();
1503 if (function_type) {
1504 CompilerType return_type =
1506 if (return_type) {
1507 StreamString s;
1508 return_type.DumpTypeDescription(&s);
1509 ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
1510 if (cast_value_sp) {
1511 cast_value_sp->SetFormat(eFormatHex);
1512 return_value_sp = cast_value_sp;
1513 }
1514 }
1515 }
1516 }
1517
1518 return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
1519 if (!return_error.Success())
1520 return return_error;
1521 }
1522
1523 // Now write the return registers for the chosen frame: Note, we can't use
1524 // ReadAllRegisterValues->WriteAllRegisterValues, since the read & write cook
1525 // their data
1526
1527 StackFrameSP youngest_frame_sp = thread->GetStackFrameAtIndex(0);
1528 if (youngest_frame_sp) {
1529 lldb::RegisterContextSP reg_ctx_sp(youngest_frame_sp->GetRegisterContext());
1530 if (reg_ctx_sp) {
1531 bool copy_success = reg_ctx_sp->CopyFromRegisterContext(
1532 older_frame_sp->GetRegisterContext());
1533 if (copy_success) {
1534 thread->DiscardThreadPlans(true);
1535 thread->ClearStackFrames();
1537 auto data_sp = std::make_shared<ThreadEventData>(shared_from_this());
1539 }
1540 } else {
1541 return_error.SetErrorString("Could not reset register values.");
1542 }
1543 } else {
1544 return_error.SetErrorString("Frame has no register context.");
1545 }
1546 } else {
1547 return_error.SetErrorString("Returned past top frame.");
1548 }
1549 return return_error;
1550}
1551
1552static void DumpAddressList(Stream &s, const std::vector<Address> &list,
1553 ExecutionContextScope *exe_scope) {
1554 for (size_t n = 0; n < list.size(); n++) {
1555 s << "\t";
1556 list[n].Dump(&s, exe_scope, Address::DumpStyleResolvedDescription,
1558 s << "\n";
1559 }
1560}
1561
1562Status Thread::JumpToLine(const FileSpec &file, uint32_t line,
1563 bool can_leave_function, std::string *warnings) {
1565 Target *target = exe_ctx.GetTargetPtr();
1566 TargetSP target_sp = exe_ctx.GetTargetSP();
1567 RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
1568 StackFrame *frame = exe_ctx.GetFramePtr();
1569 const SymbolContext &sc = frame->GetSymbolContext(eSymbolContextFunction);
1570
1571 // Find candidate locations.
1572 std::vector<Address> candidates, within_function, outside_function;
1573 target->GetImages().FindAddressesForLine(target_sp, file, line, sc.function,
1574 within_function, outside_function);
1575
1576 // If possible, we try and stay within the current function. Within a
1577 // function, we accept multiple locations (optimized code may do this,
1578 // there's no solution here so we do the best we can). However if we're
1579 // trying to leave the function, we don't know how to pick the right
1580 // location, so if there's more than one then we bail.
1581 if (!within_function.empty())
1582 candidates = within_function;
1583 else if (outside_function.size() == 1 && can_leave_function)
1584 candidates = outside_function;
1585
1586 // Check if we got anything.
1587 if (candidates.empty()) {
1588 if (outside_function.empty()) {
1589 return Status("Cannot locate an address for %s:%i.",
1590 file.GetFilename().AsCString(), line);
1591 } else if (outside_function.size() == 1) {
1592 return Status("%s:%i is outside the current function.",
1593 file.GetFilename().AsCString(), line);
1594 } else {
1595 StreamString sstr;
1596 DumpAddressList(sstr, outside_function, target);
1597 return Status("%s:%i has multiple candidate locations:\n%s",
1598 file.GetFilename().AsCString(), line, sstr.GetData());
1599 }
1600 }
1601
1602 // Accept the first location, warn about any others.
1603 Address dest = candidates[0];
1604 if (warnings && candidates.size() > 1) {
1605 StreamString sstr;
1606 sstr.Printf("%s:%i appears multiple times in this function, selecting the "
1607 "first location:\n",
1608 file.GetFilename().AsCString(), line);
1609 DumpAddressList(sstr, candidates, target);
1610 *warnings = std::string(sstr.GetString());
1611 }
1612
1613 if (!reg_ctx->SetPC(dest))
1614 return Status("Cannot change PC to target address.");
1615
1616 return Status();
1617}
1618
1619bool Thread::DumpUsingFormat(Stream &strm, uint32_t frame_idx,
1620 const FormatEntity::Entry *format) {
1621 ExecutionContext exe_ctx(shared_from_this());
1622 Process *process = exe_ctx.GetProcessPtr();
1623 if (!process || !format)
1624 return false;
1625
1626 StackFrameSP frame_sp;
1627 SymbolContext frame_sc;
1628 if (frame_idx != LLDB_INVALID_FRAME_ID) {
1629 frame_sp = GetStackFrameAtIndex(frame_idx);
1630 if (frame_sp) {
1631 exe_ctx.SetFrameSP(frame_sp);
1632 frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
1633 }
1634 }
1635
1636 return FormatEntity::Format(*format, strm, frame_sp ? &frame_sc : nullptr,
1637 &exe_ctx, nullptr, nullptr, false, false);
1638}
1639
1640void Thread::DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx,
1641 bool stop_format) {
1642 ExecutionContext exe_ctx(shared_from_this());
1643
1644 const FormatEntity::Entry *thread_format;
1645 if (stop_format)
1646 thread_format = exe_ctx.GetTargetRef().GetDebugger().GetThreadStopFormat();
1647 else
1648 thread_format = exe_ctx.GetTargetRef().GetDebugger().GetThreadFormat();
1649
1650 assert(thread_format);
1651
1652 DumpUsingFormat(strm, frame_idx, thread_format);
1653}
1654
1656
1658
1660 if (m_reg_context_sp)
1661 return m_reg_context_sp->GetThreadPointer();
1662 return LLDB_INVALID_ADDRESS;
1663}
1664
1666 lldb::addr_t tls_file_addr) {
1667 // The default implementation is to ask the dynamic loader for it. This can
1668 // be overridden for specific platforms.
1669 DynamicLoader *loader = GetProcess()->GetDynamicLoader();
1670 if (loader)
1671 return loader->GetThreadLocalData(module, shared_from_this(),
1672 tls_file_addr);
1673 else
1674 return LLDB_INVALID_ADDRESS;
1675}
1676
1678 Process *process = GetProcess().get();
1679 if (process) {
1680 DynamicLoader *loader = GetProcess()->GetDynamicLoader();
1681 if (loader && loader->IsFullyInitialized() == false)
1682 return false;
1683
1684 SystemRuntime *runtime = process->GetSystemRuntime();
1685 if (runtime) {
1686 return runtime->SafeToCallFunctionsOnThisThread(shared_from_this());
1687 }
1688 }
1689 return true;
1690}
1691
1694 return GetStackFrameList()->GetStackFrameSPForStackFramePtr(stack_frame_ptr);
1695}
1696
1698 switch (reason) {
1699 case eStopReasonInvalid:
1700 return "invalid";
1701 case eStopReasonNone:
1702 return "none";
1703 case eStopReasonTrace:
1704 return "trace";
1706 return "breakpoint";
1708 return "watchpoint";
1709 case eStopReasonSignal:
1710 return "signal";
1712 return "exception";
1713 case eStopReasonExec:
1714 return "exec";
1715 case eStopReasonFork:
1716 return "fork";
1717 case eStopReasonVFork:
1718 return "vfork";
1720 return "vfork done";
1722 return "plan complete";
1724 return "thread exiting";
1726 return "instrumentation break";
1728 return "processor trace";
1730 return "async interrupt";
1731 }
1732
1733 return "StopReason = " + std::to_string(reason);
1734}
1735
1737 switch (mode) {
1738 case eOnlyThisThread:
1739 return "only this thread";
1740 case eAllThreads:
1741 return "all threads";
1743 return "only during stepping";
1744 }
1745
1746 return "RunMode = " + std::to_string(mode);
1747}
1748
1749size_t Thread::GetStatus(Stream &strm, uint32_t start_frame,
1750 uint32_t num_frames, uint32_t num_frames_with_source,
1751 bool stop_format, bool show_hidden, bool only_stacks) {
1752
1753 if (!only_stacks) {
1754 ExecutionContext exe_ctx(shared_from_this());
1755 Target *target = exe_ctx.GetTargetPtr();
1756 Process *process = exe_ctx.GetProcessPtr();
1757 strm.Indent();
1758 bool is_selected = false;
1759 if (process) {
1760 if (process->GetThreadList().GetSelectedThread().get() == this)
1761 is_selected = true;
1762 }
1763 strm.Printf("%c ", is_selected ? '*' : ' ');
1764 if (target && target->GetDebugger().GetUseExternalEditor()) {
1765 StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame);
1766 if (frame_sp) {
1767 SymbolContext frame_sc(
1768 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
1769 if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.GetFile()) {
1770 if (llvm::Error e = Host::OpenFileInExternalEditor(
1771 target->GetDebugger().GetExternalEditor(),
1772 frame_sc.line_entry.GetFile(), frame_sc.line_entry.line)) {
1773 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(e),
1774 "OpenFileInExternalEditor failed: {0}");
1775 }
1776 }
1777 }
1778 }
1779
1780 DumpUsingSettingsFormat(strm, start_frame, stop_format);
1781 }
1782
1783 size_t num_frames_shown = 0;
1784 if (num_frames > 0) {
1785 strm.IndentMore();
1786
1787 const bool show_frame_info = true;
1788 const bool show_frame_unique = only_stacks;
1789 const char *selected_frame_marker = nullptr;
1790 if (num_frames == 1 || only_stacks ||
1791 (GetID() != GetProcess()->GetThreadList().GetSelectedThread()->GetID()))
1792 strm.IndentMore();
1793 else
1794 selected_frame_marker = "* ";
1795
1796 num_frames_shown = GetStackFrameList()->GetStatus(
1797 strm, start_frame, num_frames, show_frame_info, num_frames_with_source,
1798 show_frame_unique, show_hidden, selected_frame_marker);
1799 if (num_frames == 1)
1800 strm.IndentLess();
1801 strm.IndentLess();
1802 }
1803 return num_frames_shown;
1804}
1805
1807 bool print_json_thread, bool print_json_stopinfo) {
1808 const bool stop_format = false;
1809 DumpUsingSettingsFormat(strm, 0, stop_format);
1810 strm.Printf("\n");
1811
1813
1814 if (print_json_thread || print_json_stopinfo) {
1815 if (thread_info && print_json_thread) {
1816 thread_info->Dump(strm);
1817 strm.Printf("\n");
1818 }
1819
1820 if (print_json_stopinfo && m_stop_info_sp) {
1821 StructuredData::ObjectSP stop_info = m_stop_info_sp->GetExtendedInfo();
1822 if (stop_info) {
1823 stop_info->Dump(strm);
1824 strm.Printf("\n");
1825 }
1826 }
1827
1828 return true;
1829 }
1830
1831 if (thread_info) {
1832 StructuredData::ObjectSP activity =
1833 thread_info->GetObjectForDotSeparatedPath("activity");
1834 StructuredData::ObjectSP breadcrumb =
1835 thread_info->GetObjectForDotSeparatedPath("breadcrumb");
1836 StructuredData::ObjectSP messages =
1837 thread_info->GetObjectForDotSeparatedPath("trace_messages");
1838
1839 bool printed_activity = false;
1840 if (activity && activity->GetType() == eStructuredDataTypeDictionary) {
1841 StructuredData::Dictionary *activity_dict = activity->GetAsDictionary();
1842 StructuredData::ObjectSP id = activity_dict->GetValueForKey("id");
1843 StructuredData::ObjectSP name = activity_dict->GetValueForKey("name");
1844 if (name && name->GetType() == eStructuredDataTypeString && id &&
1845 id->GetType() == eStructuredDataTypeInteger) {
1846 strm.Format(" Activity '{0}', {1:x}\n",
1847 name->GetAsString()->GetValue(),
1848 id->GetUnsignedIntegerValue());
1849 }
1850 printed_activity = true;
1851 }
1852 bool printed_breadcrumb = false;
1853 if (breadcrumb && breadcrumb->GetType() == eStructuredDataTypeDictionary) {
1854 if (printed_activity)
1855 strm.Printf("\n");
1856 StructuredData::Dictionary *breadcrumb_dict =
1857 breadcrumb->GetAsDictionary();
1858 StructuredData::ObjectSP breadcrumb_text =
1859 breadcrumb_dict->GetValueForKey("name");
1860 if (breadcrumb_text &&
1861 breadcrumb_text->GetType() == eStructuredDataTypeString) {
1862 strm.Format(" Current Breadcrumb: {0}\n",
1863 breadcrumb_text->GetAsString()->GetValue());
1864 }
1865 printed_breadcrumb = true;
1866 }
1867 if (messages && messages->GetType() == eStructuredDataTypeArray) {
1868 if (printed_breadcrumb)
1869 strm.Printf("\n");
1870 StructuredData::Array *messages_array = messages->GetAsArray();
1871 const size_t msg_count = messages_array->GetSize();
1872 if (msg_count > 0) {
1873 strm.Printf(" %zu trace messages:\n", msg_count);
1874 for (size_t i = 0; i < msg_count; i++) {
1875 StructuredData::ObjectSP message = messages_array->GetItemAtIndex(i);
1876 if (message && message->GetType() == eStructuredDataTypeDictionary) {
1877 StructuredData::Dictionary *message_dict =
1878 message->GetAsDictionary();
1879 StructuredData::ObjectSP message_text =
1880 message_dict->GetValueForKey("message");
1881 if (message_text &&
1882 message_text->GetType() == eStructuredDataTypeString) {
1883 strm.Format(" {0}\n", message_text->GetAsString()->GetValue());
1884 }
1885 }
1886 }
1887 }
1888 }
1889 }
1890
1891 return true;
1892}
1893
1894size_t Thread::GetStackFrameStatus(Stream &strm, uint32_t first_frame,
1895 uint32_t num_frames, bool show_frame_info,
1896 uint32_t num_frames_with_source,
1897 bool show_hidden) {
1898 return GetStackFrameList()->GetStatus(strm, first_frame, num_frames,
1899 show_frame_info, num_frames_with_source,
1900 /*show_unique*/ false, show_hidden);
1901}
1902
1904 if (!m_unwinder_up)
1905 m_unwinder_up = std::make_unique<UnwindLLDB>(*this);
1906 return *m_unwinder_up;
1907}
1908
1911 m_reg_context_sp.reset();
1912}
1913
1915 // If we are currently stopped at a breakpoint, always return that stopinfo
1916 // and don't reset it. This allows threads to maintain their breakpoint
1917 // stopinfo, such as when thread-stepping in multithreaded programs.
1918 if (m_stop_info_sp) {
1919 StopReason stop_reason = m_stop_info_sp->GetStopReason();
1920 if (stop_reason == lldb::eStopReasonBreakpoint) {
1921 uint64_t value = m_stop_info_sp->GetValue();
1923 if (reg_ctx_sp) {
1924 lldb::addr_t pc = reg_ctx_sp->GetPC();
1925 BreakpointSiteSP bp_site_sp =
1926 GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
1927 if (bp_site_sp && static_cast<break_id_t>(value) == bp_site_sp->GetID())
1928 return true;
1929 }
1930 }
1931 }
1932 return false;
1933}
1934
1935Status Thread::StepIn(bool source_step,
1936 LazyBool step_in_avoids_code_without_debug_info,
1937 LazyBool step_out_avoids_code_without_debug_info)
1938
1939{
1940 Status error;
1941 Process *process = GetProcess().get();
1942 if (StateIsStoppedState(process->GetState(), true)) {
1943 StackFrameSP frame_sp = GetStackFrameAtIndex(0);
1944 ThreadPlanSP new_plan_sp;
1945 const lldb::RunMode run_mode = eOnlyThisThread;
1946 const bool abort_other_plans = false;
1947
1948 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1949 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1950 new_plan_sp = QueueThreadPlanForStepInRange(
1951 abort_other_plans, sc.line_entry, sc, nullptr, run_mode, error,
1952 step_in_avoids_code_without_debug_info,
1953 step_out_avoids_code_without_debug_info);
1954 } else {
1956 false, abort_other_plans, run_mode, error);
1957 }
1958
1959 new_plan_sp->SetIsControllingPlan(true);
1960 new_plan_sp->SetOkayToDiscard(false);
1961
1962 // Why do we need to set the current thread by ID here???
1964 error = process->Resume();
1965 } else {
1966 error.SetErrorString("process not stopped");
1967 }
1968 return error;
1969}
1970
1971Status Thread::StepOver(bool source_step,
1972 LazyBool step_out_avoids_code_without_debug_info) {
1973 Status error;
1974 Process *process = GetProcess().get();
1975 if (StateIsStoppedState(process->GetState(), true)) {
1976 StackFrameSP frame_sp = GetStackFrameAtIndex(0);
1977 ThreadPlanSP new_plan_sp;
1978
1979 const lldb::RunMode run_mode = eOnlyThisThread;
1980 const bool abort_other_plans = false;
1981
1982 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1983 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1984 new_plan_sp = QueueThreadPlanForStepOverRange(
1985 abort_other_plans, sc.line_entry, sc, run_mode, error,
1986 step_out_avoids_code_without_debug_info);
1987 } else {
1989 true, abort_other_plans, run_mode, error);
1990 }
1991
1992 new_plan_sp->SetIsControllingPlan(true);
1993 new_plan_sp->SetOkayToDiscard(false);
1994
1995 // Why do we need to set the current thread by ID here???
1997 error = process->Resume();
1998 } else {
1999 error.SetErrorString("process not stopped");
2000 }
2001 return error;
2002}
2003
2004Status Thread::StepOut(uint32_t frame_idx) {
2005 Status error;
2006 Process *process = GetProcess().get();
2007 if (StateIsStoppedState(process->GetState(), true)) {
2008 const bool first_instruction = false;
2009 const bool stop_other_threads = false;
2010 const bool abort_other_plans = false;
2011
2013 abort_other_plans, nullptr, first_instruction, stop_other_threads,
2014 eVoteYes, eVoteNoOpinion, frame_idx, error));
2015
2016 new_plan_sp->SetIsControllingPlan(true);
2017 new_plan_sp->SetOkayToDiscard(false);
2018
2019 // Why do we need to set the current thread by ID here???
2021 error = process->Resume();
2022 } else {
2023 error.SetErrorString("process not stopped");
2024 }
2025 return error;
2026}
2027
2029 if (auto frame_sp = GetStackFrameAtIndex(0))
2030 if (auto recognized_frame = frame_sp->GetRecognizedFrame())
2031 if (auto e = recognized_frame->GetExceptionObject())
2032 return e;
2033
2034 // NOTE: Even though this behavior is generalized, only ObjC is actually
2035 // supported at the moment.
2036 for (LanguageRuntime *runtime : GetProcess()->GetLanguageRuntimes()) {
2037 if (auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
2038 return e;
2039 }
2040
2041 return ValueObjectSP();
2042}
2043
2045 ValueObjectSP exception = GetCurrentException();
2046 if (!exception)
2047 return ThreadSP();
2048
2049 // NOTE: Even though this behavior is generalized, only ObjC is actually
2050 // supported at the moment.
2051 for (LanguageRuntime *runtime : GetProcess()->GetLanguageRuntimes()) {
2052 if (auto bt = runtime->GetBacktraceThreadFromException(exception))
2053 return bt;
2054 }
2055
2056 return ThreadSP();
2057}
2058
2060 ProcessSP process_sp = GetProcess();
2061 assert(process_sp);
2062 Target &target = process_sp->GetTarget();
2063 PlatformSP platform_sp = target.GetPlatform();
2064 assert(platform_sp);
2065 ArchSpec arch = target.GetArchitecture();
2066
2067 CompilerType type = platform_sp->GetSiginfoType(arch.GetTriple());
2068 if (!type.IsValid())
2069 return ValueObjectConstResult::Create(&target, Status("no siginfo_t for the platform"));
2070
2071 std::optional<uint64_t> type_size = type.GetByteSize(nullptr);
2072 assert(type_size);
2073 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data =
2074 GetSiginfo(*type_size);
2075 if (!data)
2076 return ValueObjectConstResult::Create(&target, Status(data.takeError()));
2077
2078 DataExtractor data_extractor{data.get()->getBufferStart(), data.get()->getBufferSize(),
2079 process_sp->GetByteOrder(), arch.GetAddressByteSize()};
2080 return ValueObjectConstResult::Create(&target, type, ConstString("__lldb_siginfo"), data_extractor);
2081}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition: Log.h:366
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:382
static void DumpAddressList(Stream &s, const std::vector< Address > &list, ExecutionContextScope *exe_scope)
Definition: Thread.cpp:1552
ThreadOptionValueProperties(llvm::StringRef name)
Definition: Thread.cpp:79
const Property * GetPropertyAtIndex(size_t idx, const ExecutionContext *exe_ctx) const override
Definition: Thread.cpp:82
A section + offset based address range class.
Definition: AddressRange.h:25
A section + offset based address class.
Definition: Address.h:62
@ DumpStyleSectionNameOffset
Display as the section name + offset.
Definition: Address.h:74
@ DumpStyleResolvedDescription
Display the details about what an address resolves to.
Definition: Address.h:104
An architecture specification class.
Definition: ArchSpec.h:31
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:691
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:450
An event broadcasting class.
Definition: Broadcaster.h:146
bool EventTypeHasListeners(uint32_t event_type)
Definition: Broadcaster.h:251
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
Definition: Broadcaster.h:168
A class that implements CRTP-based "virtual constructor" idiom.
Definition: Cloneable.h:40
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
CompilerType GetFunctionReturnType() const
void DumpTypeDescription(lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) const
Dump to stdout.
"lldb/Utility/ArgCompletionRequest.h"
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
A uniqued constant string class.
Definition: ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:188
An data extractor class.
Definition: DataExtractor.h:48
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
A class to manage flag bits.
Definition: Debugger.h:80
bool GetUseExternalEditor() const
Definition: Debugger.cpp:381
const FormatEntity::Entry * GetThreadStopFormat() const
Definition: Debugger.cpp:340
const FormatEntity::Entry * GetThreadFormat() const
Definition: Debugger.cpp:335
llvm::StringRef GetExternalEditor() const
Definition: Debugger.cpp:392
A plug-in interface definition class for dynamic loaders.
Definition: DynamicLoader.h:53
virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr)
Retrieves the per-module TLS block for a given thread.
virtual bool IsFullyInitialized()
Return whether the dynamic loader is fully initialized and it's safe to call its APIs.
virtual llvm::StringRef GetFlavor() const =0
EventData * GetData()
Definition: Event.h:200
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetFrameSP(const lldb::StackFrameSP &frame_sp)
Set accessor to set only the frame shared pointer.
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
void SetContext(const lldb::TargetSP &target_sp, bool get_process)
Target * GetTargetPtr() const
Returns a pointer to the target object.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
RegisterContext * GetRegisterContext() const
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
A file collection class.
Definition: FileSpecList.h:91
A file utility class.
Definition: FileSpec.h:56
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:240
CompilerType GetCompilerType()
Definition: Function.cpp:560
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types.
Definition: Function.cpp:539
static llvm::Error OpenFileInExternalEditor(llvm::StringRef editor, const FileSpec &file_spec, uint32_t line_no)
void FindAddressesForLine(const lldb::TargetSP target_sp, const FileSpec &file, uint32_t line, Function *function, std::vector< Address > &output_local, std::vector< Address > &output_extern)
Find addresses by file/line.
Definition: ModuleList.cpp:614
Property * ProtectedGetPropertyAtIndex(size_t idx)
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
static bool GetRestartedFromEvent(const Event *event_ptr)
Definition: Process.cpp:4392
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
ThreadList & GetThreadList()
Definition: Process.h:2227
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: Process.cpp:1382
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
Definition: Process.cpp:2870
lldb::StateType GetState()
Get accessor for the current process state.
Definition: Process.cpp:1335
lldb::OptionValuePropertiesSP m_collection_sp
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
This base class provides an interface to stack frames.
Definition: StackFrame.h:43
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:300
bool HasDebugInformation()
Determine whether this StackFrame has debug information available or not.
An error handling class.
Definition: Status.h:44
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:246
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:232
bool Success() const
Test for success condition.
Definition: Status.cpp:278
static lldb::StopInfoSP CreateStopReasonWithPlan(lldb::ThreadPlanSP &plan, lldb::ValueObjectSP return_valobj_sp, lldb::ExpressionVariableSP expression_variable_sp)
Definition: StopInfo.cpp:1425
static lldb::StopInfoSP CreateStopReasonWithSignal(Thread &thread, int signo, const char *description=nullptr, std::optional< int > code=std::nullopt)
Definition: StopInfo.cpp:1409
virtual void WillResume(lldb::StateType resume_state)
Definition: StopInfo.h:67
const char * GetData() const
Definition: StreamString.h:45
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void Format(const char *format, Args &&... args)
Definition: Stream.h:353
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:157
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:198
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:195
ObjectSP GetItemAtIndex(size_t idx) const
ObjectSP GetValueForKey(llvm::StringRef key) const
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
Function * function
The Function for a given query.
LineEntry line_entry
The LineEntry for a given query.
A plug-in interface definition class for system runtimes.
Definition: SystemRuntime.h:43
virtual bool SafeToCallFunctionsOnThisThread(lldb::ThreadSP thread_sp)
Determine whether it is safe to run an expression on a given thread.
Debugger & GetDebugger()
Definition: Target.h:1069
lldb::PlatformSP GetPlatform()
Definition: Target.h:1449
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:986
const ArchSpec & GetArchitecture() const
Definition: Target.h:1028
lldb::ThreadSP GetSelectedThread()
Definition: ThreadList.cpp:683
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
Definition: ThreadList.cpp:695
void DiscardPlansUpToPlan(ThreadPlan *up_to_plan_ptr)
lldb::ThreadPlanSP GetCompletedPlan(bool skip_private=true) const
lldb::ExpressionVariableSP GetExpressionVariable() const
bool IsPlanDone(ThreadPlan *plan) const
void RestoreCompletedPlanCheckpoint(size_t checkpoint)
lldb::ThreadPlanSP GetPlanByIndex(uint32_t plan_idx, bool skip_private=true) const
lldb::ValueObjectSP GetReturnValueObject() const
void PushPlan(lldb::ThreadPlanSP new_plan_sp)
lldb::ThreadPlanSP DiscardPlan()
bool WasPlanDiscarded(ThreadPlan *plan) const
ThreadPlan * GetInnermostExpression() const
lldb::ThreadPlanSP GetCurrentPlan() const
ThreadPlan * GetPreviousPlan(ThreadPlan *current_plan) const
virtual bool IsLeafPlan()
Definition: ThreadPlan.h:402
virtual Vote ShouldReportStop(Event *event_ptr)
Definition: ThreadPlan.cpp:79
virtual bool OkayToDiscard()
Definition: ThreadPlan.cpp:155
virtual bool ShouldAutoContinue(Event *event_ptr)
Returns whether this thread plan overrides the ShouldStop of subsequently processed plans.
Definition: ThreadPlan.h:376
Vote ShouldReportRun(Event *event_ptr)
Definition: ThreadPlan.cpp:94
const char * GetName() const
Returns the name of this thread plan.
Definition: ThreadPlan.h:315
ThreadPlanKind GetKind() const
Definition: ThreadPlan.h:431
virtual bool ShouldRunBeforePublicStop()
Definition: ThreadPlan.h:389
bool PlanExplainsStop(Event *event_ptr)
Definition: ThreadPlan.cpp:51
bool WillResume(lldb::StateType resume_state, bool current_plan)
Definition: ThreadPlan.cpp:116
virtual bool MischiefManaged()
Definition: ThreadPlan.cpp:72
virtual bool IsPlanStale()
Definition: ThreadPlan.h:437
virtual bool WillStop()=0
virtual bool ShouldStop(Event *event_ptr)=0
virtual bool IsBasePlan()
Definition: ThreadPlan.h:441
bool GetStepInAvoidsNoDebug() const
Definition: Thread.cpp:128
const RegularExpression * GetSymbolsToAvoidRegexp()
The regular expression returned determines symbols that this thread won't stop in during "step-in" op...
Definition: Thread.cpp:112
bool GetTraceEnabledState() const
Definition: Thread.cpp:122
ThreadProperties(bool is_global)
Definition: Thread.cpp:101
uint64_t GetMaxBacktraceDepth() const
Definition: Thread.cpp:140
FileSpecList GetLibrariesToAvoid() const
Definition: Thread.cpp:117
bool GetStepOutAvoidsNoDebug() const
Definition: Thread.cpp:134
uint64_t GetSingleThreadPlanTimeout() const
Definition: Thread.cpp:146
bool ThreadPassesBasicTests(Thread &thread) const
Definition: ThreadSpec.cpp:107
static const ThreadEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: Thread.cpp:172
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
Definition: Thread.cpp:182
void Dump(Stream *s) const override
Definition: Thread.cpp:169
static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr)
Definition: Thread.cpp:199
static llvm::StringRef GetFlavorString()
Definition: Thread.cpp:154
lldb::ThreadSP GetThread() const
Definition: Thread.h:112
static StackID GetStackIDFromEvent(const Event *event_ptr)
Definition: Thread.cpp:190
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queue the plan used to step out of the function at the current PC of thread.
Definition: Thread.cpp:1321
bool IsThreadPlanDone(ThreadPlan *plan) const
Checks whether the given plan is in the completed plans for this stop.
Definition: Thread.cpp:1151
virtual lldb::user_id_t GetProtocolID() const
Definition: Thread.h:1113
lldb::ThreadSP GetCurrentExceptionBacktrace()
Definition: Thread.cpp:2044
std::optional< lldb::addr_t > GetPreviousFrameZeroPC()
Request the pc value the thread had when previously stopped.
Definition: Thread.cpp:1429
void BroadcastSelectedFrameChange(StackID &new_frame_id)
Definition: Thread.cpp:262
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack.
Definition: Thread.cpp:1238
~Thread() override
Definition: Thread.cpp:242
const uint32_t m_index_id
A unique 1 based index assigned to each thread for easy UI/command line access.
Definition: Thread.h:1317
void SetShouldRunBeforePublicStop(bool newval)
Definition: Thread.h:1208
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Definition: Thread.h:408
bool CompletedPlanOverridesBreakpoint() const
Check if we have completed plan to override breakpoint stop reason.
Definition: Thread.cpp:1159
lldb::StackFrameListSP m_curr_frames_sp
The stack frames that get lazily populated after a thread stops.
Definition: Thread.h:1326
virtual bool SafeToCallFunctions()
Check whether this thread is safe to run functions.
Definition: Thread.cpp:1677
void RestoreThreadStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
Definition: Thread.cpp:554
Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans)
Queues a generic thread plan.
Definition: Thread.cpp:1167
bool WasThreadPlanDiscarded(ThreadPlan *plan) const
Checks whether the given plan is in the discarded plans for this stop.
Definition: Thread.cpp:1155
virtual lldb::RegisterContextSP GetRegisterContext()=0
virtual lldb::addr_t GetThreadPointer()
Retrieves the per-thread data area.
Definition: Thread.cpp:1659
@ eBroadcastBitSelectedFrameChanged
Definition: Thread.h:76
@ eBroadcastBitStackChanged
Definition: Thread.h:73
virtual lldb::ThreadPlanSP QueueThreadPlanForStepUntil(bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses, bool stop_others, uint32_t frame_idx, Status &status)
Definition: Thread.cpp:1377
virtual void DidStop()
Definition: Thread.cpp:733
virtual bool RestoreRegisterStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
Definition: Thread.cpp:532
uint32_t m_stop_info_stop_id
Definition: Thread.h:1307
void AutoCompleteThreadPlans(CompletionRequest &request) const
Format the thread plan information for auto completion.
Definition: Thread.cpp:1119
std::recursive_mutex m_frame_mutex
Multithreaded protection for m_state.
Definition: Thread.h:1325
static void SettingsInitialize()
Definition: Thread.cpp:1655
void SetShouldReportStop(Vote vote)
Definition: Thread.cpp:485
virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate=true)
Definition: Thread.cpp:385
uint32_t GetIndexID() const
Definition: Thread.cpp:1399
std::optional< lldb::addr_t > m_prev_framezero_pc
Frame 0's PC the last time this thread was stopped.
Definition: Thread.h:1331
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition: Thread.cpp:1472
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition: Thread.cpp:1415
void DiscardThreadPlans(bool force)
Discards the plans queued on the plan stack of the current thread.
Definition: Thread.cpp:1222
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
Definition: Thread.cpp:463
bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo)
Definition: Thread.cpp:1806
static std::string RunModeAsString(lldb::RunMode mode)
Definition: Thread.cpp:1736
void SetTemporaryResumeState(lldb::StateType new_state)
Definition: Thread.h:1293
virtual bool MatchesSpec(const ThreadSpec *spec)
Definition: Thread.cpp:1066
lldb::ProcessSP CalculateProcess() override
Definition: Thread.cpp:1409
StructuredData::ObjectSP GetExtendedInfo()
Retrieve a dictionary of information about this thread.
Definition: Thread.h:275
virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr)
Retrieves the per-module TLS block for a thread.
Definition: Thread.cpp:1665
void SetStopInfoToNothing()
Definition: Thread.cpp:496
virtual void DestroyThread()
Definition: Thread.cpp:251
virtual lldb::ThreadPlanSP QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr, bool stop_other_threads, Status &status)
Gets the plan used to continue from the current PC.
Definition: Thread.cpp:1366
virtual lldb::ThreadPlanSP QueueThreadPlanForStepThrough(StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads, Status &status)
Gets the plan used to step through the code that steps from a function call site at the current PC in...
Definition: Thread.cpp:1353
lldb::StackFrameSP GetSelectedFrame(SelectMostRelevant select_most_relevant)
Definition: Thread.cpp:271
virtual bool IsStillAtLastBreakpointHit()
Definition: Thread.cpp:1914
std::recursive_mutex m_state_mutex
Multithreaded protection for m_state.
Definition: Thread.h:1323
ThreadPlan * GetPreviousPlan(ThreadPlan *plan) const
Definition: Thread.cpp:1163
virtual const char * GetName()
Definition: Thread.h:283
void PushPlan(lldb::ThreadPlanSP plan_sp)
Definition: Thread.cpp:1086
lldb::StackFrameListSP m_prev_frames_sp
The previous stack frames from the last time this thread stopped.
Definition: Thread.h:1328
virtual void ClearStackFrames()
Definition: Thread.cpp:1433
ThreadPlan * GetCurrentPlan() const
Gets the plan which will execute next on the plan stack.
Definition: Thread.cpp:1135
virtual Unwind & GetUnwinder()
Definition: Thread.cpp:1903
static llvm::StringRef GetStaticBroadcasterClass()
Definition: Thread.cpp:214
void SetResumeSignal(int signal)
Definition: Thread.h:161
lldb::ValueObjectSP GetReturnValueObject() const
Gets the outer-most return value from the completed plans.
Definition: Thread.cpp:1143
virtual lldb::ThreadSP GetBackingThread() const
Definition: Thread.h:474
lldb::ExpressionVariableSP GetExpressionVariable() const
Gets the outer-most expression variable from the completed plans.
Definition: Thread.cpp:1147
Vote ShouldReportRun(Event *event_ptr)
Definition: Thread.cpp:1035
lldb::TargetSP CalculateTarget() override
Definition: Thread.cpp:1401
static std::string StopReasonAsString(lldb::StopReason reason)
Definition: Thread.cpp:1697
virtual void WillResume(lldb::StateType resume_state)
Definition: Thread.h:213
Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id=false)
Constructor.
Definition: Thread.cpp:219
bool ThreadStoppedForAReason()
Definition: Thread.cpp:504
size_t GetStackFrameStatus(Stream &strm, uint32_t first_frame, uint32_t num_frames, bool show_frame_info, uint32_t num_frames_with_source, bool show_hidden)
Definition: Thread.cpp:1894
std::string GetStopDescriptionRaw()
Definition: Thread.cpp:596
bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index)
Discards the plans queued on the plan stack of the current thread up to and including the plan in tha...
Definition: Thread.cpp:1197
virtual Status StepOver(bool source_step, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Default implementation for stepping over.
Definition: Thread.cpp:1971
bool ShouldResume(lldb::StateType resume_state)
Definition: Thread.cpp:665
std::unique_ptr< lldb_private::Unwind > m_unwinder_up
It gets set in Thread::ShouldResume.
Definition: Thread.h:1343
std::unique_ptr< ThreadPlanStack > m_null_plan_stack_up
Definition: Thread.h:1347
lldb::StateType GetTemporaryResumeState() const
Definition: Thread.h:1198
virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state)
Definition: Thread.cpp:506
void SetState(lldb::StateType state)
Definition: Thread.cpp:571
lldb::ProcessSP GetProcess() const
Definition: Thread.h:157
lldb::StackFrameSP CalculateStackFrame() override
Definition: Thread.cpp:1413
lldb::StateType GetResumeState() const
Gets the USER resume state for this thread.
Definition: Thread.h:201
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
Definition: Thread.cpp:279
lldb::StopInfoSP m_stop_info_sp
The private stop reason for this thread.
Definition: Thread.h:1306
lldb::ProcessWP m_process_wp
The process that owns this thread.
Definition: Thread.h:1305
void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format)
Definition: Thread.cpp:1640
LazyBool m_override_should_notify
Definition: Thread.h:1346
lldb::ThreadSP CalculateThread() override
Definition: Thread.cpp:1411
Status ReturnFromFrameWithIndex(uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition: Thread.cpp:1457
virtual Status StepOut(uint32_t frame_idx=0)
Default implementation for stepping out.
Definition: Thread.cpp:2004
virtual llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > GetSiginfo(size_t max_size) const
Definition: Thread.h:1300
virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, const char *step_in_target, lldb::RunMode stop_other_threads, Status &status, LazyBool step_in_avoids_code_without_debug_info=eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queues the plan used to step through an address range, stepping into functions.
Definition: Thread.cpp:1291
lldb::StateType GetState() const
Definition: Thread.cpp:565
lldb::StateType m_state
The state of our process.
Definition: Thread.h:1321
virtual lldb::ThreadPlanSP QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, StructuredData::ObjectSP extra_args_sp, bool stop_other_threads, Status &status)
Definition: Thread.cpp:1387
bool m_extended_info_fetched
Definition: Thread.h:1350
void CalculatePublicStopInfo()
Definition: Thread.cpp:380
static void SettingsTerminate()
Definition: Thread.cpp:1657
bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast=false)
Definition: Thread.cpp:288
lldb::StopReason GetStopReason()
Definition: Thread.cpp:441
ThreadPlanStack & GetPlans() const
Definition: Thread.cpp:1070
lldb::ValueObjectSP GetSiginfoValue()
Definition: Thread.cpp:2059
virtual lldb::ThreadPlanSP QueueThreadPlanForStepSingleInstruction(bool step_over, bool abort_other_plans, bool stop_other_threads, Status &status)
Queues the plan used to step one instruction from the current PC of thread.
Definition: Thread.cpp:1255
uint32_t m_stop_info_override_stop_id
Definition: Thread.h:1311
int m_resume_signal
The signal that should be used when continuing this thread.
Definition: Thread.h:1333
virtual void DidResume()
Definition: Thread.cpp:727
bool StopInfoIsUpToDate() const
Definition: Thread.cpp:448
lldb::StackFrameSP GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr)
Definition: Thread.cpp:1693
lldb::ThreadPlanSP GetCompletedPlan() const
Gets the outer-most plan that was popped off the plan stack in the most recent stop.
Definition: Thread.cpp:1139
lldb::ValueObjectSP GetCurrentException()
Definition: Thread.cpp:2028
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOutNoShouldStop(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, Status &status, bool continue_to_next_branch=false)
Queue the plan used to step out of the function at the current PC of a thread.
Definition: Thread.cpp:1334
virtual lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx)
Definition: Thread.cpp:1453
bool ShouldStop(Event *event_ptr)
Definition: Thread.cpp:735
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
Definition: Thread.cpp:1562
bool DumpUsingFormat(Stream &strm, uint32_t frame_idx, const FormatEntity::Entry *format)
Print a description of this thread using the provided thread format.
Definition: Thread.cpp:1619
void DiscardThreadPlansUpToPlan(lldb::ThreadPlanSP &up_to_plan_sp)
Discards the plans queued on the plan stack of the current thread up to and including up_to_plan_sp.
Definition: Thread.cpp:1209
void FrameSelectedCallback(lldb_private::StackFrame *frame)
Definition: Thread.cpp:333
lldb::ThreadPlanSP QueueBasePlan(bool abort_other_plans)
Queues the base plan for a thread.
Definition: Thread.cpp:1249
static ThreadProperties & GetGlobalProperties()
Definition: Thread.cpp:61
uint32_t GetCurrentInlinedDepth()
Definition: Thread.h:419
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queues the plan used to step through an address range, stepping over function calls.
Definition: Thread.cpp:1264
std::string GetStopDescription()
Definition: Thread.cpp:576
StructuredData::ObjectSP m_extended_info
Definition: Thread.h:1352
lldb::StopInfoSP GetStopInfo()
Definition: Thread.cpp:347
lldb::StateType m_temporary_resume_state
This state records what the thread was told to do by the thread plan logic for the current resume.
Definition: Thread.h:1338
lldb::StackFrameListSP GetStackFrameList()
Definition: Thread.cpp:1419
bool m_should_run_before_public_stop
Definition: Thread.h:1314
Vote ShouldReportStop(Event *event_ptr)
Definition: Thread.cpp:974
bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx, Stream &output_stream)
Definition: Thread.cpp:300
virtual bool CalculateStopInfo()=0
Ask the thread subclass to set its stop info.
lldb::StateType m_resume_state
This state is used to force a thread to be suspended from outside the ThreadPlan logic.
Definition: Thread.h:1335
virtual Status StepIn(bool source_step, LazyBool step_in_avoids_code_without_debug_info=eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Default implementation for stepping into.
Definition: Thread.cpp:1935
size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format, bool show_hidden, bool only_stacks=false)
Definition: Thread.cpp:1749
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
Definition: Thread.h:1319
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
#define LLDB_INVALID_SIGNAL_NUMBER
Definition: lldb-defines.h:92
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:83
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
#define UINT32_MAX
Definition: lldb-defines.h:19
#define LLDB_INVALID_FRAME_ID
Definition: lldb-defines.h:91
@ DoNoSelectMostRelevantFrame
bool Format(const Entry &entry, Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const Address *addr, ValueObject *valobj, bool function_changed, bool initial_function)
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:331
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
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
Definition: lldb-forward.h:449
std::shared_ptr< lldb_private::ABI > ABISP
Definition: lldb-forward.h:315
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:420
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
Definition: lldb-forward.h:321
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelInitial
@ eDescriptionLevelFull
@ eDescriptionLevelVerbose
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:446
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:480
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
Definition: lldb-forward.h:349
std::shared_ptr< lldb_private::Platform > PlatformSP
Definition: lldb-forward.h:386
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateStopped
Process or thread is stopped and can be examined.
@ 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.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
int32_t break_id_t
Definition: lldb-types.h:86
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:387
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
Definition: lldb-forward.h:427
uint64_t addr_t
Definition: lldb-types.h:80
StopReason
Thread stop reasons.
@ eStopReasonInstrumentation
@ eStopReasonPlanComplete
@ eStopReasonTrace
@ eStopReasonBreakpoint
@ eStopReasonExec
Program was re-exec'ed.
@ eStopReasonVForkDone
@ eStopReasonInterrupt
Thread requested interrupt.
@ eStopReasonProcessorTrace
@ eStopReasonThreadExiting
@ eStopReasonException
@ eStopReasonInvalid
@ eStopReasonWatchpoint
@ eStopReasonVFork
@ eStopReasonSignal
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:444
@ eStructuredDataTypeDictionary
@ eStructuredDataTypeInteger
@ eStructuredDataTypeArray
@ eStructuredDataTypeString
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
Definition: lldb-forward.h:392
RunMode
Thread Run Modes.
@ eOnlyDuringStepping
uint64_t tid_t
Definition: lldb-types.h:84
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:371
std::shared_ptr< lldb_private::RegisterCheckpoint > RegisterCheckpointSP
Definition: lldb-forward.h:391
std::shared_ptr< lldb_private::StackFrameList > StackFrameListSP
Definition: lldb-forward.h:422
A line table entry class.
Definition: LineEntry.h:21
AddressRange GetSameLineContiguousAddressRange(bool include_inlined_functions) const
Give the range for this LineEntry + any additional LineEntries for this same source line that are con...
Definition: LineEntry.cpp:182
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
Definition: LineEntry.h:147
const FileSpec & GetFile() const
Helper to access the file.
Definition: LineEntry.h:134
lldb::RegisterCheckpointSP register_backup_sp
Definition: Thread.h:131
A mix in class that contains a generic user ID.
Definition: UserID.h:31
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47