1 //===-- SBThread.h ----------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLDB_SBThreadPlan_h_
11 #define LLDB_SBThreadPlan_h_
12 
13 #include "lldb/API/SBDefines.h"
14 
15 #include <stdio.h>
16 
17 namespace lldb {
18 
19 class LLDB_API SBThreadPlan {
20 
21   friend class lldb_private::ThreadPlan;
22 
23 public:
24   SBThreadPlan();
25 
26   SBThreadPlan(const lldb::SBThreadPlan &threadPlan);
27 
28   SBThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp);
29 
30   SBThreadPlan(lldb::SBThread &thread, const char *class_name);
31 
32   ~SBThreadPlan();
33 
34   bool IsValid() const;
35 
36   void Clear();
37 
38   lldb::StopReason GetStopReason();
39 
40   /// Get the number of words associated with the stop reason.
41   /// See also GetStopReasonDataAtIndex().
42   size_t GetStopReasonDataCount();
43 
44   //--------------------------------------------------------------------------
45   /// Get information associated with a stop reason.
46   ///
47   /// Breakpoint stop reasons will have data that consists of pairs of
48   /// breakpoint IDs followed by the breakpoint location IDs (they always come
49   /// in pairs).
50   ///
51   /// Stop Reason              Count Data Type
52   /// ======================== ===== =========================================
53   /// eStopReasonNone          0
54   /// eStopReasonTrace         0
55   /// eStopReasonBreakpoint    N     duple: {breakpoint id, location id}
56   /// eStopReasonWatchpoint    1     watchpoint id
57   /// eStopReasonSignal        1     unix signal number
58   /// eStopReasonException     N     exception data
59   /// eStopReasonExec          0
60   /// eStopReasonPlanComplete  0
61   //--------------------------------------------------------------------------
62   uint64_t GetStopReasonDataAtIndex(uint32_t idx);
63 
64   SBThread GetThread() const;
65 
66   const lldb::SBThreadPlan &operator=(const lldb::SBThreadPlan &rhs);
67 
68   bool GetDescription(lldb::SBStream &description) const;
69 
70   void SetPlanComplete(bool success);
71 
72   bool IsPlanComplete();
73 
74   bool IsPlanStale();
75 
76   bool IsValid();
77 
78   // This section allows an SBThreadPlan to push another of the common types of
79   // plans...
80   SBThreadPlan QueueThreadPlanForStepOverRange(SBAddress &start_address,
81                                                lldb::addr_t range_size);
82   SBThreadPlan QueueThreadPlanForStepOverRange(SBAddress &start_address,
83                                                lldb::addr_t range_size,
84                                                SBError &error);
85 
86   SBThreadPlan QueueThreadPlanForStepInRange(SBAddress &start_address,
87                                              lldb::addr_t range_size);
88   SBThreadPlan QueueThreadPlanForStepInRange(SBAddress &start_address,
89                                              lldb::addr_t range_size,
90                                              SBError &error);
91 
92   SBThreadPlan QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
93                                          bool first_insn = false);
94   SBThreadPlan QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
95                                          bool first_insn, SBError &error);
96 
97   SBThreadPlan QueueThreadPlanForRunToAddress(SBAddress address);
98   SBThreadPlan QueueThreadPlanForRunToAddress(SBAddress address,
99                                               SBError &error);
100 
101   SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name);
102   SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name,
103                                               SBError &error);
104 
105 #ifndef SWIG
106   lldb_private::ThreadPlan *get();
107 #endif
108 
109 protected:
110   friend class SBBreakpoint;
111   friend class SBBreakpointLocation;
112   friend class SBFrame;
113   friend class SBProcess;
114   friend class SBDebugger;
115   friend class SBValue;
116   friend class lldb_private::QueueImpl;
117   friend class SBQueueItem;
118 
119 #ifndef SWIG
120   void SetThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp);
121 #endif
122 
123 private:
124   lldb::ThreadPlanSP m_opaque_sp;
125 };
126 
127 } // namespace lldb
128 
129 #endif // LLDB_SBThreadPlan_h_
130