Class: LLDB::Thread
- Inherits:
-
Object
- Object
- LLDB::Thread
- Includes:
- NativeLifecycle
- Defined in:
- lib/lldb/thread.rb
Instance Attribute Summary collapse
- #process ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
- #frame_at_index(index) ⇒ Object
- #frames ⇒ Object
- #get_process ⇒ Object
- #index_id ⇒ Object
-
#initialize(ptr, process:, context: process.context) ⇒ Thread
constructor
A new instance of Thread.
- #name ⇒ Object
- #num_frames ⇒ Object
- #queue_name ⇒ Object
- #resume ⇒ Object
- #run_to_address(address) ⇒ Object
- #select_frame(index) ⇒ Object
- #selected_frame ⇒ Object
- #step_instruction(step_over: false) ⇒ Object
- #step_into(target_name: nil, end_line: INVALID_LINE_NUMBER, run_mode: RunMode::ONLY_DURING_STEPPING) ⇒ Object
- #step_out ⇒ Object
- #step_over(run_mode: RunMode::ONLY_DURING_STEPPING) ⇒ Object
- #stop_description(max_size = 256) ⇒ Object
- #stop_reason ⇒ Object
- #stop_reason_data ⇒ Object
- #stop_reason_data_at_index(index) ⇒ Object
- #stop_reason_data_count ⇒ Object
- #stop_reason_name ⇒ Object
- #stopped? ⇒ Boolean
- #stopped_at_breakpoint? ⇒ Boolean
- #suspend ⇒ Object
- #suspended? ⇒ Boolean
- #thread_id ⇒ Object (also: #id)
- #to_ptr ⇒ Object
- #valid? ⇒ Boolean
Methods included from NativeLifecycle
#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object
Constructor Details
#initialize(ptr, process:, context: process.context) ⇒ Thread
Returns a new instance of Thread.
15 16 17 18 19 20 21 22 |
# File 'lib/lldb/thread.rb', line 15 def initialize(ptr, process:, context: process.context) @process = process initialize_native_object( ptr, release: ->(released) { FFIBindings.lldb_thread_destroy(released) }, context: context ) end |
Instance Attribute Details
#process ⇒ Object (readonly)
10 11 12 |
# File 'lib/lldb/thread.rb', line 10 def process @process end |
Class Method Details
.release(ptr) ⇒ Object
26 27 28 |
# File 'lib/lldb/thread.rb', line 26 def self.release(ptr) ->(_id) { FFIBindings.lldb_thread_destroy(ptr) unless ptr.null? } end |
Instance Method Details
#frame_at_index(index) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/lldb/thread.rb', line 99 def frame_at_index(index) raise InvalidObjectError, 'Thread is not valid' unless valid? frame_ptr = FFIBindings.lldb_thread_get_frame_at_index(@ptr, index) return nil if frame_ptr.nil? || frame_ptr.null? Frame.new(frame_ptr, thread: self, context: context) end |
#frames ⇒ Object
127 128 129 |
# File 'lib/lldb/thread.rb', line 127 def frames (0...num_frames).map { |i| frame_at_index(i) }.compact end |
#get_process ⇒ Object
249 250 251 252 253 254 255 256 |
# File 'lib/lldb/thread.rb', line 249 def get_process raise InvalidObjectError, 'Thread is not valid' unless valid? process_ptr = FFIBindings.lldb_thread_get_process(@ptr) return nil if process_ptr.nil? || process_ptr.null? Process.new(process_ptr, target: @process.target, context: context) end |
#index_id ⇒ Object
196 197 198 199 200 |
# File 'lib/lldb/thread.rb', line 196 def index_id return 0 unless valid? FFIBindings.lldb_thread_get_index_id(@ptr) end |
#name ⇒ Object
141 142 143 144 145 |
# File 'lib/lldb/thread.rb', line 141 def name return nil unless valid? FFIBindings.lldb_thread_get_name(@ptr) end |
#num_frames ⇒ Object
91 92 93 94 95 |
# File 'lib/lldb/thread.rb', line 91 def num_frames return 0 unless valid? FFIBindings.lldb_thread_get_num_frames(@ptr) end |
#queue_name ⇒ Object
203 204 205 206 207 |
# File 'lib/lldb/thread.rb', line 203 def queue_name return nil unless valid? FFIBindings.lldb_thread_get_queue_name(@ptr) end |
#resume ⇒ Object
242 243 244 245 246 |
# File 'lib/lldb/thread.rb', line 242 def resume raise InvalidObjectError, 'Thread is not valid' unless valid? FFIBindings.lldb_thread_resume(@ptr) != 0 end |
#run_to_address(address) ⇒ Object
186 187 188 189 190 191 192 193 |
# File 'lib/lldb/thread.rb', line 186 def run_to_address(address) raise InvalidObjectError, 'Thread is not valid' unless valid? error = Error.new status = FFIBindings.lldb_thread_run_to_address(@ptr, address, error.to_ptr) Native.check_status!(status, 'thread.run_to_address', error) true end |
#select_frame(index) ⇒ Object
120 121 122 123 124 |
# File 'lib/lldb/thread.rb', line 120 def select_frame(index) raise InvalidObjectError, 'Thread is not valid' unless valid? FFIBindings.lldb_thread_set_selected_frame(@ptr, index) != 0 end |
#selected_frame ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/lldb/thread.rb', line 109 def selected_frame raise InvalidObjectError, 'Thread is not valid' unless valid? frame_ptr = FFIBindings.lldb_thread_get_selected_frame(@ptr) return nil if frame_ptr.nil? || frame_ptr.null? Frame.new(frame_ptr, thread: self, context: context) end |
#step_instruction(step_over: false) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/lldb/thread.rb', line 80 def step_instruction(step_over: false) raise InvalidObjectError, 'Thread is not valid' unless valid? APISupport.require_method!(:lldb_thread_step_instruction, 'step_instruction') error = Error.new status = FFIBindings.lldb_thread_step_instruction(@ptr, step_over ? 1 : 0, error.to_ptr) Native.check_status!(status, 'thread.step_instruction', error) true end |
#step_into(target_name: nil, end_line: INVALID_LINE_NUMBER, run_mode: RunMode::ONLY_DURING_STEPPING) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lldb/thread.rb', line 51 def step_into(target_name: nil, end_line: INVALID_LINE_NUMBER, run_mode: RunMode::ONLY_DURING_STEPPING) raise InvalidObjectError, 'Thread is not valid' unless valid? APISupport.require_method!(:lldb_thread_step_into, 'step_into') error = Error.new status = FFIBindings.lldb_thread_step_into( @ptr, target_name, end_line, run_mode, error.to_ptr ) Native.check_status!(status, 'thread.step_into', error) true end |
#step_out ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/lldb/thread.rb', line 68 def step_out raise InvalidObjectError, 'Thread is not valid' unless valid? APISupport.require_method!(:lldb_thread_step_out, 'step_out') error = Error.new status = FFIBindings.lldb_thread_step_out(@ptr, error.to_ptr) Native.check_status!(status, 'thread.step_out', error) true end |
#step_over(run_mode: RunMode::ONLY_DURING_STEPPING) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/lldb/thread.rb', line 37 def step_over(run_mode: RunMode::ONLY_DURING_STEPPING) raise InvalidObjectError, 'Thread is not valid' unless valid? APISupport.require_method!(:lldb_thread_step_over, 'step_over') error = Error.new status = FFIBindings.lldb_thread_step_over(@ptr, run_mode, error.to_ptr) Native.check_status!(status, 'thread.step_over', error) true end |
#stop_description(max_size = 256) ⇒ Object
211 212 213 214 215 216 217 218 |
# File 'lib/lldb/thread.rb', line 211 def stop_description(max_size = 256) return nil unless valid? return '' if max_size.zero? NativeBuffer.read_c_string(max_size: max_size) do |buffer, length| FFIBindings.lldb_thread_get_stop_description(@ptr, buffer, length) end end |
#stop_reason ⇒ Object
148 149 150 151 152 |
# File 'lib/lldb/thread.rb', line 148 def stop_reason return StopReason::INVALID unless valid? FFIBindings.lldb_thread_get_stop_reason(@ptr) end |
#stop_reason_data ⇒ Object
180 181 182 |
# File 'lib/lldb/thread.rb', line 180 def stop_reason_data (0...stop_reason_data_count).map { |i| stop_reason_data_at_index(i) } end |
#stop_reason_data_at_index(index) ⇒ Object
173 174 175 176 177 |
# File 'lib/lldb/thread.rb', line 173 def stop_reason_data_at_index(index) raise InvalidObjectError, 'Thread is not valid' unless valid? FFIBindings.lldb_thread_get_stop_reason_data_at_index(@ptr, index) end |
#stop_reason_data_count ⇒ Object
165 166 167 168 169 |
# File 'lib/lldb/thread.rb', line 165 def stop_reason_data_count return 0 unless valid? FFIBindings.lldb_thread_get_stop_reason_data_count(@ptr) end |
#stop_reason_name ⇒ Object
155 156 157 |
# File 'lib/lldb/thread.rb', line 155 def stop_reason_name StopReason.name(stop_reason) end |
#stopped? ⇒ Boolean
221 222 223 224 225 |
# File 'lib/lldb/thread.rb', line 221 def stopped? return false unless valid? FFIBindings.lldb_thread_is_stopped(@ptr) != 0 end |
#stopped_at_breakpoint? ⇒ Boolean
160 161 162 |
# File 'lib/lldb/thread.rb', line 160 def stopped_at_breakpoint? stop_reason == StopReason::BREAKPOINT end |
#suspend ⇒ Object
235 236 237 238 239 |
# File 'lib/lldb/thread.rb', line 235 def suspend raise InvalidObjectError, 'Thread is not valid' unless valid? FFIBindings.lldb_thread_suspend(@ptr) != 0 end |
#suspended? ⇒ Boolean
228 229 230 231 232 |
# File 'lib/lldb/thread.rb', line 228 def suspended? return false unless valid? FFIBindings.lldb_thread_is_suspended(@ptr) != 0 end |
#thread_id ⇒ Object Also known as: id
132 133 134 135 136 |
# File 'lib/lldb/thread.rb', line 132 def thread_id return 0 unless valid? FFIBindings.lldb_thread_get_thread_id(@ptr) end |
#to_ptr ⇒ Object
259 260 261 |
# File 'lib/lldb/thread.rb', line 259 def to_ptr @ptr end |
#valid? ⇒ Boolean
31 32 33 |
# File 'lib/lldb/thread.rb', line 31 def valid? !@ptr.null? && FFIBindings.lldb_thread_is_valid(@ptr) != 0 end |