rbx-trepanning 0.0.1-universal-rubinius

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/ChangeLog +376 -0
  2. data/LICENSE +25 -0
  3. data/NEWS +2 -0
  4. data/README.textile +28 -0
  5. data/Rakefile +165 -0
  6. data/THANKS +14 -0
  7. data/app/breakpoint.rb +218 -0
  8. data/app/breakpoint.rbc +3564 -0
  9. data/app/brkptmgr.rb +138 -0
  10. data/app/brkptmgr.rbc +2827 -0
  11. data/app/default.rb +61 -0
  12. data/app/default.rbc +1011 -0
  13. data/app/display.rb +35 -0
  14. data/app/display.rbc +968 -0
  15. data/app/frame.rb +98 -0
  16. data/app/frame.rbc +1808 -0
  17. data/app/irb.rb +112 -0
  18. data/app/irb.rbc +2111 -0
  19. data/app/iseq.rb +95 -0
  20. data/app/iseq.rbc +1801 -0
  21. data/app/method.rb +173 -0
  22. data/app/method.rbc +2492 -0
  23. data/app/mock.rb +13 -0
  24. data/app/mock.rbc +398 -0
  25. data/app/options.rb +123 -0
  26. data/app/options.rbc +2183 -0
  27. data/app/run.rb +86 -0
  28. data/app/run.rbc +1244 -0
  29. data/app/util.rb +49 -0
  30. data/app/util.rbc +1144 -0
  31. data/app/validate.rb +30 -0
  32. data/app/validate.rbc +676 -0
  33. data/bin/trepan.compiled.rbc +1043 -0
  34. data/bin/trepanx +63 -0
  35. data/bin/trepanx.compiled.rbc +985 -0
  36. data/interface/base_intf.rb +95 -0
  37. data/interface/base_intf.rbc +1742 -0
  38. data/interface/script.rb +104 -0
  39. data/interface/script.rbc +1642 -0
  40. data/interface/user.rb +91 -0
  41. data/interface/user.rbc +1418 -0
  42. data/io/base_io.rb +94 -0
  43. data/io/base_io.rbc +1404 -0
  44. data/io/input.rb +112 -0
  45. data/io/input.rbc +1979 -0
  46. data/io/null_output.rb +42 -0
  47. data/io/null_output.rbc +730 -0
  48. data/io/string_array.rb +156 -0
  49. data/io/string_array.rbc +2466 -0
  50. data/lib/trepanning.rb +398 -0
  51. data/lib/trepanning.rbc +6661 -0
  52. data/processor/breakpoint.rb +161 -0
  53. data/processor/command/alias.rb +55 -0
  54. data/processor/command/backtrace.rb +46 -0
  55. data/processor/command/base/cmd.rb +124 -0
  56. data/processor/command/base/subcmd.rb +213 -0
  57. data/processor/command/base/submgr.rb +179 -0
  58. data/processor/command/base/subsubcmd.rb +103 -0
  59. data/processor/command/base/subsubmgr.rb +184 -0
  60. data/processor/command/break.rb +100 -0
  61. data/processor/command/continue.rb +82 -0
  62. data/processor/command/delete.rb +30 -0
  63. data/processor/command/directory.rb +43 -0
  64. data/processor/command/disassemble.rb +103 -0
  65. data/processor/command/down.rb +54 -0
  66. data/processor/command/eval.rb +31 -0
  67. data/processor/command/exit.rb +58 -0
  68. data/processor/command/finish.rb +78 -0
  69. data/processor/command/frame.rb +89 -0
  70. data/processor/command/help.rb +146 -0
  71. data/processor/command/info.rb +28 -0
  72. data/processor/command/info_subcmd/breakpoints.rb +75 -0
  73. data/processor/command/info_subcmd/file.rb +153 -0
  74. data/processor/command/info_subcmd/method.rb +71 -0
  75. data/processor/command/info_subcmd/program.rb +59 -0
  76. data/processor/command/info_subcmd/variables.rb +40 -0
  77. data/processor/command/irb.rb +96 -0
  78. data/processor/command/kill.rb +70 -0
  79. data/processor/command/list.rb +296 -0
  80. data/processor/command/next.rb +66 -0
  81. data/processor/command/nexti.rb +59 -0
  82. data/processor/command/pr.rb +38 -0
  83. data/processor/command/ps.rb +40 -0
  84. data/processor/command/restart.rb +60 -0
  85. data/processor/command/set.rb +47 -0
  86. data/processor/command/set_subcmd/auto.rb +28 -0
  87. data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
  88. data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
  89. data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
  90. data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -0
  91. data/processor/command/set_subcmd/basename.rb +26 -0
  92. data/processor/command/set_subcmd/debug.rb +27 -0
  93. data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
  94. data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
  95. data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
  96. data/processor/command/set_subcmd/different.rb +60 -0
  97. data/processor/command/set_subcmd/hidelevel.rb +63 -0
  98. data/processor/command/set_subcmd/kernelstep.rb +61 -0
  99. data/processor/command/set_subcmd/max.rb +29 -0
  100. data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
  101. data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
  102. data/processor/command/set_subcmd/max_subcmd/string.rb +54 -0
  103. data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
  104. data/processor/command/set_subcmd/substitute.rb +25 -0
  105. data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
  106. data/processor/command/set_subcmd/trace.rb +37 -0
  107. data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
  108. data/processor/command/show.rb +27 -0
  109. data/processor/command/show_subcmd/alias.rb +43 -0
  110. data/processor/command/show_subcmd/args.rb +26 -0
  111. data/processor/command/show_subcmd/auto.rb +28 -0
  112. data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
  113. data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -0
  114. data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
  115. data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
  116. data/processor/command/show_subcmd/basename.rb +22 -0
  117. data/processor/command/show_subcmd/debug.rb +27 -0
  118. data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
  119. data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
  120. data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
  121. data/processor/command/show_subcmd/different.rb +27 -0
  122. data/processor/command/show_subcmd/hidelevel.rb +42 -0
  123. data/processor/command/show_subcmd/kernelstep.rb +37 -0
  124. data/processor/command/show_subcmd/max.rb +30 -0
  125. data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
  126. data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
  127. data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
  128. data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
  129. data/processor/command/show_subcmd/trace.rb +29 -0
  130. data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
  131. data/processor/command/source.rb +83 -0
  132. data/processor/command/step.rb +41 -0
  133. data/processor/command/tbreak.rb +19 -0
  134. data/processor/command/unalias.rb +44 -0
  135. data/processor/command/up.rb +87 -0
  136. data/processor/default.rb +56 -0
  137. data/processor/disassemble.rb +32 -0
  138. data/processor/eval.rb +96 -0
  139. data/processor/frame.rb +211 -0
  140. data/processor/help.rb +72 -0
  141. data/processor/hook.rb +133 -0
  142. data/processor/load_cmds.rb +101 -0
  143. data/processor/location.rb +128 -0
  144. data/processor/main.rb +394 -0
  145. data/processor/mock.rb +137 -0
  146. data/processor/msg.rb +28 -0
  147. data/processor/running.rb +230 -0
  148. data/processor/stepping.rb +115 -0
  149. data/processor/subcmd.rb +160 -0
  150. data/processor/validate.rb +355 -0
  151. data/test/data/enable.right +36 -0
  152. data/test/data/fname-with-blank.cmd +6 -0
  153. data/test/data/fname-with-blank.right +1 -0
  154. data/test/data/quit-Xdebug.right +3 -0
  155. data/test/data/quit.cmd +5 -0
  156. data/test/data/quit.right +0 -0
  157. data/test/example/fname with blank.rb +1 -0
  158. data/test/example/gcd-xx.rb +18 -0
  159. data/test/example/gcd.rb +19 -0
  160. data/test/example/gcd1.rb +24 -0
  161. data/test/example/null.rb +1 -0
  162. data/test/example/thread1.rb +3 -0
  163. data/test/functional/fn_helper.rb +112 -0
  164. data/test/functional/test-break-name.rb +52 -0
  165. data/test/functional/test-break.rb +51 -0
  166. data/test/functional/test-finish.rb +70 -0
  167. data/test/functional/test-fn_helper.rb +43 -0
  168. data/test/functional/test-list.rb +55 -0
  169. data/test/functional/test-next-bug.rb +49 -0
  170. data/test/functional/test-next.rb +101 -0
  171. data/test/functional/test-step.rb +272 -0
  172. data/test/functional/test-step2.rb +35 -0
  173. data/test/functional/test-tbreak.rb +41 -0
  174. data/test/integration/file-diff.rb +89 -0
  175. data/test/integration/helper.rb +78 -0
  176. data/test/integration/test-fname-with-blank.rb +12 -0
  177. data/test/integration/test-quit.rb +25 -0
  178. data/test/unit/cmd-helper.rb +46 -0
  179. data/test/unit/test-app-brkpt.rb +30 -0
  180. data/test/unit/test-app-brkptmgr.rb +51 -0
  181. data/test/unit/test-app-iseq.rb +49 -0
  182. data/test/unit/test-app-method.rb +54 -0
  183. data/test/unit/test-app-options.rb +61 -0
  184. data/test/unit/test-app-run.rb +16 -0
  185. data/test/unit/test-app-util.rb +28 -0
  186. data/test/unit/test-app-validate.rb +18 -0
  187. data/test/unit/test-base-subcmd.rb +61 -0
  188. data/test/unit/test-bin-trepanx.rb +48 -0
  189. data/test/unit/test-cmd-alias.rb +49 -0
  190. data/test/unit/test-cmd-break.rb +23 -0
  191. data/test/unit/test-cmd-exit.rb +27 -0
  192. data/test/unit/test-cmd-help.rb +101 -0
  193. data/test/unit/test-cmd-kill.rb +48 -0
  194. data/test/unit/test-intf-user.rb +46 -0
  195. data/test/unit/test-io-input.rb +27 -0
  196. data/test/unit/test-proc-eval.rb +37 -0
  197. data/test/unit/test-proc-frame.rb +79 -0
  198. data/test/unit/test-proc-help.rb +16 -0
  199. data/test/unit/test-proc-hook.rb +30 -0
  200. data/test/unit/test-proc-load_cmds.rb +41 -0
  201. data/test/unit/test-proc-location.rb +48 -0
  202. data/test/unit/test-proc-main.rb +96 -0
  203. data/test/unit/test-proc-validate.rb +91 -0
  204. data/test/unit/test-subcmd-help.rb +51 -0
  205. metadata +337 -0
data/app/breakpoint.rb ADDED
@@ -0,0 +1,218 @@
1
+ module Trepanning
2
+ class Breakpoint
3
+
4
+ attr_accessor :condition # If non-nil, this is a String to be eval'd
5
+ # which must be true to enter the debugger
6
+ attr_reader :event # Symbol. Optional type of event associated with
7
+ # breakpoint.
8
+ attr_accessor :hits # Fixnum. The number of timea a breakpoint
9
+ # has been hit (with a true condition). Do
10
+ # we want to (also) record hits independent
11
+ # of the condition?
12
+ attr_reader :id # Fixnum. Name of breakpoint
13
+
14
+ @@next_id = 1
15
+
16
+ BRKPT_DEFAULT_SETTINGS = {
17
+ :condition => 'true',
18
+ :enabled => 'true',
19
+ :temp => false,
20
+ :event => :Unknown,
21
+ } unless defined?(BRKPT_DEFAULT_SETTINGS)
22
+
23
+ def self.for_ip(exec, ip, opts={})
24
+ name = opts[:name] || :anon
25
+ line = exec.line_from_ip(ip)
26
+
27
+ Breakpoint.new(name, exec, ip, line, nil, opts)
28
+ end
29
+
30
+ def initialize(name, method, ip, line, id=nil, opts = {})
31
+ @descriptor = name
32
+ @id = id
33
+ @method = method
34
+ @ip = ip
35
+ @line = line
36
+
37
+ # If not nil, is a Rubinius::VariableScope. This is what we
38
+ # check to have call-frame-specific breakpoints.
39
+ @scope = nil
40
+
41
+ @related_bp = []
42
+
43
+ opts = BRKPT_DEFAULT_SETTINGS.merge(opts)
44
+ opts.keys.each do |key|
45
+ self.instance_variable_set('@'+key.to_s, opts[key])
46
+ end
47
+
48
+ @hits = 0
49
+ # unless @id
50
+ # @id = @@next_id
51
+ # @@next_id += 1
52
+ # end
53
+
54
+ @set = false
55
+ end
56
+
57
+ attr_reader :method, :ip, :line, :descriptor
58
+ attr_accessor :related_bp
59
+
60
+ def scoped!(scope, temp = true)
61
+ @temp = temp
62
+ @scope = scope
63
+ end
64
+
65
+ def set_temp!
66
+ @temp = true
67
+ end
68
+
69
+ def scoped?
70
+ !!@scope
71
+ end
72
+
73
+ def related_with(bp)
74
+ @related_bp += [bp] + bp.related_bp
75
+ @related_bp.uniq!
76
+ # List of related breakpoints should be shared.
77
+ bp.related_bp = @related_bp
78
+ end
79
+
80
+ def activate
81
+ @set = true
82
+ @method.set_breakpoint @ip, self
83
+ end
84
+
85
+ # Return true if the breakpoint is relevant. That is, the
86
+ # breakpoint is either not a scoped or it is scoped and test_scope
87
+ # matches the desired scope. We also remove the breakpoint and any
88
+ # related breakpoints if it was hit and temporary.
89
+ def hit!(test_scope)
90
+ return true unless @temp
91
+ return false if @scope && test_scope != @scope
92
+
93
+ @related_bp.each { |bp| bp.remove! }
94
+ remove!
95
+ return true
96
+ end
97
+
98
+ # def condition?(bind)
99
+ # if eval(@condition, bind)
100
+ # if @ignore > 0
101
+ # @ignore -= 1
102
+ # return false
103
+ # else
104
+ # @hits += 1
105
+ # return true
106
+ # end
107
+ # else
108
+ # return false
109
+ # end
110
+ # end
111
+
112
+ def delete!
113
+ remove!
114
+ end
115
+
116
+ def describe
117
+ "#{descriptor} - #{location}"
118
+ end
119
+
120
+ def disable
121
+ @enabled = false
122
+ end
123
+
124
+ def enabled
125
+ @enabled = true
126
+ end
127
+
128
+ def enabled=(bool)
129
+ @enabled = bool
130
+ end
131
+
132
+ def enabled?
133
+ @enabled
134
+ end
135
+
136
+ # Return a one-character "icon" giving the state of the breakpoint
137
+ # 't': temporary breakpoint
138
+ # 'B': enabled breakpoint
139
+ # 'b': disabled breakpoint
140
+ def icon_char
141
+ temp? ? 't' : (enabled? ? 'B' : 'b')
142
+ end
143
+
144
+ def location
145
+ "#{@method.active_path}:#{@line} (@#{ip})"
146
+ end
147
+
148
+ def remove!
149
+ return unless @set
150
+
151
+ @set = false
152
+ @method.clear_breakpoint(@ip)
153
+ end
154
+
155
+ def temp?
156
+ @temp
157
+ end
158
+
159
+ end
160
+
161
+ class DeferredBreakpoint
162
+ def initialize(debugger, frame, klass, which, name, line=nil, list=nil)
163
+ @debugger = debugger
164
+ @frame = frame
165
+ @klass_name = klass
166
+ @which = which
167
+ @name = name
168
+ @line = line
169
+ @list = list
170
+ end
171
+
172
+ def descriptor
173
+ "#{@klass_name}#{@which}#{@name}"
174
+ end
175
+
176
+ def resolve!
177
+ begin
178
+ klass = @frame.run(@klass_name)
179
+ rescue NameError
180
+ return false
181
+ end
182
+
183
+ begin
184
+ if @which == "#"
185
+ meth = klass.instance_method(@name)
186
+ else
187
+ meth = klass.method(@name)
188
+ end
189
+ rescue NameError
190
+ return false
191
+ end
192
+
193
+ @debugger.processor.msg "Resolved breakpoint for #{@klass_name}#{@which}#{@name}"
194
+
195
+ @debugger.processor.set_breakpoint_method descriptor, meth, @line
196
+
197
+ return true
198
+ end
199
+
200
+ def describe
201
+ "#{descriptor} - unknown location (deferred)"
202
+ end
203
+
204
+ def delete!
205
+ if @list
206
+ @list.delete self
207
+ end
208
+ end
209
+ end
210
+ end
211
+
212
+ if __FILE__ == $0
213
+ method = Rubinius::CompiledMethod.of_sender
214
+ bp = Trepanning::Breakpoint.new '<start>', method, 1, 2, 0
215
+ %w(describe location icon_char hits temp? enabled? condition).each do |field|
216
+ puts "#{field}: #{bp.send(field.to_sym)}"
217
+ end
218
+ end