Class: Thread
- Defined in:
- lib/maglev-database-explorer/database_views/thread.rb
Instance Method Summary collapse
- #__basetype ⇒ Object
- #__exception ⇒ Object
- #__set_exception(exception) ⇒ Object
- #__source_offset_for(frame, level) ⇒ Object
- #__source_with_break_for(frame) ⇒ Object
- #__stack_frame(index) ⇒ Object
- #__stack_method_names ⇒ Object
- #__step_over_at(frame) ⇒ Object
- #__xy_position_in_string(string, offset) ⇒ Object
- #to_database_view(depth, ranges = {}, params = {}) ⇒ Object
Instance Method Details
#__basetype ⇒ Object
2 3 4 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 2 def __basetype :thread end |
#__exception ⇒ Object
34 35 36 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 34 def __exception self[:last_exception] end |
#__set_exception(exception) ⇒ Object
30 31 32 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 30 def __set_exception(exception) self[:last_exception] = exception end |
#__source_offset_for(frame, level) ⇒ Object
47 48 49 50 51 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 47 def __source_offset_for(frame, level) # (frame at: 1) _sourceOffsetsAt: ((frame at: 1) _previousStepPointForIp: (frame at: 2)) method = frame[0] method.__source_offsets_at(method.__step_point_for_ip(frame[1], level, __is_native_stack)) end |
#__source_with_break_for(frame) ⇒ Object
53 54 55 56 57 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 53 def __source_with_break_for(frame) # (frame at: 1) _sourceOffsetsAt: ((frame at: 1) _previousStepPointForIp: (frame at: 2)) method = frame[0] method.__source_at_ip(frame[1]) end |
#__stack_frame(index) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 73 def __stack_frame(index) frame = __local_frame_contents_at(index) arg_values = [] (10..frame.size - 1).each do |idx| arg_values.push(frame[idx].to_database_view(1, {}, {})) end method = frame[0] source_offset = __source_offset_for(frame, index) source_string = method.__source_string # magic numbers copied from GsProcess # [GsNMethod, ipOffset, frameOffset, varContext (nil), saveProtectionMode, markerOrException, nil (not used), self, argAndTempNames, receiver, args and temps, source offset, x-y source offset... [GsNMethodProxy.for(method).__for_database_explorer, frame[1], frame[2], nil, frame[4], frame[5].to_database_view(1, {}, {}), nil, frame[7].to_database_view(1, {}, {}), frame[8], frame[9].to_database_view(1, {}, {}), arg_values, source_offset, __xy_position_in_string(source_string, source_offset), __source_with_break_for(frame)] end |
#__stack_method_names ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 90 def __stack_method_names methods = [] (1..__local_stack_depth).each do |idx| method = __local_method_at(idx) methods.push(method.__description_for_stack) if method != nil # TODO: why do we need to check for nil here? end methods end |
#__step_over_at(frame) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 38 def __step_over_at(frame) thread = Thread.start(self) do |debug_thread| Thread.pass debug_thread.__step_over_in_frame(frame) end sleep 0.1 unless thread.stop? end |
#__xy_position_in_string(string, offset) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 59 def __xy_position_in_string(string, offset) substr = string[0, offset] y = substr.count("\n") x = nil if substr[-1] == "\n" x = 0 else x = substr.split("\n").last.size - 1 end return [x, y] end |
#to_database_view(depth, ranges = {}, params = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/maglev-database-explorer/database_views/thread.rb', line 6 def to_database_view(depth, ranges = {}, params = {}) obj = super if depth > 0 obj[:exception] = __exception.to_database_view(depth - 1, {}, {}) obj[:threadLocalStorage] = __environment.to_database_view(1, {}, {}) obj[:threadLocalStorageSize] = __environment ? __environment.size : -1 obj[:isRailsThread] = self[:is_rails_thread] ? true : false obj[:status] = self.status.to_s end return obj end |