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