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,81 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../processor'
5
+ require_relative '../../processor/frame'
6
+ require_relative '../../processor/mock'
7
+
8
+ $errors = []
9
+ $msgs = []
10
+
11
+ # Test Trepan::CmdProcessor Frame portion
12
+ class TestCmdProcessorFrame < Test::Unit::TestCase
13
+
14
+ def setup
15
+ $errors = []
16
+ $msgs = []
17
+ @dbgr = MockDebugger::MockDebugger.new
18
+ @proc = Trepan::CmdProcessor.new(@dbgr)
19
+ @proc.frame_index = 0
20
+ @proc.frame_initialize
21
+ class << @proc
22
+ def msg(msg)
23
+ $msgs << msg
24
+ end
25
+ def errmsg(msg)
26
+ $errors << msg
27
+ end
28
+ def print_location
29
+ # $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
30
+ $msgs << File.basename(@frame.file)
31
+ # puts $msgs
32
+ end
33
+ end
34
+ end
35
+
36
+ # See that we have can load up commands
37
+ def test_basic
38
+ @proc.frame_setup
39
+
40
+ # Test absolute positioning. Should all be okay
41
+ 0.upto(@proc.stack_size-1) do |i|
42
+ @proc.adjust_frame(i, true)
43
+ assert_equal(0, $errors.size)
44
+ assert_equal(true, $msgs.size >= i+1)
45
+ end
46
+
47
+ # Test absolute before the beginning fo the stack
48
+ frame_index = @proc.frame_index
49
+ @proc.adjust_frame(-1, true)
50
+ assert_equal(0, $errors.size)
51
+ assert_equal(frame_index, @proc.frame_index)
52
+ @proc.adjust_frame(-@proc.stack_size-1, true)
53
+ assert_equal(1, $errors.size, $errors)
54
+ assert_equal(frame_index, @proc.frame_index)
55
+
56
+ ## FIXME: look over and reinstate this code...
57
+ # setup
58
+ # @proc.top_frame = @proc.frame = @dbgr.vm_locations[0]
59
+ # @proc.adjust_frame(0, true)
60
+
61
+ # @dbgr.vm_locations.size-1.times do
62
+ # frame_index = @proc.frame_index
63
+ # @proc.adjust_frame(1, false)
64
+ # assert_equal(0, $errors.size)
65
+ # assert_not_equal(frame_index, @proc.frame_index,
66
+ # '@proc.frame_index should have moved')
67
+ # end
68
+
69
+ # FIXME: bug in threadframe top_frame.stack_size?
70
+ # # Adjust relative beyond the end
71
+ # @proc.adjust_frame(1, false)
72
+ # assert_equal(1, $errors.size)
73
+
74
+ # Should have stayed at the end
75
+ # proc.adjust_frame(proc.top_frame.stack_size-1, true)
76
+ # proc.top_frame.stack_size.times { proc.adjust_frame(-1, false) }
77
+
78
+ end
79
+
80
+
81
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../processor/help'
5
+
6
+ # Test Trepan::CmdProcessor
7
+ class TestCmdProcessor < Test::Unit::TestCase
8
+
9
+ include Trepan::Help
10
+ # See that we have can load up commands
11
+ def test_abbrev_stringify
12
+ assert_equal('(test)ing',
13
+ abbrev_stringify('testing', 'test'.size))
14
+ end
15
+
16
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../processor/hook'
5
+
6
+ # Test Debugger:CmdProcessor Hook portion
7
+ class TestProcHook < Test::Unit::TestCase
8
+
9
+ def test_basic
10
+ @args = []
11
+ hook1 = Proc.new {|name, a| @args << [name, a]}
12
+ hooks = Trepan::CmdProcessor::Hook.new()
13
+ assert_equal(true, hooks.empty?)
14
+ hooks.insert(-1, 'hook1', hook1)
15
+ hooks.run
16
+ assert_equal([['hook1', nil]], @args)
17
+ hooks.insert_if_new(-1, 'hook1', hook1)
18
+ assert_equal([['hook1', nil]], @args)
19
+
20
+ @args = []
21
+ hooks.insert_if_new(-1, 'hook2', hook1)
22
+ hooks.run(10)
23
+ assert_equal([['hook1', 10], ['hook2', 10]], @args)
24
+
25
+ @args = []
26
+ hooks.delete_by_name('hook2')
27
+ hooks.run(30)
28
+ assert_equal([['hook1', 30]], @args)
29
+ end
30
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../processor'
5
+ require_relative '../../processor/frame'
6
+ require_relative '../../processor/list'
7
+ require_relative '../../processor/mock'
8
+
9
+ # Test Trepan::CmdProcessor List portion
10
+ class TestProcList < Test::Unit::TestCase
11
+
12
+ def setup
13
+ $errors = []
14
+ $msgs = []
15
+ @dbgr = MockDebugger::MockDebugger.new
16
+ @proc = Trepan::CmdProcessor.new(@dbgr)
17
+ @proc.frame_index = 0
18
+ @proc.frame_initialize
19
+ class << @proc
20
+ def msg(msg)
21
+ $msgs << msg
22
+ end
23
+ def errmsg(msg)
24
+ $errors << msg
25
+ end
26
+ def print_location
27
+ # $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
28
+ $msgs << "#{@frame.source_container} "
29
+ # puts $msgs
30
+ end
31
+ end
32
+ end
33
+
34
+ def test_basic
35
+ @proc.frame_setup
36
+
37
+ def foo; 5 end
38
+ def check(cmdp, arg, last=10)
39
+ r = cmdp.parse_list_cmd('.', last)
40
+ assert r[1]
41
+ assert r[2]
42
+ assert r[3]
43
+ end
44
+ check(@proc, '-')
45
+ check(@proc, 'foo')
46
+ check(@proc, '@0')
47
+ check(@proc, "#{__LINE__}")
48
+ check(@proc, "#{__FILE__} @0")
49
+ check(@proc, "#{__FILE__}:#{__LINE__}")
50
+ check(@proc, "#{__FILE__} #{__LINE__}")
51
+ check(@proc, "#{__FILE__} #{__LINE__}", -10)
52
+ check(@proc, "@proc.errmsg")
53
+ check(@proc, "@proc.errmsg:@0")
54
+ end
55
+ end
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../processor'
5
+ require_relative '../../app/mock'
6
+
7
+ class TestCmdProcessorLoadCmds < Test::Unit::TestCase
8
+
9
+ def setup
10
+ @proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
11
+ @proc.instance_variable_set('@settings', {})
12
+ end
13
+
14
+ # See that we have can load up commands
15
+ def test_basic
16
+ @proc.load_cmds_initialize
17
+ assert_equal(false, @proc.commands.empty?)
18
+ assert_equal(false, @proc.aliases.empty?)
19
+ end
20
+
21
+ def test_complete
22
+ assert_equal(%w(delete directory disable disassemble display down),
23
+ @proc.complete('d', 'd'),
24
+ "Failed completion of 'd' commands")
25
+ assert_equal(['debug', 'different', 'directories'],
26
+ @proc.complete('sho d', 'd'),
27
+ "Failed completion of 'sho d' subcommands")
28
+ $errors = []
29
+ end
30
+
31
+ def test_run_cmd
32
+ $errors = []
33
+
34
+ def @proc.errmsg(mess)
35
+ $errors << mess
36
+ end
37
+
38
+ def test_it(size, *args)
39
+ @proc.run_cmd(*args)
40
+ assert_equal(size, $errors.size, $errors)
41
+ end
42
+ test_it(1, 'foo')
43
+ test_it(2, [])
44
+ test_it(3, ['list', 5])
45
+ # See that we got different error messages
46
+ assert_not_equal($errors[0], $errors[1], $errors)
47
+ assert_not_equal($errors[1], $errors[2], $errors)
48
+ assert_not_equal($errors[2], $errors[0], $errors)
49
+ end
50
+
51
+ end
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require 'linecache'
5
+ require_relative '../../processor/location'
6
+ require_relative 'cmd-helper'
7
+
8
+ # Test Trepan::CmdProcessor location portion
9
+ class TestCmdProcessorLocation < Test::Unit::TestCase
10
+
11
+ include UnitHelper
12
+ def setup
13
+ common_setup
14
+ @file ||= File.basename(__FILE__)
15
+ end
16
+
17
+ # Test resolve_file_with_dir() and line_at()
18
+ def test_line_at
19
+ @cmdproc.settings[:directory] = ''
20
+ assert_equal(nil, @cmdproc.resolve_file_with_dir(@file))
21
+ if File.expand_path(Dir.pwd) == File.expand_path(File.dirname(__FILE__))
22
+ line = @cmdproc.line_at(@file, __LINE__)
23
+ assert_match(/line = @cmdproc.line_at/, line)
24
+ else
25
+ assert_equal(nil, @cmdproc.line_at(@file, __LINE__))
26
+ end
27
+ dir = @cmdproc.settings[:directory] = File.dirname(__FILE__)
28
+ assert_equal(File.join(dir, @file),
29
+ @cmdproc.resolve_file_with_dir('test-proc-location.rb'))
30
+ test_line = 'test_line'
31
+ line = @cmdproc.line_at(@file, __LINE__-1)
32
+ assert_match(/#{line}/, line)
33
+ end
34
+
35
+ def test_loc_and_text
36
+ @cmdproc.frame_index = 0
37
+ @cmdproc.frame_initialize
38
+ @cmdproc.frame_setup
39
+ LineCache::clear_file_cache
40
+ dir = @cmdproc.settings[:directory] = File.dirname(__FILE__)
41
+ loc, line_no, text = @cmdproc.loc_and_text('hi')
42
+ assert loc and line_no.is_a?(Fixnum) and text
43
+ assert @cmdproc.current_source_text
44
+ # FIXME test that filename remapping works.
45
+ end
46
+
47
+ def test_canonic_file
48
+ @cmdproc.settings[:basename] = false
49
+ assert_equal __FILE__, @cmdproc.canonic_file(__FILE__)
50
+ assert @cmdproc.canonic_file('lib/compiler/ast.rb')
51
+ @cmdproc.settings[:basename] = true
52
+ assert_equal File.basename(__FILE__), @cmdproc.canonic_file(__FILE__)
53
+ assert_equal 'ast.rb', @cmdproc.canonic_file('lib/compiler/ast.rb')
54
+ end
55
+
56
+
57
+ def test_eval_current_source_text
58
+ eval <<-EOE
59
+ @cmdproc.frame_index = 0
60
+ @cmdproc.frame_initialize
61
+ @cmdproc.frame_setup
62
+ LineCache::clear_file_cache
63
+ assert @cmdproc.current_source_text
64
+ EOE
65
+ end
66
+
67
+ end
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'; require 'require_relative'
3
+ require_relative 'cmd-helper'
4
+ require_relative '../../processor'
5
+ ## require_relative '../../app/core'
6
+
7
+ # Test Trepan:CmdProcessor
8
+ class TestCmdProcessor < Test::Unit::TestCase
9
+
10
+ include UnitHelper
11
+ def setup
12
+ common_setup
13
+ @cmds = @cmdproc.instance_variable_get('@commands')
14
+ end
15
+
16
+ # See that we have can load up commands
17
+ def test_command_load
18
+ assert @cmds.is_a?(Hash), 'Should have gotten a command hash'
19
+ assert @cmds.keys.size > 0, 'Should have found at least one command'
20
+ cmd_name, cmd_obj = @cmds.first
21
+ assert cmd_name.is_a?(String), 'Should have string name for a command'
22
+ assert(cmd_obj.kind_of?(Trepan::Command),
23
+ 'Command should be a Trapan::Command')
24
+ assert cmd_obj.respond_to?(:run), 'Command should have a run method'
25
+ end
26
+
27
+ def no_test_compute_prompt
28
+ assert_equal('(rbdbgr): ', @cmdproc.compute_prompt)
29
+ Thread.new{ assert_equal('(rbdbgr@55): ', @cmdproc.compute_prompt.gsub(/@\d+/, '@55'))}.join
30
+ x = Thread.new{ Thread.pass; x = 1 }
31
+ assert_equal('(rbdbgr@main): ', @cmdproc.compute_prompt)
32
+ x.join
33
+ @cmdproc.debug_nest += 1
34
+ assert_equal('((rbdbgr)): ', @cmdproc.compute_prompt)
35
+ @cmdproc.debug_nest -= 1
36
+ end
37
+
38
+ # See that each command has required constants defined. Possibly in
39
+ # a strongly-typed language we wouldn't need to do much of this.
40
+ def test_command_class_vars
41
+ @cmds.each do |cmd_name, cmd|
42
+ %w(HELP CATEGORY NAME SHORT_HELP).each do
43
+ |const|
44
+ value = cmd.class.const_get(const)
45
+ assert(value.is_a?(String),
46
+ "#{const} in command #{cmd_name} should be a String; got #{value}.")
47
+ end
48
+ %w(MIN_ARGS MAX_ARGS).each do
49
+ |const|
50
+ value = cmd.class.const_get(const)
51
+ assert(value.is_a?(Fixnum) || value.nil?,
52
+ "#{const} in command #{cmd_name} should be a Fixnum or nil; got #{value}.")
53
+ end
54
+ %w(ALIASES).each do
55
+ |const|
56
+ next unless cmd.class.constants.member?(:ALIASES)
57
+ ary = cmd.class.const_get(const)
58
+ assert(ary.is_a?(Array),
59
+ "#{const} in command #{cmd_name} should be an Array")
60
+
61
+ ary.each do |v|
62
+ assert(v.is_a?(String),
63
+ "#{const} in command #{cmd_name} should be Array of Strings; got #{v}.")
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ def no__test_run_command
70
+ def run_and_check(cmd, expect_msgs, expect_errmsgs, add_msg)
71
+ $errs = []; $msgs = []
72
+ @cmdproc.run_command(cmd)
73
+ assert_equal(expect_msgs, $msgs,
74
+ "#{add_msg}: mismatched messages from #{caller[0]}")
75
+ assert_equal(expect_errmsgs, $errs,
76
+ "Mismatched error messages from #{caller[0]}")
77
+ end
78
+ def @cmdproc.msg(mess, opts={})
79
+ $msgs << "#{mess}"
80
+ end
81
+ def @cmdproc.errmsg(mess, opts={})
82
+ $errs << "#{mess}"
83
+ end
84
+ run_and_check('!s=1', ['D=> 1'], [], "! evaluation")
85
+ run_and_check('print "foo"', ['foo'], [], "print command")
86
+ run_and_check('set autoeval off',
87
+ ['Evaluation of unrecognized debugger commands is off.'], [],
88
+ "autoeval set")
89
+ run_and_check('asdf', [],
90
+ ['Undefined command: "asdf". Try "help".'],
91
+ "invalid command")
92
+
93
+ end
94
+
95
+ end
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../processor'
5
+ require_relative '../../processor/validate'
6
+ require_relative '../../app/mock'
7
+ require_relative 'cmd-helper'
8
+
9
+ $errors = []
10
+ $msgs = []
11
+
12
+ # Test Trepan::CmdProcessor Validation portion
13
+ class TestValidate < Test::Unit::TestCase
14
+
15
+ def setup
16
+ $errors = []
17
+ $msgs = []
18
+ @dbg ||= MockDebugger::MockDebugger.new(:nx => true)
19
+ @cmdproc = Trepan::CmdProcessor.new(@dbg)
20
+
21
+ class << @cmdproc
22
+ def errmsg(msg)
23
+ $errors << msg
24
+ end
25
+ def print_location
26
+ # $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
27
+ $msgs << "#{@frame.source_container} "
28
+ # puts $msgs
29
+ end
30
+ end
31
+ end
32
+
33
+ def test_get_int
34
+ [['1', 1], ['1E', nil], ['bad', nil], ['1+1', 2], ['-5', -5]].each do
35
+ |arg, expected|
36
+ assert_equal(expected, @cmdproc.get_int_noerr(arg))
37
+ end
38
+ end
39
+
40
+ def test_get_on_off
41
+ onoff =
42
+ [['1', true], ['on', true],
43
+ ['0', false], ['off', false]].each do |arg, expected|
44
+ assert_equal(expected, @cmdproc.get_onoff(arg))
45
+ end
46
+ end
47
+
48
+ include UnitHelper
49
+ def outer_line
50
+ @line = __LINE__
51
+ end
52
+
53
+ def test_parse_position
54
+ common_setup
55
+ outer_line
56
+ @dbg.instance_variable_set('@current_frame',
57
+ Trepan::Frame.new(self, 0,
58
+ Rubinius::VM.backtrace(0, true)[0]))
59
+ @cmdproc.frame_setup
60
+ file = File.basename(__FILE__)
61
+ [
62
+ [__FILE__, [true, file, nil, nil]],
63
+ ['@8', [true, file, 8, :offset]],
64
+ [@line.to_s , [true, file, @line, :line]],
65
+ ['2' , [true, file, 2, :line]],
66
+ ["#{__FILE__}:#{__LINE__}" , [true, file, __LINE__, :line]],
67
+ ["#{__FILE__} #{__LINE__}" , [true, file, __LINE__, :line]]
68
+ ].each do |pos_str, expected|
69
+ result = @cmdproc.parse_position(pos_str)
70
+ result[1] = File.basename(result[1])
71
+ result[0] = !!result[0]
72
+ assert_equal(expected, result, "parsing position #{pos_str}")
73
+ end
74
+ end
75
+
76
+ def test_file_exists_proc
77
+ load 'tmpdir.rb'
78
+ # %W(#{__FILE__} tmpdir.rb mock.rb).each do |name|
79
+ %W(#{__FILE__}).each do |name|
80
+ assert_equal true, @cmdproc.file_exists_proc.call(name), "Should find #{name}"
81
+ end
82
+ %W(#{File.dirname(__FILE__)} tmpdir).each do |name|
83
+ assert_equal false, !!@cmdproc.file_exists_proc.call(name), "Should not find #{name}"
84
+ end
85
+ end
86
+
87
+ def test_breakpoint_position
88
+ start_line = __LINE__
89
+ common_setup
90
+ outer_line
91
+ @dbg.instance_variable_set('@current_frame',
92
+ Trepan::Frame.new(self, 0,
93
+ Rubinius::VM.backtrace(0, true)[0]))
94
+ @cmdproc.frame_setup
95
+
96
+ def munge(args)
97
+ args[0] = args[0].class
98
+ args
99
+ end
100
+
101
+ assert_equal([Rubinius::CompiledMethod, start_line, 0, 'true', false],
102
+ munge(@cmdproc.breakpoint_position('@0', false)))
103
+ result = @cmdproc.breakpoint_position("outer_line:#{@line}", true)
104
+ result[0] = result[0].name
105
+ assert_equal([:outer_line, @line, 0, 'true', false], result)
106
+ result = @cmdproc.breakpoint_position("#{@line} unless 1 == 2", true)
107
+ result[0] = result[0].name
108
+ assert_equal([:outer_line, @line, 0, '1 == 2', true], result)
109
+ end
110
+
111
+ def test_int_list
112
+ assert_equal([1,2,3], @cmdproc.get_int_list(%w(1+0 3-1 3)))
113
+ assert_equal(0, $errors.size)
114
+ assert_equal([2,3], @cmdproc.get_int_list(%w(a 2 3)))
115
+ assert_equal(1, $errors.size)
116
+ end
117
+
118
+ def test_method?
119
+ def foo; 5 end
120
+
121
+ # require_relative '../../lib/rbdbgr'
122
+ # dbgr = Trepan.new(:set_restart => true)
123
+ # FIXME: 'foo',
124
+ ['Array.map', 'Trepan::CmdProcessor.new',
125
+ 'errmsg'
126
+ ].each do |str|
127
+ # dbgr.debugger if 'foo' == str
128
+ assert @cmdproc.method?(str), "#{str} should be known as a method"
129
+ end
130
+ ['food', '.errmsg'
131
+ ].each do |str|
132
+ # dbgr.debugger if 'foo' == str
133
+ assert_equal(false, !!@cmdproc.method?(str),
134
+ "#{str} should not be known as a method")
135
+ end
136
+
137
+ end
138
+
139
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../processor'
5
+
6
+ # Test Trepan::CmdProcessor
7
+ class TestSubCmdHelp < Test::Unit::TestCase
8
+
9
+ def setup
10
+ @dbg = Trepan.new
11
+ @cmdproc = Trepan::CmdProcessor.new(@dbg)
12
+ @cmds = @cmdproc.instance_variable_get('@commands')
13
+ end
14
+
15
+ # See that subcommand class constants exist.
16
+ def test_required_class_constants
17
+ @cmds.each do |cmd_name, cmd|
18
+ if cmd.is_a?(Trepan::SubcommandMgr)
19
+ cmd.subcmds.subcmds.each do |subcmd_name, subcmd|
20
+ where = "of subcommand #{subcmd_name} in command #{cmd_name}"
21
+ %w(HELP NAME SHORT_HELP).each do
22
+ |const|
23
+ value = subcmd.my_const(const)
24
+ assert_equal(true, value.is_a?(String),
25
+ "#{const} #{where} should be a String; got #{value}.")
26
+ end
27
+ value = subcmd.my_const('MIN_ABBREV')
28
+ assert(value.is_a?(Fixnum),
29
+ "MIN_ABBREV #{where} should be a Fixnum; got #{value}.")
30
+
31
+ if 'show' == cmd_name
32
+ short_help = subcmd.my_const('SHORT_HELP')
33
+ needed_start = 'Show '
34
+ assert_equal(needed_start, short_help[0..needed_start.size-1],
35
+ "Short help #{where} should start: \"#{needed_start}\"; got #{short_help}")
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ end