rbx-trepanning 0.0.1-universal-rubinius
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +376 -0
- data/LICENSE +25 -0
- data/NEWS +2 -0
- data/README.textile +28 -0
- data/Rakefile +165 -0
- data/THANKS +14 -0
- data/app/breakpoint.rb +218 -0
- data/app/breakpoint.rbc +3564 -0
- data/app/brkptmgr.rb +138 -0
- data/app/brkptmgr.rbc +2827 -0
- data/app/default.rb +61 -0
- data/app/default.rbc +1011 -0
- data/app/display.rb +35 -0
- data/app/display.rbc +968 -0
- data/app/frame.rb +98 -0
- data/app/frame.rbc +1808 -0
- data/app/irb.rb +112 -0
- data/app/irb.rbc +2111 -0
- data/app/iseq.rb +95 -0
- data/app/iseq.rbc +1801 -0
- data/app/method.rb +173 -0
- data/app/method.rbc +2492 -0
- data/app/mock.rb +13 -0
- data/app/mock.rbc +398 -0
- data/app/options.rb +123 -0
- data/app/options.rbc +2183 -0
- data/app/run.rb +86 -0
- data/app/run.rbc +1244 -0
- data/app/util.rb +49 -0
- data/app/util.rbc +1144 -0
- data/app/validate.rb +30 -0
- data/app/validate.rbc +676 -0
- data/bin/trepan.compiled.rbc +1043 -0
- data/bin/trepanx +63 -0
- data/bin/trepanx.compiled.rbc +985 -0
- data/interface/base_intf.rb +95 -0
- data/interface/base_intf.rbc +1742 -0
- data/interface/script.rb +104 -0
- data/interface/script.rbc +1642 -0
- data/interface/user.rb +91 -0
- data/interface/user.rbc +1418 -0
- data/io/base_io.rb +94 -0
- data/io/base_io.rbc +1404 -0
- data/io/input.rb +112 -0
- data/io/input.rbc +1979 -0
- data/io/null_output.rb +42 -0
- data/io/null_output.rbc +730 -0
- data/io/string_array.rb +156 -0
- data/io/string_array.rbc +2466 -0
- data/lib/trepanning.rb +398 -0
- data/lib/trepanning.rbc +6661 -0
- data/processor/breakpoint.rb +161 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +46 -0
- data/processor/command/base/cmd.rb +124 -0
- data/processor/command/base/subcmd.rb +213 -0
- data/processor/command/base/submgr.rb +179 -0
- data/processor/command/base/subsubcmd.rb +103 -0
- data/processor/command/base/subsubmgr.rb +184 -0
- data/processor/command/break.rb +100 -0
- data/processor/command/continue.rb +82 -0
- data/processor/command/delete.rb +30 -0
- data/processor/command/directory.rb +43 -0
- data/processor/command/disassemble.rb +103 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/eval.rb +31 -0
- data/processor/command/exit.rb +58 -0
- data/processor/command/finish.rb +78 -0
- data/processor/command/frame.rb +89 -0
- data/processor/command/help.rb +146 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/breakpoints.rb +75 -0
- data/processor/command/info_subcmd/file.rb +153 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +59 -0
- data/processor/command/info_subcmd/variables.rb +40 -0
- data/processor/command/irb.rb +96 -0
- data/processor/command/kill.rb +70 -0
- data/processor/command/list.rb +296 -0
- data/processor/command/next.rb +66 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/pr.rb +38 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +28 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -0
- data/processor/command/set_subcmd/basename.rb +26 -0
- data/processor/command/set_subcmd/debug.rb +27 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
- data/processor/command/set_subcmd/different.rb +60 -0
- data/processor/command/set_subcmd/hidelevel.rb +63 -0
- data/processor/command/set_subcmd/kernelstep.rb +61 -0
- data/processor/command/set_subcmd/max.rb +29 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +54 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/substitute.rb +25 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
- data/processor/command/show.rb +27 -0
- data/processor/command/show_subcmd/alias.rb +43 -0
- data/processor/command/show_subcmd/args.rb +26 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
- data/processor/command/show_subcmd/basename.rb +22 -0
- data/processor/command/show_subcmd/debug.rb +27 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
- data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
- data/processor/command/show_subcmd/different.rb +27 -0
- data/processor/command/show_subcmd/hidelevel.rb +42 -0
- data/processor/command/show_subcmd/kernelstep.rb +37 -0
- data/processor/command/show_subcmd/max.rb +30 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
- data/processor/command/show_subcmd/trace.rb +29 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/source.rb +83 -0
- data/processor/command/step.rb +41 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/up.rb +87 -0
- data/processor/default.rb +56 -0
- data/processor/disassemble.rb +32 -0
- data/processor/eval.rb +96 -0
- data/processor/frame.rb +211 -0
- data/processor/help.rb +72 -0
- data/processor/hook.rb +133 -0
- data/processor/load_cmds.rb +101 -0
- data/processor/location.rb +128 -0
- data/processor/main.rb +394 -0
- data/processor/mock.rb +137 -0
- data/processor/msg.rb +28 -0
- data/processor/running.rb +230 -0
- data/processor/stepping.rb +115 -0
- data/processor/subcmd.rb +160 -0
- data/processor/validate.rb +355 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +1 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +0 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-xx.rb +18 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/gcd1.rb +24 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/fn_helper.rb +112 -0
- data/test/functional/test-break-name.rb +52 -0
- data/test/functional/test-break.rb +51 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +55 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-step.rb +272 -0
- data/test/functional/test-step2.rb +35 -0
- data/test/functional/test-tbreak.rb +41 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +78 -0
- data/test/integration/test-fname-with-blank.rb +12 -0
- data/test/integration/test-quit.rb +25 -0
- data/test/unit/cmd-helper.rb +46 -0
- data/test/unit/test-app-brkpt.rb +30 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-iseq.rb +49 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +61 -0
- data/test/unit/test-app-run.rb +16 -0
- data/test/unit/test-app-util.rb +28 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-subcmd.rb +61 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +49 -0
- data/test/unit/test-cmd-break.rb +23 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-help.rb +101 -0
- data/test/unit/test-cmd-kill.rb +48 -0
- data/test/unit/test-intf-user.rb +46 -0
- data/test/unit/test-io-input.rb +27 -0
- data/test/unit/test-proc-eval.rb +37 -0
- data/test/unit/test-proc-frame.rb +79 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-load_cmds.rb +41 -0
- data/test/unit/test-proc-location.rb +48 -0
- data/test/unit/test-proc-main.rb +96 -0
- data/test/unit/test-proc-validate.rb +91 -0
- data/test/unit/test-subcmd-help.rb +51 -0
- metadata +337 -0
data/app/method.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
module Trepanning
|
3
|
+
module Method
|
4
|
+
|
5
|
+
## FIXME: until the next two routines find their way back into
|
6
|
+
## Rubinius::CompiledMethod...
|
7
|
+
##
|
8
|
+
# Locates the instruction address (IP) of the first instruction on
|
9
|
+
# the specified line if is in CompiledMethod cm only, or nil if no
|
10
|
+
# match for the specified line is found.
|
11
|
+
#
|
12
|
+
# @return [Fixnum, NilClass] returns
|
13
|
+
# nil if nothing is found, else the first IP for the line
|
14
|
+
def locate_line_in_cm(line, cm=self)
|
15
|
+
cm.lines.each_with_index do |l, i|
|
16
|
+
next unless (i&1 == 1)
|
17
|
+
if (l == line)
|
18
|
+
# Found target line - return first IP
|
19
|
+
return cm.lines[i-1]
|
20
|
+
elsif l > line
|
21
|
+
return nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
return nil
|
25
|
+
end
|
26
|
+
module_function :locate_line_in_cm
|
27
|
+
|
28
|
+
## FIXME: Try using Routine in Rubinius now.
|
29
|
+
##
|
30
|
+
# Locates the CompiledMethod and instruction address (IP) of the
|
31
|
+
# first instruction on the specified line. This method recursively
|
32
|
+
# examines child compiled methods until an exact match for the
|
33
|
+
# searched line is found. It returns both the matching
|
34
|
+
# CompiledMethod and the IP of the first instruction on the
|
35
|
+
# requested line, or nil if no match for the specified line is
|
36
|
+
# found.
|
37
|
+
#
|
38
|
+
# @return [(Rubinius::CompiledMethod, Fixnum), NilClass] returns
|
39
|
+
# nil if nothing is found, else an array of size 2 containing the method
|
40
|
+
# the line was found in and the IP pointing there.
|
41
|
+
def locate_line(line, cm=self)
|
42
|
+
## p [cm, lines_of_method(cm)]
|
43
|
+
ip = locate_line_in_cm(line, cm)
|
44
|
+
return cm, ip if ip
|
45
|
+
|
46
|
+
# Didn't find line in this CM, so check if a contained
|
47
|
+
# CM encompasses the line searched for
|
48
|
+
cm.child_methods.each do |child|
|
49
|
+
if res = locate_line(line, child)
|
50
|
+
return res
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# No child method is a match - fail
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
module_function :locate_line
|
58
|
+
|
59
|
+
def lines_of_method(cm)
|
60
|
+
lines = []
|
61
|
+
cm.lines.each_with_index do |l, i|
|
62
|
+
lines << l if (i&1 == 1)
|
63
|
+
end
|
64
|
+
return lines
|
65
|
+
end
|
66
|
+
module_function :lines_of_method
|
67
|
+
|
68
|
+
# Return true if ip is the start of some instruction in meth.
|
69
|
+
# FIXME: be more stringent.
|
70
|
+
def valid_ip?(cm, ip)
|
71
|
+
size = cm.lines.size
|
72
|
+
ip >= 0 && ip < cm.lines[size-1]
|
73
|
+
end
|
74
|
+
module_function :valid_ip?
|
75
|
+
|
76
|
+
# Returns a CompiledMethod for the specified line. We search the
|
77
|
+
# current method +meth+ and then up the parent scope. If we hit
|
78
|
+
# the top and we can't find +line+ that way, then we
|
79
|
+
# reverse the search from the top and search down. This will add
|
80
|
+
# all siblings of ancestors of +meth+.
|
81
|
+
def find_method_with_line(cm, line)
|
82
|
+
unless cm.kind_of?(Rubinius::CompiledMethod)
|
83
|
+
return nil
|
84
|
+
end
|
85
|
+
|
86
|
+
lines = lines_of_method(cm)
|
87
|
+
## p ['++++1', cm, lines]
|
88
|
+
return cm if lines.member?(line)
|
89
|
+
scope = cm.scope
|
90
|
+
return nil unless scope.current_script
|
91
|
+
cm = scope.current_script.compiled_method
|
92
|
+
lines = lines_of_method(cm)
|
93
|
+
## p ['++++2', cm, lines]
|
94
|
+
until lines.member?(line) do
|
95
|
+
child = scope
|
96
|
+
scope = scope.parent
|
97
|
+
unless scope
|
98
|
+
# child is the top-most scope. Search down from here.
|
99
|
+
cm = child.current_script.compiled_method
|
100
|
+
pair = locate_line(line, cm)
|
101
|
+
## pair = cm.locate_line(line)
|
102
|
+
return pair ? pair[0] : nil
|
103
|
+
end
|
104
|
+
cm = scope.current_script.compiled_method
|
105
|
+
lines = lines_of_method(cm)
|
106
|
+
## p ['++++3', cm, lines]
|
107
|
+
end
|
108
|
+
return cm
|
109
|
+
end
|
110
|
+
module_function :find_method_with_line
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
module Rubinius
|
116
|
+
|
117
|
+
class Location
|
118
|
+
def next_ip
|
119
|
+
ip_on_current? ? ip : ip + 1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class CompiledMethod < Executable
|
124
|
+
##
|
125
|
+
# Returns the address (IP) of the first instruction in this
|
126
|
+
# CompiledMethod that is on the specified line but not before the
|
127
|
+
# given, or the address of the first instruction on the next code
|
128
|
+
# line after the specified line if there are no instructions on
|
129
|
+
# the requested line. This method only looks at instructions
|
130
|
+
# within the current CompiledMethod; see #locate_line for an
|
131
|
+
# alternate method that also searches inside the child
|
132
|
+
# CompiledMethods.
|
133
|
+
|
134
|
+
#
|
135
|
+
# @return [Fixnum] the address of the first instruction
|
136
|
+
def first_ip_on_line_after(line, start_ip)
|
137
|
+
i = 0
|
138
|
+
last_i = @lines.size - 1
|
139
|
+
while i < last_i
|
140
|
+
ip = @lines.at(i)
|
141
|
+
cur_line = @lines.at(i+1)
|
142
|
+
if cur_line >= line and ip >= start_ip
|
143
|
+
return ip
|
144
|
+
end
|
145
|
+
i += 2
|
146
|
+
end
|
147
|
+
-1
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
if __FILE__ == $0
|
154
|
+
include Trepanning::Method
|
155
|
+
require "#{File.dirname(__FILE__)}/../lib/trepanning"
|
156
|
+
|
157
|
+
line = __LINE__
|
158
|
+
def find_line(line) # :nodoc
|
159
|
+
cm = Rubinius::VM.backtrace(0)[0].method
|
160
|
+
p lines_of_method(cm)
|
161
|
+
p find_method_with_line(cm, line)
|
162
|
+
end
|
163
|
+
|
164
|
+
cm = Rubinius::VM.backtrace(0)[0].method
|
165
|
+
p lines_of_method(cm)
|
166
|
+
find_line(line)
|
167
|
+
p find_method_with_line(cm, line+2)
|
168
|
+
ip = locate_line( __LINE__, cm)[1]
|
169
|
+
puts "Line #{__LINE__} has ip #{ip}"
|
170
|
+
[-1, 0, 10, ip, 10000].each do |i|
|
171
|
+
puts "IP #{i} is %svalid" % (valid_ip?(cm, i) ? '' : 'not ')
|
172
|
+
end
|
173
|
+
end
|