From 018c5191bfc13be1c002f4fff64b572a031a4a7a Mon Sep 17 00:00:00 2001 From: nahi Date: Sat, 23 Feb 2002 09:40:58 +0000 Subject: 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 --- lib/debug.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'lib/debug.rb') 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) -- cgit v1.2.3