diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-10-15 08:52:18 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-10-15 08:52:18 +0000 |
commit | 3196645aee3add70a33f3d926d1d6e3820d39377 (patch) | |
tree | 326561008f8512e3560810077a2505da6aa6d082 /lib | |
parent | 826f10c6ce5cf11ba57f47f58384f4da58806c35 (diff) |
-r debug, -s, etc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/debug.rb | 30 | ||||
-rw-r--r-- | lib/tracer.rb | 9 |
2 files changed, 15 insertions, 24 deletions
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 diff --git a/lib/tracer.rb b/lib/tracer.rb index a8dc2a104d..095173e53b 100644 --- a/lib/tracer.rb +++ b/lib/tracer.rb @@ -40,7 +40,6 @@ class Tracer end @get_line_procs = {} - @sources = {} @filters = [] end @@ -79,17 +78,17 @@ class Tracer return p.call line end - unless list = @sources[file] + unless list = LINES__[file] # print file if $DEBUG begin f = open(file) begin - @sources[file] = list = f.readlines + LINES__[file] = list = f.readlines ensure f.close end rescue - @sources[file] = list = [] + LINES__[file] = list = [] end end if l = list[line - 1] @@ -148,6 +147,8 @@ class Tracer end +LINES__ = {} unless defined? LINES__ + if caller(0).size == 1 if $0 == Tracer::MY_FILE_NAME # direct call |