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,72 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'optparse'
4
+ require 'rubygems'; require 'require_relative'
5
+ require_relative '../command'
6
+ require_relative '../../app/default'
7
+ require_relative '../../interface/server' # server interface (remote debugging)
8
+ class Trepan::Command::ServerCommand < Trepan::Command
9
+ include Trepanning
10
+
11
+ unless defined?(HELP)
12
+ CATEGORY = 'support'
13
+ DEFAULT_OPTIONS = {
14
+ :host => Trepan::DEFAULT_SETTINGS[:host],
15
+ :port => Trepan::DEFAULT_SETTINGS[:port]
16
+ }
17
+ MAX_ARGS = 4 # Need at most this many
18
+ NAME = File.basename(__FILE__, '.rb')
19
+ HELP = <<-HELP
20
+ #{NAME} [{--port|-p} NUM] [{--host|-h} HOST-OR-IP]
21
+
22
+ Put session into server mode which allows an out-of-process or remote
23
+ connection to the debugged program. --port and --host can be supplied
24
+ to specify the port number to use and the host name for TCP
25
+ connections. If neither is given, the default host (#{Trepan::DEFAULT_SETTINGS[:host]})
26
+ and the default port (#{Trepan::DEFAULT_SETTINGS[:port]}) are used.
27
+
28
+ Examples:
29
+ #{NAME} # Accept remote connections using defaults
30
+ #{NAME} --port 123 # Accept remote connections on port 123
31
+ #{NAME} --host my.host.net --port 2048
32
+ #{NAME} -h my.host.net -p 2048 # same as above
33
+ HELP
34
+
35
+ SHORT_HELP = 'Go into out-of-process debugging (server) mode'
36
+
37
+ end
38
+
39
+ def parse_options(options, args) # nodoc
40
+ parser = OptionParser.new do |opts|
41
+ opts.on("-h", "--host NAME", String,
42
+ "Host or IP used in TCP connections for --server or --client. " +
43
+ "Default is #{DEFAULT_SETTINGS[:host].inspect}.") do
44
+ |name_or_ip|
45
+ options[:host] = name_or_ip
46
+ end
47
+ opts.on("-p", "--port NUMBER", Integer,
48
+ "Port number used in TCP connections for --server or --client. " +
49
+ "Default is #{DEFAULT_SETTINGS[:port]}.") do
50
+ |num|
51
+ options[:port] = num
52
+ end
53
+ end
54
+ parser.parse(args)
55
+ return options
56
+ end
57
+
58
+ # This method runs the command
59
+ def run(args) # :nodoc
60
+ options = parse_options(DEFAULT_OPTIONS.dup, args[1..-1])
61
+ msg("starting debugger in out-of-process mode on host #{options[:host].inspect}, " +
62
+ "port: #{options[:port]}")
63
+ @proc.dbgr.intf << Trepan::ServerInterface.new(nil, nil, options)
64
+ end
65
+ end
66
+
67
+ if __FILE__ == $0
68
+ require_relative '../mock'
69
+ dbgr, cmd = MockDebugger::setup
70
+ # cmd.run([cmd.name])
71
+ # cmd.run([cmd.name, '--server'])
72
+ end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'base/submgr'
5
+
6
+ class Trepan::Command::SetCommand < Trepan::SubcommandMgr
7
+ unless defined?(HELP)
8
+ HELP =
9
+ 'Modifies parts of the debugger environment.
10
+
11
+ You can give unique prefix of the name of a subcommand to get
12
+ information about just that subcommand.
13
+
14
+ Type "set" for a list of "set" subcommands and what they do.
15
+ Type "help set *" for just the list of "set" subcommands.
16
+
17
+ For compatability with older ruby-debug "set auto..." is the
18
+ same as "set auto ...". For example "set autolist" is the same
19
+ as "set auto list".
20
+ '
21
+
22
+ CATEGORY = 'support'
23
+ NAME = File.basename(__FILE__, '.rb')
24
+ NEED_STACK = false
25
+ SHORT_HELP = 'Modify parts of the debugger environment'
26
+ end
27
+
28
+ def run(args)
29
+ if args.size > 1
30
+ first = args[1].downcase
31
+ alen = 'auto'.size
32
+ args[1..1] = ['auto', first[alen..-1]] if
33
+ first.start_with?('auto') && first.size > alen
34
+ end
35
+ super
36
+ end
37
+
38
+ end
39
+
40
+ if __FILE__ == $0
41
+ require_relative '../mock'
42
+ dbgr, cmd = MockDebugger::setup
43
+ cmd.run([cmd.name])
44
+ cmd.run([cmd.name, 'autolist'])
45
+ cmd.run([cmd.name, 'autoeval', 'off'])
46
+ cmd.run([cmd.name, 'basename'])
47
+ end
@@ -0,0 +1,2 @@
1
+ /*~
2
+ /*.rbc
@@ -0,0 +1,25 @@
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::SetAbbrev < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Set to allow unique abbreviations of commands"
9
+ IN_LIST = true
10
+ MIN_ABBREV = 'ab'.size
11
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
12
+ end
13
+
14
+ end
15
+
16
+ if __FILE__ == $0
17
+ # Demo it.
18
+ $0 = __FILE__ + 'notagain' # So we don't run this again
19
+ require_relative '../../mock'
20
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetAbbrev, false)
21
+ cmd.run(cmd.prefix + ['off'])
22
+ cmd.run(cmd.prefix + ['ofn'])
23
+ cmd.run(cmd.prefix)
24
+ puts cmd.save_command
25
+ end
@@ -0,0 +1,33 @@
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::SetAuto < Trepan::SubSubcommandMgr
8
+ unless defined?(HELP)
9
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
+ HELP = <<-EOH
11
+ Set controls for things with some sort of "automatic" default behavior.
12
+
13
+ See "#{PREFIX.join(' ')} *" for a list of subcommands or "#{PREFIX.join(' ')} <name>"
14
+ for help on a particular trace subcommand.
15
+ EOH
16
+ SHORT_HELP = 'Set controls for some "automatic" default behaviors';
17
+ end
18
+ end
19
+
20
+ if __FILE__ == $0
21
+ require_relative '../../mock'
22
+ dbgr, cmd = MockDebugger::setup('set')
23
+ # cmds = dbgr.core.processor.commands
24
+ # set_cmd = cmds['set']
25
+ # command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
26
+ # set_cmd)
27
+ # name = File.basename(__FILE__, '.rb')
28
+ # cmd_args = ['set', name]
29
+ # set_cmd.instance_variable_set('@last_args', cmd_args)
30
+ # # require_relative '../../../lib/trepanning'
31
+ # # Trepan.debug(:set_restart => true)
32
+ # command.run(cmd_args)
33
+ end
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,33 @@
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::Subcommand::SetAutoDis < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Set to run a 'disassemble' command each time we enter the debugger"
9
+ MIN_ABBREV = 'd'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %W(set auto #{NAME})
12
+ SHORT_HELP = "Set running a 'disassemble' command each time we enter the debugger"
13
+ end
14
+
15
+ def run(args)
16
+ super
17
+ if @proc.settings[:autodis]
18
+ @proc.cmdloop_prehooks.insert_if_new(10, *@proc.autodis_hook)
19
+ else
20
+ @proc.cmdloop_prehooks.delete_by_name('autodis')
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ if __FILE__ == $0
27
+ # Demo it.
28
+ require_relative '../../../mock'
29
+ require_relative '../auto'
30
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
31
+ Trepan::SubSubcommand::SetAutoDis)
32
+ cmd.run([cmd.name, 'off'])
33
+ end
@@ -0,0 +1,53 @@
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::SetAutoEval < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Evaluate unrecognized debugger commands.
10
+
11
+ Often inside the debugger, one would like to be able to run arbitrary
12
+ Ruby commands without having to preface Python expressions with \"print\" or
13
+ \"eval\". Setting \"auto eval\" on will cause unrecognized debugger
14
+ commands to be eval'd as a Ruby expression.
15
+
16
+ Note that if this is set, on error the message shown on type a bad
17
+ debugger command changes from:
18
+
19
+ Undefined command: \"fdafds\". Try \"help\".
20
+
21
+ to something more Ruby-eval-specific such as:
22
+
23
+ NameError: name 'fdafds' is not defined
24
+
25
+ One other thing that trips people up is when setting auto eval is that
26
+ there are some short debugger commands that sometimes one wants to use
27
+ as a variable, such as in an assignment statement. For example:
28
+
29
+ s = 5
30
+
31
+ which produce when 'auto eval' is on:
32
+ *** Command 'step' can take at most 1 argument(s); got 2.
33
+
34
+ because by default, 's' is an alias for the debugger 'step'
35
+ command. It is possible to remove that alias if this causes constant
36
+ problem. Another possibility is to go into a real Ruby shell via the
37
+ 'irb' command.
38
+ "
39
+ MIN_ABBREV = 'ev'.size
40
+ SHORT_HELP = "Set evaluation of unrecognized debugger commands"
41
+ end
42
+
43
+ end
44
+
45
+ if __FILE__ == $0
46
+ # Demo it.
47
+ require_relative '../../../mock'
48
+ require_relative '../auto'
49
+
50
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
51
+ Trepan::SubSubcommand::SetAutoEval)
52
+ cmd.run([cmd.name, 'off'])
53
+ end
@@ -0,0 +1,33 @@
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::Subcommand::SetAutoIrb < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Set to automatically go into irb each time we enter the debugger"
10
+ MIN_ABBREV = 'ir'.size
11
+ end
12
+
13
+ def run(args)
14
+ super
15
+ if @proc.settings[:autoirb]
16
+ @proc.cmdloop_prehooks.insert_if_new(-1, *@proc.autoirb_hook)
17
+ else
18
+ @proc.cmdloop_prehooks.delete_by_name('autoirb')
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ if __FILE__ == $0
25
+ # Demo it.
26
+ require_relative '../../../mock'
27
+ require_relative '../auto'
28
+
29
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
30
+ Trepan::SubSubcommand::SetAutoIrb)
31
+ cmd.run([cmd.name, 'off'])
32
+ cmd.run([cmd.name, 'on'])
33
+ end
@@ -0,0 +1,33 @@
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::Subcommand::SetAutoList < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Set to run a 'list' command each time we enter the debugger"
10
+ MIN_ABBREV = 'l'.size
11
+ SHORT_HELP = "Set running a 'list' command each time we enter the debugger"
12
+ end
13
+
14
+ def run(args)
15
+ super
16
+ if @proc.settings[:autolist]
17
+ @proc.cmdloop_prehooks.insert_if_new(10, *@proc.autolist_hook)
18
+ else
19
+ @proc.cmdloop_prehooks.delete_by_name('autolist')
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ if __FILE__ == $0
26
+ # Demo it.
27
+ require_relative '../../../mock'
28
+ require_relative '../auto'
29
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
30
+ Trepan::SubSubcommand::SetAutoList)
31
+ cmd.run([cmd.name, 'off'])
32
+ cmd.run([cmd.name, 'on'])
33
+ end
@@ -0,0 +1,25 @@
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::SetBasename < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Set to show only file basename in showing file names"
9
+ IN_LIST = true
10
+ MIN_ABBREV = 'ba'.size
11
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
12
+ end
13
+
14
+ end
15
+
16
+ if __FILE__ == $0
17
+ # Demo it.
18
+ $0 = __FILE__ + 'notagain' # So we don't run this again
19
+ require_relative '../../mock'
20
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetBasename, false)
21
+ cmd.run(cmd.prefix + ['off'])
22
+ cmd.run(cmd.prefix + ['ofn'])
23
+ cmd.run(cmd.prefix)
24
+ puts cmd.save_command
25
+ end
@@ -0,0 +1,24 @@
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::SetConfirm < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Set whether to confirm potentially dangerous operations."
10
+ IN_LIST = true
11
+ MIN_ABBREV = 'co'.size
12
+ end
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ $0 = __FILE__ + 'notagain' # So we don't run this agin
18
+ require_relative '../../mock'
19
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetConfirm, false)
20
+ cmd.run(cmd.prefix + ['off'])
21
+ cmd.run(cmd.prefix + ['ofn'])
22
+ cmd.run(cmd.prefix)
23
+ puts cmd.save_command
24
+ end
@@ -0,0 +1,26 @@
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::SetDebug < Trepan::SubSubcommandMgr
8
+ unless defined?(HELP)
9
+ HELP = 'Set internal debugger settings'
10
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
11
+ end
12
+ end
13
+
14
+ if __FILE__ == $0
15
+ require_relative '../../mock'
16
+ dbgr, cmd = MockDebugger::setup('set')
17
+ set_cmd = cmds['set']
18
+ # command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
19
+ # set_cmd)
20
+ # name = File.basename(__FILE__, '.rb')
21
+ # cmd_args = ['set', name]
22
+ # set_cmd.instance_variable_set('@last_args', cmd_args)
23
+ # # require_relative '../../../lib/trepanning'
24
+ # # Trepan.debug(:set_restart => true)
25
+ # command.run(cmd_args)
26
+ end
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -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::SetDebugDbgr < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'set debug dbgr [on|off]
9
+
10
+ Facilitates debugging the debugger. Global variables $trepan_cmdproc
11
+ and $trepan_frame are set to the current values of @frame and self
12
+ when the command processor was entered. '
13
+
14
+ MIN_ABBREV = 'db'.size
15
+ NAME = File.basename(__FILE__, '.rb')
16
+ PREFIX = %W(set debug #{NAME})
17
+ SHORT_HELP = 'Set debugging debugger'
18
+ end
19
+
20
+ def run(args)
21
+ super
22
+ @proc.cmdloop_prehooks.insert_if_new(-1, *@proc.debug_dbgr_hook)
23
+ @proc.debug_dbgr_hook[1].call
24
+ end
25
+
26
+ end
27
+
28
+ if __FILE__ == $0
29
+ # Demo it.
30
+ require_relative '../../../mock'
31
+ require_relative '../debug'
32
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
33
+ Trepan::SubSubcommand::SetDebugDbgr)
34
+ cmd.run([cmd.name, 'off'])
35
+ cmd.run([cmd.name, 'on'])
36
+ end
@@ -0,0 +1,23 @@
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::SetDebugSkip < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Set debugging of statement skip logic'
9
+ MIN_ABBREV = 'sk'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %W(set debug #{NAME})
12
+ end
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ require_relative '../debug'
19
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
20
+ Trepan::SubSubcommand::SetDebugSkip)
21
+ cmd.run([cmd.name, 'off'])
22
+ cmd.run([cmd.name, 'on'])
23
+ end
@@ -0,0 +1,23 @@
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::SetDebugStep < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Set debugging of statement step logic'
9
+ MIN_ABBREV = 'st'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %W(set debug #{NAME})
12
+ end
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ require_relative '../debug'
19
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
20
+ Trepan::SubSubcommand::SetDebugStep)
21
+ cmd.run([cmd.name, 'off'])
22
+ cmd.run([cmd.name, 'on'])
23
+ end
@@ -0,0 +1,61 @@
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::SetDifferent < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{PREFIX.join(' ')} [on|off|nostack]
11
+
12
+ Set to make sure 'next' or 'step' moves to a new position.
13
+
14
+ Due to the interpretive, expression-oriented nature of the Ruby
15
+ Language and implementation, each line often may contain many possible
16
+ stopping points with possibly different event type. In a debugger it
17
+ is sometimes desirable to continue but stop only when the position
18
+ next changes.
19
+
20
+ Setting 'different' to on will cause each 'step' or 'next' command to
21
+ stop at a different position.
22
+
23
+ Note though that the notion of different does take into account stack
24
+ nesting. So in ARGV.map {|arg| arg.to_i} you get a stop before ARGV as
25
+ well as one in the block.
26
+
27
+ If you to ignore stopping at added nesting levels, there are two
28
+ possibilities. 'set step nostack' will ignore stack nestings levels on
29
+ a given line. Also you can use 'next', but that also stepping into
30
+ functions on different lines to also be skipped.
31
+
32
+ See also 'step', 'next' which have suffixes '+' and '-' which
33
+ override this setting.
34
+ EOH
35
+
36
+ IN_LIST = true
37
+ MIN_ABBREV = 'dif'.size
38
+ SHORT_HELP = "Set to make sure 'next/step' move to a new position."
39
+ end
40
+
41
+ completion %w(on off nostack)
42
+
43
+ def run(args)
44
+ if args.size == 3 && 'nostack' == args[2]
45
+ @proc.settings[:different] = 'nostack'
46
+ msg("different is nostack.")
47
+ else
48
+ super
49
+ end
50
+ @proc.different_pos = @proc.settings[:different]
51
+ end
52
+
53
+ end
54
+
55
+ if __FILE__ == $0
56
+ # Demo it.
57
+ require_relative '../../mock'
58
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetDifferent)
59
+ cmd.run(cmd.prefix + ['off'])
60
+ puts cmd.save_command
61
+ end
@@ -0,0 +1,62 @@
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::SetHidelevel < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{PREFIX.join(' ')} [NUM]
11
+
12
+ Hide this many stack frames from the bottom (or least-recent) frame.
13
+
14
+ Often the bottom-most frames are setup frames that one doesn't think
15
+ of as being part of one's program but are part of the overhead loading
16
+ or debugging the program. As such generally they are unintersting in
17
+ a backtrace command and one wants these omitted.
18
+
19
+ If NUM is 0, no stack frames are hidden. If NUM is < 0 or omitted,
20
+ then use value the program sets automatically. If the value is larger
21
+ than the current number of entries in the stack, i.e. the stack shown
22
+ would be otherwise be, empty then we show all entries, or take NUM to
23
+ be 0.
24
+
25
+ Examples:
26
+ #{PREFIX.join(' ')} # Use the default value and hide 'uninteresting' ones
27
+ #{PREFIX.join(' ')} 0 # Show all stack entries, even from loading the program
28
+ # or initial stack entries the debugger created to
29
+ # debug the program.
30
+ #{PREFIX.join(' ')} 1 # Hide only the bottom-most or least-recent stack frame.
31
+
32
+ See also 'backtrace' and 'show hidelevel'.
33
+ .
34
+ EOH
35
+
36
+ IN_LIST = true
37
+ MIN_ABBREV = 'hide'.size
38
+ SHORT_HELP = "Set the number of bottom frames to hide."
39
+ end
40
+
41
+ def run(args)
42
+ if args.size == 2
43
+ val = nil
44
+ else
45
+ val = @proc.get_an_int(args[2])
46
+ return unless val
47
+ end
48
+ @proc.hidelevels[@current_thread] = nil
49
+ @proc.settings[:hidelevel] = val
50
+ @proc.set_hide_level
51
+ @proc.run_command('show hidelevel')
52
+ end
53
+
54
+ end
55
+
56
+ if __FILE__ == $0
57
+ # Demo it.
58
+ require_relative '../../mock'
59
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetHidelevel, false)
60
+ cmd.run(cmd.prefix + %w(10))
61
+ cmd.run(cmd.prefix)
62
+ end
@@ -0,0 +1,39 @@
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::SetHighlight < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = 'Set whether we use terminal highlighting'
10
+ IN_LIST = true
11
+ MIN_ABBREV = 'hi'.size
12
+ end
13
+
14
+ def complete(prefix)
15
+ Trepan::Complete.complete_token(%w(on off reset), prefix)
16
+ end
17
+
18
+ def run(args)
19
+ if args.size == 3 && 'reset' == args[2]
20
+ LineCache::clear_file_format_cache
21
+ @proc.settings[:highlight] = :term
22
+ else
23
+ super
24
+ @proc.settings[:highlight] = :term if @proc.settings[:highlight]
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ if __FILE__ == $0
31
+ # Demo it.
32
+ $0 = __FILE__ + 'notagain' # So we don't run this again
33
+ require_relative '../../mock'
34
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetHighlight, false)
35
+ cmd.run(cmd.prefix + ['off'])
36
+ cmd.run(cmd.prefix + ['ofn'])
37
+ cmd.run(cmd.prefix)
38
+ puts cmd.save_command
39
+ end