BreakpointOptions.h revision 5bc7b67ccc8bb4a977d129e51313067dcbc7bb94
1//===-- BreakpointOptions.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 liblldb_BreakpointOptions_h_ 11#define liblldb_BreakpointOptions_h_ 12 13// C Includes 14// C++ Includes 15#include <memory> 16// Other libraries and framework includes 17// Project includes 18#include "lldb/lldb-private.h" 19#include "lldb/Core/Baton.h" 20#include "lldb/Core/StringList.h" 21 22namespace lldb_private { 23 24//---------------------------------------------------------------------- 25/// @class BreakpointOptions BreakpointOptions.h "lldb/Breakpoint/BreakpointOptions.h" 26/// @brief Class that manages the options on a breakpoint or breakpoint location. 27//---------------------------------------------------------------------- 28 29class BreakpointOptions 30{ 31public: 32 //------------------------------------------------------------------ 33 // Constructors and Destructors 34 //------------------------------------------------------------------ 35 //------------------------------------------------------------------ 36 /// Default constructor. The breakpoint is enabled, and has no condition, 37 /// callback, ignore count, etc... 38 //------------------------------------------------------------------ 39 BreakpointOptions(); 40 BreakpointOptions(const BreakpointOptions& rhs); 41 42 static BreakpointOptions * 43 CopyOptionsNoCallback (BreakpointOptions &rhs); 44 //------------------------------------------------------------------ 45 /// This constructor allows you to specify all the breakpoint options. 46 /// 47 /// @param[in] condition 48 /// The expression which if it evaluates to \b true if we are to stop 49 /// 50 /// @param[in] callback 51 /// This is the plugin for some code that gets run, returns \b true if we are to stop. 52 /// 53 /// @param[in] baton 54 /// Client data that will get passed to the callback. 55 /// 56 /// @param[in] enabled 57 /// Is this breakpoint enabled. 58 /// 59 /// @param[in] ignore 60 /// How many breakpoint hits we should ignore before stopping. 61 /// 62 /// @param[in] thread_id 63 /// Only stop if \a thread_id hits the breakpoint. 64 //------------------------------------------------------------------ 65 BreakpointOptions(void *condition, 66 BreakpointHitCallback callback, 67 void *baton, 68 bool enabled = true, 69 int32_t ignore = 0, 70 lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID); 71 72 virtual ~BreakpointOptions(); 73 74 //------------------------------------------------------------------ 75 // Operators 76 //------------------------------------------------------------------ 77 const BreakpointOptions& 78 operator=(const BreakpointOptions& rhs); 79 80 //------------------------------------------------------------------ 81 // Callbacks 82 //------------------------------------------------------------------ 83 void SetCallback (BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false); 84 bool InvokeCallback (StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id); 85 bool IsCallbackSynchronous () { 86 return m_callback_is_synchronous; 87 } 88 Baton *GetBaton (); 89 const Baton *GetBaton () const; 90 void ClearCallback (); 91 92 //------------------------------------------------------------------ 93 // Enabled/Ignore Count 94 //------------------------------------------------------------------ 95 96 //------------------------------------------------------------------ 97 /// Check the Enable/Disable state. 98 /// @return 99 /// \b true if the breakpoint is enabled, \b false if disabled. 100 //------------------------------------------------------------------ 101 bool 102 IsEnabled () const; 103 104 //------------------------------------------------------------------ 105 /// If \a enable is \b true, enable the breakpoint, if \b false disable it. 106 //------------------------------------------------------------------ 107 void 108 SetEnabled (bool enabled); 109 110 void 111 SetIgnoreCount (uint32_t n); 112 113 //------------------------------------------------------------------ 114 /// Return the current Ignore Count. 115 /// @return 116 /// The number of breakpoint hits to be ignored. 117 //------------------------------------------------------------------ 118 uint32_t 119 GetIgnoreCount () const; 120 121 //------------------------------------------------------------------ 122 /// Set the breakpoint to ignore the next \a count breakpoint hits. 123 /// @param[in] count 124 /// The number of breakpoint hits to ignore. 125 //------------------------------------------------------------------ 126 127 //------------------------------------------------------------------ 128 /// Return the current thread spec for this option. This will return NULL if the no thread 129 /// specifications have been set for this Option yet. 130 /// @return 131 /// The thread specification pointer for this option, or NULL if none has 132 /// been set yet. 133 //------------------------------------------------------------------ 134 const ThreadSpec * 135 GetThreadSpecNoCreate () const; 136 137 //------------------------------------------------------------------ 138 /// Returns a pointer to the ThreadSpec for this option, creating it. 139 /// if it hasn't been created already. This API is used for setting the 140 /// ThreadSpec items for this option. 141 //------------------------------------------------------------------ 142 ThreadSpec * 143 GetThreadSpec (); 144 145 void 146 SetThreadID(lldb::tid_t thread_id); 147 148 void 149 GetDescription (Stream *s, lldb::DescriptionLevel level) const; 150 151 //------------------------------------------------------------------ 152 /// Returns true if the breakpoint option has a callback set. 153 //------------------------------------------------------------------ 154 bool 155 HasCallback(); 156 157 //------------------------------------------------------------------ 158 /// This is the default empty callback. 159 /// @return 160 /// The thread id for which the breakpoint hit will stop, 161 /// LLDB_INVALID_THREAD_ID for all threads. 162 //------------------------------------------------------------------ 163 static bool 164 NullCallback (void *baton, 165 StoppointCallbackContext *context, 166 lldb::user_id_t break_id, 167 lldb::user_id_t break_loc_id); 168 169 170 struct CommandData 171 { 172 CommandData () : 173 user_source(), 174 script_source() 175 { 176 } 177 178 ~CommandData () 179 { 180 } 181 182 StringList user_source; 183 StringList script_source; 184 }; 185 186 class CommandBaton : public Baton 187 { 188 public: 189 CommandBaton (CommandData *data) : 190 Baton (data) 191 { 192 } 193 194 virtual 195 ~CommandBaton () 196 { 197 delete ((CommandData *)m_data); 198 m_data = NULL; 199 } 200 201 virtual void 202 GetDescription (Stream *s, lldb::DescriptionLevel level) const; 203 204 }; 205 206protected: 207 //------------------------------------------------------------------ 208 // Classes that inherit from BreakpointOptions can see and modify these 209 //------------------------------------------------------------------ 210 211private: 212 //------------------------------------------------------------------ 213 // For BreakpointOptions only 214 //------------------------------------------------------------------ 215 BreakpointHitCallback m_callback; // This is the callback function pointer 216 lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback 217 bool m_callback_is_synchronous; 218 bool m_enabled; 219 uint32_t m_ignore_count; // Number of times to ignore this breakpoint 220 std::auto_ptr<ThreadSpec> m_thread_spec_ap; // Thread for which this breakpoint will take 221 222}; 223 224} // namespace lldb_private 225 226#endif // liblldb_BreakpointOptions_h_ 227