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