From 3196645aee3add70a33f3d926d1d6e3820d39377 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 15 Oct 1999 08:52:18 +0000 Subject: -r debug, -s, etc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/debug.rb | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'lib/debug.rb') diff --git a/lib/debug.rb b/lib/debug.rb index d2f1da83ff..1209f60ee2 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -1,3 +1,5 @@ +LINES__ = {} unless defined? LINES__ + class DEBUGGER__ begin require 'readline' @@ -24,7 +26,6 @@ class DEBUGGER__ @frames = [nil] @last_file = nil @last = [nil, nil] - @scripts = {} end DEBUG_LAST_CMD = [] @@ -206,7 +207,7 @@ class DEBUGGER__ previus_line = b STDOUT.printf "[%d, %d] in %s\n", b, e, binding_file line_at(binding_file, binding_line) - if lines = @scripts[binding_file] and lines != true + if lines = LINES__[binding_file] and lines != true n = 0 b.upto(e) do |n| if n > 0 && lines[n-1] @@ -289,26 +290,14 @@ class DEBUGGER__ end def line_at(file, line) - lines = @scripts[file] + lines = LINES__[file] if lines return "\n" if lines == true line = lines[line-1] return "\n" unless line return line end - save = $DEBUG - begin - $DEBUG = false - f = open(file) - lines = @scripts[file] = f.readlines - rescue - $DEBUG = save - @scripts[file] = true - return "\n" - end - line = lines[line-1] - return "\n" unless line - return line + return "\n" end def debug_funcname(id) @@ -396,8 +385,9 @@ class DEBUGGER__ end CONTEXT = new -end -set_trace_func proc{|event, file, line, id, binding,*rest| - DEBUGGER__::CONTEXT.trace_func event, file, line, id, binding -} + + set_trace_func proc{|event, file, line, id, binding,*rest| + DEBUGGER__::CONTEXT.trace_func event, file, line, id, binding + } +end -- cgit v1.2.3