Module: Debugger::FrameFunctions

Included in:
DownCommand, FrameCommand, UpCommand, WhereCommand
Defined in:
lib/ruby-debug/commands/frame.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#adjust_frame(frame_pos, absolute) ⇒ Object



3
4
5
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
# File 'lib/ruby-debug/commands/frame.rb', line 3

def adjust_frame(frame_pos, absolute)
  if absolute
    if frame_pos < 0
      abs_frame_pos = @state.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 >= @state.context.stack_size then
    print "Adjusting would put us beyond the oldest (initial) frame.\n"
    return
  elsif abs_frame_pos < 0 then
    print "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 format_frame(@state.frame_pos)
end

#format_frame(pos) ⇒ Object



41
42
43
44
45
# File 'lib/ruby-debug/commands/frame.rb', line 41

def format_frame(pos)
  printf "\032\032" if ENV['EMACS']
  file, line, id = @state.context.frame_file(pos), @state.context.frame_line(pos), @state.context.frame_id(pos)
  "#%d %s:%s%s\n" % [pos, file, line, (id ? ":in `#{id.id2name}'" : "")]
end

#get_int(str, cmd) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/ruby-debug/commands/frame.rb', line 32

def get_int(str, cmd)
  begin
    return Integer(@match[1])
  rescue
    print "%s argument needs to be a number.\n" % cmd
    return nil
  end
end