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