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,56 @@
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
+ def test_list_frame_change
11
+ # Check that list update the frame position
12
+ # of sibling returns. We have one more 'continue' than we need
13
+ # just in case something goes wrong.
14
+ cmds_pat = [
15
+ 'set max list 2',
16
+ 'list',
17
+ "continue %d",
18
+ 'list',
19
+ 'up',
20
+ 'list',
21
+ 'continue'].join("\n")
22
+ line = __LINE__
23
+ cmds = (cmds_pat % (line+5)).split(/\n/)
24
+ d = strarray_setup(cmds)
25
+ ##############################
26
+ def foo # line + 4
27
+ a = 5 # line + 5
28
+ b = 6 # line + 6
29
+ end # line + 7
30
+ d.start # line + 8
31
+ foo
32
+ ##############################
33
+ d.stop # ({:remove => true})
34
+ out = [
35
+ "-- ",
36
+ "foo",
37
+ "max list is 2.",
38
+ " 31 ->\t foo",
39
+ " 32 \t ##############################",
40
+ "Set temporary breakpoint 1: foo.rb:55 (@3)",
41
+ "x1 ",
42
+ "a = 5 # line + 5",
43
+ " 27 ->\t a = 5 # line + 5",
44
+ " 28 \t b = 6 # line + 6",
45
+ "--> #1 TestBreak#test_list_frame_change at test-list.rb:31",
46
+ " ",
47
+ "foo",
48
+ " 31 ->\t foo",
49
+ " 32 \t ##############################"
50
+ ]
51
+ compare_output(out, d, cmds)
52
+ end
53
+
54
+ end
55
+
56
+
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ def discontinuous(obj)
7
+ if klass = obj.class and klass.kind_of?(String)
8
+ return true
9
+ end
10
+ return nil
11
+ end
12
+
13
+ class TestNextBug < Test::Unit::TestCase
14
+
15
+ include FnTestHelper
16
+
17
+ # Sometimes a line may have a disconnected set of IP. For example
18
+ # Rubinius::VariableScope#method_visibility which has these
19
+ # offset/lines
20
+ #
21
+ # ... 0, 126, 22, 127, 29, 128, 43, 130, 48, 126, 50, ...
22
+ # ^^^ ^^^
23
+ #
24
+ # Make sure when can "next" when we are stopped at the 2nd part of
25
+ # line 126 (offset 50).
26
+ #
27
+ def test_next_on_line_with_discontinuous_ips
28
+ lines = method(:discontinuous).executable.lines
29
+ unless lines.at(3) == lines.at(7)
30
+ puts("Skipping #{__FILE__} test because code generated is not " +
31
+ "what we need to test here. Please fix.")
32
+ end
33
+ cmds = %w(step next continue)
34
+ d = strarray_setup(cmds)
35
+ d.start
36
+ discontinuous(4)
37
+ d.stop
38
+ out = ['-- ',
39
+ 'discontinuous(4)',
40
+ '-> ',
41
+ 'if klass = obj.class and klass.kind_of?(String)',
42
+ '-- ',
43
+ 'return nil'
44
+ ]
45
+ compare_output(out, d, cmds)
46
+ end
47
+ end
48
+
49
+
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestNext < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ def test_next_same_level
11
+
12
+ # See that we can next with parameter which is the same as 'next 1'
13
+ cmds = %w(next next continue)
14
+ d = strarray_setup(cmds)
15
+ d.start
16
+ x = 5
17
+ y = 6
18
+ d.stop
19
+ out = ['-- ', 'x = 5', '-- ', 'y = 6', '-- ', 'd.stop']
20
+ compare_output(out, d, cmds)
21
+
22
+ # See that we can next with a computed count value
23
+ cmds = ['step', 'next 5-3', 'continue']
24
+ d = strarray_setup(cmds)
25
+ d.start
26
+ ########### t1 ###############
27
+ x = 5
28
+ y = 6
29
+ z = 7
30
+ ##############################
31
+ d.stop
32
+ out = ['-- ', 'x = 5', '-- ', 'y = 6', '-- ', 'd.stop']
33
+ compare_output(out, d, cmds)
34
+ end
35
+
36
+ def test_next_between_fn
37
+
38
+ # Next over functions
39
+ cmds = ['next 2', 'continue']
40
+ d = strarray_setup(cmds)
41
+ d.start
42
+ ########### t2 ###############
43
+ def fact(x)
44
+ return 1 if x <= 1
45
+ return fact(x-1)
46
+ end
47
+ x = fact(4)
48
+ y = 5
49
+ ##############################
50
+ d.stop # ({:remove => true})
51
+ out = ['-- ', 'def fact(x)', '-- ', 'y = 5']
52
+ compare_output(out, d, cmds)
53
+ end
54
+
55
+ def test_scoped_next
56
+ # "Next" over a recursive function. We use a recursive function so
57
+ # that we check that the temporary breakpoint created in the
58
+ # implementation is specific to the frame. See Rubinius issue
59
+ # #558.
60
+ def fact(x)
61
+ return 1 if x <= 1
62
+ x = x * fact(x-1)
63
+ return x
64
+ end
65
+ cmds = ['step', 'next 3', 'pr x', 'continue']
66
+ d = strarray_setup(cmds)
67
+ d.start
68
+ ##############################
69
+ x = fact(4)
70
+ y = 5
71
+ ##############################
72
+ d.stop # ({:remove => true})
73
+ out = ['-- ',
74
+ 'x = fact(4)',
75
+ '-> ',
76
+ 'return 1 if x <= 1',
77
+ '-- ',
78
+ 'return x',
79
+ '24']
80
+ compare_output(out, d, cmds)
81
+ end
82
+
83
+ # def test_next_in_exception
84
+ # cmds = %w(next! continue)
85
+ # d = strarray_setup(cmds)
86
+ # d.start
87
+ # ########### t2 ###############
88
+ # begin
89
+ # got_boom = false
90
+ # x = 4/0
91
+ # rescue
92
+ # got_boom = true
93
+ # end
94
+ # ##############################
95
+ # d.stop # ({:remove => true})
96
+ # out = ['-- ', 'begin']
97
+ # compare_output(out, d, cmds)
98
+ # end
99
+ end
100
+
101
+
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestRecursiveBt < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ def test_recursive_backtrace
11
+
12
+ cmds = [
13
+ 'set basename on',
14
+ 'next',
15
+ 'bt 1',
16
+ 'step',
17
+ 'step',
18
+ 'bt 2',
19
+ 'step',
20
+ 'step',
21
+ 'bt 3',
22
+ 'step',
23
+ 'step',
24
+ 'step',
25
+ 'bt 5',
26
+ 'step',
27
+ 'step',
28
+ 'step',
29
+ 'bt 7',
30
+ 'continue'
31
+ ]
32
+ d = strarray_setup(cmds)
33
+ d.start
34
+ ##############################
35
+ def factorial(n)
36
+ if n > 0
37
+ return n * factorial(n-1)
38
+ else
39
+ return 1
40
+ end
41
+ end
42
+ z = factorial(5)
43
+ ##############################
44
+ d.stop
45
+ out =
46
+ ["-- ",
47
+ "def factorial(n)",
48
+ "basename is on.",
49
+ "-- ",
50
+ "z = factorial(5)",
51
+ "--> #0 TestRecursiveBt#test_recursive_backtrace at test-recursive-bt.rb:42",
52
+ "(More stack frames follow...)",
53
+ "-> ",
54
+ "if n > 0",
55
+ "-- ",
56
+ "return n * factorial(n-1)",
57
+ "--> #0 TestRecursiveBt#factorial(n) at test-recursive-bt.rb:37",
58
+ " #1 TestRecursiveBt#test_recursive_backtrace at test-recursive-bt.rb:42",
59
+ "(More stack frames follow...)",
60
+ "-> ",
61
+ "if n > 0",
62
+ "-- ",
63
+ "return n * factorial(n-1)",
64
+ "--> #0 TestRecursiveBt#factorial(n) at test-recursive-bt.rb:37",
65
+ " #1 TestRecursiveBt#factorial(n) at test-recursive-bt.rb:37",
66
+ " #2 TestRecursiveBt#test_recursive_backtrace at test-recursive-bt.rb:42",
67
+ "(More stack frames follow...)",
68
+ "-> ",
69
+ "if n > 0",
70
+ "-- ",
71
+ "return n * factorial(n-1)",
72
+ "-> ",
73
+ "if n > 0",
74
+ "--> #0 TestRecursiveBt#factorial(n) at test-recursive-bt.rb:36",
75
+ " #1 TestRecursiveBt#factorial(n) at test-recursive-bt.rb:37",
76
+ "... above line repeated 2 times",
77
+ " #4 TestRecursiveBt#test_recursive_backtrace at test-recursive-bt.rb:42",
78
+ "(More stack frames follow...)",
79
+ "-- ",
80
+ "return n * factorial(n-1)",
81
+ "-> ",
82
+ "if n > 0",
83
+ "-- ",
84
+ "return n * factorial(n-1)",
85
+ "--> #0 TestRecursiveBt#factorial(n) at test-recursive-bt.rb:37",
86
+ " #1 TestRecursiveBt#factorial(n) at test-recursive-bt.rb:37",
87
+ "... above line repeated 3 times",
88
+ " #5 TestRecursiveBt#test_recursive_backtrace at test-recursive-bt.rb:42",
89
+ " #6 Test::Unit::TestCase(TestRecursiveBt)#run(result) at testcase.rb:78",
90
+ "(More stack frames follow...)"]
91
+ compare_output(out, d, cmds)
92
+
93
+ end
94
+ end
@@ -0,0 +1,272 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestStep < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ def test_step_same_level
11
+
12
+ # See that we can step with parameter which is the same as 'step 1'
13
+ cmds = ['step', 'continue']
14
+ d = strarray_setup(cmds)
15
+
16
+ d.start
17
+ ########### t1 ###############
18
+ x = 5
19
+ y = 6
20
+ ##############################
21
+ d.stop
22
+ out = ['-- ', 'x = 5', '-- ', 'y = 6']
23
+ compare_output(out, d, cmds)
24
+
25
+ # See that we can step with a computed count value
26
+ cmds = ['step 5-3', 'continue']
27
+ d = strarray_setup(cmds)
28
+ d.start
29
+ ########### t2 ###############
30
+ x = 5
31
+ y = 6
32
+ z = 7
33
+ ##############################
34
+ d.stop # ({:remove => true})
35
+ out = ["-- ", "x = 5", "-- ", "z = 7"]
36
+ compare_output(out, d, cmds)
37
+
38
+ # # Test step>
39
+ # cmds = ['step>', 'continue']
40
+ # d = strarray_setup(cmds)
41
+ # d.start
42
+ # ########### t3 ###############
43
+ # x = 5
44
+ # def foo()
45
+ # end
46
+ # y = 6
47
+ # foo
48
+ # ##############################
49
+ # d.stop # {:remove => true})
50
+ # out = ['-- ', 'x = 5', 'METHOD TestStep#foo()', '-> ', 'def foo()']
51
+ # compare_output(out, d, cmds)
52
+
53
+ # # Test step!
54
+ # cmds = ['step!', 'continue']
55
+ # d = strarray_setup(cmds)
56
+ # d.start()
57
+ # ########### t4 ###############
58
+ # x = 5
59
+ # begin
60
+ # y = 2
61
+ # z = 1/0
62
+ # rescue
63
+ # end
64
+ # ##############################
65
+ # d.stop # ({:remove => true})
66
+ # out = ['-- ', 'x = 5',
67
+ # '#<ZeroDivisionError: divided by 0>',
68
+ # '!! ', 'z = 1/0']
69
+ # compare_output(out, d, cmds)
70
+
71
+ # # Test "step" with sets of events. Part 1
72
+ # cmds = ['set events call raise',
73
+ # 'step', 's!']
74
+ # d = strarray_setup(cmds)
75
+ # d.start()
76
+ # ########### t5 ###############
77
+ # x = 5
78
+ # def foo1
79
+ # y = 2
80
+ # raise Exception
81
+ # rescue Exception
82
+ # end
83
+ # foo1()
84
+ # z = 1
85
+ # ##############################
86
+ # d.stop # ({:remove => true})
87
+ # out = ['-- ',
88
+ # 'x = 5',
89
+ # 'Trace events we may stop on:',
90
+ # "\tbrkpt, call, raise",
91
+ # 'METHOD TestStep#foo1()',
92
+ # '-> ',
93
+ # 'def foo1',
94
+ # '#<Exception: Exception>',
95
+ # '!! ',
96
+ # 'raise Exception']
97
+
98
+ # got = filter_line_cmd(d.intf[-1].output.output)
99
+ # out.pop if got.size+1 == out.size
100
+ # compare_output(out, d, cmds)
101
+
102
+ # # Test "step" will sets of events. Part 2
103
+ # cmds = ['step> 1+0',
104
+ # 'step! 1', 'continue']
105
+ # d = strarray_setup(cmds)
106
+ # d.start()
107
+ # ########### t6 ###############
108
+ # x = 5
109
+ # begin
110
+ # def foo2()
111
+ # y = 2
112
+ # raise Exception
113
+ # end
114
+ # foo2()
115
+ # rescue Exception
116
+ # end
117
+ # z = 1
118
+ # ##############################
119
+ # d.stop({:remove => true})
120
+ # out = ['-- ',
121
+ # 'x = 5',
122
+ # 'METHOD TestStep#foo2()',
123
+ # '-> ',
124
+ # 'def foo2()',
125
+ # 'TestStep',
126
+ # '!! ',
127
+ # 'raise Exception']
128
+
129
+ end
130
+
131
+ def no_test_step_between_fn
132
+
133
+ # Step into and out of a function
134
+ def sqr(x)
135
+ y = x * x
136
+ end
137
+ cmds = %w(step) * 4 + %w(continue)
138
+ out = ['-- ',
139
+ 'x = sqr(4)',
140
+ 'METHOD TestStep#sqr(x)',
141
+ '-> ',
142
+ 'def sqr(x)',
143
+ '-- ',
144
+ 'y = x * x',
145
+ '<- ',
146
+ 'R=> 16',
147
+ 'end',
148
+ '-- ',
149
+ 'y = 5']
150
+ d = strarray_setup(cmds)
151
+ d.start
152
+ ########### t7 ###############
153
+ x = sqr(4)
154
+ y = 5
155
+ ##############################
156
+ d.stop # ({:remove => true})
157
+ compare_output(out, d, cmds)
158
+
159
+ cmds = ['set events call return',
160
+ 'step', 'step', 'continue']
161
+ out = ['-- ',
162
+ 'x = sqr(4)',
163
+ 'Trace events we may stop on:',
164
+ "\tbrkpt, call, return",
165
+ 'METHOD TestStep#sqr(x)',
166
+ '-> ',
167
+ 'def sqr(x)',
168
+ '<- ',
169
+ 'R=> 16',
170
+ 'end']
171
+ d = strarray_setup(cmds)
172
+ d.start
173
+ ########### t8 ###############
174
+ x = sqr(4)
175
+ y = 5
176
+ ##############################
177
+ d.stop # ({:remove => true})
178
+ compare_output(out, d, cmds)
179
+ end
180
+
181
+ def no_test_step_in_exception
182
+ def boom(x)
183
+ y = 0/x
184
+ end
185
+ def bad(x)
186
+ boom(x)
187
+ y = x * x
188
+ end
189
+ cmds = %w(step! continue)
190
+ d = strarray_setup(cmds)
191
+ begin
192
+ d.start()
193
+ x = bad(0)
194
+ assert_equal(false, true, 'should have raised an exception')
195
+ rescue ZeroDivisionError
196
+ assert true, 'Got the exception'
197
+ ensure
198
+ d.stop({:remove => true})
199
+ end
200
+
201
+ out = ['-- ',
202
+ 'x = bad(0)', # line event
203
+ '#<ZeroDivisionError: divided by 0>',
204
+ '!! ', # exception event
205
+ 'y = 0/x']
206
+
207
+ compare_output(out, d, cmds)
208
+ end
209
+
210
+ def no_test_step_event
211
+
212
+ def fact(x)
213
+ return 1 if x <= 1
214
+ x = x * fact(x-1)
215
+ return x
216
+ end
217
+ cmds = ['step<', '1 == x', 'continue']
218
+ d = strarray_setup(cmds)
219
+ d.start
220
+ ########### t9 ###############
221
+ x = fact(4)
222
+ y = 5
223
+ ##############################
224
+ d.stop # ({:remove => true})
225
+ out = ['-- ',
226
+ 'x = fact(4)',
227
+ '<- ',
228
+ 'R=> 1',
229
+ 'return 1 if x <= 1',
230
+ 'D=> true']
231
+ compare_output(out, d, cmds)
232
+ end
233
+
234
+ def no_test_step_into_fun
235
+
236
+ # Bug was that we were stopping at a VM instruction before the fn
237
+ # call proper ('bar' below), and not getting a line number for it.
238
+ # So a subsequent 'step' when 'set different' in effect was to stay
239
+ # at the same place at the function call.
240
+ cmds = ['set different', 'set events call, class, line, return',
241
+ 'step', 'step', 'step', 'step', 'continue']
242
+ d = strarray_setup(cmds)
243
+ d.start
244
+ ########### t10 ###############
245
+ def bar
246
+ return 1
247
+ end
248
+
249
+ def foo
250
+ bar
251
+ return 5
252
+ end
253
+ foo
254
+ ##############################
255
+ d.stop # ({:remove => true})
256
+ out = ['-- ',
257
+ 'def bar',
258
+ 'different is on.',
259
+ 'Trace events we may stop on:',
260
+ "\tbrkpt, call, class, line, return",
261
+ '-- ',
262
+ 'def foo',
263
+ '-- ',
264
+ 'foo',
265
+ 'METHOD TestStep#foo()',
266
+ '-> ',
267
+ 'def foo',
268
+ '-- ',
269
+ 'bar']
270
+ compare_output(out, d, cmds)
271
+ end
272
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestStep2 < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ def test_step_out_of_fn
11
+
12
+ # See that handle stepping out of a function properly.
13
+ cmds = ['step', 'step', 'continue']
14
+ d = strarray_setup(cmds)
15
+
16
+ def echo(x)
17
+ return x
18
+ end
19
+
20
+ d.start
21
+ ########### t1 ###############
22
+ x = echo("hi")
23
+ y = 3
24
+ ##############################
25
+ d.stop
26
+ out = ['-- ',
27
+ 'x = echo("hi")',
28
+ '-> ',
29
+ 'return x',
30
+ '-- ',
31
+ 'x = echo("hi")']
32
+ compare_output(out, d, cmds)
33
+ end
34
+
35
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'fn_helper'
5
+
6
+ class TestTBreak < Test::Unit::TestCase
7
+
8
+ include FnTestHelper
9
+
10
+ def foo
11
+ a = 3
12
+ b = 4
13
+ c = 5
14
+ d = 6
15
+ end
16
+
17
+ def test_basic
18
+ # Check that temporary breaks are, well, temporary.
19
+ # The last "continue" below isn't used. It to make sure we finish
20
+ # the test even when the breakpoint isn't temporary.
21
+ cmds = ['tbreak TestTBreak.foo', 'continue', 'continue', 'continue']
22
+ d = strarray_setup(cmds)
23
+ d.start
24
+ ##############################
25
+ 2.times do
26
+ foo
27
+ end
28
+ ##############################
29
+ d.stop # ({:remove => true})
30
+ out = ['-- ',
31
+ '2.times do ',
32
+ 'Set temporary breakpoint 1: foo.rb:55 (@3)',
33
+ "x1 ",
34
+ 'a = 3'
35
+ ]
36
+ compare_output(out, d, cmds)
37
+ end
38
+
39
+ end
40
+
41
+
@@ -0,0 +1,3 @@
1
+ /*.out
2
+ /*~
3
+ /*.rbc