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