debug.rb: Fix debug listing
* lib/debug.rb (script_lines): get source lines from SCRIPT_LINES__ or read from the file. * lib/debug.rb (display_list): use script_lines instead of recursion. [Bug #8318] * lib/debug.rb (line_at): use script_lines same as display_list. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7dd8c1f20f
commit
181a4ea8c6
10
ChangeLog
10
ChangeLog
@ -1,4 +1,12 @@
|
|||||||
Thu Apr 25 01:18:55 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Apr 25 01:21:51 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/debug.rb (script_lines): get source lines from SCRIPT_LINES__ or
|
||||||
|
read from the file.
|
||||||
|
|
||||||
|
* lib/debug.rb (display_list): use script_lines instead of recursion.
|
||||||
|
[Bug #8318]
|
||||||
|
|
||||||
|
* lib/debug.rb (line_at): use script_lines same as display_list.
|
||||||
|
|
||||||
* lib/debug.rb (display_list): Fix debug listing when called from the
|
* lib/debug.rb (display_list): Fix debug listing when called from the
|
||||||
same file it has been required. patch by Dario Bertini <berdario AT
|
same file it has been required. patch by Dario Bertini <berdario AT
|
||||||
|
21
lib/debug.rb
21
lib/debug.rb
@ -752,8 +752,17 @@ EOHELP
|
|||||||
(id ? ":in `#{id.id2name}'" : "")
|
(id ? ":in `#{id.id2name}'" : "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def script_lines(file, line)
|
||||||
|
unless (lines = SCRIPT_LINES__[file]) and lines != true
|
||||||
|
Tracer::Single.get_line(file, line) if File.exist?(file)
|
||||||
|
lines = SCRIPT_LINES__[file]
|
||||||
|
lines = nil if lines == true
|
||||||
|
end
|
||||||
|
lines
|
||||||
|
end
|
||||||
|
|
||||||
def display_list(b, e, file, line)
|
def display_list(b, e, file, line)
|
||||||
if lines = SCRIPT_LINES__[file] and lines != true
|
if lines = script_lines(file, line)
|
||||||
stdout.printf "[%d, %d] in %s\n", b, e, file
|
stdout.printf "[%d, %d] in %s\n", b, e, file
|
||||||
b.upto(e) do |n|
|
b.upto(e) do |n|
|
||||||
if n > 0 && lines[n-1]
|
if n > 0 && lines[n-1]
|
||||||
@ -764,20 +773,14 @@ EOHELP
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif File.exists? file
|
|
||||||
Tracer::Single.get_line(file, line)
|
|
||||||
display_list(b, e, file, line)
|
|
||||||
else
|
else
|
||||||
stdout.printf "No sourcefile available for %s\n", file
|
stdout.printf "No sourcefile available for %s\n", file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def line_at(file, line)
|
def line_at(file, line)
|
||||||
lines = SCRIPT_LINES__[file]
|
lines = script_lines(file, line)
|
||||||
if lines
|
if lines and line = lines[line-1]
|
||||||
return "\n" if lines == true
|
|
||||||
line = lines[line-1]
|
|
||||||
return "\n" unless line
|
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
return "\n"
|
return "\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user