diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-02-23 09:40:58 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-02-23 09:40:58 +0000 |
commit | ca3e1c748893dce33268ddde890a670a4feb36e6 (patch) | |
tree | 30f78387d3b63d24e332fb52c70c62222d550466 | |
parent | bdd5dabaebb5c82af81b472495e3bb1ac5fe66e2 (diff) | |
download | ruby-ca3e1c748893dce33268ddde890a670a4feb36e6.tar.gz ruby-ca3e1c748893dce33268ddde890a670a4feb36e6.tar.xz ruby-ca3e1c748893dce33268ddde890a670a4feb36e6.zip |
Refactoring. Added Context#format_frame to format a frame, used by up/down
command and Context#display_frames.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/debug.rb | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/debug.rb b/lib/debug.rb index b9703ed7d..b69e7f991 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) |