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,34 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::ShowKernelstep < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Show stepping into kernel methods"
10
+ MIN_ABBREV = 'kern'.size
11
+
12
+ # Specific to this class
13
+ KERNEL_METHOD_FILE_RE = /^kernel\//
14
+ end
15
+
16
+ def ignore?
17
+ @proc.ignore_file_re.member?(KERNEL_METHOD_FILE_RE)
18
+ end
19
+
20
+ def show
21
+ msg("stepping into kernel methods is %s." %
22
+ (ignore? ? 'disallowed' : 'allowed'))
23
+ end
24
+
25
+ def run(args)
26
+ show
27
+ end
28
+ end
29
+
30
+ if __FILE__ == $0
31
+ # Demo it.
32
+ require_relative '../../mock'
33
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowKernelstep)
34
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subsubcmd'
5
+ require_relative '../base/subsubmgr'
6
+
7
+ class Trepan::SubSubcommand::ShowMax < Trepan::SubSubcommandMgr
8
+ unless defined?(HELP)
9
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
+ HELP = 'Show "maximum length" settings'
11
+ end
12
+
13
+ def run(args)
14
+ super
15
+ end
16
+ end
17
+
18
+ if __FILE__ == $0
19
+ require_relative '../../mock'
20
+ cmd_ary = Trepan::SubSubcommand::ShowMax::PREFIX
21
+ dbgr, parent_cmd = MockDebugger::setup(cmd_ary[0], false)
22
+ cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.processor,
23
+ parent_cmd)
24
+ cmd_name = cmd_ary.join('')
25
+ prefix_run = cmd_ary[1..-1]
26
+ cmd.run(prefix_run)
27
+ end
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::ShowMaxList < Trepan::ShowIntSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Show the number of source file lines to list'
9
+ MIN_ABBREV = 'lis'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %w(show max list)
12
+ end
13
+
14
+ end
15
+
16
+ if __FILE__ == $0
17
+ # Demo it.
18
+ require_relative '../../../mock'
19
+
20
+ # FIXME: DRY the below code
21
+ cmd_ary = Trepan::SubSubcommand::ShowMaxList::PREFIX
22
+ dbgr, parent_cmd = MockDebugger::setup(cmd_ary[0], false)
23
+ cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.processor,
24
+ parent_cmd)
25
+ cmd_name = cmd_ary.join('')
26
+ subcmd = Trepan::SubSubcommand::ShowMaxList.new(parent_cmd.proc,
27
+ cmd,
28
+ cmd.name)
29
+ prefix_run = cmd_ary[1..-1]
30
+ subcmd.run(prefix_run)
31
+
32
+ # require_relative '../../../../lib/trepanning'
33
+ # dbgr = Trepan.new(:set_restart => true)
34
+ # dbgr.debugger
35
+ puts subcmd.summary_help(cmd.name)
36
+ puts
37
+ puts '-' * 20
38
+ end
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::ShowMaxStack < Trepan::ShowIntSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Show the number of backtrace lines the debugger will show'
9
+ MIN_ABBREV = 'sta'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %w(show max stack)
12
+ end
13
+
14
+ end
15
+
16
+ if __FILE__ == $0
17
+ # Demo it.
18
+ require_relative '../../../mock'
19
+
20
+ # FIXME: DRY the below code
21
+ dbgr, show_cmd = MockDebugger::setup('show')
22
+ testcmdMgr = Trepan::Subcmd.new(show_cmd)
23
+ # max_cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.core.processor,
24
+ # show_cmd)
25
+
26
+ # cmd_name = Trepan::SubSubcommand::ShowMaxStack::PREFIX.join('')
27
+ # maxx_cmd = Trepan::SubSubcommand::ShowMaxStack.new(show_cmd.proc,
28
+ # max_cmd,
29
+ # cmd_name)
30
+ # # require_relative '../../../../lib/trepanning'
31
+ # # dbgr = Trepan.new(:set_restart => true)
32
+ # # dbgr.debugger
33
+ puts max_cmd.summary_help(maxx_cmd)
34
+ puts
35
+ # maxx_cmd.run([])
36
+ end
@@ -0,0 +1,42 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::ShowMaxString < Trepan::ShowIntSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Show the number of characters in a string before truncating.
9
+
10
+ Sometimes the string representation of an object is very long. This
11
+ setting limits how much of the string representation you want to
12
+ see. However if the string has an embedded newline then we will assume
13
+ the output is intended to be formated as.'
14
+ MIN_ABBREV = 'st'.size
15
+ NAME = File.basename(__FILE__, '.rb')
16
+ PREFIX = %w(show max string)
17
+ end
18
+
19
+ end
20
+
21
+ if __FILE__ == $0
22
+ # Demo it.
23
+ require_relative '../../../mock'
24
+
25
+ # FIXME: DRY the below code
26
+ dbgr, show_cmd = MockDebugger::setup('show')
27
+ testcmdMgr = Trepan::Subcmd.new(show_cmd)
28
+ # max_cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.core.processor,
29
+ # show_cmd)
30
+
31
+ # cmd_name = Trepan::SubSubcommand::ShowMaxString::PREFIX.join('')
32
+ # maxx_cmd = Trepan::SubSubcommand::ShowMaxString.new(show_cmd.proc,
33
+ # max_cmd,
34
+ # cmd_name)
35
+
36
+ # # require_relative '../../../../lib/trepanning'
37
+ # # dbgr = Trepan.new(:set_restart => true)
38
+ # # dbgr.debugger
39
+ puts max_cmd.summary_help(maxx_cmd)
40
+ puts
41
+ maxx_cmd.run([])
42
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::ShowMaxWidth < Trepan::ShowIntSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Show the number of characters the debugger thinks are in a line.'
9
+ MIN_ABBREV = 'wid'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %w(show max width)
12
+ end
13
+
14
+ end
15
+
16
+ if __FILE__ == $0
17
+ # Demo it.
18
+ require_relative '../../../mock'
19
+
20
+ # FIXME: DRY the below code
21
+ dbgr, show_cmd = MockDebugger::setup('show')
22
+ testcmdMgr = Trepan::Subcmd.new(show_cmd)
23
+ # max_cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.core.processor,
24
+ # show_cmd)
25
+ # cmd_name = Trepan::SubSubcommand::ShowMaxWidth::PREFIX.join('')
26
+ # maxx_cmd = Trepan::SubSubcommand::ShowMaxWidth.new(show_cmd.proc,
27
+ # max_cmd,
28
+ # cmd_name)
29
+
30
+ name = File.basename(__FILE__, '.rb')
31
+ # require_relative '../../../../lib/trepanning'
32
+ # dbgr = Trepan.new(:set_restart => true)
33
+ # dbgr.debugger
34
+ # puts max_cmd.summary_help(maxx_cmd)
35
+ # puts
36
+ # maxx_cmd.run([])
37
+ end
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::ShowReload < Trepan::ShowBoolSubcommand
7
+ unless defined?(SHORT_HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Show whether to reread source text when it changes"
10
+ MIN_ABBREV = 're'.size
11
+ end
12
+ end
13
+
14
+ if __FILE__ == $0
15
+ # Demo it.
16
+ require_relative '../../mock'
17
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowReload, false)
18
+ end
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::ShowTimer < Trepan::ShowBoolSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Show status of the timing hook"
10
+ MIN_ABBREV = 'ti'.size
11
+ end
12
+ end
13
+
14
+ if __FILE__ == $0
15
+ # Demo it.
16
+ require_relative '../../mock'
17
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowTimer)
18
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subsubcmd'
5
+ require_relative '../base/subsubmgr'
6
+
7
+ class Trepan::SubSubcommand::ShowTrace < Trepan::SubSubcommandMgr
8
+
9
+ unless defined?(HELP)
10
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
11
+ HELP = "Show event tracing printing"
12
+ MIN_ABBREV = 'tr'.size
13
+ SHORT_HELP = HELP
14
+ end
15
+ end
16
+
17
+ if __FILE__ == $0
18
+ # Demo it.
19
+ require_relative '../../mock'
20
+ cmd_ary = Trepan::SubSubcommand::ShowTrace::PREFIX
21
+ dbgr, parent_cmd = MockDebugger::setup(cmd_ary[0], false)
22
+ cmd = Trepan::SubSubcommand::ShowTrace.new(dbgr.processor,
23
+ parent_cmd)
24
+ cmd_name = cmd_ary.join('')
25
+ prefix_run = cmd_ary[1..-1]
26
+ cmd.run(prefix_run)
27
+ end
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,64 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::ShowTraceBuffer < Trepan::ShowBoolSubSubcommand
7
+ Trepanning::SubSubcommand.set_name_prefix(__FILE__, self)
8
+ unless defined?(HELP)
9
+ HELP = <<-EOH
10
+ #{CMD} [NUM]
11
+
12
+ Show the events recorded in the event buffer. If NUM is a negative
13
+ number, events run starting from that many debugger stops back. If NUM
14
+ is a positive number, we print starting from that (adjusted) position
15
+ in the event buffer with Since the event buffer may be a ring, its
16
+ zero being the first position. (Since the event buffer may be a ring
17
+ the earliest position recorded may move around.)
18
+ EOH
19
+ MIN_ABBREV = 'b'.size
20
+ SHORT_HELP = "Show tracing buffer"
21
+ end
22
+
23
+ def parse_show_buffer_args(args)
24
+ marksize = @proc.eventbuf.size
25
+ opts = {
26
+ :max_value => @proc.eventbuf.size,
27
+ :min_value => - marksize,
28
+ :msg_on_error =>
29
+ 'Positive or negative number expected, got %s.' % args[0]
30
+ }
31
+ num = @proc.get_an_int(args[0], opts)
32
+ return nil, nil unless num
33
+ num = marksize + num if num < 0
34
+ first = @proc.eventbuf.zero_pos + num
35
+ return first, nil
36
+ end
37
+
38
+ def run(args)
39
+ if args.size > 1
40
+ if @proc.eventbuf.size == 0
41
+ msg 'no events recorded.'
42
+ errmsg 'event buffer tracing is off. ' +
43
+ 'use "set trace buffer on" to turn on.' unless
44
+ settings[:tracebuffer]
45
+ return
46
+ end
47
+ first, last = parse_show_buffer_args(args[1..-1])
48
+
49
+ return unless first
50
+ @proc.eventbuf_print(first, last, settings[:maxwidth])
51
+ else
52
+ super
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ if __FILE__ == $0
59
+ # Demo it.
60
+ require_relative '../../../mock'
61
+ require_relative '../trace'
62
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::ShowTrace,
63
+ Trepan::SubSubcommand::ShowTraceBuffer)
64
+ end
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::ShowTracePrint < Trepan::ShowBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Show tracing print status"
9
+ MIN_ABBREV = 'p'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %w(show trace buffer)
12
+ SHORT_HELP = "Show tracing print status"
13
+ end
14
+
15
+ end
16
+
17
+ if __FILE__ == $0
18
+ # Demo it.
19
+ require_relative '../../../mock'
20
+ require_relative '../trace'
21
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::ShowTrace,
22
+ Trepan::SubSubcommand::ShowTracePrint)
23
+ end
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../../app/options'
5
+ require_relative '../base/subcmd'
6
+
7
+ class Trepan::Subcommand::ShowVersion < Trepan::Subcommand
8
+ unless defined?(HELP)
9
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
+ HELP = "Show what version of #{Trepan::PROGRAM} this is"
11
+ MIN_ABBREV = 'vers'.size
12
+ end
13
+
14
+ def run(args)
15
+ msg Trepan::show_version
16
+ end
17
+ end
18
+
19
+ if __FILE__ == $0
20
+ # Demo it.
21
+ require_relative '../../mock'
22
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowVersion)
23
+ end
@@ -0,0 +1,133 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'optparse'
4
+
5
+ # Our local modules
6
+ require 'rubygems'; require 'require_relative'
7
+ require_relative '../command'
8
+ require_relative '../../interface/script'
9
+ require_relative '../../io/null_output'
10
+ require_relative '../../app/default'
11
+
12
+ class Trepan::Command::SourceCommand < Trepan::Command
13
+ unless defined?(HELP)
14
+ NAME = File.basename(__FILE__, '.rb')
15
+ HELP = <<-HELP
16
+ #{NAME} [options] FILE
17
+
18
+ options:
19
+ -q | --quiet | --no-quiet
20
+ -c | --continue | --no-continue
21
+ -Y | --yes | -N | --no
22
+ -v | --verbose | --no-verbose
23
+
24
+ Read debugger commands from a file named FILE. Optional -v switch
25
+ causes each command in FILE to be echoed as it is executed. Option -Y
26
+ sets the default value in any confirmation command to be 'yes' and -N
27
+ sets the default value to 'no'.
28
+
29
+ Option -q will turn off any debugger output that normally occurs in the
30
+ running of the program.
31
+
32
+ Note that the command startup file #{Trepan::CMD_INITFILE_BASE} is read automatically
33
+ via a #{NAME} command the debugger is started.
34
+
35
+ An error in any command terminates execution of the command file
36
+ unless option -c or --continue is given.
37
+ HELP
38
+ CATEGORY = 'support'
39
+ MIN_ARGS = 1 # Need at least this many
40
+ MAX_ARGS = nil
41
+ SHORT_HELP = 'Read and run debugger commands from a file'
42
+
43
+ DEFAULT_OPTIONS = {
44
+ :abort_on_error => false,
45
+ :confirm_val => false,
46
+ :quiet => false,
47
+ :verbose => false
48
+ }
49
+
50
+ end
51
+
52
+ def complete(prefix)
53
+ # opts = %w(-c --continue --no-continue -N --no -y --yes
54
+ # --verbose --no-verbose)
55
+ # return Trepan::Complete.complete_token(opts, prefix) if prefix.empty?
56
+ Readline::FILENAME_COMPLETION_PROC.call(prefix) || []
57
+ end
58
+
59
+ def parse_options(options, args) # :nodoc
60
+ seen_yes_no = false
61
+ parser = OptionParser.new do |opts|
62
+ opts.on('-c', '--[no-]continue',
63
+ 'Continue in the face of errors') do
64
+ |v|
65
+ options[:abort_on_error] = !v
66
+ end
67
+ opts.on('-v',
68
+ '--[no-]verbose', 'echo each command as it is executed') do
69
+ |v|
70
+ options[:verbose] = v
71
+ end
72
+ opts.on('-N', '--no', "Use 'no' in any confirmation prompts") do
73
+ |v|
74
+ if seen_yes_no
75
+ msg('Yes/No option already seen. This option (no) ignored.')
76
+ end
77
+ options[:confirm_val] = false
78
+ end
79
+ opts.on('-q', '--[no-]quiet', 'Silence debugger output') do
80
+ |v|
81
+ options[:quiet] = v
82
+ end
83
+ opts.on('-Y', '--yes', "Use 'yes' in any confirmation prompts") do
84
+ |v|
85
+ if seen_yes_no
86
+ msg("Yes/No option already seen. This option, --yes, ignored.")
87
+ end
88
+ options[:confirm_val] = true
89
+ seen_yes_no = true
90
+ end
91
+ end
92
+ parser.parse(args)
93
+ return options
94
+ end
95
+
96
+ def run(args)
97
+ options = parse_options(DEFAULT_OPTIONS.dup, args[1..-2])
98
+ intf = @proc.dbgr.intf
99
+ output = options[:quiet] ? Trepan::OutputNull.new(nil) : intf[-1].output
100
+
101
+ filename = args[-1]
102
+
103
+ expanded_file = File.expand_path(filename)
104
+ unless File.readable?(expanded_file)
105
+ errmsg("Debugger command file '%s' is not a readable file" % filename)
106
+ return false
107
+ end
108
+
109
+ # Push a new debugger interface.
110
+ script_intf = Trepan::ScriptInterface.new(expanded_file, output, options)
111
+ intf << script_intf
112
+ return false
113
+ end
114
+ end
115
+
116
+ # Demo it
117
+ if __FILE__ == $0
118
+ require_relative '../mock'
119
+ dbgr, cmd = MockDebugger::setup
120
+ %w(--quiet -q --no-quiet --continue --no-continue -c -v --verbose
121
+ --no-verbose).each do |opt|
122
+ puts "parsing #{opt}"
123
+ options =
124
+ cmd.parse_options(Trepan::Command::SourceCommand::DEFAULT_OPTIONS.dup,
125
+ opt)
126
+ p options
127
+ end
128
+
129
+ if ARGV.size >= 1
130
+ puts "running... #{cmd.name} #{ARGV}"
131
+ cmd.run([cmd.name, *ARGV])
132
+ end
133
+ end
@@ -0,0 +1,97 @@
1
+ require 'rubygems'; require 'require_relative'
2
+ require_relative '../command'
3
+ require_relative '../../app/condition'
4
+ require_relative '../stepping'
5
+
6
+ class Trepan::Command::StepCommand < Trepan::Command
7
+
8
+ ALIASES = %w(s s+ s- step+ step-)
9
+ CATEGORY = 'running'
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ HELP = <<-HELP
12
+ #{NAME}[+|-] [into] [count]
13
+ #{NAME} until EXPRESSION
14
+ #{NAME} over [args..]
15
+ #{NAME} out [args..]
16
+
17
+ Execute the current line, stopping at the next line. Sometimes this
18
+ is called 'step into'.
19
+
20
+ Behaves like 'next', but if there is a method call on the current line,
21
+ execution is stopped in the called method.
22
+
23
+ Examples:
24
+ #{NAME} # step 1 line
25
+ #{NAME} 1 # same as above
26
+ #{NAME} into # same as above
27
+ #{NAME} into 1 # same as above
28
+ #{NAME} 5/5+0 # same as above
29
+ #{NAME}+ # same but force stopping on a new line
30
+ #{NAME}- # same but force stopping on a new line a new frame added
31
+ #{NAME} until a > b
32
+ #{NAME} over # same as 'next'
33
+ #{NAME} out # same as 'finish'
34
+
35
+ Related and similar is the 'next' (step over) and 'finish' (step out)
36
+ commands.
37
+
38
+ See also the commands:
39
+ 'continue', 'next', 'nexti' and 'finish' for other ways to progress execution.
40
+ HELP
41
+ NEED_RUNNING = true
42
+ SHORT_HELP = 'Step into next method call or to next line'
43
+
44
+ Keyword_to_related_cmd = {
45
+ 'out' => 'finish',
46
+ 'over' => 'next',
47
+ 'into' => 'step',
48
+ }
49
+
50
+ include Trepan::Condition
51
+ # This method runs the command
52
+ def run(args) # :nodoc
53
+ condition = nil
54
+ opts = {}
55
+ if args.size == 1
56
+ step_count = 1
57
+ else
58
+ replace_cmd = Keyword_to_related_cmd[args[1]]
59
+ if replace_cmd
60
+ cmd = @proc.commands[replace_cmd]
61
+ return cmd.run([replace_cmd] + args[2..-1])
62
+ elsif 'until' == args[1]
63
+ try_condition = args[2..-1].join(' ')
64
+ if valid_condition?(try_condition)
65
+ condition = try_condition
66
+ opts[:different_pos] = false
67
+ step_count = 0
68
+ end
69
+ else
70
+ step_str = args[1]
71
+ opts = @proc.parse_next_step_suffix(args[0])
72
+ count_opts = {
73
+ :msg_on_error =>
74
+ "The #{NAME} command argument must eval to an integer. Got: %s" %
75
+ step_str,
76
+ :min_value => 1
77
+ }
78
+ step_count = @proc.get_an_int(step_str, count_opts)
79
+ return unless step_count
80
+ end
81
+ end
82
+
83
+ @proc.step('step', step_count, opts, condition)
84
+ end
85
+ end
86
+
87
+ if __FILE__ == $0
88
+ require_relative '../mock'
89
+ dbgr, cmd = MockDebugger::setup
90
+ [%W(#{cmd.name}), %W(#{cmd.name} 2), %W(#{cmd.name} into 1+2),
91
+ %W(#{cmd.name} over)].each do |c|
92
+ cmd.proc.instance_variable_set('@return_to_program', false)
93
+ cmd.run(c)
94
+ puts 'return_to_program: %s' % cmd.proc.instance_variable_get('@return_to_program')
95
+ puts 'step_count: %s' % cmd.proc.instance_variable_get('@step_count')
96
+ end
97
+ end
@@ -0,0 +1,20 @@
1
+ require 'rubygems'; require 'require_relative'
2
+ require_relative '../command'
3
+ require_relative 'break'
4
+
5
+ class Trepan::Command::SetTempBreakpointCommand <
6
+ Trepan::Command::BreakCommand
7
+ ALIASES = []
8
+ CATEGORY = 'breakpoints'
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ HELP = <<-HELP
11
+ Same as break, but the breakpoint is deleted when it is hit.
12
+ See also "break".
13
+ HELP
14
+ SHORT_HELP = 'Set a temporary breakpoint'
15
+
16
+ def run(args)
17
+ super args, true
18
+ end
19
+ end
20
+