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