class DEBUGGER__::FrameInfo
Constants
- BLOCK_LABL_REGEXP
- HOME
Public Instance Methods
block_identifier()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 84 def block_identifier return unless frame_type == :block args = parameters_info(iseq.argc) _, level, block_loc = location.label.match(BLOCK_LABL_REGEXP).to_a [level || "", block_loc, args] end
c_identifier()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 98 def c_identifier return unless frame_type == :c "[C] #{klass_sig}#{location.base_label}" end
callee()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 108 def callee self._callee ||= self.binding&.eval('__callee__') end
eval_binding()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 122 def eval_binding if b = self.dupped_binding b else b = TOPLEVEL_BINDING unless b = self.binding b = self.binding || TOPLEVEL_BINDING self.dupped_binding = b.dup end end
file_lines()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 64 def file_lines SESSION.source(self.iseq) end
frame_type()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 68 def frame_type if self.local_variables && iseq if iseq.type == :block :block elsif callee :method else :other end else :c end end
local_variables()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 132 def local_variables if lvars = self._local_variables lvars elsif b = self.binding b.local_variables.map{|var| [var, b.local_variable_get(var)] }.to_h end end
location_str()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 118 def location_str "#{pretty_path}:#{location.lineno}" end
method_identifier()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 91 def method_identifier return unless frame_type == :method args = parameters_info(iseq.argc) ci = "#{klass_sig}#{callee}" [ci, args] end
name()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 48 def name # p frame_type: frame_type, self: self case frame_type when :block level, block_loc, _args = block_identifier "block in #{block_loc}#{level}" when :method ci, _args = method_identifier "#{ci}" when :c c_identifier when :other other_identifier end end
other_identifier()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 103 def other_identifier return unless frame_type == :other location.label end
path()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 22 def path location.path end
pretty_path()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 30 def pretty_path return '#<none>' unless path = self.path use_short_path = CONFIG[:use_short_path] case when use_short_path && path.start_with?(dir = RbConfig::CONFIG["rubylibdir"] + '/') path.sub(dir, '$(rubylibdir)/') when use_short_path && Gem.path.any? do |gp| path.start_with?(dir = gp + '/gems/') end path.sub(dir, '$(Gem)/') when HOME && path.start_with?(HOME) path.sub(HOME, '~/') else path end end
realpath()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 26 def realpath location.absolute_path end
return_str()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 112 def return_str if self.binding && iseq && has_return_value DEBUGGER__.safe_inspect(return_value, short: true) end end
Private Instance Methods
get_singleton_class(obj)
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 144 def get_singleton_class obj obj.singleton_class # TODO: don't use it rescue TypeError nil end
klass_sig()
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 165 def klass_sig if self.class == get_singleton_class(self.self) "#{self.self}." else "#{self.class}#" end end
local_variable_get(var)
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 150 def local_variable_get var local_variables[var] end
parameters_info(argc)
click to toggle source
# File debug-1.4.0/lib/debug/frame_info.rb, line 154 def parameters_info(argc) vars = iseq.locals[0...argc] vars.map{|var| begin { name: var, value: DEBUGGER__.safe_inspect(local_variable_get(var), short: true) } rescue NameError, TypeError nil end }.compact end