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 /// Unwinds the thread stack for the innermost expression plan currently
1031 /// on the thread plan stack.
1032 ///
1033 /// \return
1034 /// An error if the thread plan could not be unwound.
1035
1037
1038 /// Gets the outer-most plan that was popped off the plan stack in the
1039 /// most recent stop. Useful for printing the stop reason accurately.
1040 ///
1041 /// \return
1042 /// A pointer to the last completed plan.
1044
1045 /// Gets the outer-most return value from the completed plans
1046 ///
1047 /// \return
1048 /// A ValueObjectSP, either empty if there is no return value,
1049 /// or containing the return value.
1051
1052 /// Gets the outer-most expression variable from the completed plans
1053 ///
1054 /// \return
1055 /// A ExpressionVariableSP, either empty if there is no
1056 /// plan completed an expression during the current stop
1057 /// or the expression variable that was made for the completed expression.
1059
1060 /// Checks whether the given plan is in the completed plans for this
1061 /// stop.
1062 ///
1063 /// \param[in] plan
1064 /// Pointer to the plan you're checking.
1065 ///
1066 /// \return
1067 /// Returns true if the input plan is in the completed plan stack,
1068 /// false otherwise.
1069 bool IsThreadPlanDone(ThreadPlan *plan) const;
1070
1071 /// Checks whether the given plan is in the discarded plans for this
1072 /// stop.
1073 ///
1074 /// \param[in] plan
1075 /// Pointer to the plan you're checking.
1076 ///
1077 /// \return
1078 /// Returns true if the input plan is in the discarded plan stack,
1079 /// false otherwise.
1080 bool WasThreadPlanDiscarded(ThreadPlan *plan) const;
1081
1082 /// Check if we have completed plan to override breakpoint stop reason
1083 ///
1084 /// \return
1085 /// Returns true if completed plan stack is not empty
1086 /// false otherwise.
1088
1089 /// Queues a generic thread plan.
1090 ///
1091 /// \param[in] plan_sp
1092 /// The plan to queue.
1093 ///
1094 /// \param[in] abort_other_plans
1095 /// \b true if we discard the currently queued plans and replace them with
1096 /// this one.
1097 /// Otherwise this plan will go on the end of the plan stack.
1098 ///
1099 /// \return
1100 /// A pointer to the last completed plan.
1101 Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
1102
1103 /// Discards the plans queued on the plan stack of the current thread. This
1104 /// is
1105 /// arbitrated by the "Controlling" ThreadPlans, using the "OkayToDiscard"
1106 /// call.
1107 // But if \a force is true, all thread plans are discarded.
1108 void DiscardThreadPlans(bool force);
1109
1110 /// Discards the plans queued on the plan stack of the current thread up to
1111 /// and
1112 /// including up_to_plan_sp.
1113 //
1114 // \param[in] up_to_plan_sp
1115 // Discard all plans up to and including this one.
1117
1118 void DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr);
1119
1120 /// Discards the plans queued on the plan stack of the current thread up to
1121 /// and
1122 /// including the plan in that matches \a thread_index counting only
1123 /// the non-Private plans.
1124 ///
1125 /// \param[in] thread_index
1126 /// Discard all plans up to and including this user plan given by this
1127 /// index.
1128 ///
1129 /// \return
1130 /// \b true if there was a thread plan with that user index, \b false
1131 /// otherwise.
1132 bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index);
1133
1134 virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state);
1135
1136 virtual bool
1138
1140
1141 // Get the thread index ID. The index ID that is guaranteed to not be re-used
1142 // by a process. They start at 1 and increase with each new thread. This
1143 // allows easy command line access by a unique ID that is easier to type than
1144 // the actual system thread ID.
1145 uint32_t GetIndexID() const;
1146
1147 // Get the originating thread's index ID.
1148 // In the case of an "extended" thread -- a thread which represents the stack
1149 // that enqueued/spawned work that is currently executing -- we need to
1150 // provide the IndexID of the thread that actually did this work. We don't
1151 // want to just masquerade as that thread's IndexID by using it in our own
1152 // IndexID because that way leads to madness - but the driver program which
1153 // is iterating over extended threads may ask for the OriginatingThreadID to
1154 // display that information to the user.
1155 // Normal threads will return the same thing as GetIndexID();
1157 return GetIndexID();
1158 }
1159
1160 // The API ID is often the same as the Thread::GetID(), but not in all cases.
1161 // Thread::GetID() is the user visible thread ID that clients would want to
1162 // see. The API thread ID is the thread ID that is used when sending data
1163 // to/from the debugging protocol.
1164 virtual lldb::user_id_t GetProtocolID() const { return GetID(); }
1165
1166 // lldb::ExecutionContextScope pure virtual functions
1168
1170
1172
1174
1175 void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
1176
1179
1180 size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames,
1181 uint32_t num_frames_with_source, bool stop_format,
1182 bool show_hidden, bool only_stacks = false);
1183
1184 size_t GetStackFrameStatus(Stream &strm, uint32_t first_frame,
1185 uint32_t num_frames, bool show_frame_info,
1186 uint32_t num_frames_with_source, bool show_hidden);
1187
1188 // We need a way to verify that even though we have a thread in a shared
1189 // pointer that the object itself is still valid. Currently this won't be the
1190 // case if DestroyThread() was called. DestroyThread is called when a thread
1191 // has been removed from the Process' thread list.
1192 bool IsValid() const { return !m_destroy_called; }
1193
1194 // Sets and returns a valid stop info based on the process stop ID and the
1195 // current thread plan. If the thread stop ID does not match the process'
1196 // stop ID, the private stop reason is not set and an invalid StopInfoSP may
1197 // be returned.
1198 //
1199 // NOTE: This function must be called before the current thread plan is
1200 // moved to the completed plan stack (in Thread::ShouldStop()).
1201 //
1202 // NOTE: If subclasses override this function, ensure they do not overwrite
1203 // the m_actual_stop_info if it is valid. The stop info may be a
1204 // "checkpointed and restored" stop info, so if it is still around it is
1205 // right even if you have not calculated this yourself, or if it disagrees
1206 // with what you might have calculated.
1207 virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate = true);
1208
1209 // Calculate the stop info that will be shown to lldb clients. For instance,
1210 // a "step out" is implemented by running to a breakpoint on the function
1211 // return PC, so the process plugin initially sets the stop info to a
1212 // StopInfoBreakpoint. But once we've run the ShouldStop machinery, we
1213 // discover that there's a completed ThreadPlanStepOut, and that's really
1214 // the StopInfo we want to show. That will happen naturally the next
1215 // time GetStopInfo is called, but if you want to force the replacement,
1216 // you can call this.
1217
1219
1220 /// Ask the thread subclass to set its stop info.
1221 ///
1222 /// Thread subclasses should call Thread::SetStopInfo(...) with the reason the
1223 /// thread stopped.
1224 ///
1225 /// A thread that is sitting at a breakpoint site, but has not yet executed
1226 /// the breakpoint instruction, should have a breakpoint-hit StopInfo set.
1227 /// When execution is resumed, any thread sitting at a breakpoint site will
1228 /// instruction-step over the breakpoint instruction silently, and we will
1229 /// never record this breakpoint as being hit, updating the hit count,
1230 /// possibly executing breakpoint commands or conditions.
1231 ///
1232 /// \return
1233 /// True if Thread::SetStopInfo(...) was called, false otherwise.
1234 virtual bool CalculateStopInfo() = 0;
1235
1236 // Gets the temporary resume state for a thread.
1237 //
1238 // This value gets set in each thread by complex debugger logic in
1239 // Thread::ShouldResume() and an appropriate thread resume state will get set
1240 // in each thread every time the process is resumed prior to calling
1241 // Process::DoResume(). The lldb_private::Process subclass should adhere to
1242 // the thread resume state request which will be one of:
1243 //
1244 // eStateRunning - thread will resume when process is resumed
1245 // eStateStepping - thread should step 1 instruction and stop when process
1246 // is resumed
1247 // eStateSuspended - thread should not execute any instructions when
1248 // process is resumed
1252
1253 void SetStopInfo(const lldb::StopInfoSP &stop_info_sp);
1254
1255 void ResetStopInfo();
1256
1257 void SetShouldReportStop(Vote vote);
1258
1259 void SetShouldRunBeforePublicStop(bool newval) {
1261 }
1262
1266
1267 /// Sets the extended backtrace token for this thread
1268 ///
1269 /// Some Thread subclasses may maintain a token to help with providing
1270 /// an extended backtrace. The SystemRuntime plugin will set/request this.
1271 ///
1272 /// \param [in] token The extended backtrace token.
1273 virtual void SetExtendedBacktraceToken(uint64_t token) {}
1274
1275 /// Gets the extended backtrace token for this thread
1276 ///
1277 /// Some Thread subclasses may maintain a token to help with providing
1278 /// an extended backtrace. The SystemRuntime plugin will set/request this.
1279 ///
1280 /// \return
1281 /// The token needed by the SystemRuntime to create an extended backtrace.
1282 /// LLDB_INVALID_ADDRESS is returned if no token is available.
1284
1286
1288
1290
1291 /// Request the pc value the thread had when previously stopped.
1292 ///
1293 /// When the thread performs execution, it copies the current RegisterContext
1294 /// GetPC() value. This method returns that value, if it is available.
1295 ///
1296 /// \return
1297 /// The PC value before execution was resumed. May not be available;
1298 /// an empty std::optional is returned in that case.
1299 std::optional<lldb::addr_t> GetPreviousFrameZeroPC();
1300
1302
1303 /// Push/pop provider input frames for the current host thread.
1304 /// Used by SyntheticStackFrameList to scope re-entrant frame lookups.
1306 void PopProviderFrameList();
1307
1308 /// Get a frame list by its unique identifier.
1310
1311 llvm::Error
1313
1314 llvm::Expected<ScriptedFrameProviderDescriptor>
1316
1318
1319 const llvm::DenseMap<lldb::frame_list_id_t, lldb::SyntheticFrameProviderSP> &
1321 return m_frame_providers;
1322 }
1323
1324 /// Returns true if any host thread is currently inside a provider.
1325 bool IsAnyProviderActive();
1326
1327protected:
1328 friend class ThreadPlan;
1329 friend class ThreadList;
1330 friend class ThreadEventData;
1331 friend class StackFrameList;
1332 friend class StackFrame;
1333 friend class OperatingSystem;
1334
1335 // This is necessary to make sure thread assets get destroyed while the
1336 // thread is still in good shape to call virtual thread methods. This must
1337 // be called by classes that derive from Thread in their destructor.
1338 virtual void DestroyThread();
1339
1340 ThreadPlanStack &GetPlans() const;
1341
1342 void PushPlan(lldb::ThreadPlanSP plan_sp);
1343
1344 void PopPlan();
1345
1346 void DiscardPlan();
1347
1349
1350 virtual Unwind &GetUnwinder();
1351
1352 // Check to see whether the thread is still at the last breakpoint hit that
1353 // stopped it.
1354 virtual bool IsStillAtLastBreakpointHit();
1355
1356 // Some threads are threads that are made up by OperatingSystem plugins that
1357 // are threads that exist and are context switched out into memory. The
1358 // OperatingSystem plug-in need a ways to know if a thread is "real" or made
1359 // up.
1360 virtual bool IsOperatingSystemPluginThread() const { return false; }
1361
1362 // Subclasses that have a way to get an extended info dictionary for this
1363 // thread should fill
1367
1369 m_temporary_resume_state = new_state;
1370 }
1371
1373
1374 virtual llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
1375 GetSiginfo(size_t max_size) const {
1376 return llvm::make_error<UnimplementedError>();
1377 }
1378
1379 // Classes that inherit from Process can see and modify these
1380 lldb::ProcessWP m_process_wp; ///< The process that owns this thread.
1381 lldb::StopInfoSP m_stop_info_sp; ///< The private stop reason for this thread
1382 uint32_t m_stop_info_stop_id; // This is the stop id for which the StopInfo is
1383 // valid. Can use this so you know that
1384 // the thread's m_stop_info_sp is current and you don't have to fetch it
1385 // again
1386 uint32_t m_stop_info_override_stop_id; // The stop ID containing the last time
1387 // the stop info was checked against
1388 // the stop info override
1389 bool m_should_run_before_public_stop; // If this thread has "stop others"
1390 // private work to do, then it will
1391 // set this.
1392 lldb::addr_t m_stopped_at_unexecuted_bp; // Set to the address of a breakpoint
1393 // instruction that we have not yet
1394 // hit, but will hit when we resume.
1395 const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread
1396 /// for easy UI/command line access.
1397 lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this
1398 ///thread's current register state.
1399 lldb::StateType m_state; ///< The state of our process.
1400 mutable std::recursive_mutex
1401 m_state_mutex; ///< Multithreaded protection for m_state.
1402 mutable std::recursive_mutex
1403 m_frame_mutex; ///< Multithreaded protection for m_state.
1405 m_unwinder_frames_sp; ///< The unwinder frame list (ID 0).
1406 lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily
1407 ///populated after a thread stops.
1408 /// Per-host-thread stack of active provider input frames. A provider
1409 /// always operates on its parent StackFrameList — not the synthetic list
1410 /// currently being constructed. While a provider is running, its parent
1411 /// list is pushed here so that any code the provider executes that
1412 /// fetches a StackFrameList (e.g. GetFrameAtIndex, EvaluateExpression)
1413 /// transparently sees the parent list rather than the in-construction
1414 /// list at the end of the provider chain.
1415 ///
1416 /// Keyed by host thread so the provider's own thread and the private state
1417 /// thread get the parent list, while unrelated threads proceed normally.
1418 /// ClearStackFrames() is also guarded: frame state is shared, so it must
1419 /// not be torn down while any provider is mid-construction.
1421 llvm::DenseMap<HostThread, std::vector<lldb::StackFrameListSP>>
1423 lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from
1424 ///the last time this thread stopped.
1425 std::optional<lldb::addr_t>
1426 m_prev_framezero_pc; ///< Frame 0's PC the last
1427 /// time this thread was stopped.
1428 int m_resume_signal; ///< The signal that should be used when continuing this
1429 ///thread.
1430 lldb::StateType m_resume_state; ///< This state is used to force a thread to
1431 ///be suspended from outside the ThreadPlan
1432 ///logic.
1433 lldb::StateType m_temporary_resume_state; ///< This state records what the
1434 ///thread was told to do by the
1435 ///thread plan logic for the current
1436 ///resume.
1437 /// It gets set in Thread::ShouldResume.
1438 std::unique_ptr<lldb_private::Unwind> m_unwinder_up;
1439 bool m_destroy_called; // This is used internally to make sure derived Thread
1440 // classes call DestroyThread.
1442 mutable std::unique_ptr<ThreadPlanStack> m_null_plan_stack_up;
1443
1444 /// The Thread backed by this thread, if any.
1446
1447 /// Map from frame list ID to its frame provider.
1448 /// Cleared in ClearStackFrames(), repopulated in GetStackFrameList().
1449 llvm::DenseMap<lldb::frame_list_id_t, lldb::SyntheticFrameProviderSP>
1451
1452 /// Ordered chain of provider IDs.
1453 /// Persists across ClearStackFrames() to maintain stable provider IDs.
1454 std::vector<std::pair<ScriptedFrameProviderDescriptor, lldb::frame_list_id_t>>
1456
1457 /// Map from frame list identifier to frame list weak pointer.
1458 mutable llvm::DenseMap<lldb::frame_list_id_t, lldb::StackFrameListWP>
1460
1461 /// Counter for assigning unique provider IDs. Starts at 1 since 0 is
1462 /// reserved for normal unwinder frames. Persists across ClearStackFrames.
1464
1465private:
1466 bool m_extended_info_fetched; // Have we tried to retrieve the m_extended_info
1467 // for this thread?
1468 StructuredData::ObjectSP m_extended_info; // The extended info for this thread
1469
1470 void BroadcastSelectedFrameChange(StackID &new_frame_id);
1471
1472 Thread(const Thread &) = delete;
1473 const Thread &operator=(const Thread &) = delete;
1474};
1475
1476} // namespace lldb_private
1477
1478#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:354
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:134
const RegularExpression * GetSymbolsToAvoidRegexp()
The regular expression returned determines symbols that this thread won't stop in during "step-in" op...
Definition Thread.cpp:118
bool GetTraceEnabledState() const
Definition Thread.cpp:128
ThreadProperties(bool is_global)
Definition Thread.cpp:107
uint64_t GetMaxBacktraceDepth() const
Definition Thread.cpp:146
FileSpecList GetLibrariesToAvoid() const
Definition Thread.cpp:123
bool GetStepOutAvoidsNoDebug() const
Definition Thread.cpp:140
uint64_t GetSingleThreadPlanTimeout() const
Definition Thread.cpp:152
static const ThreadEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition Thread.cpp:178
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
Definition Thread.cpp:188
void Dump(Stream *s) const override
Definition Thread.cpp:175
static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr)
Definition Thread.cpp:205
llvm::StringRef GetFlavor() const override
Definition Thread.h:101
static llvm::StringRef GetFlavorString()
Definition Thread.cpp:160
const ThreadEventData & operator=(const ThreadEventData &)=delete
ThreadEventData(const lldb::ThreadSP thread_sp)
Definition Thread.cpp:164
lldb::ThreadSP GetThread() const
Definition Thread.h:115
ThreadEventData(const ThreadEventData &)=delete
static StackID GetStackIDFromEvent(const Event *event_ptr)
Definition Thread.cpp:196
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:1362
bool IsThreadPlanDone(ThreadPlan *plan) const
Checks whether the given plan is in the completed plans for this stop.
Definition Thread.cpp:1195
virtual lldb::user_id_t GetProtocolID() const
Definition Thread.h:1164
lldb::ThreadSP GetCurrentExceptionBacktrace()
Definition Thread.cpp:2341
virtual void SetExtendedBacktraceToken(uint64_t token)
Sets the extended backtrace token for this thread.
Definition Thread.h:1273
std::optional< lldb::addr_t > GetPreviousFrameZeroPC()
Request the pc value the thread had when previously stopped.
Definition Thread.cpp:1691
void BroadcastSelectedFrameChange(StackID &new_frame_id)
Definition Thread.cpp:277
@ 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:1278
~Thread() override
Definition Thread.cpp:249
bool DecrementCurrentInlinedDepth()
Definition Thread.h:441
llvm::Expected< ScriptedFrameProviderDescriptor > GetScriptedFrameProviderDescriptorForID(lldb::frame_list_id_t id) const
Definition Thread.cpp:1662
const uint32_t m_index_id
A unique 1 based index assigned to each thread for easy UI/command line access.
Definition Thread.h:1395
void SetShouldRunBeforePublicStop(bool newval)
Definition Thread.h:1259
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:1203
Thread(const Thread &)=delete
lldb::StackFrameListSP m_curr_frames_sp
The stack frames that get lazily populated after a thread stops.
Definition Thread.h:1406
virtual bool SafeToCallFunctions()
Check whether this thread is safe to run functions.
Definition Thread.cpp:1964
void RestoreThreadStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
Definition Thread.cpp:570
Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans)
Queues a generic thread plan.
Definition Thread.cpp:1211
bool WasThreadPlanDiscarded(ThreadPlan *plan) const
Checks whether the given plan is in the discarded plans for this stop.
Definition Thread.cpp:1199
virtual lldb::RegisterContextSP GetRegisterContext()=0
virtual lldb::addr_t GetThreadPointer()
Retrieves the per-thread data area.
Definition Thread.cpp:1946
virtual void DidStop()
Definition Thread.cpp:778
virtual bool RestoreRegisterStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
Definition Thread.cpp:548
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:1328
virtual void ClearBackingThread()
Definition Thread.h:527
bool SetupToStepOverBreakpointIfNeeded(lldb::RunDirection direction)
Definition Thread.cpp:637
uint32_t m_stop_info_stop_id
Definition Thread.h:1382
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:1163
std::recursive_mutex m_frame_mutex
Multithreaded protection for m_state.
Definition Thread.h:1403
virtual void RefreshStateAfterStop()=0
static void SettingsInitialize()
Definition Thread.cpp:1942
void SetShouldReportStop(Vote vote)
Definition Thread.cpp:500
virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate=true)
Definition Thread.cpp:400
uint32_t GetIndexID() const
Definition Thread.cpp:1439
std::optional< lldb::addr_t > m_prev_framezero_pc
Frame 0's PC the last time this thread was stopped.
Definition Thread.h:1426
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition Thread.cpp:1749
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition Thread.cpp:1455
void DiscardThreadPlans(bool force)
Discards the plans queued on the plan stack of the current thread.
Definition Thread.cpp:1264
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
Definition Thread.cpp:478
bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo)
Definition Thread.cpp:2098
static std::string RunModeAsString(lldb::RunMode mode)
Definition Thread.cpp:2025
void PushProviderFrameList(lldb::StackFrameListSP frames)
Push/pop provider input frames for the current host thread.
Definition Thread.cpp:1459
void SetTemporaryResumeState(lldb::StateType new_state)
Definition Thread.h:1368
virtual bool MatchesSpec(const ThreadSpec *spec)
Definition Thread.cpp:1112
lldb::ProcessSP CalculateProcess() override
Definition Thread.cpp:1449
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:1952
void SetStopInfoToNothing()
Definition Thread.cpp:511
virtual void DestroyThread()
Definition Thread.cpp:258
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:1406
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:1393
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:286
virtual bool IsStillAtLastBreakpointHit()
Definition Thread.cpp:2211
std::recursive_mutex m_state_mutex
Multithreaded protection for m_state.
Definition Thread.h:1401
void PopProviderFrameList()
Definition Thread.cpp:1469
ThreadPlan * GetPreviousPlan(ThreadPlan *plan) const
Definition Thread.cpp:1207
virtual const char * GetName()
Definition Thread.h:289
const llvm::DenseMap< lldb::frame_list_id_t, lldb::SyntheticFrameProviderSP > & GetFrameProviders() const
Definition Thread.h:1320
void PushPlan(lldb::ThreadPlanSP plan_sp)
Definition Thread.cpp:1132
lldb::StackFrameListSP m_prev_frames_sp
The previous stack frames from the last time this thread stopped.
Definition Thread.h:1423
lldb::frame_list_id_t m_next_provider_id
Counter for assigning unique provider IDs.
Definition Thread.h:1463
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:1695
void SetThreadHitBreakpointSite()
Definition Thread.h:405
ThreadPlan * GetCurrentPlan() const
Gets the plan which will execute next on the plan stack.
Definition Thread.cpp:1179
virtual Unwind & GetUnwinder()
Definition Thread.cpp:2199
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:220
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:1486
lldb::ValueObjectSP GetReturnValueObject() const
Gets the outer-most return value from the completed plans.
Definition Thread.cpp:1187
virtual lldb::ThreadSP GetBackingThread() const
Definition Thread.h:525
lldb::ExpressionVariableSP GetExpressionVariable() const
Gets the outer-most expression variable from the completed plans.
Definition Thread.cpp:1191
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:1080
lldb::TargetSP CalculateTarget() override
Definition Thread.cpp:1441
static std::string StopReasonAsString(lldb::StopReason reason)
Definition Thread.cpp:1984
lldb::StackFrameListSP GetFrameListByIdentifier(lldb::frame_list_id_t id)
Get a frame list by its unique identifier.
Definition Thread.cpp:1595
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:225
virtual void SetAssociatedWithLibdispatchQueue(lldb_private::LazyBool associated_with_libdispatch_queue)
Definition Thread.h:313
virtual bool IsOperatingSystemPluginThread() const
Definition Thread.h:1360
friend class OperatingSystem
Definition Thread.h:1333
lldb::addr_t m_stopped_at_unexecuted_bp
Definition Thread.h:1392
bool ThreadStoppedForAReason()
Definition Thread.cpp:519
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:2186
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:613
void ClearScriptedFrameProvider()
Definition Thread.cpp:1681
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:1239
bool ShouldRunBeforePublicStop()
Definition Thread.h:1263
virtual Status StepOver(bool source_step, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Default implementation for stepping over.
Definition Thread.cpp:2268
bool ShouldResume(lldb::StateType resume_state)
Definition Thread.cpp:701
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:1438
void ClearBackedThread()
Definition Thread.h:516
std::unique_ptr< ThreadPlanStack > m_null_plan_stack_up
Definition Thread.h:1442
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:1249
void SetDefaultFileAndLineToSelectedFrame()
Definition Thread.h:490
virtual lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame)=0
virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state)
Definition Thread.cpp:521
void SetState(lldb::StateType state)
Definition Thread.cpp:588
uint32_t GetSelectedFrameIndex(SelectMostRelevant select_most_relevant)
Definition Thread.h:470
llvm::Error LoadScriptedFrameProvider(const ScriptedFrameProviderDescriptor &descriptor)
Definition Thread.cpp:1611
int GetResumeSignal() const
Definition Thread.h:163
lldb::ProcessSP GetProcess() const
Definition Thread.h:161
lldb::StackFrameSP CalculateStackFrame() override
Definition Thread.cpp:1453
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:1332
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
Definition Thread.cpp:294
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:1417
lldb::StopInfoSP m_stop_info_sp
The private stop reason for this thread.
Definition Thread.h:1381
std::mutex m_provider_frames_mutex
Per-host-thread stack of active provider input frames.
Definition Thread.h:1420
lldb::ProcessWP m_process_wp
The process that owns this thread.
Definition Thread.h:1380
void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format)
Definition Thread.cpp:1923
LazyBool m_override_should_notify
Definition Thread.h:1441
lldb::ThreadSP CalculateThread() override
Definition Thread.cpp:1451
Status ReturnFromFrameWithIndex(uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
Definition Thread.cpp:1734
virtual Status StepOut(uint32_t frame_idx=0)
Default implementation for stepping out.
Definition Thread.cpp:2301
virtual llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > GetSiginfo(size_t max_size) const
Definition Thread.h:1375
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:1332
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:582
lldb::StateType m_state
The state of our process.
Definition Thread.h:1399
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:1427
bool m_extended_info_fetched
Definition Thread.h:1466
void CalculatePublicStopInfo()
Definition Thread.cpp:395
virtual lldb_private::StructuredData::ObjectSP FetchThreadExtendedInfo()
Definition Thread.h:1364
virtual void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t)
Definition Thread.h:387
static void SettingsTerminate()
Definition Thread.cpp:1944
lldb::ThreadWP m_backed_thread
The Thread backed by this thread, if any.
Definition Thread.h:1445
bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast=false)
Definition Thread.cpp:303
virtual lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id)
Definition Thread.h:460
lldb::StopReason GetStopReason()
Definition Thread.cpp:456
virtual void SetName(const char *name)
Definition Thread.h:291
ThreadPlanStack & GetPlans() const
Definition Thread.cpp:1116
lldb::ValueObjectSP GetSiginfoValue()
Definition Thread.cpp:2356
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:1296
uint32_t m_stop_info_override_stop_id
Definition Thread.h:1386
int m_resume_signal
The signal that should be used when continuing this thread.
Definition Thread.h:1428
bool IsValid() const
Definition Thread.h:1192
virtual void DidResume()
Definition Thread.cpp:772
bool StopInfoIsUpToDate() const
Definition Thread.cpp:463
lldb::StackFrameSP GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr)
Definition Thread.cpp:1980
llvm::DenseMap< lldb::frame_list_id_t, lldb::SyntheticFrameProviderSP > m_frame_providers
Map from frame list ID to its frame provider.
Definition Thread.h:1450
lldb::ThreadPlanSP GetCompletedPlan() const
Gets the outer-most plan that was popped off the plan stack in the most recent stop.
Definition Thread.cpp:1183
lldb::ValueObjectSP GetCurrentException()
Definition Thread.cpp:2325
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:1375
virtual lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx)
Definition Thread.cpp:1730
bool ShouldStop(Event *event_ptr)
Definition Thread.cpp:780
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
Definition Thread.cpp:1841
friend class StackFrameList
Definition Thread.h:1331
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:1901
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:1251
void FrameSelectedCallback(lldb_private::StackFrame *frame)
Definition Thread.cpp:348
lldb::ThreadPlanSP QueueBasePlan(bool abort_other_plans)
Queues the base plan for a thread.
Definition Thread.cpp:1290
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:67
virtual uint64_t GetExtendedBacktraceToken()
Gets the extended backtrace token for this thread.
Definition Thread.h:1283
virtual uint32_t GetExtendedBacktraceOriginatingIndexID()
Definition Thread.h:1156
uint32_t GetCurrentInlinedDepth()
Definition Thread.h:445
llvm::DenseMap< HostThread, std::vector< lldb::StackFrameListSP > > m_active_frame_providers_by_thread
Definition Thread.h:1422
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:1305
std::string GetStopDescription()
Definition Thread.cpp:593
StructuredData::ObjectSP m_extended_info
Definition Thread.h:1468
lldb::StopInfoSP GetStopInfo()
Definition Thread.cpp:362
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:1459
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:1433
lldb::StackFrameListSP GetStackFrameList()
Definition Thread.cpp:1491
bool m_should_run_before_public_stop
Definition Thread.h:1389
Vote ShouldReportStop(Event *event_ptr)
Definition Thread.cpp:1019
bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx, Stream &output_stream)
Definition Thread.cpp:315
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:1455
lldb::StateType m_resume_state
This state is used to force a thread to be suspended from outside the ThreadPlan logic.
Definition Thread.h:1430
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:2232
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:2038
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
Definition Thread.h:1397
lldb::StackFrameListSP m_unwinder_frames_sp
The unwinder frame list (ID 0).
Definition Thread.h:1405
friend class ThreadList
Definition Thread.h:1329
#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