aboutsummaryrefslogtreecommitdiffstats
path: root/lib/debug.rb
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-23 09:40:58 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-23 09:40:58 +0000
commit018c5191bfc13be1c002f4fff64b572a031a4a7a (patch)
tree30f78387d3b63d24e332fb52c70c62222d550466 /lib/debug.rb
parentd80b8cd59eea063deb82b28abf7fd94f4ad0d432 (diff)
downloadruby-018c5191bfc13be1c002f4fff64b572a031a4a7a.tar.gz
Refactoring. Added Context#format_frame to format a frame, used by up/down
command and Context#display_frames. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/debug.rb')
-rw-r--r--lib/debug.rb29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/debug.rb b/lib/debug.rb
index b9703ed7de..b69e7f9913 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -450,7 +450,7 @@ class DEBUGGER__
stdout.print "At toplevel\n"
end
binding, binding_file, binding_line = @frames[frame_pos]
- stdout.printf "#%d %s:%s\n", frame_pos+1, binding_file, binding_line
+ stdout.print format_frame(frame_pos)
when /^\s*down(?:\s+(\d+))?$/
previous_line = nil
@@ -465,7 +465,7 @@ class DEBUGGER__
stdout.print "At stack bottom\n"
end
binding, binding_file, binding_line = @frames[frame_pos]
- stdout.printf "#%d %s:%s\n", frame_pos+1, binding_file, binding_line
+ stdout.print format_frame(frame_pos)
when /^\s*fin(?:ish)?$/
if frame_pos == @frames.size
@@ -596,20 +596,22 @@ EOHELP
end
def display_frames(pos)
- pos += 1
- n = 0
- at = @frames
- for bind, file, line, id in at
- n += 1
- break unless bind
- if pos == n
- stdout.printf "--> #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
- else
- stdout.printf " #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
- end
+ 0.upto(@frames.size - 1) do |n|
+ if n == pos
+ stdout.print "--> "
+ else
+ stdout.print " "
+ end
+ stdout.print format_frame(n)
end
end
+ def format_frame(pos)
+ bind, file, line, id = @frames[pos]
+ sprintf "#%d %s:%s%s\n", pos + 1, file, line,
+ (id ? ":in `#{id.id2name}'" : "")
+ end
+
def display_list(b, e, file, line)
stdout.printf "[%d, %d] in %s\n", b, e, file
if lines = SCRIPT_LINES__[file] and lines != true
@@ -778,6 +780,7 @@ EOHELP
context(th[0]).set_trace arg
end
Thread.critical = false
+ arg
end
def set_last_thread(th)