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,93 @@
1
+ require 'rubygems'; require 'require_relative'
2
+ require_relative '../command'
3
+
4
+ class Trepan::Command::FrameCommand < Trepan::Command
5
+ CATEGORY = 'stack'
6
+ HELP = <<-HELP
7
+ frame [frame-number]
8
+
9
+ Change the current frame to frame `frame-number' if specified, or the
10
+ most-recent frame, 0, if no frame number specified.
11
+
12
+ A negative number indicates the position from the other or
13
+ least-recently-entered end. So 'frame -1' moves to the oldest frame.
14
+ Any variable or expression that evaluates to a number can be used as a
15
+ position, however due to parsing limitations, the position expression
16
+ has to be seen as a single blank-delimited parameter. That is, the
17
+ expression '(5*3)-1' is okay while '( (5 * 3) - 1 )' isn't.
18
+
19
+ Examples:
20
+ frame # Set current frame at the current stopping point
21
+ frame 0 # Same as above
22
+ frame 5-5 # Same as above. Note: no spaces allowed in expression 5-5
23
+ frame 1 # Move to frame 1. Same as: frame 0; up
24
+ frame -1 # The least-recent frame
25
+
26
+ See also 'up', 'down', and 'backtrace'.
27
+ HELP
28
+ NAME = File.basename(__FILE__, '.rb')
29
+ SHORT_HELP = 'Make a specific frame in the call stack the current frame'
30
+
31
+ def complete(prefix)
32
+ @proc.frame_complete(prefix, nil)
33
+ end
34
+
35
+ def run(args)
36
+
37
+ if args.size == 1
38
+ # Form is: "frame" which means "frame 0"
39
+ position_str = '0'
40
+ elsif args.size == 2
41
+ # Form is: "frame position"
42
+ position_str = args[1]
43
+ # elsif args.size == 3
44
+ # # Form is: frame <position> <thread>
45
+ # name_or_id = args[1]
46
+ # thread_str = args[2]
47
+ # th = @proc.get_thread_from_string(thread_str)
48
+ # if th
49
+ # @proc.frame_setup(th.threadframe)
50
+ # return
51
+ # else
52
+ # # FIXME: Give suitable error message was given
53
+ # end
54
+ # else
55
+ # # Form should be: "frame thread" which means
56
+ # # "frame thread 0"
57
+ # position_str = '0'
58
+ # ## FIXME:
59
+ # ## @proc.find_and_set_debugged_frame(frame, thread_id)
60
+ end
61
+
62
+ stack_size = @proc.frame.stack_size
63
+ if stack_size == 0
64
+ errmsg('No frames recorded.')
65
+ return false
66
+ end
67
+ low, high = @proc.frame_low_high(nil)
68
+ opts={
69
+ :msg_on_error =>
70
+ "The '#{NAME}' command requires a frame number. Got: #{position_str}",
71
+ :min_value => low, :max_value => high
72
+ }
73
+ frame_num = @proc.get_an_int(position_str, opts)
74
+ return false unless frame_num
75
+
76
+ @proc.adjust_frame(frame_num, true)
77
+ return true
78
+ end
79
+ end
80
+
81
+ if __FILE__ == $0
82
+ # Demo it.
83
+ require_relative '../mock'
84
+ dbgr, cmd = MockDebugger::setup
85
+
86
+ # def sep ; puts '=' * 40 end
87
+ # %w(0 1 -2).each {|count| cmd.run([cmd.name, count]); sep }
88
+ # def foo(cmd, cmd.name)
89
+ # cmd.proc.frame_setup(RubyVM::ThreadFrame::current)
90
+ # %w(0 -1).each {|count| cmd.run([cmd.name, count]); sep }
91
+ # end
92
+ # foo(cmd, cmd.name)
93
+ end
@@ -0,0 +1 @@
1
+ /*~
@@ -0,0 +1,10 @@
1
+ Files in this directory are help for "help syntax".
2
+
3
+ A list of sub-names is obtained by Dir.glob('*.txt') in this
4
+ directory.
5
+
6
+ Each file name without the trailing ".txt' is the name of the help
7
+ subcategory under "help syntax".
8
+
9
+ The first line in the file is a summary shown in help summary.
10
+ Lines 3 on are shown as help text.
@@ -0,0 +1,58 @@
1
+ Overall Debugger Command Syntax
2
+
3
+ If the first non-blank character of a line starts with #,
4
+ the command is ignored.
5
+
6
+ If a line starts with ! in column one, the line is eval'd.
7
+
8
+ If the command you want Ruby to eval uses ! initially, add that
9
+ after the first ! or start the line with a space.
10
+
11
+ Commands are split at whereever ;; appears. This process disregards
12
+ any quotes or other symbols that have meaning in Ruby. The strings
13
+ after the leading command string are put back on a command queue.
14
+
15
+ Within a single command, tokens are then white-space split. Again,
16
+ this process disregards quotes or symbols that have meaning in Ruby.
17
+ Some commands like 'eval', 'macro', and 'break' have access to the
18
+ untokenized string entered and make use of that rather than the
19
+ tokenized list.
20
+
21
+ Resolving a command name involves possibly 4 steps. Some steps may be
22
+ omitted depending on early success or some debugger settings:
23
+
24
+ 1. The leading token is first looked up in the macro table. If it is in
25
+ the table, the expansion is replaces the current command and possibly
26
+ other commands pushed onto a command queue. See the "help macros" for
27
+ help on how to define macros, and "info macro" for current macro
28
+ definitions.
29
+
30
+ 2. The leading token is next looked up in the debugger alias table and
31
+ the name may be substituted there. See "help alias" for how to define
32
+ aliases, and "show alias" for the current list of aliases.
33
+
34
+ 3. After the above, The leading token is looked up a table of debugger
35
+ commands. If an exact match is found, the command name and arguments
36
+ are dispatched to that command. Otherwise, we may check to see the the
37
+ token is a unique prefix of a valid command. For example, "dis" is not
38
+ a unique prefix because there are both "display" and "disable"
39
+ commands, but "disp" is a unique prefix. You can allow or disallow
40
+ abbreviations for commands using "set abbrev". The default is
41
+ abbreviations are on.
42
+
43
+ 4. If after all of the above, we still don't find a command, the line
44
+ may be evaluated as a Ruby statement in the current context of the
45
+ program at the point it is stoppped. However this is done only if
46
+ "autoeval" is on. (It is on by default.)
47
+
48
+ If "auto eval" is not set on, or if running the Ruby statement
49
+ produces an error, we display an error message that the entered string
50
+ is "undefined".
51
+
52
+ If you want irb-like command-processing, it's possible to go into an
53
+ irb shell with the "irb" command. It is also possible to arrange going
54
+ into an irb shell every time you enter the debugger.
55
+
56
+ See also:
57
+ "help syntax examples"
58
+ "help syntax suffix"
@@ -0,0 +1,16 @@
1
+ Command examples
2
+
3
+ # This line does nothing. It is a comment. Useful in debugger command files.
4
+ # This line also does nothing.
5
+ s # by default, this is an alias for the "step" command
6
+ !s # shows the value of variable "s".
7
+ !!s # Evaluates "!s" (or "not s"). The first ! is indicates evaluate.
8
+ !s # Same as above, since there is a space in column one.
9
+
10
+ info program;; list # Runs two commands "info program" and "list"
11
+ pr "hi ;;-)" # Syntax error since ;; splits the line and " is not closed.
12
+ !puts "hi ;;-)" # One way to do the above.
13
+
14
+ See also "macro" "alias", "irb", "set auto eval", "set auto irb", "set
15
+ abbrev", "info macro", and "show" variants of the above "set"
16
+ commands.
@@ -0,0 +1,40 @@
1
+ Syntax for indicating a filename
2
+
3
+ There are two ways you can give a file name:
4
+ - unadorned (without double-quotes) with possible escapes
5
+ - as a double-quoted string with possible escapes in the string
6
+
7
+ Probably most of the time a file name will be specified in the first
8
+ form, without using quotes. If the file name however has a space or a
9
+ colon in it, escape that character with a backslash. Also, if you need
10
+ to enter a backslash and the character followinng that is unlucky
11
+ enough to be a colon, space, or backslash use two backslashes. Some
12
+ examples:
13
+
14
+ irb.rb => irb.rb
15
+ /tmp/irb.rb => /tmp/irb.rb
16
+ C\:irb.rb => C:irb.rb
17
+ C\:\irb.rb => C:\irb.rb
18
+ C\:\\irb.rb => C:\irb.rb # Note: double slash not needed
19
+ \\new.rb => \new.rb # Note: double slash, or filename has newline
20
+ my\ file.rb => my file.rb
21
+
22
+
23
+ The quoted string is useful if you have a file name that contains
24
+ several characters that normally confuse the debugger parser, notably
25
+ a space, newline, or a colon. The quoted string starts with a double
26
+ quote ("). Escape sequences are allowed inside the string to be able
27
+ to enter tabs or newlines, or a double quote inside the string. The
28
+ list of translations is as follows:
29
+
30
+ \t => <tab>
31
+ \n => <newline>
32
+ \" => "
33
+ \\ => \
34
+
35
+ Here are some examples of quoted filenames:
36
+
37
+ "This is a file with blanks.rb" => This is a file with blanks.rb
38
+ "/tmp/RubyProgram \"foo\".rb => /tmp/RubyProgram "foo".rb
39
+ "/Ruby\nProgram.rb" => /tmp/Ruby
40
+ Program.rb
@@ -0,0 +1,37 @@
1
+ syntax for source code locations; e.g. used "list" and "break"
2
+
3
+ Locations are used to indicates places in the source code or the
4
+ places in bytecode compiled from source code. Locations are used in
5
+ the listing commands like "list" or "disassemble"; they are also used
6
+ in "breakpoint" commands like "break", "tbreak" and "continue"
7
+
8
+ A location is either some sort of "container" and a position inside
9
+ that container. A container is either a file name or a method
10
+ name. And a position is either a line number or a bytecode offset.
11
+ Bytecode offsets are prefaced with an '@'. So 4 is a line number 4, but
12
+ @4 is bytecode offset 4.
13
+
14
+ File names are distinguished from method names purely by semantic
15
+ means. That its "foo" (without the quotes) could conceivably be
16
+ either a method or a file name. The debugger does a file check to see
17
+ if "foo" is a file.
18
+
19
+ In gdb, locations are often given using a filename a colon and a line
20
+ number. That is supported here are well. So myfile.rb:5 indicates line 5
21
+ of file "myfile.rb". But since we also allow method names you can also use
22
+ "gcd:5" to indicate line 5 of method "gcd".
23
+
24
+ Line numbers in methods are not relative to the beginning of the
25
+ method but relative the beginning of source text that contains the
26
+ method. This is also how Ruby stores line numbers for methods which
27
+ are shown for example in a backtrace. So all of this hopefully will
28
+ feel familiar and consistent.
29
+
30
+ Instead of using a colon to separate the container and the position,
31
+ you can also use spacs. So "gcd 5" is the same as gcd:5.
32
+
33
+ If the filename has an embedded blank in it, you can indicate that by
34
+ using a backslash escape. For example: "file\ with\ blanks.rb"
35
+
36
+
37
+
@@ -0,0 +1,17 @@
1
+ Command suffixes which have special meaning
2
+
3
+ Some commands like "step", or "list" do different things when an
4
+ alias to the command ends in a particular suffix like ">".
5
+
6
+ Here are a list of commands and the special suffixes:
7
+
8
+ command suffix
9
+ ------- ------
10
+ list >
11
+ step +,-,<,>
12
+ next +,-,<,>
13
+ quit !
14
+ kill !
15
+ eval ?
16
+
17
+ See help on the commands listed above for the specific meaning of the suffix.
@@ -0,0 +1,228 @@
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
+ require 'rubygems'; require 'require_relative'
3
+ require_relative '../command'
4
+ require_relative '../../app/complete'
5
+ class Trepan::Command::HelpCommand < Trepan::Command
6
+ unless defined?(HELP)
7
+ NAME = File.basename(__FILE__, '.rb')
8
+ HELP = <<-HELP
9
+ #{NAME} [command [subcommand]|expression]
10
+
11
+ Without argument, print the list of available debugger commands.
12
+
13
+ When an argument is given, it is first checked to see if it is command
14
+ name. 'help where' gives help on the 'where' debugger command.
15
+
16
+ If the environment variable $PAGER is defined, the file is
17
+ piped through that command. You'll notice this only for long help
18
+ output.
19
+
20
+ Some commands like 'info', 'set', and 'show' can accept an
21
+ additional subcommand to give help just about that particular
22
+ subcommand. For example 'help info line' give help about the
23
+ info line command.
24
+ HELP
25
+
26
+ ALIASES = %w(?)
27
+ CATEGORIES = {
28
+ 'breakpoints' => 'Making the program stop at certain points',
29
+ 'data' => 'Examining data',
30
+ 'files' => 'Specifying and examining files',
31
+ 'running' => 'Running the program',
32
+ 'status' => 'Status inquiries',
33
+ 'support' => 'Support facilities',
34
+ 'stack' => 'Examining the call stack',
35
+ 'syntax' => 'Debugger command syntax'
36
+ }
37
+ CATEGORY = 'support'
38
+ NEED_STACK = false
39
+ SHORT_HELP = 'Print commands or give help for command(s)'
40
+
41
+ ROOT_DIR = File.dirname(RequireRelative.abs_file)
42
+ HELP_DIR = File.join(ROOT_DIR, 'help')
43
+ end
44
+
45
+ class Syntax
46
+ def initialize(syntax_files); @syntax_files = syntax_files; end
47
+ def complete(prefix)
48
+ matches = Trepan::Complete.complete_token(syntax_files, prefix)
49
+ end
50
+ end
51
+
52
+ def complete(prefix)
53
+ matches = Trepan::Complete.complete_token(CATEGORIES.keys + %w(* all) +
54
+ @proc.commands.keys, prefix)
55
+ aliases = Trepan::Complete.complete_token_filtered(@proc.aliases, prefix,
56
+ matches)
57
+ (matches + aliases).sort
58
+ end
59
+
60
+ def complete_token_with_next(prefix)
61
+ complete(prefix).map do |cmd|
62
+ [cmd, @proc.commands.member?(cmd) ? @proc.commands[cmd] : nil]
63
+ end
64
+ end
65
+
66
+ # List the command categories and a short description of each.
67
+ def list_categories
68
+ section 'Help classes:'
69
+ CATEGORIES.keys.sort.each do |cat|
70
+ msg("%-13s -- %s" % [cat, CATEGORIES[cat]])
71
+ end
72
+ final_msg = '
73
+ Type "help" followed by a class name for a list of help items in that class.
74
+ Type "help aliases" for a list of current aliases.
75
+ Type "help macros" for a list of current macros.
76
+ Type "help *" for the list of all commands, macros and aliases.
77
+ Type "help all" for a brief description of all commands.
78
+ Type "help REGEXP" for the list of commands matching /^#{REGEXP}/.
79
+ Type "help CLASS *" for the list of all commands in class CLASS.
80
+ Type "help" followed by a command name for full documentation.
81
+ '
82
+ msg(final_msg)
83
+ end
84
+
85
+ # This method runs the command
86
+ def run(args) # :nodoc
87
+ if args.size > 1
88
+ cmd_name = args[1]
89
+ if cmd_name == '*'
90
+ section 'All command names:'
91
+ msg columnize_commands(@proc.commands.keys.sort)
92
+ show_aliases unless @proc.aliases.empty?
93
+ show_macros unless @proc.macros.empty?
94
+ elsif cmd_name =~ /^aliases$/i
95
+ show_aliases
96
+ elsif cmd_name =~ /^macros$/i
97
+ show_macros
98
+ elsif cmd_name =~ /^syntax$/i
99
+ show_command_syntax(args)
100
+ elsif cmd_name =~ /^all$/i
101
+ CATEGORIES.sort.each do |category|
102
+ show_category(category[0], [])
103
+ msg('')
104
+ end
105
+ elsif CATEGORIES.member?(cmd_name)
106
+ show_category(args[1], args[2..-1])
107
+ elsif @proc.commands.member?(cmd_name) or @proc.aliases.member?(cmd_name)
108
+ real_name =
109
+ if @proc.commands.member?(cmd_name)
110
+ cmd_name
111
+ else
112
+ @proc.aliases[cmd_name]
113
+ end
114
+ cmd_obj = @proc.commands[real_name]
115
+ help_text =
116
+ cmd_obj.respond_to?(:help) ? cmd_obj.help(args) :
117
+ cmd_obj.class.const_get(:HELP)
118
+ if help_text
119
+ msg(help_text)
120
+ if cmd_obj.class.constants.member?('ALIASES') and
121
+ args.size == 2
122
+ msg "Aliases: #{cmd_obj.class.const_get(:ALIASES).join(', ')}"
123
+ end
124
+ end
125
+ elsif @proc.macros.member?(cmd_name)
126
+ msg "#{cmd_name} is a macro which expands to:"
127
+ msg " #{@proc.macros[cmd_name]}", {:unlimited => true}
128
+ else
129
+ matches = @proc.commands.keys.grep(/^#{cmd_name}/).sort rescue []
130
+ if matches.empty?
131
+ errmsg("No commands found matching /^#{cmd_name}/. Try \"help\".")
132
+ else
133
+ section "Command names matching /^#{cmd_name}/:"
134
+ msg columnize_commands(matches.sort)
135
+ end
136
+ end
137
+ else
138
+ list_categories
139
+ end
140
+ end
141
+
142
+ def show_aliases
143
+ section 'All alias names:'
144
+ msg columnize_commands(@proc.aliases.keys.sort)
145
+ end
146
+
147
+ # Show short help for all commands in `category'.
148
+ def show_category(category, args)
149
+
150
+ if args.size == 1 && args[0] == '*'
151
+ section "Commands in class %s:" % category
152
+
153
+ cmds = @proc.commands.keys.select do |cmd_name|
154
+ category == @proc.commands[cmd_name].category
155
+ end.sort
156
+ width = settings[:maxwidth]
157
+ msg columnize_commands(cmds)
158
+ return
159
+ end
160
+
161
+ section "Command class: %s" % category
162
+ @proc.commands.keys.sort.each do |name|
163
+ next if category != @proc.commands[name].category
164
+ msg("%-13s -- %s" % [name, @proc.commands[name].short_help])
165
+ end
166
+ end
167
+
168
+ def syntax_files
169
+ @syntax_files ||= Dir.glob(File.join(HELP_DIR, '*.txt')).map do |txt|
170
+ basename = File.basename(txt, '.txt')
171
+ end
172
+ end
173
+
174
+ def show_command_syntax(args)
175
+ if args.size == 2
176
+ @syntax_summary_help ||= {}
177
+ section "List of syntax help"
178
+ syntax_files.each do |name|
179
+ @syntax_summary_help[name] ||=
180
+ File.open(File.join(HELP_DIR, "#{name}.txt")).readline.chomp
181
+ msg " %-8s -- %s" % [name, @syntax_summary_help[name]]
182
+ end
183
+ else
184
+ args[2..-1].each do |name|
185
+ if syntax_files.member?(name)
186
+ @syntax_help ||= {}
187
+ @syntax_help[name] =
188
+ File.open(File.join(HELP_DIR, "#{name}.txt")).readlines[2..-1].join
189
+ section "Help for #{name}:"
190
+ msg @syntax_help[name]
191
+ else
192
+ errmsg "No syntax help for #{name}"
193
+ end
194
+ end
195
+ end
196
+ end
197
+
198
+ def show_macros
199
+ section 'All macro names:'
200
+ msg columnize_commands(@proc.macros.keys.sort)
201
+ end
202
+
203
+ end
204
+
205
+ if __FILE__ == $0
206
+ # Demo it.
207
+ require_relative '../mock'
208
+ dbgr, cmd = MockDebugger::setup
209
+
210
+ cmd.run %W(#{cmd.name} help)
211
+ puts '=' * 40
212
+ cmd.run %W(#{cmd.name} *)
213
+ puts '=' * 40
214
+ cmd.run %W(#{cmd.name} fdafsasfda)
215
+ puts '=' * 40
216
+ cmd.run [cmd.name]
217
+ puts '=' * 40
218
+ cmd.run %W(#{cmd.name} support)
219
+ puts '=' * 40
220
+ cmd.run %W(#{cmd.name} support *)
221
+ puts '=' * 40
222
+ cmd.run %W(#{cmd.name} s.*)
223
+ puts '=' * 40
224
+ cmd.run %W(#{cmd.name} s<>)
225
+ puts '=' * 40
226
+ p cmd.complete('br')
227
+ p cmd.complete('un')
228
+ end
@@ -0,0 +1,30 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'base/submgr'
5
+
6
+ class Trepan::Command::InfoCommand < Trepan::SubcommandMgr
7
+ unless defined?(HELP)
8
+ HELP =
9
+ 'Generic command for showing things about the program being debugged.
10
+
11
+ You can give unique prefix of the name of a subcommand to get
12
+ information about just that subcommand.
13
+
14
+ Type "info" for a list of "info" subcommands and what they do.
15
+ Type "help info *" for just a list of "info" subcommands.
16
+ '
17
+
18
+ ALIASES = %w(i)
19
+ CATEGORY = 'status'
20
+ NAME = File.basename(__FILE__, '.rb')
21
+ SHORT_HELP = 'Information about debugged program and its environment'
22
+ end
23
+ end
24
+
25
+ if __FILE__ == $0
26
+ require_relative '../mock'
27
+ require 'ruby-debug'; Debugger.start; debugger
28
+ dbgr, cmd = MockDebugger::setup
29
+ cmd.run(['info', 'iv'])
30
+ end
@@ -0,0 +1,3 @@
1
+ /*.rbc
2
+ /*~
3
+
@@ -0,0 +1,103 @@
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::InfoBreakpoints < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{PREFIX.join(' ')} [num1 ...] [verbose]
11
+
12
+ Show status of user-settable breakpoints. If no breakpoint numbers are
13
+ given, the show all breakpoints. Otherwise only those breakpoints
14
+ listed are shown and the order given. If VERBOSE is given, more
15
+ information provided about each breakpoint.
16
+
17
+ The "Disp" column contains one of "keep", "del", the disposition of
18
+ the breakpoint after it gets hit.
19
+
20
+ The "enb" column indicates whether the breakpoint is enabled.
21
+
22
+ The "Where" column indicates where the breakpoint is located.
23
+ EOH
24
+ MIN_ABBREV = 'br'.size
25
+ SHORT_HELP = 'Status of user-settable breakpoints'
26
+ end
27
+
28
+ def bpprint(bp, verbose=false)
29
+ disp = bp.temp? ? 'del ' : 'keep '
30
+ disp += bp.enabled? ? 'y ' : 'n '
31
+ msg "%-4dbreakpoint %s at %s" % [bp.id, disp, bp.describe]
32
+ if bp.condition && bp.condition != 'true'
33
+ msg("\tstop %s %s" %
34
+ [bp.negate ? "unless" : "only if", bp.condition])
35
+ end
36
+ if bp.hits > 0
37
+ ss = (bp.hits > 1) ? 's' : ''
38
+ msg("\tbreakpoint already hit %d time%s" %
39
+ [bp.hits, ss])
40
+ end
41
+
42
+ if bp.ignore > 0
43
+ msg("\tignore next %d hits" % bp.ignore)
44
+ end
45
+ end
46
+
47
+ def run(args)
48
+ verbose = false
49
+ unless args.empty?
50
+ if 'verbose' == args[-1]
51
+ verbose = true
52
+ args.pop
53
+ end
54
+ end
55
+
56
+
57
+ show_all =
58
+ if args.size > 2
59
+ opts = {
60
+ :msg_on_error =>
61
+ "An '#{PREFIX.join(' ')}' argument must eval to a breakpoint between 1..#{@proc.brkpts.max}.",
62
+ :min_value => 1,
63
+ :max_value => @proc.brkpts.max
64
+ }
65
+ bp_nums = @proc.get_int_list(args[2..-1])
66
+ false
67
+ else
68
+ true
69
+ end
70
+
71
+ bpmgr = @proc.brkpts
72
+ if bpmgr.empty? && @proc.dbgr.deferred_breakpoints.empty?
73
+ msg('No breakpoints.')
74
+ else
75
+ # There's at least one
76
+ section("Num Type Disp Enb Where")
77
+ bpmgr.list.each do |bp|
78
+ bpprint(bp)
79
+ end
80
+ section 'Deferred breakpoints...'
81
+ @proc.dbgr.deferred_breakpoints.each_with_index do |bp, i|
82
+ if bp
83
+ msg "%3d: %s" % [i+1, bp.describe]
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ if __FILE__ == $0
91
+ # Demo it.
92
+ require_relative '../../mock'
93
+ name = File.basename(__FILE__, '.rb')
94
+ dbgr, cmd = MockDebugger::setup('info')
95
+ subcommand = Trepan::Subcommand::InfoBreakpoints.new(cmd)
96
+
97
+ puts '-' * 20
98
+ subcommand.run(%w(info break))
99
+ puts '-' * 20
100
+ subcommand.summary_help(name)
101
+ puts
102
+ puts '-' * 20
103
+ end