LLDB mainline
Thread.h
Go to the documentation of this file.
1//===-- Thread.h ------------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_TARGET_THREAD_H
10#define LLDB_TARGET_THREAD_H
11
12#include <memory>
13#include <mutex>
14#include <optional>
15#include <string>
16#include <variant>
17#include <vector>
18
27#include "lldb/Utility/Event.h"
31#include "lldb/Utility/UserID.h"
32#include "lldb/lldb-private.h"
33#include "llvm/ADT/DenseMap.h"
34#include "llvm/Support/MemoryBuffer.h"
35
36#define LLDB_THREAD_MAX_STOP_EXC_DATA 8
37
38namespace lldb_private {
39
40class ThreadPlanStack;
41
43public:
44 ThreadProperties(bool is_global);
45
47
48 /// The regular expression returned determines symbols that this
49 /// thread won't stop in during "step-in" operations.
50 ///
51 /// \return
52 /// A pointer to a regular expression to compare against symbols,
53 /// or nullptr if all symbols are allowed.
54 ///
56
58
59 bool GetTraceEnabledState() const;
60
61 bool GetStepInAvoidsNoDebug() const;
62
63 bool GetStepOutAvoidsNoDebug() const;
64
65 uint64_t GetMaxBacktraceDepth() const;
66
67 uint64_t GetSingleThreadPlanTimeout() const;
68};
69
70/// A value a function returned.
74
75/// An error a function threw instead of returning.
79
80/// What a completed thread plan computed for the function it stepped out of or
81/// called: nothing, the value it returned, or the error it threw.
83 std::variant<std::monostate, ReturnedValue, ThrownError>;
84
85class Thread : public std::enable_shared_from_this<Thread>,
86 public ThreadProperties,
87 public UserID,
89 public Broadcaster {
90public:
91 /// Broadcaster event bits definitions.
92 enum {
98 };
99
100 static llvm::StringRef GetStaticBroadcasterClass();
101
102 llvm::StringRef GetBroadcasterClass() const override {
104 }
105
106 class ThreadEventData : public EventData {
107 public:
108 ThreadEventData(const lldb::ThreadSP thread_sp);
109
110 ThreadEventData(const lldb::ThreadSP thread_sp, const StackID &stack_id);
111
113
115
116 static llvm::StringRef GetFlavorString();
117
118 llvm::StringRef GetFlavor() const override {
120 }
121
122 void Dump(Stream *s) const override;
123
124 static const ThreadEventData *GetEventDataFromEvent(const Event *event_ptr);
125
126 static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr);
127
128 static StackID GetStackIDFromEvent(const Event *event_ptr);
129
130 static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr);
131
133
134 StackID GetStackID() const { return m_stack_id; }
135
136 private:
139
141 const ThreadEventData &operator=(const ThreadEventData &) = delete;
142 };
143
145 uint32_t orig_stop_id; // Dunno if I need this yet but it is an interesting
146 // bit of data.
147 lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you
148 // might continue with the wrong signals.
151 register_backup_sp; // You need to restore the registers, of course...
155 };
156
157 /// Constructor
158 ///
159 /// \param [in] use_invalid_index_id
160 /// Optional parameter, defaults to false. The only subclass that
161 /// is likely to set use_invalid_index_id == true is the HistoryThread
162 /// class. In that case, the Thread we are constructing represents
163 /// a thread from earlier in the program execution. We may have the
164 /// tid of the original thread that they represent but we don't want
165 /// to reuse the IndexID of that thread, or create a new one. If a
166 /// client wants to know the original thread's IndexID, they should use
167 /// Thread::GetExtendedBacktraceOriginatingIndexID().
168 Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id = false);
169
170 ~Thread() override;
171
172 static void SettingsInitialize();
173
174 static void SettingsTerminate();
175
177
178 lldb::ProcessSP GetProcess() const { return m_process_wp.lock(); }
179
180 int GetResumeSignal() const { return m_resume_signal; }
181
182 void SetResumeSignal(int signal) { m_resume_signal = signal; }
183
185
186 void SetState(lldb::StateType state);
187
188 /// Sets the USER resume state for this thread. If you set a thread to
189 /// suspended with
190 /// this API, it won't take part in any of the arbitration for ShouldResume,
191 /// and will stay
192 /// suspended even when other threads do get to run.
193 ///
194 /// N.B. This is not the state that is used internally by thread plans to
195 /// implement
196 /// staying on one thread while stepping over a breakpoint, etc. The is the
197 /// TemporaryResume state, and if you are implementing some bit of strategy in
198 /// the stepping
199 /// machinery you should be using that state and not the user resume state.
200 ///
201 /// If you are just preparing all threads to run, you should not override the
202 /// threads that are
203 /// marked as suspended by the debugger. In that case, pass override_suspend
204 /// = false. If you want
205 /// to force the thread to run (e.g. the "thread continue" command, or are
206 /// resetting the state
207 /// (e.g. in SBThread::Resume()), then pass true to override_suspend.
208 void SetResumeState(lldb::StateType state, bool override_suspend = false) {
209 if (m_resume_state == lldb::eStateSuspended && !override_suspend)
210 return;
211 m_resume_state = state;
212 }
213
214 /// Gets the USER resume state for this thread. This is not the same as what
215 /// this thread is going to do for any particular step, however if this thread
216 /// returns eStateSuspended, then the process control logic will never allow
217 /// this
218 /// thread to run.
219 ///
220 /// \return
221 /// The User resume state for this thread.
223
224 // This function is called to determine whether the thread needs to
225 // step over a breakpoint and if so, push a step-over-breakpoint thread
226 // plan.
227 ///
228 /// \return
229 /// True if we pushed a ThreadPlanStepOverBreakpoint
231
232 // Do not override this function, it is for thread plan logic only
233 bool ShouldResume(lldb::StateType resume_state);
234
235 // Override this to do platform specific tasks before resume.
236 virtual void WillResume(lldb::StateType resume_state) {}
237
238 // This clears generic thread state after a resume. If you subclass this, be
239 // sure to call it.
240 virtual void DidResume();
241
242 // This notifies the thread when a private stop occurs.
243 virtual void DidStop();
244
245 virtual void RefreshStateAfterStop() = 0;
246
247 std::string GetStopDescription();
248
249 std::string GetStopDescriptionRaw();
250
251 void WillStop();
252
253 bool ShouldStop(Event *event_ptr);
254
255 Vote ShouldReportStop(Event *event_ptr);
256
257 Vote ShouldReportRun(Event *event_ptr);
258
259 void Flush();
260
261 // Return whether this thread matches the specification in ThreadSpec. This
262 // is a virtual method because at some point we may extend the thread spec
263 // with a platform specific dictionary of attributes, which then only the
264 // platform specific Thread implementation would know how to match. For now,
265 // this just calls through to the ThreadSpec's ThreadPassesBasicTests method.
266 virtual bool MatchesSpec(const ThreadSpec *spec);
267
268 // Get the current public stop info, calculating it if necessary.
270
272
273 bool StopInfoIsUpToDate() const;
274
275 // This sets the stop reason to a "blank" stop reason, so you can call
276 // functions on the thread without having the called function run with
277 // whatever stop reason you stopped with.
279
281
282 static std::string RunModeAsString(lldb::RunMode mode);
283
284 static std::string StopReasonAsString(lldb::StopReason reason);
285
286 virtual const char *GetInfo() { return nullptr; }
287
288 /// Retrieve a dictionary of information about this thread
289 ///
290 /// On Mac OS X systems there may be voucher information.
291 /// The top level dictionary returned will have an "activity" key and the
292 /// value of the activity is a dictionary. Keys in that dictionary will
293 /// be "name" and "id", among others.
294 /// There may also be "trace_messages" (an array) with each entry in that
295 /// array
296 /// being a dictionary (keys include "message" with the text of the trace
297 /// message).
305
306 virtual const char *GetName() { return nullptr; }
307
308 virtual void SetName(const char *name) {}
309
310 /// Whether this thread can be associated with a libdispatch queue
311 ///
312 /// The Thread may know if it is associated with a libdispatch queue,
313 /// it may know definitively that it is NOT associated with a libdispatch
314 /// queue, or it may be unknown whether it is associated with a libdispatch
315 /// queue.
316 ///
317 /// \return
318 /// eLazyBoolNo if this thread is definitely not associated with a
319 /// libdispatch queue (e.g. on a non-Darwin system where GCD aka
320 /// libdispatch is not available).
321 ///
322 /// eLazyBoolYes this thread is associated with a libdispatch queue.
323 ///
324 /// eLazyBoolCalculate this thread may be associated with a libdispatch
325 /// queue but the thread doesn't know one way or the other.
329
331 lldb_private::LazyBool associated_with_libdispatch_queue) {}
332
333 /// Retrieve the Queue ID for the queue currently using this Thread
334 ///
335 /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
336 /// retrieve the QueueID.
337 ///
338 /// This is a unique identifier for the libdispatch/GCD queue in a
339 /// process. Often starting at 1 for the initial system-created
340 /// queues and incrementing, a QueueID will not be reused for a
341 /// different queue during the lifetime of a process.
342 ///
343 /// \return
344 /// A QueueID if the Thread subclass implements this, else
345 /// LLDB_INVALID_QUEUE_ID.
347
348 virtual void SetQueueID(lldb::queue_id_t new_val) {}
349
350 /// Retrieve the Queue name for the queue currently using this Thread
351 ///
352 /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
353 /// retrieve the Queue name.
354 ///
355 /// \return
356 /// The Queue name, if the Thread subclass implements this, else
357 /// nullptr.
358 virtual const char *GetQueueName() { return nullptr; }
359
360 virtual void SetQueueName(const char *name) {}
361
362 /// Retrieve the Queue kind for the queue currently using this Thread
363 ///
364 /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
365 /// retrieve the Queue kind - either eQueueKindSerial or
366 /// eQueueKindConcurrent, indicating that this queue processes work
367 /// items serially or concurrently.
368 ///
369 /// \return
370 /// The Queue kind, if the Thread subclass implements this, else
371 /// eQueueKindUnknown.
373
374 virtual void SetQueueKind(lldb::QueueKind kind) {}
375
376 /// Retrieve the Queue for this thread, if any.
377 ///
378 /// \return
379 /// A QueueSP for the queue that is currently associated with this
380 /// thread.
381 /// An empty shared pointer indicates that this thread is not
382 /// associated with a queue, or libdispatch queues are not
383 /// supported on this target.
384 virtual lldb::QueueSP GetQueue() { return lldb::QueueSP(); }
385
386 /// Retrieve the address of the libdispatch_queue_t struct for queue
387 /// currently using this Thread
388 ///
389 /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
390 /// retrieve the address of the libdispatch_queue_t structure describing
391 /// the queue.
392 ///
393 /// This address may be reused for different queues later in the Process
394 /// lifetime and should not be used to identify a queue uniquely. Use
395 /// the GetQueueID() call for that.
396 ///
397 /// \return
398 /// The Queue's libdispatch_queue_t address if the Thread subclass
399 /// implements this, else LLDB_INVALID_ADDRESS.
403
404 virtual void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) {}
405
406 /// When a thread stops at an enabled BreakpointSite that has not executed,
407 /// the Process plugin should call SetThreadStoppedAtUnexecutedBP(pc).
408 /// If that BreakpointSite was actually triggered (the instruction was
409 /// executed, for a software breakpoint), regardless of whether the
410 /// breakpoint is valid for this thread, SetThreadHitBreakpointSite()
411 /// should be called to record that fact.
412 ///
413 /// Depending on the structure of the Process plugin, it may be easiest
414 /// to call SetThreadStoppedAtUnexecutedBP(pc) unconditionally when at
415 /// a BreakpointSite, and later when it is known that it was triggered,
416 /// SetThreadHitBreakpointSite() can be called. These two methods
417 /// overwrite the same piece of state in the Thread, the last one
418 /// called on a Thread wins.
425
426 /// Whether this Thread already has all the Queue information cached or not
427 ///
428 /// A Thread may be associated with a libdispatch work Queue at a given
429 /// public stop event. If so, the thread can satisify requests like
430 /// GetQueueLibdispatchQueueAddress, GetQueueKind, GetQueueName, and
431 /// GetQueueID
432 /// either from information from the remote debug stub when it is initially
433 /// created, or it can query the SystemRuntime for that information.
434 ///
435 /// This method allows the SystemRuntime to discover if a thread has this
436 /// information already, instead of calling the thread to get the information
437 /// and having the thread call the SystemRuntime again.
438 virtual bool ThreadHasQueueInformation() const { return false; }
439
440 /// GetStackFrameCount can be expensive. Stacks can get very deep, and they
441 /// require memory reads for each frame. So only use GetStackFrameCount when
442 /// you need to know the depth of the stack. When iterating over frames, its
443 /// better to generate the frames one by one with GetFrameAtIndex, and when
444 /// that returns NULL, you are at the end of the stack. That way your loop
445 /// will only do the work it needs to, without forcing lldb to realize
446 /// StackFrames you weren't going to look at.
447 virtual uint32_t GetStackFrameCount() {
448 return GetStackFrameList()->GetNumFrames();
449 }
450
452 return GetStackFrameList()->GetFrameAtIndex(idx);
453 }
454
455 virtual lldb::StackFrameSP
456 GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
457
459 return GetStackFrameList()->DecrementCurrentInlinedDepth();
460 }
461
463 return GetStackFrameList()->GetCurrentInlinedDepth();
464 }
465
466 Status ReturnFromFrameWithIndex(uint32_t frame_idx,
467 lldb::ValueObjectSP return_value_sp,
468 bool broadcast = false);
469
471 lldb::ValueObjectSP return_value_sp,
472 bool broadcast = false);
473
474 Status JumpToLine(const FileSpec &file, uint32_t line,
475 bool can_leave_function, std::string *warnings = nullptr);
476
478 if (stack_id.IsValid())
479 return GetStackFrameList()->GetFrameWithStackID(stack_id);
480 return lldb::StackFrameSP();
481 }
482
483 // Only pass true to select_most_relevant if you are fulfilling an explicit
484 // user request for GetSelectedFrameIndex. The most relevant frame is only
485 // for showing to the user, and can do arbitrary work, so we don't want to
486 // call it internally.
487 uint32_t GetSelectedFrameIndex(SelectMostRelevant select_most_relevant) {
488 return GetStackFrameList()->GetSelectedFrameIndex(select_most_relevant);
489 }
490
492 GetSelectedFrame(SelectMostRelevant select_most_relevant);
493
495 bool broadcast = false);
496
497 bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast = false);
498
499 bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
500 Stream &output_stream);
501
502 /// Resets the selected frame index of this object.
504 return GetStackFrameList()->ClearSelectedFrameIndex();
505 }
506
508 GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
509 }
510
512
515
516 virtual void ClearStackFrames();
517
518 /// Sets the thread that is backed by this thread.
519 /// If backed_thread.GetBackedThread() is null, this method also calls
520 /// backed_thread.SetBackingThread(this).
521 /// If backed_thread.GetBackedThread() is non-null, asserts that it is equal
522 /// to `this`.
523 void SetBackedThread(Thread &backed_thread) {
524 m_backed_thread = backed_thread.shared_from_this();
525
526 // Ensure the bidrectional relationship is preserved.
527 Thread *backing_thread = backed_thread.GetBackingThread().get();
528 assert(backing_thread == nullptr || backing_thread == this);
529 if (backing_thread == nullptr)
530 backed_thread.SetBackingThread(shared_from_this());
531 }
532
534
535 /// Returns the thread that is backed by this thread, if any.
537
538 virtual bool SetBackingThread(const lldb::ThreadSP &thread_sp) {
539 return false;
540 }
541
542 virtual lldb::ThreadSP GetBackingThread() const { return lldb::ThreadSP(); }
543
544 virtual void ClearBackingThread() {
545 // Subclasses can use this function if a thread is actually backed by
546 // another thread. This is currently used for the OperatingSystem plug-ins
547 // where they might have a thread that is in memory, yet its registers are
548 // available through the lldb_private::Thread subclass for the current
549 // lldb_private::Process class. Since each time the process stops the
550 // backing threads for memory threads can change, we need a way to clear
551 // the backing thread for all memory threads each time we stop.
552 }
553
554 /// Dump \a count instructions of the thread's \a Trace starting at the \a
555 /// start_position position in reverse order.
556 ///
557 /// The instructions are indexed in reverse order, which means that the \a
558 /// start_position 0 represents the last instruction of the trace
559 /// chronologically.
560 ///
561 /// \param[in] s
562 /// The stream object where the instructions are printed.
563 ///
564 /// \param[in] count
565 /// The number of instructions to print.
566 ///
567 /// \param[in] start_position
568 /// The position of the first instruction to print.
569 void DumpTraceInstructions(Stream &s, size_t count,
570 size_t start_position = 0) const;
571
572 /// Print a description of this thread using the provided thread format.
573 ///
574 /// \param[out] strm
575 /// The Stream to print the description to.
576 ///
577 /// \param[in] frame_idx
578 /// If not \b LLDB_INVALID_FRAME_ID, then use this frame index as context to
579 /// generate the description.
580 ///
581 /// \param[in] format
582 /// The input format.
583 ///
584 /// \return
585 /// \b true if and only if dumping with the given \p format worked.
586 bool DumpUsingFormat(Stream &strm, uint32_t frame_idx,
587 const FormatEntity::Entry *format);
588
589 // If stop_format is true, this will be the form used when we print stop
590 // info. If false, it will be the form we use for thread list and co.
591 void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx,
592 bool stop_format);
593
595 bool print_json_thread, bool print_json_stopinfo);
596
597 /// Default implementation for stepping into.
598 ///
599 /// This function is designed to be used by commands where the
600 /// process is publicly stopped.
601 ///
602 /// \param[in] source_step
603 /// If true and the frame has debug info, then do a source level
604 /// step in, else do a single instruction step in.
605 ///
606 /// \param[in] step_in_avoids_code_without_debug_info
607 /// If \a true, then avoid stepping into code that doesn't have
608 /// debug info, else step into any code regardless of whether it
609 /// has debug info.
610 ///
611 /// \param[in] step_out_avoids_code_without_debug_info
612 /// If \a true, then if you step out to code with no debug info, keep
613 /// stepping out till you get to code with debug info.
614 ///
615 /// \return
616 /// An error that describes anything that went wrong
617 virtual Status
618 StepIn(bool source_step,
619 LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
620 LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
621
622 /// Default implementation for stepping over.
623 ///
624 /// This function is designed to be used by commands where the
625 /// process is publicly stopped.
626 ///
627 /// \param[in] source_step
628 /// If true and the frame has debug info, then do a source level
629 /// step over, else do a single instruction step over.
630 ///
631 /// \return
632 /// An error that describes anything that went wrong
633 virtual Status StepOver(
634 bool source_step,
635 LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
636
637 /// Default implementation for stepping out.
638 ///
639 /// This function is designed to be used by commands where the
640 /// process is publicly stopped.
641 ///
642 /// \param[in] frame_idx
643 /// The frame index to step out of.
644 ///
645 /// \return
646 /// An error that describes anything that went wrong
647 virtual Status StepOut(uint32_t frame_idx = 0);
648
649 /// Retrieves the per-thread data area.
650 /// Most OSs maintain a per-thread pointer (e.g. the FS register on
651 /// x64), which we return the value of here.
652 ///
653 /// \return
654 /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread
655 /// pointer value.
657
658 /// Retrieves the per-module TLS block for a thread.
659 ///
660 /// \param[in] module
661 /// The module to query TLS data for.
662 ///
663 /// \param[in] tls_file_addr
664 /// The thread local address in module
665 /// \return
666 /// If the thread has TLS data allocated for the
667 /// module, the address of the TLS block. Otherwise
668 /// LLDB_INVALID_ADDRESS is returned.
670 lldb::addr_t tls_file_addr);
671
672 /// Check whether this thread is safe to run functions
673 ///
674 /// The SystemRuntime may know of certain thread states (functions in
675 /// process of execution, for instance) which can make it unsafe for
676 /// functions to be called.
677 ///
678 /// \return
679 /// True if it is safe to call functions on this thread.
680 /// False if function calls should be avoided on this thread.
681 virtual bool SafeToCallFunctions();
682
683 // Thread Plan Providers:
684 // This section provides the basic thread plans that the Process control
685 // machinery uses to run the target. ThreadPlan.h provides more details on
686 // how this mechanism works. The thread provides accessors to a set of plans
687 // that perform basic operations. The idea is that particular Platform
688 // plugins can override these methods to provide the implementation of these
689 // basic operations appropriate to their environment.
690 //
691 // NB: All the QueueThreadPlanXXX providers return Shared Pointers to
692 // Thread plans. This is useful so that you can modify the plans after
693 // creation in ways specific to that plan type. Also, it is often necessary
694 // for ThreadPlans that utilize other ThreadPlans to implement their task to
695 // keep a shared pointer to the sub-plan. But besides that, the shared
696 // pointers should only be held onto by entities who live no longer than the
697 // thread containing the ThreadPlan.
698 // FIXME: If this becomes a problem, we can make a version that just returns a
699 // pointer,
700 // which it is clearly unsafe to hold onto, and a shared pointer version, and
701 // only allow ThreadPlan and Co. to use the latter. That is made more
702 // annoying to do because there's no elegant way to friend a method to all
703 // sub-classes of a given class.
704 //
705
706 /// Queues the base plan for a thread.
707 /// The version returned by Process does some things that are useful,
708 /// like handle breakpoints and signals, so if you return a plugin specific
709 /// one you probably want to call through to the Process one for anything
710 /// your plugin doesn't explicitly handle.
711 ///
712 /// \param[in] abort_other_plans
713 /// \b true if we discard the currently queued plans and replace them with
714 /// this one.
715 /// Otherwise this plan will go on the end of the plan stack.
716 ///
717 /// \return
718 /// A shared pointer to the newly queued thread plan, or nullptr if the
719 /// plan could not be queued.
720 lldb::ThreadPlanSP QueueBasePlan(bool abort_other_plans);
721
722 /// Queues the plan used to step one instruction from the current PC of \a
723 /// thread.
724 ///
725 /// \param[in] step_over
726 /// \b true if we step over calls to functions, false if we step in.
727 ///
728 /// \param[in] abort_other_plans
729 /// \b true if we discard the currently queued plans and replace them with
730 /// this one.
731 /// Otherwise this plan will go on the end of the plan stack.
732 ///
733 /// \param[in] stop_other_threads
734 /// \b true if we will stop other threads while we single step this one.
735 ///
736 /// \param[out] status
737 /// A status with an error if queuing failed.
738 ///
739 /// \return
740 /// A shared pointer to the newly queued thread plan, or nullptr if the
741 /// plan could not be queued.
743 bool step_over, bool abort_other_plans, bool stop_other_threads,
744 Status &status);
745
746 /// Queues the plan used to step through an address range, stepping over
747 /// function calls.
748 ///
749 /// \param[in] abort_other_plans
750 /// \b true if we discard the currently queued plans and replace them with
751 /// this one.
752 /// Otherwise this plan will go on the end of the plan stack.
753 ///
754 /// \param[in] type
755 /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported
756 /// by this plan.
757 ///
758 /// \param[in] range
759 /// The address range to step through.
760 ///
761 /// \param[in] addr_context
762 /// When dealing with stepping through inlined functions the current PC is
763 /// not enough information to know
764 /// what "step" means. For instance a series of nested inline functions
765 /// might start at the same address.
766 // The \a addr_context provides the current symbol context the step
767 /// is supposed to be out of.
768 // FIXME: Currently unused.
769 ///
770 /// \param[in] stop_other_threads
771 /// \b true if we will stop other threads while we single step this one.
772 ///
773 /// \param[out] status
774 /// A status with an error if queuing failed.
775 ///
776 /// \param[in] step_out_avoids_code_without_debug_info
777 /// If eLazyBoolYes, if the step over steps out it will continue to step
778 /// out till it comes to a frame with debug info.
779 /// If eLazyBoolCalculate, we will consult the default set in the thread.
780 ///
781 /// \return
782 /// A shared pointer to the newly queued thread plan, or nullptr if the
783 /// plan could not be queued.
785 bool abort_other_plans, const AddressRange &range,
786 const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
787 Status &status,
788 LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
789
790 // Helper function that takes a LineEntry to step, insted of an AddressRange.
791 // This may combine multiple LineEntries of the same source line number to
792 // step over a longer address range in a single operation.
794 bool abort_other_plans, const LineEntry &line_entry,
795 const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
796 Status &status,
797 LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
798
799 /// Queues the plan used to step through an address range, stepping into
800 /// functions.
801 ///
802 /// \param[in] abort_other_plans
803 /// \b true if we discard the currently queued plans and replace them with
804 /// this one.
805 /// Otherwise this plan will go on the end of the plan stack.
806 ///
807 /// \param[in] type
808 /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported
809 /// by this plan.
810 ///
811 /// \param[in] range
812 /// The address range to step through.
813 ///
814 /// \param[in] addr_context
815 /// When dealing with stepping through inlined functions the current PC is
816 /// not enough information to know
817 /// what "step" means. For instance a series of nested inline functions
818 /// might start at the same address.
819 // The \a addr_context provides the current symbol context the step
820 /// is supposed to be out of.
821 // FIXME: Currently unused.
822 ///
823 /// \param[in] step_in_target
824 /// Name if function we are trying to step into. We will step out if we
825 /// don't land in that function.
826 ///
827 /// \param[in] stop_other_threads
828 /// \b true if we will stop other threads while we single step this one.
829 ///
830 /// \param[out] status
831 /// A status with an error if queuing failed.
832 ///
833 /// \param[in] step_in_avoids_code_without_debug_info
834 /// If eLazyBoolYes we will step out if we step into code with no debug
835 /// info.
836 /// If eLazyBoolCalculate we will consult the default set in the thread.
837 ///
838 /// \param[in] step_out_avoids_code_without_debug_info
839 /// If eLazyBoolYes, if the step over steps out it will continue to step
840 /// out till it comes to a frame with debug info.
841 /// If eLazyBoolCalculate, it will consult the default set in the thread.
842 ///
843 /// \return
844 /// A shared pointer to the newly queued thread plan, or nullptr if the
845 /// plan could not be queued.
847 bool abort_other_plans, const AddressRange &range,
848 const SymbolContext &addr_context, llvm::StringRef step_in_target,
849 lldb::RunMode stop_other_threads, Status &status,
850 LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
851 LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
852
853 // Helper function that takes a LineEntry to step, insted of an AddressRange.
854 // This may combine multiple LineEntries of the same source line number to
855 // step over a longer address range in a single operation.
857 bool abort_other_plans, const LineEntry &line_entry,
858 const SymbolContext &addr_context, llvm::StringRef step_in_target,
859 lldb::RunMode stop_other_threads, Status &status,
860 LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
861 LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
862
863 /// Queue the plan used to step out of the function at the current PC of
864 /// \a thread.
865 ///
866 /// \param[in] abort_other_plans
867 /// \b true if we discard the currently queued plans and replace them with
868 /// this one.
869 /// Otherwise this plan will go on the end of the plan stack.
870 ///
871 /// \param[in] addr_context
872 /// When dealing with stepping through inlined functions the current PC is
873 /// not enough information to know
874 /// what "step" means. For instance a series of nested inline functions
875 /// might start at the same address.
876 // The \a addr_context provides the current symbol context the step
877 /// is supposed to be out of.
878 // FIXME: Currently unused.
879 ///
880 /// \param[in] first_insn
881 /// \b true if this is the first instruction of a function.
882 ///
883 /// \param[in] stop_other_threads
884 /// \b true if we will stop other threads while we single step this one.
885 ///
886 /// \param[in] report_stop_vote
887 /// See standard meanings for the stop & run votes in ThreadPlan.h.
888 ///
889 /// \param[in] report_run_vote
890 /// See standard meanings for the stop & run votes in ThreadPlan.h.
891 ///
892 /// \param[out] status
893 /// A status with an error if queuing failed.
894 ///
895 /// \param[in] step_out_avoids_code_without_debug_info
896 /// If eLazyBoolYes, if the step over steps out it will continue to step
897 /// out till it comes to a frame with debug info.
898 /// If eLazyBoolCalculate, it will consult the default set in the thread.
899 ///
900 /// \return
901 /// A shared pointer to the newly queued thread plan, or nullptr if the
902 /// plan could not be queued.
904 bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
905 bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote,
906 uint32_t frame_idx, Status &status,
907 LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
908
909 /// Queue the plan used to step out of the function at the current PC of
910 /// a thread. This version does not consult the should stop here callback,
911 /// and should only
912 /// be used by other thread plans when they need to retain control of the step
913 /// out.
914 ///
915 /// \param[in] abort_other_plans
916 /// \b true if we discard the currently queued plans and replace them with
917 /// this one.
918 /// Otherwise this plan will go on the end of the plan stack.
919 ///
920 /// \param[in] addr_context
921 /// When dealing with stepping through inlined functions the current PC is
922 /// not enough information to know
923 /// what "step" means. For instance a series of nested inline functions
924 /// might start at the same address.
925 // The \a addr_context provides the current symbol context the step
926 /// is supposed to be out of.
927 // FIXME: Currently unused.
928 ///
929 /// \param[in] first_insn
930 /// \b true if this is the first instruction of a function.
931 ///
932 /// \param[in] stop_other_threads
933 /// \b true if we will stop other threads while we single step this one.
934 ///
935 /// \param[in] report_stop_vote
936 /// See standard meanings for the stop & run votes in ThreadPlan.h.
937 ///
938 /// \param[in] report_run_vote
939 /// See standard meanings for the stop & run votes in ThreadPlan.h.
940 ///
941 /// \param[in] frame_idx
942 /// The frame index.
943 ///
944 /// \param[out] status
945 /// A status with an error if queuing failed.
946 ///
947 /// \param[in] continue_to_next_branch
948 /// Normally this will enqueue a plan that will put a breakpoint on the
949 /// return address and continue
950 /// to there. If continue_to_next_branch is true, this is an operation not
951 /// involving the user --
952 /// e.g. stepping "next" in a source line and we instruction stepped into
953 /// another function --
954 /// so instead of putting a breakpoint on the return address, advance the
955 /// breakpoint to the
956 /// end of the source line that is doing the call, or until the next flow
957 /// control instruction.
958 /// If the return value from the function call is to be retrieved /
959 /// displayed to the user, you must stop
960 /// on the return address. The return value may be stored in volatile
961 /// registers which are overwritten
962 /// before the next branch instruction.
963 ///
964 /// \return
965 /// A shared pointer to the newly queued thread plan, or nullptr if the
966 /// plan could not be queued.
968 bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
969 bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote,
970 uint32_t frame_idx, Status &status, bool continue_to_next_branch = false);
971
972 /// Gets the plan used to step through the code that steps from a function
973 /// call site at the current PC into the actual function call.
974 ///
975 /// \param[in] return_stack_id
976 /// The stack id that we will return to (by setting backstop breakpoints on
977 /// the return
978 /// address to that frame) if we fail to step through.
979 ///
980 /// \param[in] abort_other_plans
981 /// \b true if we discard the currently queued plans and replace them with
982 /// this one.
983 /// Otherwise this plan will go on the end of the plan stack.
984 ///
985 /// \param[in] stop_other_threads
986 /// \b true if we will stop other threads while we single step this one.
987 ///
988 /// \param[out] status
989 /// A status with an error if queuing failed.
990 ///
991 /// \return
992 /// A shared pointer to the newly queued thread plan, or nullptr if the
993 /// plan could not be queued.
994 virtual lldb::ThreadPlanSP
995 QueueThreadPlanForStepThrough(StackID &return_stack_id,
996 bool abort_other_plans, bool stop_other_threads,
997 Status &status);
998
999 /// Gets the plan used to continue from the current PC.
1000 /// This is a simple plan, mostly useful as a backstop when you are continuing
1001 /// for some particular purpose.
1002 ///
1003 /// \param[in] abort_other_plans
1004 /// \b true if we discard the currently queued plans and replace them with
1005 /// this one.
1006 /// Otherwise this plan will go on the end of the plan stack.
1007 ///
1008 /// \param[in] target_addr
1009 /// The address to which we're running.
1010 ///
1011 /// \param[in] stop_other_threads
1012 /// \b true if we will stop other threads while we single step this one.
1013 ///
1014 /// \param[out] status
1015 /// A status with an error if queuing failed.
1016 ///
1017 /// \return
1018 /// A shared pointer to the newly queued thread plan, or nullptr if the
1019 /// plan could not be queued.
1020 virtual lldb::ThreadPlanSP
1021 QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr,
1022 bool stop_other_threads, Status &status);
1023
1025 bool abort_other_plans, llvm::ArrayRef<lldb::addr_t> address_list,
1026 bool stop_others, uint32_t frame_idx, Status &status);
1027
1028 virtual lldb::ThreadPlanSP
1029 QueueThreadPlanForStepScripted(bool abort_other_plans,
1030 const ScriptedMetadata &scripted_metadata,
1031 bool stop_other_threads, Status &status);
1032
1033 // Thread Plan accessors:
1034
1035 /// Format the thread plan information for auto completion.
1036 ///
1037 /// \param[in] request
1038 /// The reference to the completion handler.
1039 void AutoCompleteThreadPlans(CompletionRequest &request) const;
1040
1041 /// Gets the plan which will execute next on the plan stack.
1042 ///
1043 /// \return
1044 /// A pointer to the next executed plan.
1045 ThreadPlan *GetCurrentPlan() const;
1046
1047 /// Returns true if this thread has a ThreadPlanCallFunction on its
1048 /// plan stack, indicating it is running a debugger-injected expression.
1049 bool IsRunningCallFunctionPlan() const;
1050
1051 /// Unwinds the thread stack for the innermost expression plan currently
1052 /// on the thread plan stack.
1053 ///
1054 /// \return
1055 /// An error if the thread plan could not be unwound.
1056
1058
1059 /// Gets the outer-most plan that was popped off the plan stack in the
1060 /// most recent stop. Useful for printing the stop reason accurately.
1061 ///
1062 /// \return
1063 /// A pointer to the last completed plan.
1065
1066 /// Gets the outer-most return value from the completed plans
1067 ///
1068 /// \return
1069 /// The return value, which is empty if there is none, or the error the
1070 /// function threw.
1072
1073 /// Gets the outer-most expression variable from the completed plans
1074 ///
1075 /// \return
1076 /// A ExpressionVariableSP, either empty if there is no
1077 /// plan completed an expression during the current stop
1078 /// or the expression variable that was made for the completed expression.
1080
1081 /// Checks whether the given plan is in the completed plans for this
1082 /// stop.
1083 ///
1084 /// \param[in] plan
1085 /// Pointer to the plan you're checking.
1086 ///
1087 /// \return
1088 /// Returns true if the input plan is in the completed plan stack,
1089 /// false otherwise.
1090 bool IsThreadPlanDone(ThreadPlan *plan) const;
1091
1092 /// Checks whether the given plan is in the discarded plans for this
1093 /// stop.
1094 ///
1095 /// \param[in] plan
1096 /// Pointer to the plan you're checking.
1097 ///
1098 /// \return
1099 /// Returns true if the input plan is in the discarded plan stack,
1100 /// false otherwise.
1101 bool WasThreadPlanDiscarded(ThreadPlan *plan) const;
1102
1103 /// Check if we have completed plan to override breakpoint stop reason
1104 ///
1105 /// \return
1106 /// Returns true if completed plan stack is not empty
1107 /// false otherwise.
1109
1110 /// Queues a generic thread plan.
1111 ///
1112 /// \param[in] plan_sp
1113 /// The plan to queue.
1114 ///
1115 /// \param[in] abort_other_plans
1116 /// \b true if we discard the currently queued plans and replace them with
1117 /// this one.
1118 /// Otherwise this plan will go on the end of the plan stack.
1119 ///
1120 /// \return
1121 /// A pointer to the last completed plan.
1122 Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
1123
1124 /// Discards the plans queued on the plan stack of the current thread. This
1125 /// is
1126 /// arbitrated by the "Controlling" ThreadPlans, using the "OkayToDiscard"
1127 /// call.
1128 // But if \a force is true, all thread plans are discarded.
1129 void DiscardThreadPlans(bool force);
1130
1131 /// Discards the plans queued on the plan stack of the current thread up to
1132 /// and
1133 /// including up_to_plan_sp.
1134 //
1135 // \param[in] up_to_plan_sp
1136 // Discard all plans up to and including this one.
1138
1139 void DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr);
1140
1141 /// Discards the plans queued on the plan stack of the current thread up to
1142 /// and
1143 /// including the plan in that matches \a thread_index counting only
1144 /// the non-Private plans.
1145 ///
1146 /// \param[in] thread_index
1147 /// Discard all plans up to and including this user plan given by this
1148 /// index.
1149 ///
1150 /// \return
1151 /// \b true if there was a thread plan with that user index, \b false
1152 /// otherwise.
1153 bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index);
1154
1155 virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state);
1156
1157 virtual bool
1159
1161
1162 // Get the thread index ID. The index ID that is guaranteed to not be re-used
1163 // by a process. They start at 1 and increase with each new thread. This
1164 // allows easy command line access by a unique ID that is easier to type than
1165 // the actual system thread ID.
1166 uint32_t GetIndexID() const;
1167
1168 // Get the originating thread's index ID.
1169 // In the case of an "extended" thread -- a thread which represents the stack
1170 // that enqueued/spawned work that is currently executing -- we need to
1171 // provide the IndexID of the thread that actually did this work. We don't
1172 // want to just masquerade as that thread's IndexID by using it in our own
1173 // IndexID because that way leads to madness - but the driver program which
1174 // is iterating over extended threads may ask for the OriginatingThreadID to
1175 // display that information to the user.
1176 // Normal threads will return the same thing as GetIndexID();
1178 return GetIndexID();
1179 }
1180
1181 // The API ID is often the same as the Thread::GetID(), but not in all cases.
1182 // Thread::GetID() is the user visible thread ID that clients would want to
1183 // see. The API thread ID is the thread ID that is used when sending data
1184 // to/from the debugging protocol.
1185 virtual lldb::user_id_t GetProtocolID() const { return GetID(); }
1186
1187 // lldb::ExecutionContextScope pure virtual functions
1189
1191
1193
1195
1196 void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
1197
1200
1201 size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames,
1202 uint32_t num_frames_with_source, bool stop_format,
1203 bool show_hidden, bool only_stacks = false);
1204
1205 size_t GetStackFrameStatus(Stream &strm, uint32_t first_frame,
1206 uint32_t num_frames, bool show_frame_info,
1207 uint32_t num_frames_with_source, bool show_hidden);
1208
1209 /// If this thread stopped on a binary-loaded breakpoint, the
1210 /// addresses of the newly added binaries may have already been
1211 /// provided by the gdb stub in the stop-packet.
1212 virtual std::vector<lldb::addr_t> FetchNewlyAddedBinaries() { return {}; }
1213
1214 /// If this thread stopped on a binary-loaded breakpoint, the
1215 /// detailed information about the new binaries may be provided.
1216 /// If any detailed information about binaries is provided, it must
1217 /// be provided for all binaries that have been loaded at this stop.
1218 /// Detailed information is likely to only be provided when the number
1219 /// of new binaries is small.
1223
1224 // We need a way to verify that even though we have a thread in a shared
1225 // pointer that the object itself is still valid. Currently this won't be the
1226 // case if DestroyThread() was called. DestroyThread is called when a thread
1227 // has been removed from the Process' thread list.
1228 bool IsValid() const { return !m_destroy_called; }
1229
1230 // Sets and returns a valid stop info based on the process stop ID and the
1231 // current thread plan. If the thread stop ID does not match the process'
1232 // stop ID, the private stop reason is not set and an invalid StopInfoSP may
1233 // be returned.
1234 //
1235 // NOTE: This function must be called before the current thread plan is
1236 // moved to the completed plan stack (in Thread::ShouldStop()).
1237 //
1238 // NOTE: If subclasses override this function, ensure they do not overwrite
1239 // the m_actual_stop_info if it is valid. The stop info may be a
1240 // "checkpointed and restored" stop info, so if it is still around it is
1241 // right even if you have not calculated this yourself, or if it disagrees
1242 // with what you might have calculated.
1243 virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate = true);
1244
1245 // Calculate the stop info that will be shown to lldb clients. For instance,
1246 // a "step out" is implemented by running to a breakpoint on the function
1247 // return PC, so the process plugin initially sets the stop info to a
1248 // StopInfoBreakpoint. But once we've run the ShouldStop machinery, we
1249 // discover that there's a completed ThreadPlanStepOut, and that's really
1250 // the StopInfo we want to show. That will happen naturally the next
1251 // time GetStopInfo is called, but if you want to force the replacement,
1252 // you can call this.
1253
1255
1256 /// Ask the thread subclass to set its stop info.
1257 ///
1258 /// Thread subclasses should call Thread::SetStopInfo(...) with the reason the
1259 /// thread stopped.
1260 ///
1261 /// A thread that is sitting at a breakpoint site, but has not yet executed
1262 /// the breakpoint instruction, should have a breakpoint-hit StopInfo set.
1263 /// When execution is resumed, any thread sitting at a breakpoint site will
1264 /// instruction-step over the breakpoint instruction silently, and we will
1265 /// never record this breakpoint as being hit, updating the hit count,
1266 /// possibly executing breakpoint commands or conditions.
1267 ///
1268 /// \return
1269 /// True if Thread::SetStopInfo(...) was called, false otherwise.
1270 virtual bool CalculateStopInfo() = 0;
1271
1272 // Gets the temporary resume state for a thread.
1273 //
1274 // This value gets set in each thread by complex debugger logic in
1275 // Thread::ShouldResume() and an appropriate thread resume state will get set
1276 // in each thread every time the process is resumed prior to calling
1277 // Process::DoResume(). The lldb_private::Process subclass should adhere to
1278 // the thread resume state request which will be one of:
1279 //
1280 // eStateRunning - thread will resume when process is resumed
1281 // eStateStepping - thread should step 1 instruction and stop when process
1282 // is resumed
1283 // eStateSuspended - thread should not execute any instructions when
1284 // process is resumed
1288
1289 void SetStopInfo(const lldb::StopInfoSP &stop_info_sp);
1290
1291 void ResetStopInfo();
1292
1293 void SetShouldReportStop(Vote vote);
1294
1295 void SetShouldRunBeforePublicStop(bool newval) {
1297 }
1298
1302
1303 /// Sets the extended backtrace token for this thread
1304 ///
1305 /// Some Thread subclasses may maintain a token to help with providing
1306 /// an extended backtrace. The SystemRuntime plugin will set/request this.
1307 ///
1308 /// \param [in] token The extended backtrace token.
1309 virtual void SetExtendedBacktraceToken(uint64_t token) {}
1310
1311 /// Gets the extended backtrace token for this thread
1312 ///
1313 /// Some Thread subclasses may maintain a token to help with providing
1314 /// an extended backtrace. The SystemRuntime plugin will set/request this.
1315 ///
1316 /// \return
1317 /// The token needed by the SystemRuntime to create an extended backtrace.
1318 /// LLDB_INVALID_ADDRESS is returned if no token is available.
1320
1322
1324
1326
1327 /// Request the pc value the thread had when previously stopped.
1328 ///
1329 /// When the thread performs execution, it copies the current RegisterContext
1330 /// GetPC() value. This method returns that value, if it is available.
1331 ///
1332 /// \return
1333 /// The PC value before execution was resumed. May not be available;
1334 /// an empty std::optional is returned in that case.
1335 std::optional<lldb::addr_t> GetPreviousFrameZeroPC();
1336
1338
1339 /// Push/pop provider input frames for the current host thread.
1340 /// Used by SyntheticStackFrameList to scope re-entrant frame lookups.
1342 void PopProviderFrameList();
1343
1344 /// Get a frame list by its unique identifier.
1346
1347 llvm::Error
1349
1350 llvm::Expected<ScriptedFrameProviderDescriptor>
1352
1354
1355 const llvm::DenseMap<lldb::frame_list_id_t, lldb::SyntheticFrameProviderSP> &
1357 return m_frame_providers;
1358 }
1359
1360 /// Returns true if any host thread is currently inside a provider.
1361 bool IsAnyProviderActive();
1362
1363 /// Get the ordered chain of provider descriptors and their frame list IDs.
1364 ///
1365 /// Each element is a pair of:
1366 /// - \b ScriptedFrameProviderDescriptor: metadata for the provider
1367 /// (class name, description, priority, thread specs).
1368 /// - \b frame_list_id_t: the sequential frame list identifier assigned
1369 /// to that provider in the chain (1 for the first provider, 2 for the
1370 /// second, etc.). ID 0 is reserved for the base unwinder and is never
1371 /// present in this vector.
1372 ///
1373 /// The vector is ordered by provider chain position (registration order
1374 /// adjusted by priority). It persists across \c ClearStackFrames() so that
1375 /// provider IDs remain stable for the lifetime of the thread.
1376 const std::vector<
1377 std::pair<ScriptedFrameProviderDescriptor, lldb::frame_list_id_t>> &
1379 return m_provider_chain_ids;
1380 }
1381
1382protected:
1383 friend class ThreadPlan;
1384 friend class ThreadList;
1385 friend class ThreadEventData;
1386 friend class StackFrameList;
1387 friend class StackFrame;
1388 friend class OperatingSystem;
1389
1390 // This is necessary to make sure thread assets get destroyed while the
1391 // thread is still in good shape to call virtual thread methods. This must
1392 // be called by classes that derive from Thread in their destructor.
1393 virtual void DestroyThread();
1394
1395 ThreadPlanStack &GetPlans() const;
1396
1397 void PushPlan(lldb::ThreadPlanSP plan_sp);
1398
1399 void PopPlan();
1400
1401 void DiscardPlan();
1402
1404
1405 virtual Unwind &GetUnwinder();
1406
1407 // Check to see whether the thread is still at the last breakpoint hit that
1408 // stopped it.
1409 virtual bool IsStillAtLastBreakpointHit();
1410
1411 // Some threads are threads that are made up by OperatingSystem plugins that
1412 // are threads that exist and are context switched out into memory. The
1413 // OperatingSystem plug-in need a ways to know if a thread is "real" or made
1414 // up.
1415 virtual bool IsOperatingSystemPluginThread() const { return false; }
1416
1417 // Subclasses that have a way to get an extended info dictionary for this
1418 // thread should fill
1422
1424 m_temporary_resume_state = new_state;
1425 }
1426
1428
1429 virtual llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
1430 GetSiginfo(size_t max_size) const {
1431 return llvm::make_error<UnimplementedError>();
1432 }
1433
1434 // Classes that inherit from Process can see and modify these
1435 lldb::ProcessWP m_process_wp; ///< The process that owns this thread.
1436 lldb::StopInfoSP m_stop_info_sp; ///< The private stop reason for this thread
1437 uint32_t m_stop_info_stop_id; // This is the stop id for which the StopInfo is
1438 // valid. Can use this so you know that
1439 // the thread's m_stop_info_sp is current and you don't have to fetch it
1440 // again
1441 uint32_t m_stop_info_override_stop_id; // The stop ID containing the last time
1442 // the stop info was checked against
1443 // the stop info override
1444 bool m_should_run_before_public_stop; // If this thread has "stop others"
1445 // private work to do, then it will
1446 // set this.
1447 lldb::addr_t m_stopped_at_unexecuted_bp; // Set to the address of a breakpoint
1448 // instruction that we have not yet
1449 // hit, but will hit when we resume.
1450 const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread
1451 /// for easy UI/command line access.
1452 lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this
1453 ///thread's current register state.
1454 lldb::StateType m_state; ///< The state of our process.
1455 mutable std::recursive_mutex
1456 m_state_mutex; ///< Multithreaded protection for m_state.
1457 mutable std::recursive_mutex
1458 m_frame_mutex; ///< Multithreaded protection for m_state.
1460 m_unwinder_frames_sp; ///< The unwinder frame list (ID 0).
1461 lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily
1462 ///populated after a thread stops.
1463 /// Per-host-thread stack of active provider input frames. A provider
1464 /// always operates on its parent StackFrameList — not the synthetic list
1465 /// currently being constructed. While a provider is running, its parent
1466 /// list is pushed here so that any code the provider executes that
1467 /// fetches a StackFrameList (e.g. GetFrameAtIndex, EvaluateExpression)
1468 /// transparently sees the parent list rather than the in-construction
1469 /// list at the end of the provider chain.
1470 ///
1471 /// Keyed by host thread so the provider's own thread and the private state
1472 /// thread get the parent list, while unrelated threads proceed normally.
1473 /// ClearStackFrames() is also guarded: frame state is shared, so it must
1474 /// not be torn down while any provider is mid-construction.
1476 llvm::DenseMap<HostThread, std::vector<lldb::StackFrameListSP>>
1478 lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from
1479 ///the last time this thread stopped.
1480 /// The unwinder frame list from the last time this thread stopped. New
1481 /// unwinder frame lists take their previous frames from here rather than
1482 /// from m_prev_frames_sp.
1484 std::optional<lldb::addr_t>
1485 m_prev_framezero_pc; ///< Frame 0's PC the last
1486 /// time this thread was stopped.
1487 int m_resume_signal; ///< The signal that should be used when continuing this
1488 ///thread.
1489 lldb::StateType m_resume_state; ///< This state is used to force a thread to
1490 ///be suspended from outside the ThreadPlan
1491 ///logic.
1492 lldb::StateType m_temporary_resume_state; ///< This state records what the
1493 ///thread was told to do by the
1494 ///thread plan logic for the current
1495 ///resume.
1496 /// It gets set in Thread::ShouldResume.
1497 std::unique_ptr<lldb_private::Unwind> m_unwinder_up;
1498 bool m_destroy_called; // This is used internally to make sure derived Thread
1499 // classes call DestroyThread.
1501 mutable std::unique_ptr<ThreadPlanStack> m_null_plan_stack_up;
1502
1503 /// The Thread backed by this thread, if any.
1505
1506 /// Map from frame list ID to its frame provider.
1507 /// Cleared in ClearStackFrames(), repopulated in GetStackFrameList().
1508 llvm::DenseMap<lldb::frame_list_id_t, lldb::SyntheticFrameProviderSP>
1510
1511 /// Ordered chain of provider IDs.
1512 /// Persists across ClearStackFrames() to maintain stable provider IDs.
1513 std::vector<std::pair<ScriptedFrameProviderDescriptor, lldb::frame_list_id_t>>
1515
1516 /// Map from frame list identifier to frame list weak pointer.
1517 mutable llvm::DenseMap<lldb::frame_list_id_t, lldb::StackFrameListWP>
1519
1520private:
1521 bool m_extended_info_fetched; // Have we tried to retrieve the m_extended_info
1522 // for this thread?
1523 StructuredData::ObjectSP m_extended_info; // The extended info for this thread
1524
1525 void BroadcastSelectedFrameChange(StackID &new_frame_id);
1526
1527 Thread(const Thread &) = delete;
1528 const Thread &operator=(const Thread &) = delete;
1529};
1530
1531} // namespace lldb_private
1532
1533#endif // LLDB_TARGET_THREAD_H
A section + offset based address range class.
A section + offset based address class.
Definition Address.h:62
Broadcaster(lldb::BroadcasterManagerSP manager_sp, std::string name)
Construct with a broadcaster with a name.
"lldb/Utility/ArgCompletionRequest.h"
"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.
A file collection class.
A file utility class.
Definition FileSpec.h:56
A plug-in interface definition class for debugging a process.
Definition Process.h:370
This base class provides an interface to stack frames.
Definition StackFrame.h:44
bool IsValid() const
Definition StackID.h:55
An error handling class.
Definition Status.h:118
A stream class that can stream formatted output to a file.
Definition Stream.h:28
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
bool GetStepInAvoidsNoDebug() const
Definition Thread.cpp:135
const RegularExpression * GetSymbolsToAvoidRegexp()
The regular expression returned determines symbols that this thread won't stop in during "step-in" op...
Definition Thread.cpp:119
bool GetTraceEnabledState() const
Definition Thread.cpp:129
ThreadProperties(bool is_global)
Definition Thread.cpp:108
uint64_t GetMaxBacktraceDepth() const
Definition Thread.cpp:147
FileSpecList GetLibrariesToAvoid() const
Definition Thread.cpp:124
bool GetStepOutAvoidsNoDebug() const
Definition Thread.cpp:141
uint64_t GetSingleThreadPlanTimeout() const
Definition Thread.cpp:153
static const ThreadEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition Thread.cpp:179
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
Definition Thread.cpp:189
void Dump(Stream *s) const override
Definition Thread.cpp:176
static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr)
Definition Thread.cpp:206
llvm::StringRef GetFlavor() const override
Definition Thread.h:118
static llvm::StringRef GetFlavorString()
Definition Thread.cpp:161
const ThreadEventData & operator=(const ThreadEventData &)=delete
ThreadEventData(const lldb::ThreadSP thread_sp)
Definition Thread.cpp:165
lldb::ThreadSP GetThread() const
Definition Thread.h:132
ThreadEventData(const ThreadEventData &)=delete
static StackID GetStackIDFromEvent(const Event *event_ptr)
Definition Thread.cpp:197
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:1376
bool IsThreadPlanDone(ThreadPlan *plan) const
Checks whether the given plan is in the completed plans for this stop.
Definition Thread.cpp:1209
virtual lldb::user_id_t GetProtocolID() const
Definition Thread.h:1185
lldb::ThreadSP GetCurrentExceptionBacktrace()
Definition Thread.cpp:2406
virtual void SetExtendedBacktraceToken(uint64_t token)
Sets the extended backtrace token for this thread.
Definition Thread.h:1309
std::optional< lldb::addr_t > GetPreviousFrameZeroPC()
Request the pc value the thread had when previously stopped.
Definition Thread.cpp:1753
void BroadcastSelectedFrameChange(StackID &new_frame_id)
Definition Thread.cpp:279
@ eBroadcastBitSelectedFrameChanged
Definition Thread.h:96
@ eBroadcastBitThreadSelected
Definition Thread.h:97
@ eBroadcastBitThreadSuspended
Definition Thread.h:94
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack.
Definition Thread.cpp:1292
~Thread() override
Definition Thread.cpp:250
bool DecrementCurrentInlinedDepth()
Definition Thread.h:458
llvm::Expected< ScriptedFrameProviderDescriptor > GetScriptedFrameProviderDescriptorForID(lldb::frame_list_id_t id) const
Definition Thread.cpp:1723
const uint32_t m_index_id
A unique 1 based index assigned to each thread for easy UI/command line access.
Definition Thread.h:1450
void SetShouldRunBeforePublicStop(bool newval)
Definition Thread.h:1295
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Definition Thread.h:451
virtual const char * GetQueueName()
Retrieve the Queue name for the queue currently using this Thread.
Definition Thread.h:358
bool CompletedPlanOverridesBreakpoint() const
Check if we have completed plan to override breakpoint stop reason.
Definition Thread.cpp:1217
Thread(const Thread &)=delete
lldb::StackFrameListSP m_curr_frames_sp
The stack frames that get lazily populated after a thread stops.
Definition Thread.h:1461
virtual bool SafeToCallFunctions()
Check whether this thread is safe to run functions.
Definition Thread.cpp:2027
void RestoreThreadStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
Definition Thread.cpp:572
Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans)
Queues a generic thread plan.
Definition Thread.cpp:1225
bool WasThreadPlanDiscarded(ThreadPlan *plan) const
Checks whether the given plan is in the discarded plans for this stop.
Definition Thread.cpp:1213
virtual lldb::RegisterContextSP GetRegisterContext()=0
virtual lldb::addr_t GetThreadPointer()
Retrieves the per-thread data area.
Definition Thread.cpp:2009
virtual void DidStop()
Definition Thread.cpp:780
virtual bool RestoreRegisterStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
Definition Thread.cpp:550
llvm::StringRef GetBroadcasterClass() const override
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager ...
Definition Thread.h:102
friend class ThreadPlan
Definition Thread.h:1383
virtual void ClearBackingThread()
Definition Thread.h:544
bool SetupToStepOverBreakpointIfNeeded(lldb::RunDirection direction)
Definition Thread.cpp:639
uint32_t m_stop_info_stop_id
Definition Thread.h:1437
virtual lldb_private::StructuredData::ObjectSP FetchDetailedBinariesInfo()
If this thread stopped on a binary-loaded breakpoint, the detailed information about the new binaries...
Definition Thread.h:1220
void ClearSelectedFrameIndex()
Resets the selected frame index of this object.
Definition Thread.h:503
virtual bool SetBackingThread(const lldb::ThreadSP &thread_sp)
Definition Thread.h:538
void AutoCompleteThreadPlans(CompletionRequest &request) const
Format the thread plan information for auto completion.
Definition Thread.cpp:1168
std::recursive_mutex m_frame_mutex
Multithreaded protection for m_state.
Definition Thread.h:1458
virtual void RefreshStateAfterStop()=0
static void SettingsInitialize()
Definition Thread.cpp:2005
void SetShouldReportStop(Vote vote)
Definition Thread.cpp:502
virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate=true)
Definition Thread.cpp:402
uint32_t GetIndexID() const
Definition Thread.cpp:1451
std::optional< lldb::addr_t > m_prev_framezero_pc
Frame 0's PC the last time this thread was stopped.
Definition Thread.h:1485
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition Thread.cpp:1813
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition Thread.cpp:1467
void DiscardThreadPlans(bool force)
Discards the plans queued on the plan stack of the current thread.
Definition Thread.cpp:1278
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
Definition Thread.cpp:480
bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo)
Definition Thread.cpp:2163
static std::string RunModeAsString(lldb::RunMode mode)
Definition Thread.cpp:2090
void PushProviderFrameList(lldb::StackFrameListSP frames)
Push/pop provider input frames for the current host thread.
Definition Thread.cpp:1471
void SetTemporaryResumeState(lldb::StateType new_state)
Definition Thread.h:1423
virtual bool MatchesSpec(const ThreadSpec *spec)
Definition Thread.cpp:1117
lldb::ProcessSP CalculateProcess() override
Definition Thread.cpp:1461
StructuredData::ObjectSP GetExtendedInfo()
Retrieve a dictionary of information about this thread.
Definition Thread.h:298
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:2015
void SetStopInfoToNothing()
Definition Thread.cpp:513
ThreadPlanReturnValue GetReturnValue() const
Gets the outer-most return value from the completed plans.
Definition Thread.cpp:1201
virtual void DestroyThread()
Definition Thread.cpp:259
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:1420
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:1407
void SetResumeState(lldb::StateType state, bool override_suspend=false)
Sets the USER resume state for this thread.
Definition Thread.h:208
lldb::StackFrameSP GetSelectedFrame(SelectMostRelevant select_most_relevant)
Definition Thread.cpp:288
virtual bool IsStillAtLastBreakpointHit()
Definition Thread.cpp:2276
std::recursive_mutex m_state_mutex
Multithreaded protection for m_state.
Definition Thread.h:1456
void PopProviderFrameList()
Definition Thread.cpp:1481
ThreadPlan * GetPreviousPlan(ThreadPlan *plan) const
Definition Thread.cpp:1221
virtual const char * GetName()
Definition Thread.h:306
const llvm::DenseMap< lldb::frame_list_id_t, lldb::SyntheticFrameProviderSP > & GetFrameProviders() const
Definition Thread.h:1356
void PushPlan(lldb::ThreadPlanSP plan_sp)
Definition Thread.cpp:1137
lldb::StackFrameListSP m_prev_frames_sp
The previous stack frames from the last time this thread stopped.
Definition Thread.h:1478
virtual lldb::addr_t GetQueueLibdispatchQueueAddress()
Retrieve the address of the libdispatch_queue_t struct for queue currently using this Thread.
Definition Thread.h:400
virtual void ClearStackFrames()
Definition Thread.cpp:1757
void SetThreadHitBreakpointSite()
Definition Thread.h:422
ThreadPlan * GetCurrentPlan() const
Gets the plan which will execute next on the plan stack.
Definition Thread.cpp:1184
virtual Unwind & GetUnwinder()
Definition Thread.cpp:2264
virtual const char * GetInfo()
Definition Thread.h:286
lldb::ThreadSP GetBackedThread() const
Returns the thread that is backed by this thread, if any.
Definition Thread.h:536
virtual lldb::QueueKind GetQueueKind()
Retrieve the Queue kind for the queue currently using this Thread.
Definition Thread.h:372
static llvm::StringRef GetStaticBroadcasterClass()
Definition Thread.cpp:221
void SetResumeSignal(int signal)
Definition Thread.h:182
virtual lldb::QueueSP GetQueue()
Retrieve the Queue for this thread, if any.
Definition Thread.h:384
bool IsAnyProviderActive()
Returns true if any host thread is currently inside a provider.
Definition Thread.cpp:1498
virtual lldb::ThreadSP GetBackingThread() const
Definition Thread.h:542
bool IsRunningCallFunctionPlan() const
Returns true if this thread has a ThreadPlanCallFunction on its plan stack, indicating it is running ...
Definition Thread.cpp:1188
lldb::ExpressionVariableSP GetExpressionVariable() const
Gets the outer-most expression variable from the completed plans.
Definition Thread.cpp:1205
virtual bool ThreadHasQueueInformation() const
Whether this Thread already has all the Queue information cached or not.
Definition Thread.h:438
Vote ShouldReportRun(Event *event_ptr)
Definition Thread.cpp:1085
lldb::TargetSP CalculateTarget() override
Definition Thread.cpp:1453
static std::string StopReasonAsString(lldb::StopReason reason)
Definition Thread.cpp:2047
lldb::StackFrameListSP GetFrameListByIdentifier(lldb::frame_list_id_t id)
Get a frame list by its unique identifier.
Definition Thread.cpp:1648
virtual void WillResume(lldb::StateType resume_state)
Definition Thread.h:236
Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id=false)
Constructor.
Definition Thread.cpp:226
virtual void SetAssociatedWithLibdispatchQueue(lldb_private::LazyBool associated_with_libdispatch_queue)
Definition Thread.h:330
virtual bool IsOperatingSystemPluginThread() const
Definition Thread.h:1415
friend class OperatingSystem
Definition Thread.h:1388
lldb::addr_t m_stopped_at_unexecuted_bp
Definition Thread.h:1447
bool ThreadStoppedForAReason()
Definition Thread.cpp:521
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:2251
virtual lldb_private::LazyBool GetAssociatedWithLibdispatchQueue()
Whether this thread can be associated with a libdispatch queue.
Definition Thread.h:326
std::string GetStopDescriptionRaw()
Definition Thread.cpp:615
void ClearScriptedFrameProvider()
Definition Thread.cpp:1742
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:1253
bool ShouldRunBeforePublicStop()
Definition Thread.h:1299
virtual Status StepOver(bool source_step, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Default implementation for stepping over.
Definition Thread.cpp:2333
bool ShouldResume(lldb::StateType resume_state)
Definition Thread.cpp:703
void SetThreadStoppedAtUnexecutedBP(lldb::addr_t pc)
When a thread stops at an enabled BreakpointSite that has not executed, the Process plugin should cal...
Definition Thread.h:419
std::unique_ptr< lldb_private::Unwind > m_unwinder_up
It gets set in Thread::ShouldResume.
Definition Thread.h:1497
void ClearBackedThread()
Definition Thread.h:533
std::unique_ptr< ThreadPlanStack > m_null_plan_stack_up
Definition Thread.h:1501
void SetBackedThread(Thread &backed_thread)
Sets the thread that is backed by this thread.
Definition Thread.h:523
virtual void SetQueueName(const char *name)
Definition Thread.h:360
lldb::StateType GetTemporaryResumeState() const
Definition Thread.h:1285
void SetDefaultFileAndLineToSelectedFrame()
Definition Thread.h:507
virtual lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame)=0
virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state)
Definition Thread.cpp:523
void SetState(lldb::StateType state)
Definition Thread.cpp:590
uint32_t GetSelectedFrameIndex(SelectMostRelevant select_most_relevant)
Definition Thread.h:487
llvm::Error LoadScriptedFrameProvider(const ScriptedFrameProviderDescriptor &descriptor)
Definition Thread.cpp:1670
const std::vector< std::pair< ScriptedFrameProviderDescriptor, lldb::frame_list_id_t > > & GetProviderChainIds() const
Get the ordered chain of provider descriptors and their frame list IDs.
Definition Thread.h:1378
int GetResumeSignal() const
Definition Thread.h:180
lldb::ProcessSP GetProcess() const
Definition Thread.h:178
lldb::StackFrameSP CalculateStackFrame() override
Definition Thread.cpp:1465
virtual void SetQueueKind(lldb::QueueKind kind)
Definition Thread.h:374
lldb::StateType GetResumeState() const
Gets the USER resume state for this thread.
Definition Thread.h:222
virtual void SetQueueID(lldb::queue_id_t new_val)
Definition Thread.h:348
friend class StackFrame
Definition Thread.h:1387
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
Definition Thread.cpp:296
virtual lldb::ThreadPlanSP QueueThreadPlanForStepUntil(bool abort_other_plans, llvm::ArrayRef< lldb::addr_t > address_list, bool stop_others, uint32_t frame_idx, Status &status)
Definition Thread.cpp:1431
lldb::StopInfoSP m_stop_info_sp
The private stop reason for this thread.
Definition Thread.h:1436
std::mutex m_provider_frames_mutex
Per-host-thread stack of active provider input frames.
Definition Thread.h:1475
lldb::ProcessWP m_process_wp
The process that owns this thread.
Definition Thread.h:1435
lldb::StackFrameListSP m_prev_unwinder_frames_sp
The unwinder frame list from the last time this thread stopped.
Definition Thread.h:1483
void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format)
Definition Thread.cpp:1986
LazyBool m_override_should_notify
Definition Thread.h:1500
lldb::ThreadSP CalculateThread() override
Definition Thread.cpp:1463
Status ReturnFromFrameWithIndex(uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition Thread.cpp:1798
virtual Status StepOut(uint32_t frame_idx=0)
Default implementation for stepping out.
Definition Thread.cpp:2366
virtual llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > GetSiginfo(size_t max_size) const
Definition Thread.h:1430
const Thread & operator=(const Thread &)=delete
void DumpTraceInstructions(Stream &s, size_t count, size_t start_position=0) const
Dump count instructions of the thread's Trace starting at the start_position position in reverse orde...
lldb::StateType GetState() const
Definition Thread.cpp:584
lldb::StateType m_state
The state of our process.
Definition Thread.h:1454
bool m_extended_info_fetched
Definition Thread.h:1521
void CalculatePublicStopInfo()
Definition Thread.cpp:397
virtual lldb_private::StructuredData::ObjectSP FetchThreadExtendedInfo()
Definition Thread.h:1419
virtual void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t)
Definition Thread.h:404
static void SettingsTerminate()
Definition Thread.cpp:2007
lldb::ThreadWP m_backed_thread
The Thread backed by this thread, if any.
Definition Thread.h:1504
bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast=false)
Definition Thread.cpp:305
virtual lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id)
Definition Thread.h:477
lldb::StopReason GetStopReason()
Definition Thread.cpp:458
virtual void SetName(const char *name)
Definition Thread.h:308
ThreadPlanStack & GetPlans() const
Definition Thread.cpp:1121
lldb::ValueObjectSP GetSiginfoValue()
Definition Thread.cpp:2421
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:1310
uint32_t m_stop_info_override_stop_id
Definition Thread.h:1441
int m_resume_signal
The signal that should be used when continuing this thread.
Definition Thread.h:1487
bool IsValid() const
Definition Thread.h:1228
virtual void DidResume()
Definition Thread.cpp:774
bool StopInfoIsUpToDate() const
Definition Thread.cpp:465
lldb::StackFrameSP GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr)
Definition Thread.cpp:2043
llvm::DenseMap< lldb::frame_list_id_t, lldb::SyntheticFrameProviderSP > m_frame_providers
Map from frame list ID to its frame provider.
Definition Thread.h:1509
lldb::ThreadPlanSP GetCompletedPlan() const
Gets the outer-most plan that was popped off the plan stack in the most recent stop.
Definition Thread.cpp:1197
lldb::ValueObjectSP GetCurrentException()
Definition Thread.cpp:2390
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:1389
virtual lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx)
Definition Thread.cpp:1794
bool ShouldStop(Event *event_ptr)
Definition Thread.cpp:782
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
Definition Thread.cpp:1905
friend class StackFrameList
Definition Thread.h:1386
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:1964
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:1265
void FrameSelectedCallback(lldb_private::StackFrame *frame)
Definition Thread.cpp:350
lldb::ThreadPlanSP QueueBasePlan(bool abort_other_plans)
Queues the base plan for a thread.
Definition Thread.cpp:1304
virtual lldb::queue_id_t GetQueueID()
Retrieve the Queue ID for the queue currently using this Thread.
Definition Thread.h:346
static ThreadProperties & GetGlobalProperties()
Definition Thread.cpp:68
virtual uint64_t GetExtendedBacktraceToken()
Gets the extended backtrace token for this thread.
Definition Thread.h:1319
virtual uint32_t GetExtendedBacktraceOriginatingIndexID()
Definition Thread.h:1177
uint32_t GetCurrentInlinedDepth()
Definition Thread.h:462
llvm::DenseMap< HostThread, std::vector< lldb::StackFrameListSP > > m_active_frame_providers_by_thread
Definition Thread.h:1477
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:1319
std::string GetStopDescription()
Definition Thread.cpp:595
virtual std::vector< lldb::addr_t > FetchNewlyAddedBinaries()
If this thread stopped on a binary-loaded breakpoint, the addresses of the newly added binaries may h...
Definition Thread.h:1212
virtual lldb::ThreadPlanSP QueueThreadPlanForStepScripted(bool abort_other_plans, const ScriptedMetadata &scripted_metadata, bool stop_other_threads, Status &status)
Definition Thread.cpp:1441
StructuredData::ObjectSP m_extended_info
Definition Thread.h:1523
lldb::StopInfoSP GetStopInfo()
Definition Thread.cpp:364
virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, llvm::StringRef 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:1346
llvm::DenseMap< lldb::frame_list_id_t, lldb::StackFrameListWP > m_frame_lists_by_id
Map from frame list identifier to frame list weak pointer.
Definition Thread.h:1518
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:1492
lldb::StackFrameListSP GetStackFrameList()
Definition Thread.cpp:1503
bool m_should_run_before_public_stop
Definition Thread.h:1444
Vote ShouldReportStop(Event *event_ptr)
Definition Thread.cpp:1024
bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx, Stream &output_stream)
Definition Thread.cpp:317
virtual bool CalculateStopInfo()=0
Ask the thread subclass to set its stop info.
std::vector< std::pair< ScriptedFrameProviderDescriptor, lldb::frame_list_id_t > > m_provider_chain_ids
Ordered chain of provider IDs.
Definition Thread.h:1514
lldb::StateType m_resume_state
This state is used to force a thread to be suspended from outside the ThreadPlan logic.
Definition Thread.h:1489
virtual uint32_t GetStackFrameCount()
GetStackFrameCount can be expensive.
Definition Thread.h:447
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:2297
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:2103
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
Definition Thread.h:1452
lldb::StackFrameListSP m_unwinder_frames_sp
The unwinder frame list (ID 0).
Definition Thread.h:1460
friend class ThreadList
Definition Thread.h:1384
#define LLDB_INVALID_QUEUE_ID
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
std::variant< std::monostate, ReturnedValue, ThrownError > ThreadPlanReturnValue
What a completed thread plan computed for the function it stepped out of or called: nothing,...
Definition Thread.h:82
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::Queue > QueueSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
RunDirection
Execution directions.
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
StateType
Process and Thread States.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
std::shared_ptr< lldb_private::Process > ProcessSP
QueueKind
Queue type.
std::weak_ptr< lldb_private::Process > ProcessWP
uint64_t user_id_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
uint64_t addr_t
Definition lldb-types.h:80
StopReason
Thread stop reasons.
std::shared_ptr< lldb_private::Target > TargetSP
std::weak_ptr< lldb_private::Thread > ThreadWP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
RunMode
Thread Run Modes.
uint64_t tid_t
Definition lldb-types.h:85
std::shared_ptr< lldb_private::Module > ModuleSP
uint64_t queue_id_t
Definition lldb-types.h:92
std::shared_ptr< lldb_private::RegisterCheckpoint > RegisterCheckpointSP
std::shared_ptr< lldb_private::StackFrameList > StackFrameListSP
uint32_t frame_list_id_t
Definition lldb-types.h:87
A line table entry class.
Definition LineEntry.h:21
A value a function returned.
Definition Thread.h:71
lldb::ValueObjectSP valobj_sp
Definition Thread.h:72
This struct contains the metadata needed to instantiate a frame provider and optional filters to cont...
lldb::RegisterCheckpointSP register_backup_sp
Definition Thread.h:151
An error a function threw instead of returning.
Definition Thread.h:76
lldb::ValueObjectSP valobj_sp
Definition Thread.h:77
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