Module: Byebug::FrameFunctions
- Defined in:
- lib/byebug/commands/frame.rb
Overview
Mix-in module to assist in command parsing.
Instance Method Summary collapse
- #adjust_frame(frame_pos, absolute, context = @state.context) ⇒ Object
- #get_frame_call(prefix, pos) ⇒ Object
- #print_backtrace ⇒ Object
- #print_frame(pos, mark_current = true) ⇒ Object
Instance Method Details
#adjust_frame(frame_pos, absolute, context = @state.context) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/byebug/commands/frame.rb', line 6 def adjust_frame(frame_pos, absolute, context=@state.context) @state.frame_pos = 0 if context != @state.context if absolute if frame_pos < 0 abs_frame_pos = context.stack_size + frame_pos else abs_frame_pos = frame_pos end else abs_frame_pos = @state.frame_pos + frame_pos end if abs_frame_pos >= context.stack_size then return \ errmsg "Adjusting would put us beyond the oldest (initial) frame.\n" elsif abs_frame_pos < 0 then return \ errmsg "Adjusting would put us beyond the newest (innermost) frame.\n" return end if @state.frame_pos != abs_frame_pos then @state.previous_line = nil @state.frame_pos = abs_frame_pos end @state.file = @state.context.frame_file @state.frame_pos @state.line = @state.context.frame_line @state.frame_pos print_frame @state.frame_pos, false end |
#get_frame_call(prefix, pos) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/byebug/commands/frame.rb', line 38 def get_frame_call(prefix, pos) id = @state.context.frame_method(pos) return "<main>" unless id klass = @state.context.frame_class(pos) if Command.settings[:callstyle] != :short && klass call_str = "#{klass}.#{id.id2name}" else call_str = "#{id.id2name}" end args = @state.context.frame_args pos locals = @state.context.frame_locals pos if args.any? call_str += "(" args.each_with_index do |name, i| case Command.settings[:callstyle] when :short call_str += "#{name}, " when :last klass = locals[name].class if klass.inspect.size > 20 + 3 klass = klass.inspect[0..20] + "..." end call_str += "#{name}##{klass}, " when :tracked arg_info = context.frame_args_info pos if arg_info && arg_info.size > i call_str += "#{name}: #{arg_info[i].inspect}, " else call_str += "#{name}, " end end if call_str.size > Command.settings[:width] - prefix.size # Strip off trailing ', ' if any but add stuff for later trunc call_str[-2..-1] = ",...XX" break end end call_str[-2..-1] = ")" # Strip off trailing ', ' if any end return call_str end |
#print_backtrace ⇒ Object
83 84 85 86 87 |
# File 'lib/byebug/commands/frame.rb', line 83 def print_backtrace (0...@state.context.stack_size).each do |idx| print_frame(idx) end end |
#print_frame(pos, mark_current = true) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/byebug/commands/frame.rb', line 89 def print_frame(pos, mark_current = true) file = @state.context.frame_file pos line = @state.context.frame_line pos unless Command.settings[:frame_fullpath] path_components = file.split(/[\\\/]/) if path_components.size > 3 path_components[0...-3] = '...' file = path_components.join(File::ALT_SEPARATOR || File::SEPARATOR) end end if mark_current frame_str = (pos == @state.frame_pos) ? "--> " : " " else frame_str = "" end frame_str += sprintf "#%-2d ", pos frame_str += get_frame_call frame_str, pos file_line = "at #{CommandProcessor.canonic_file(file)}:#{line}" if frame_str.size + file_line.size + 1 > Command.settings[:width] frame_str += "\n #{file_line}\n" else frame_str += " #{file_line}\n" end print frame_str end |