rbx-trepanning 0.2.0-universal-rubinius-2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (312) hide show
  1. data/.gitignore +7 -0
  2. data/ChangeLog +2967 -0
  3. data/LICENSE +25 -0
  4. data/Makefile +13 -0
  5. data/NEWS +105 -0
  6. data/README.textile +34 -0
  7. data/Rakefile +244 -0
  8. data/THANKS +14 -0
  9. data/app/.gitignore +2 -0
  10. data/app/breakpoint.rb +242 -0
  11. data/app/brkptmgr.rb +153 -0
  12. data/app/client.rb +71 -0
  13. data/app/cmd_parse.kpeg +242 -0
  14. data/app/cmd_parse.rb +209 -0
  15. data/app/cmd_parser.rb +2083 -0
  16. data/app/complete.rb +79 -0
  17. data/app/condition.rb +22 -0
  18. data/app/default.rb +71 -0
  19. data/app/display.rb +186 -0
  20. data/app/eventbuffer.rb +147 -0
  21. data/app/file.rb +24 -0
  22. data/app/frame.rb +120 -0
  23. data/app/irb.rb +113 -0
  24. data/app/iseq.rb +188 -0
  25. data/app/method.rb +178 -0
  26. data/app/mock.rb +13 -0
  27. data/app/options.rb +154 -0
  28. data/app/rbx-llvm.rb +163 -0
  29. data/app/run.rb +92 -0
  30. data/app/util.rb +99 -0
  31. data/app/validate.rb +30 -0
  32. data/bin/.gitignore +2 -0
  33. data/bin/trepanx +69 -0
  34. data/data/.gitignore +2 -0
  35. data/data/irbrc +41 -0
  36. data/interface/.gitignore +2 -0
  37. data/interface/client.rb +84 -0
  38. data/interface/comcodes.rb +20 -0
  39. data/interface/script.rb +112 -0
  40. data/interface/server.rb +147 -0
  41. data/interface/user.rb +158 -0
  42. data/interface.rb +109 -0
  43. data/io/.gitignore +3 -0
  44. data/io/input.rb +151 -0
  45. data/io/null_output.rb +46 -0
  46. data/io/string_array.rb +155 -0
  47. data/io/tcpclient.rb +129 -0
  48. data/io/tcpfns.rb +33 -0
  49. data/io/tcpserver.rb +141 -0
  50. data/io.rb +148 -0
  51. data/lib/.gitignore +2 -0
  52. data/lib/trepanning.rb +467 -0
  53. data/processor/.gitignore +3 -0
  54. data/processor/Makefile +7 -0
  55. data/processor/breakpoint.rb +167 -0
  56. data/processor/command/.gitignore +2 -0
  57. data/processor/command/alias.rb +65 -0
  58. data/processor/command/backtrace.rb +68 -0
  59. data/processor/command/base/.gitignore +2 -0
  60. data/processor/command/base/subcmd.rb +226 -0
  61. data/processor/command/base/submgr.rb +185 -0
  62. data/processor/command/base/subsubcmd.rb +125 -0
  63. data/processor/command/base/subsubmgr.rb +196 -0
  64. data/processor/command/break.rb +78 -0
  65. data/processor/command/complete.rb +39 -0
  66. data/processor/command/condition.rb +64 -0
  67. data/processor/command/continue.rb +61 -0
  68. data/processor/command/delete.rb +44 -0
  69. data/processor/command/directory.rb +51 -0
  70. data/processor/command/disable.rb +71 -0
  71. data/processor/command/disassemble.rb +180 -0
  72. data/processor/command/display.rb +84 -0
  73. data/processor/command/down.rb +54 -0
  74. data/processor/command/edit.rb +74 -0
  75. data/processor/command/enable.rb +43 -0
  76. data/processor/command/eval.rb +93 -0
  77. data/processor/command/exit.rb +83 -0
  78. data/processor/command/finish.rb +80 -0
  79. data/processor/command/frame.rb +93 -0
  80. data/processor/command/help/.gitignore +1 -0
  81. data/processor/command/help/README +10 -0
  82. data/processor/command/help/command.txt +58 -0
  83. data/processor/command/help/examples.txt +16 -0
  84. data/processor/command/help/filename.txt +40 -0
  85. data/processor/command/help/location.txt +37 -0
  86. data/processor/command/help/suffixes.txt +17 -0
  87. data/processor/command/help.rb +228 -0
  88. data/processor/command/info.rb +30 -0
  89. data/processor/command/info_subcmd/.gitignore +3 -0
  90. data/processor/command/info_subcmd/breakpoints.rb +103 -0
  91. data/processor/command/info_subcmd/files.rb +219 -0
  92. data/processor/command/info_subcmd/frame.rb +68 -0
  93. data/processor/command/info_subcmd/line.rb +75 -0
  94. data/processor/command/info_subcmd/locals.rb +22 -0
  95. data/processor/command/info_subcmd/macro.rb +62 -0
  96. data/processor/command/info_subcmd/method.rb +71 -0
  97. data/processor/command/info_subcmd/program.rb +51 -0
  98. data/processor/command/info_subcmd/ruby.rb +64 -0
  99. data/processor/command/info_subcmd/source.rb +75 -0
  100. data/processor/command/info_subcmd/stack.rb +25 -0
  101. data/processor/command/info_subcmd/variables.rb +35 -0
  102. data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
  103. data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
  104. data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
  105. data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
  106. data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
  107. data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
  108. data/processor/command/kill.rb +79 -0
  109. data/processor/command/list.rb +234 -0
  110. data/processor/command/macro.rb +86 -0
  111. data/processor/command/next.rb +67 -0
  112. data/processor/command/nexti.rb +59 -0
  113. data/processor/command/parsetree.rb +51 -0
  114. data/processor/command/pr.rb +37 -0
  115. data/processor/command/ps.rb +40 -0
  116. data/processor/command/restart.rb +60 -0
  117. data/processor/command/save.rb +58 -0
  118. data/processor/command/server.rb +72 -0
  119. data/processor/command/set.rb +47 -0
  120. data/processor/command/set_subcmd/.gitignore +2 -0
  121. data/processor/command/set_subcmd/abbrev.rb +25 -0
  122. data/processor/command/set_subcmd/auto.rb +33 -0
  123. data/processor/command/set_subcmd/auto_subcmd/.gitignore +2 -0
  124. data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
  125. data/processor/command/set_subcmd/auto_subcmd/eval.rb +53 -0
  126. data/processor/command/set_subcmd/auto_subcmd/irb.rb +33 -0
  127. data/processor/command/set_subcmd/auto_subcmd/list.rb +33 -0
  128. data/processor/command/set_subcmd/basename.rb +25 -0
  129. data/processor/command/set_subcmd/confirm.rb +24 -0
  130. data/processor/command/set_subcmd/debug.rb +26 -0
  131. data/processor/command/set_subcmd/debug_subcmd/.gitignore +2 -0
  132. data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
  133. data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
  134. data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
  135. data/processor/command/set_subcmd/different.rb +61 -0
  136. data/processor/command/set_subcmd/hidelevel.rb +62 -0
  137. data/processor/command/set_subcmd/highlight.rb +39 -0
  138. data/processor/command/set_subcmd/kernelstep.rb +60 -0
  139. data/processor/command/set_subcmd/max.rb +26 -0
  140. data/processor/command/set_subcmd/max_subcmd/.gitignore +2 -0
  141. data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
  142. data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
  143. data/processor/command/set_subcmd/max_subcmd/string.rb +76 -0
  144. data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
  145. data/processor/command/set_subcmd/reload.rb +42 -0
  146. data/processor/command/set_subcmd/substitute.rb +24 -0
  147. data/processor/command/set_subcmd/substitute_subcmd/.gitignore +3 -0
  148. data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
  149. data/processor/command/set_subcmd/timer.rb +58 -0
  150. data/processor/command/set_subcmd/trace.rb +37 -0
  151. data/processor/command/set_subcmd/trace_subcmd/.gitignore +2 -0
  152. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
  153. data/processor/command/set_subcmd/trace_subcmd/print.rb +41 -0
  154. data/processor/command/shell.rb +131 -0
  155. data/processor/command/show.rb +39 -0
  156. data/processor/command/show_subcmd/.gitignore +3 -0
  157. data/processor/command/show_subcmd/abbrev.rb +20 -0
  158. data/processor/command/show_subcmd/aliases.rb +46 -0
  159. data/processor/command/show_subcmd/args.rb +25 -0
  160. data/processor/command/show_subcmd/auto.rb +28 -0
  161. data/processor/command/show_subcmd/auto_subcmd/.gitignore +3 -0
  162. data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
  163. data/processor/command/show_subcmd/auto_subcmd/eval.rb +24 -0
  164. data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
  165. data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
  166. data/processor/command/show_subcmd/basename.rb +20 -0
  167. data/processor/command/show_subcmd/confirm.rb +18 -0
  168. data/processor/command/show_subcmd/debug.rb +26 -0
  169. data/processor/command/show_subcmd/debug_subcmd/.gitignore +3 -0
  170. data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
  171. data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
  172. data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
  173. data/processor/command/show_subcmd/different.rb +26 -0
  174. data/processor/command/show_subcmd/directories.rb +22 -0
  175. data/processor/command/show_subcmd/hidelevel.rb +41 -0
  176. data/processor/command/show_subcmd/highlight.rb +25 -0
  177. data/processor/command/show_subcmd/kernelstep.rb +34 -0
  178. data/processor/command/show_subcmd/max.rb +27 -0
  179. data/processor/command/show_subcmd/max_subcmd/.gitignore +2 -0
  180. data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
  181. data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
  182. data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
  183. data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
  184. data/processor/command/show_subcmd/reload.rb +18 -0
  185. data/processor/command/show_subcmd/timer.rb +18 -0
  186. data/processor/command/show_subcmd/trace.rb +27 -0
  187. data/processor/command/show_subcmd/trace_subcmd/.gitignore +2 -0
  188. data/processor/command/show_subcmd/trace_subcmd/buffer.rb +64 -0
  189. data/processor/command/show_subcmd/trace_subcmd/print.rb +23 -0
  190. data/processor/command/show_subcmd/version.rb +23 -0
  191. data/processor/command/source.rb +133 -0
  192. data/processor/command/step.rb +97 -0
  193. data/processor/command/tbreak.rb +20 -0
  194. data/processor/command/unalias.rb +49 -0
  195. data/processor/command/undisplay.rb +63 -0
  196. data/processor/command/up.rb +89 -0
  197. data/processor/command.rb +173 -0
  198. data/processor/default.rb +64 -0
  199. data/processor/disassemble.rb +59 -0
  200. data/processor/display.rb +53 -0
  201. data/processor/eval.rb +97 -0
  202. data/processor/eventbuf.rb +101 -0
  203. data/processor/frame.rb +265 -0
  204. data/processor/help.rb +94 -0
  205. data/processor/hook.rb +134 -0
  206. data/processor/list.rb +123 -0
  207. data/processor/load_cmds.rb +253 -0
  208. data/processor/location.rb +228 -0
  209. data/processor/mock.rb +138 -0
  210. data/processor/msg.rb +74 -0
  211. data/processor/running.rb +244 -0
  212. data/processor/stepping.rb +135 -0
  213. data/processor/subcmd.rb +136 -0
  214. data/processor/validate.rb +379 -0
  215. data/processor/virtual.rb +33 -0
  216. data/processor.rb +404 -0
  217. data/rbx-trepanning.gemspec +39 -0
  218. data/sample/.gitignore +2 -0
  219. data/sample/list-terminal-colors.rb +139 -0
  220. data/sample/rocky-dot-trepanxrc +14 -0
  221. data/sample/rocky-trepanx-colors.rb +46 -0
  222. data/test/data/.gitignore +1 -0
  223. data/test/data/enable.right +36 -0
  224. data/test/data/fname-with-blank.cmd +6 -0
  225. data/test/data/fname-with-blank.right +6 -0
  226. data/test/data/inline-call.cmd +6 -0
  227. data/test/data/inline-call.right +14 -0
  228. data/test/data/quit-Xdebug.right +3 -0
  229. data/test/data/quit.cmd +5 -0
  230. data/test/data/quit.right +3 -0
  231. data/test/data/quit2.cmd +6 -0
  232. data/test/data/quit2.right +3 -0
  233. data/test/example/.gitignore +2 -0
  234. data/test/example/debugger-stop.rb +16 -0
  235. data/test/example/factorial.rb +10 -0
  236. data/test/example/fname with blank.rb +1 -0
  237. data/test/example/gcd-server.rb +22 -0
  238. data/test/example/gcd.rb +19 -0
  239. data/test/example/goto2goto.rb +11 -0
  240. data/test/example/inline-call.rb +23 -0
  241. data/test/example/null.rb +1 -0
  242. data/test/example/thread1.rb +3 -0
  243. data/test/functional/.gitignore +3 -0
  244. data/test/functional/fn_helper.rb +112 -0
  245. data/test/functional/test-break-name.rb +52 -0
  246. data/test/functional/test-break.rb +85 -0
  247. data/test/functional/test-eval.rb +115 -0
  248. data/test/functional/test-finish.rb +70 -0
  249. data/test/functional/test-fn_helper.rb +43 -0
  250. data/test/functional/test-list.rb +56 -0
  251. data/test/functional/test-next-bug.rb +49 -0
  252. data/test/functional/test-next.rb +101 -0
  253. data/test/functional/test-recursive-bt.rb +94 -0
  254. data/test/functional/test-step.rb +272 -0
  255. data/test/functional/test-step2.rb +35 -0
  256. data/test/functional/test-tbreak.rb +41 -0
  257. data/test/integration/.gitignore +3 -0
  258. data/test/integration/file-diff.rb +89 -0
  259. data/test/integration/helper.rb +81 -0
  260. data/test/integration/test-fname-with-blank.rb +16 -0
  261. data/test/integration/test-inline-call.rb +20 -0
  262. data/test/integration/test-quit.rb +47 -0
  263. data/test/unit/.gitignore +3 -0
  264. data/test/unit/cmd-helper.rb +50 -0
  265. data/test/unit/mock-helper.rb +10 -0
  266. data/test/unit/test-app-brkpt.rb +31 -0
  267. data/test/unit/test-app-brkptmgr.rb +51 -0
  268. data/test/unit/test-app-cmd_parse.rb +97 -0
  269. data/test/unit/test-app-cmd_parser.rb +23 -0
  270. data/test/unit/test-app-complete.rb +39 -0
  271. data/test/unit/test-app-condition.rb +18 -0
  272. data/test/unit/test-app-display.rb +22 -0
  273. data/test/unit/test-app-iseq.rb +64 -0
  274. data/test/unit/test-app-method.rb +54 -0
  275. data/test/unit/test-app-options.rb +94 -0
  276. data/test/unit/test-app-run.rb +14 -0
  277. data/test/unit/test-app-util.rb +44 -0
  278. data/test/unit/test-app-validate.rb +18 -0
  279. data/test/unit/test-base-cmd.rb +45 -0
  280. data/test/unit/test-base-subcmd.rb +57 -0
  281. data/test/unit/test-base-submgr.rb +24 -0
  282. data/test/unit/test-base-subsubcmd.rb +17 -0
  283. data/test/unit/test-bin-trepanx.rb +48 -0
  284. data/test/unit/test-cmd-alias.rb +48 -0
  285. data/test/unit/test-cmd-break.rb +66 -0
  286. data/test/unit/test-cmd-edit.rb +34 -0
  287. data/test/unit/test-cmd-exit.rb +27 -0
  288. data/test/unit/test-cmd-finish.rb +31 -0
  289. data/test/unit/test-cmd-help.rb +104 -0
  290. data/test/unit/test-cmd-kill.rb +54 -0
  291. data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
  292. data/test/unit/test-cmd-source.rb +34 -0
  293. data/test/unit/test-cmd-step.rb +29 -0
  294. data/test/unit/test-command.rb +45 -0
  295. data/test/unit/test-completion.rb +48 -0
  296. data/test/unit/test-intf-user.rb +46 -0
  297. data/test/unit/test-io-input.rb +27 -0
  298. data/test/unit/test-io-tcp.rb +33 -0
  299. data/test/unit/test-io-tcpclient.rb +54 -0
  300. data/test/unit/test-io-tcpfns.rb +17 -0
  301. data/test/unit/test-io-tcpserver.rb +50 -0
  302. data/test/unit/test-proc-eval.rb +35 -0
  303. data/test/unit/test-proc-frame.rb +81 -0
  304. data/test/unit/test-proc-help.rb +16 -0
  305. data/test/unit/test-proc-hook.rb +30 -0
  306. data/test/unit/test-proc-list.rb +55 -0
  307. data/test/unit/test-proc-load_cmds.rb +51 -0
  308. data/test/unit/test-proc-location.rb +67 -0
  309. data/test/unit/test-proc-main.rb +95 -0
  310. data/test/unit/test-proc-validate.rb +139 -0
  311. data/test/unit/test-subcmd-help.rb +43 -0
  312. metadata +545 -0
@@ -0,0 +1,6 @@
1
+ -> (fname with blank.rb:1 @0)
2
+ puts "Ha!"
3
+ basename is off.
4
+ Ha!
5
+ trepanx: That's all, folks...
6
+ trepanx: That's all, folks...
@@ -0,0 +1,6 @@
1
+ # ***************************************************
2
+ # This calling the debugger from inside the source
3
+ # ***************************************************
4
+ set basename off
5
+ list
6
+ q!
@@ -0,0 +1,14 @@
1
+ -- (inline-call.rb:11 @12)
2
+ if a > b
3
+ basename is off.
4
+ 3 require_relative '../../lib/trepanning.rb'
5
+ 4 DATA_DIR = File.join(File.dirname(RequireRelative::abs_file), %w(.. data))
6
+ 5 cmdfile = File.join(DATA_DIR, 'inline-call.cmd')
7
+ 6 $dbgr = Trepan.new(:nx => true, :cmdfiles => [cmdfile])
8
+ 7 # GCD. We assume positive numbers
9
+ 8 def gcd(a, b)
10
+ 9 $dbgr.debugger
11
+ 10 # Make: a <= b
12
+ 11 -> if a > b
13
+ 12 a, b = [b, a]
14
+ trepanx: That's all, folks...
@@ -0,0 +1,3 @@
1
+ -> (/home/rocky-rvm/.rvm/src/rbx-trepanning/test/example/null.rb:1 @0)
2
+ # Nothing here. Move along.
3
+ (trepanx): (trepanx): (trepanx): (trepanx): (trepanx):
@@ -0,0 +1,5 @@
1
+ # ***************************************************
2
+ # This tests the quit.
3
+ # ***************************************************
4
+ # FIXME need to test --no-quit.
5
+ quit!
@@ -0,0 +1,3 @@
1
+ -> (null.rb:1 @0)
2
+ # Nothing here. Move along.
3
+ trepanx: That's all, folks...
@@ -0,0 +1,6 @@
1
+ # ***************************************************
2
+ # This tests the quit via "set confirm off"
3
+ # ***************************************************
4
+ # FIXME need to test --no-quit.
5
+ set confirm off
6
+ quit
@@ -0,0 +1,3 @@
1
+ -> (null.rb:1 @0)
2
+ # Nothing here. Move along.
3
+ confirm is off.
@@ -0,0 +1,2 @@
1
+ /*~
2
+ /*.rbc
@@ -0,0 +1,16 @@
1
+ # !/usr/bin/env ruby
2
+ # Bug in debugger in 1.9.2 only in that where
3
+ # stopping where we were inside debugger was stopping
4
+ # inside itself because multiple debugger names in the presence of modules
5
+ #
6
+ require 'rubygems'; require 'require_relative'
7
+ require_relative '../../lib/trepanning'
8
+ module Foo
9
+ module_function
10
+ def five
11
+ debugger # Resolves to Module#debugger not Kernel#debugger
12
+ 5
13
+ end
14
+ end
15
+ debugger(:immediate=>true)
16
+ Foo::five
@@ -0,0 +1,10 @@
1
+ def factorial(n)
2
+ if n > 0
3
+ return n * factorial(n-1)
4
+ else
5
+ return 1
6
+ end
7
+ end
8
+ n = ARGV[0] || 5
9
+ puts "#{n}! is #{factorial(5)}"
10
+
@@ -0,0 +1 @@
1
+ puts "Ha!"
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ # GCD. We assume positive numbers
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../lib/trepanning.rb'
5
+ $dbgr = Trepan.new(:server => true)
6
+ def gcd(a, b)
7
+ $dbgr.debugger
8
+ # Make: a <= b
9
+ if a > b
10
+ a, b = [b, a]
11
+ end
12
+
13
+ return nil if a <= 0
14
+
15
+ if a == 1 or b-a == 0
16
+ return a
17
+ end
18
+ return gcd(b-a, a)
19
+ end
20
+
21
+ a, b = ARGV[0..1].map {|arg| arg.to_i}
22
+ puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # GCD. We assume positive numbers
4
+ def gcd(a, b)
5
+ # Make: a <= b
6
+ if a > b
7
+ a, b = [b, a]
8
+ end
9
+
10
+ return nil if a <= 0
11
+
12
+ if a == 1 or b-a == 0
13
+ return a
14
+ end
15
+ return gcd(b-a, a)
16
+ end
17
+
18
+ a, b = ARGV[0..1].map {|arg| arg.to_i}
19
+ puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
@@ -0,0 +1,11 @@
1
+ def find_main_script(loc)
2
+ candidate = nil
3
+ if loc
4
+ candidate = 20
5
+ else
6
+ return 10
7
+ end
8
+ candidate
9
+ end
10
+
11
+ find_main_script('foo')
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'; require 'require_relative'
3
+ require_relative '../../lib/trepanning.rb'
4
+ DATA_DIR = File.join(File.dirname(RequireRelative::abs_file), %w(.. data))
5
+ cmdfile = File.join(DATA_DIR, 'inline-call.cmd')
6
+ $dbgr = Trepan.new(:nx => true, :cmdfiles => [cmdfile])
7
+ # GCD. We assume positive numbers
8
+ def gcd(a, b)
9
+ $dbgr.debugger
10
+ # Make: a <= b
11
+ if a > b
12
+ a, b = [b, a]
13
+ end
14
+
15
+ return nil if a <= 0
16
+
17
+ if a == 1 or b-a == 0
18
+ return a
19
+ end
20
+ end
21
+
22
+ a, b = ARGV[0..1].map {|arg| arg.to_i}
23
+ puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
@@ -0,0 +1 @@
1
+ # Nothing here. Move along.
@@ -0,0 +1,3 @@
1
+ Thread.new do
2
+ x = 1
3
+ end.join
@@ -0,0 +1,3 @@
1
+ /*.rbc
2
+ /*~
3
+
@@ -0,0 +1,112 @@
1
+ ## require 'thread_frame'
2
+ ## require 'trace'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../lib/trepanning'
5
+ require_relative '../../io/string_array'
6
+
7
+ module FnTestHelper
8
+ ## include Trace
9
+
10
+ ## # Synchronous events without C frames or instructions
11
+ # Common setup to create a debugger with String Array I/O attached
12
+ def strarray_setup(debugger_cmds, insn_stepping=false)
13
+ stringin = Trepan::StringArrayInput.open(debugger_cmds)
14
+ stringout = Trepan::StringArrayOutput.open
15
+ d_opts = {:input => stringin, :output => stringout,
16
+ :nx => true}
17
+ d = Trepan.new(d_opts)
18
+
19
+ d.settings[:basename] = d.processor.settings[:basename] = true
20
+ d.settings[:different] = false
21
+ d.settings[:autoeval] = false
22
+ return d
23
+ end
24
+
25
+ unless defined?(TREPAN_PROMPT)
26
+ TREPAN_PROMPT = /^\(trepanx\): /
27
+ TREPAN_LOC = /.. \(.+:\d+( @\d+)?\)/
28
+ end
29
+
30
+ # Return the caller's line number
31
+ def get_lineno
32
+ Rubinius::VM.backtrace(0)[1].line
33
+ end
34
+
35
+ def compare_output(right, d, debugger_cmds)
36
+ # require_relative '../../lib/trepanning'
37
+ # Trepan.debug(:set_restart => true)
38
+ got = filter_line_cmd(d.intf[-1].output.output)
39
+ if got != right
40
+ got.each_with_index do |got_line, i|
41
+ if i < right.size and got_line != right[i]
42
+ # dbgr.debugger
43
+ puts "! #{got_line}"
44
+ else
45
+ puts " #{got_line}"
46
+ end
47
+ end
48
+ puts '-' * 10
49
+ right.each_with_index do |right_line, i|
50
+ if i < got.size and got[i] != right_line
51
+ # dbgr.debugger
52
+ puts "! #{right_line}"
53
+ else
54
+ puts " #{right_line}"
55
+ end
56
+ end
57
+ end
58
+ assert_equal(right, got, caller[0])
59
+ end
60
+
61
+ # Return output with source lines prompt and command removed
62
+ def filter_line_cmd(a, show_prompt=false)
63
+ # Remove debugger prompt
64
+ a = a.map do |s|
65
+ s =~ TREPAN_PROMPT ? nil : s
66
+ end.compact unless show_prompt
67
+
68
+ # Remove debugger location lines.
69
+ # For example:
70
+ # -- (/src/external-vcs/trepan/tmp/gcd.rb:4 @21)
71
+ # becomes:
72
+ # --
73
+ a2 = a.map do |s|
74
+ s =~ TREPAN_LOC ? s.gsub(/\(.+:\d+( @\d+)?\)\n/, '').chomp : s.chomp
75
+ end
76
+
77
+ # Canonicalize breakpoint messages.
78
+ # For example:
79
+ # Set breakpoint 1: test/functional/test-tbreak.rb:10 (@0)
80
+ # becomes :
81
+ # Set breakpoint 1: foo.rb:55 (@3)
82
+ a3 = a2.map do |s|
83
+ s.gsub(/^Set (temporary )?breakpoint (\d+): .+:(\d+) \(@\d+\)/,
84
+ 'Set \1breakpoint \2: foo.rb:55 (@3)')
85
+ end
86
+ return a3
87
+ end
88
+
89
+ end
90
+
91
+ # Demo it
92
+ if __FILE__ == $0
93
+ include FnTestHelper
94
+ strarray_setup(%w(eh bee see))
95
+ puts get_lineno()
96
+ p '-- (/src/external-vcs/trepan/tmp/gcd.rb:4)' =~ TREPAN_LOC
97
+ p '(trepan): exit' =~ TREPAN_PROMPT
98
+ output='
99
+ -- (/src/external-vcs/trepan/tmp/gcd.rb:4)
100
+ (trepan): s
101
+ -- (/src/external-vcs/trepan/tmp/gcd.rb:18)
102
+ (trepan): s
103
+ -- (/src/external-vcs/trepan/tmp/gcd.rb:19)
104
+ (trepan): s
105
+ .. (/src/external-vcs/trepan/tmp/gcd.rb:0)
106
+ (trepan): s
107
+ -> (/src/external-vcs/trepan/tmp/gcd.rb:4)
108
+ '.split(/\n/)
109
+ puts filter_line_cmd(output)
110
+ puts '-' * 10
111
+ puts filter_line_cmd(output, true)
112
+ end
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ def five
7
+ 5
8
+ end
9
+
10
+ class TestNameBreak < Test::Unit::TestCase
11
+
12
+ include FnTestHelper
13
+
14
+ def self.six=(val)
15
+ @six = val
16
+ end
17
+
18
+ def five?(num) 5 == num; end
19
+
20
+ def test_basic
21
+ # Check that we can set breakpoints in parent, sibling and children
22
+ # of sibling returns. We have one more 'continue' than we need
23
+ # just in case something goes wrong.
24
+ cmds = ['break Object.five', 'break TestNameBreak.five?',
25
+ 'break TestNameBreak.six=',
26
+ 'continue', 'continue', 'continue', 'continue']
27
+
28
+ d = strarray_setup(cmds)
29
+ ##############################
30
+ d.start
31
+ five
32
+ five?(5)
33
+ TestNameBreak::six=6
34
+ ##############################
35
+ d.stop # ({:remove => true})
36
+ out = ["-- ",
37
+ "five ",
38
+ "Set breakpoint 1: foo.rb:55 (@3)",
39
+ "Set breakpoint 2: foo.rb:55 (@3)",
40
+ "Set breakpoint 3: foo.rb:55 (@3)",
41
+ "xx ",
42
+ "5",
43
+ "xx ",
44
+ "def five?(num) 5 == num; end",
45
+ "xx ",
46
+ "@six = val"]
47
+ compare_output(out, d, cmds)
48
+ end
49
+
50
+ end
51
+
52
+
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestBreak < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ # Looks like we can no longer get lines inside of foo or inner blocks
11
+ def FIXME_test_line_only_break
12
+ # Check that we can set breakpoints in parent, sibling and children
13
+ # of sibling returns. We have one more 'continue' than we need
14
+ # just in case something goes wrong.
15
+ cmds_pat = ((['break %d'] * 4) + (%w(continue) * 4)).join("\n")
16
+ line = __LINE__
17
+ cmds = (cmds_pat % [line, line+6, line+11, line+14]).split(/\n/)
18
+ d = strarray_setup(cmds)
19
+ ##############################
20
+ def foo # line + 4
21
+ a = 5 # line + 5
22
+ b = 6 # line + 6
23
+ end # line + 7
24
+ 1.times do # line + 8
25
+ d.start # line + 9
26
+ 1.times do # line + 10
27
+ x = 11 # line + 11
28
+ foo # line + 12
29
+ end # line + 13
30
+ c = 14 # line + 14
31
+ end
32
+ ##############################
33
+ d.stop # ({:remove => true})
34
+ puts d.intf[-1].output.output
35
+ assert(true)
36
+ return
37
+ out = ["-- ",
38
+ '1.times do # line + 10',
39
+ 'Set breakpoint 1: foo.rb:55 (@3)',
40
+ 'Set breakpoint 2: foo.rb:55 (@3)',
41
+ 'Set breakpoint 3: foo.rb:55 (@3)',
42
+ 'Set breakpoint 4: foo.rb:55 (@3)',
43
+ 'xx ',
44
+ 'x = 11 # line + 11',
45
+ 'xx ',
46
+ 'b = 6 # line + 6',
47
+ 'xx ',
48
+ 'c = 14 # line + 14'
49
+ ]
50
+ compare_output(out, d, cmds)
51
+ end
52
+
53
+ def test_line_only_break_reduced
54
+ # Check that we can set breakpoints in parent, sibling and children
55
+ # of sibling returns. We have one more 'continue' than we need
56
+ # just in case something goes wrong.
57
+ cmds_pat = ((['break %d'] * 1) + (%w(continue) * 3)).join("\n")
58
+ line = __LINE__
59
+ cmds = (cmds_pat % [line+14]).split(/\n/)
60
+ d = strarray_setup(cmds)
61
+ ##############################
62
+ def foo # line + 4
63
+ a = 5 # line + 5
64
+ b = 6 # line + 6
65
+ end # line + 7
66
+ 1.times do # line + 8
67
+ d.start # line + 9
68
+ 1.times do # line + 10
69
+ x = 11 # line + 11
70
+ foo # line + 12
71
+ end # line + 13
72
+ c = 14 # line + 14
73
+ end
74
+ ##############################
75
+ d.stop # ({:remove => true})
76
+ out = ["-- ",
77
+ '1.times do # line + 10',
78
+ 'Set breakpoint 1: foo.rb:55 (@3)',
79
+ 'xx ',
80
+ 'c = 14 # line + 14'
81
+ ]
82
+ compare_output(out, d, cmds)
83
+ end
84
+
85
+ end
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestEval < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ def test_eval_questionmark
11
+
12
+ # See that eval? strips 'if'
13
+ cmds = %w(eval? continue)
14
+ d = strarray_setup(cmds)
15
+ d.start
16
+ if 3 > 5
17
+ assert false
18
+ end
19
+ d.stop
20
+ out = ['-- ', 'if 3 > 5', 'eval: 3 > 5', '$d0 = false']
21
+ compare_output(out, d, cmds)
22
+
23
+ # See that eval? strips 'if' and 'then'
24
+ cmds = %w(eval? continue)
25
+ d = strarray_setup(cmds)
26
+ d.start
27
+ if 3 > 5 then
28
+ assert false
29
+ end
30
+ d.stop
31
+ out = ['-- ', 'if 3 > 5 then', 'eval: 3 > 5', '$d0 = false']
32
+ compare_output(out, d, cmds)
33
+
34
+ # See that eval? strips 'unless'
35
+ cmds = %w(eval? continue)
36
+ d = strarray_setup(cmds)
37
+ d.start
38
+ unless 3 < 5
39
+ assert false
40
+ end
41
+ d.stop
42
+ out = ['-- ', 'unless 3 < 5', 'eval: 3 < 5', '$d0 = true']
43
+ compare_output(out, d, cmds)
44
+
45
+ # See that eval? strips 'unless' and 'then
46
+ cmds = %w(eval? continue)
47
+ d = strarray_setup(cmds)
48
+ d.start
49
+ unless 3 < 5 then
50
+ assert false
51
+ end
52
+ d.stop
53
+ out = ['-- ', 'unless 3 < 5 then', 'eval: 3 < 5', '$d0 = true']
54
+ compare_output(out, d, cmds)
55
+
56
+ # See that eval? strips 'while'
57
+ cmds = %w(eval? continue)
58
+ d = strarray_setup(cmds)
59
+ d.start
60
+ while nil
61
+ assert false
62
+ end
63
+ d.stop
64
+ out = ['-- ', 'while nil', 'eval: nil', '$d0 = nil']
65
+ compare_output(out, d, cmds)
66
+
67
+ # See that eval? strips 'while' and 'do'
68
+ cmds = %w(eval? continue)
69
+ d = strarray_setup(cmds)
70
+ d.start
71
+ while nil do
72
+ assert false
73
+ end
74
+ d.stop
75
+ out = ['-- ', 'while nil do', 'eval: nil', '$d0 = nil']
76
+ compare_output(out, d, cmds)
77
+
78
+ # See that eval? strips 'until' and 'do'
79
+ cmds = %w(eval? continue)
80
+ d = strarray_setup(cmds)
81
+ d.start
82
+ until true do
83
+ assert false
84
+ end
85
+ d.stop
86
+ out = ['-- ', 'until true do', 'eval: true', '$d0 = true']
87
+ compare_output(out, d, cmds)
88
+
89
+ # See that eval? strips 'until'
90
+ cmds = %w(eval? continue)
91
+ d = strarray_setup(cmds)
92
+ d.start
93
+ until true
94
+ assert false
95
+ end
96
+ d.stop
97
+ out = ['-- ', 'until true', 'eval: true', '$d0 = true']
98
+ compare_output(out, d, cmds)
99
+
100
+ # See that eval? strips 'return'
101
+ def five
102
+ return 5
103
+ end
104
+ cmds = %w(step eval? continue)
105
+ d = strarray_setup(cmds)
106
+ d.start
107
+ five
108
+ d.stop
109
+ out = ['-- ', 'five', '-> ', 'return 5', 'eval: 5', '$d0 = 5']
110
+ compare_output(out, d, cmds)
111
+ end
112
+
113
+ end
114
+
115
+
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestFinish < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ def test_finish_between_fn
11
+ # "Finish" over a recursive function. We use a recursive function
12
+ # so that we check that the temporary breakpoint created in the
13
+ # implementation is specific to the frame. See Rubinius issue
14
+ # #558.
15
+ def fact(x)
16
+ return 1 if x <= 1
17
+ x = x * fact(x-1)
18
+ return x
19
+ end
20
+ # An extra 'continue' added in case something goes wrong.
21
+ cmds = %w(step finish) + ['pr x', 'continue', 'continue']
22
+ d = strarray_setup(cmds)
23
+ d.start
24
+ ##############################
25
+ x = fact(4)
26
+ y = 5
27
+ ##############################
28
+ d.stop # ({:remove => true})
29
+ out = ['-- ',
30
+ 'x = fact(4)',
31
+ '-> ',
32
+ 'return 1 if x <= 1',
33
+ '<- ',
34
+ 'return x',
35
+ '24']
36
+ compare_output(out, d, cmds)
37
+ end
38
+
39
+ def test_finish_between_fn_simple
40
+
41
+ # Finish over functions
42
+ def five; 5 end
43
+ def something(x)
44
+ return 1 if x <= 1
45
+ x =
46
+ if five > 5
47
+ 24
48
+ else
49
+ 22
50
+ end
51
+ end
52
+ cmds = %w(step finish) + ['pr x', 'continue']
53
+ d = strarray_setup(cmds)
54
+ d.start
55
+ ##############################
56
+ x = something(4)
57
+ y = 5
58
+ ##############################
59
+ d.stop # ({:remove => true})
60
+ out = [
61
+ '-- ',
62
+ 'x = something(4)',
63
+ '-> ',
64
+ 'return 1 if x <= 1',
65
+ '<- ',
66
+ 'x =', '22']
67
+ compare_output(out, d, cmds)
68
+ end
69
+
70
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestFnTestHelper < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ def test_basic
11
+ assert_equal(__LINE__, get_lineno, 'get_lineno()')
12
+ assert_equal(0,
13
+ '-- (/tmp/trepan/tmp/gcd.rb:4)' =~ TREPAN_LOC)
14
+ assert_equal(0, '(trepanx): exit' =~ TREPAN_PROMPT)
15
+
16
+ output='
17
+ -- (/tmp/trepan/tmp/gcd.rb:4)
18
+ (trepanx): s
19
+ -- (/tmp/trepan/tmp/gcd.rb:18)
20
+ (trepanx): s
21
+ -- (/tmp/trepan/tmp/gcd.rb:19)
22
+ (trepanx): s
23
+ .. (/tmp/trepan/tmp/gcd.rb:0)
24
+ (trepanx): s
25
+ -> (/tmp/trepan/tmp/gcd.rb:4)
26
+ '.split(/\n/)
27
+ expect='
28
+ -- (/tmp/trepan/tmp/gcd.rb:4)
29
+ -- (/tmp/trepan/tmp/gcd.rb:18)
30
+ -- (/tmp/trepan/tmp/gcd.rb:19)
31
+ .. (/tmp/trepan/tmp/gcd.rb:0)
32
+ -> (/tmp/trepan/tmp/gcd.rb:4)
33
+ '.split(/\n/)
34
+ assert_equal(expect, filter_line_cmd(output))
35
+ end
36
+
37
+ end
38
+
39
+
40
+
41
+
42
+
43
+