rb8-trepanning 0.1.3-universal-ruby-1.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. data/.gitignore +3 -0
  2. data/CHANGES +34 -0
  3. data/ChangeLog +875 -0
  4. data/README.textile +59 -0
  5. data/Rakefile +215 -0
  6. data/app/.gitignore +1 -0
  7. data/app/cmd_parse.kpeg +241 -0
  8. data/app/cmd_parse.rb +212 -0
  9. data/app/cmd_parser.rb +1948 -0
  10. data/app/complete.rb +79 -0
  11. data/app/default.rb +90 -0
  12. data/app/display.rb +148 -0
  13. data/app/eventbuffer.rb +147 -0
  14. data/app/frame.rb +166 -0
  15. data/app/irb.rb +114 -0
  16. data/app/options.rb +200 -0
  17. data/app/run.rb +74 -0
  18. data/app/util.rb +65 -0
  19. data/bin/.gitignore +1 -0
  20. data/bin/trepan8 +115 -0
  21. data/data/.gitignore +1 -0
  22. data/data/irbrc +41 -0
  23. data/interface/.gitignore +1 -0
  24. data/interface/base_intf.rb +109 -0
  25. data/interface/client.rb +82 -0
  26. data/interface/comcodes.rb +20 -0
  27. data/interface/script.rb +110 -0
  28. data/interface/server.rb +147 -0
  29. data/interface/user.rb +165 -0
  30. data/io/base_io.rb +148 -0
  31. data/io/input.rb +158 -0
  32. data/io/null_output.rb +46 -0
  33. data/io/string_array.rb +156 -0
  34. data/io/tcpclient.rb +129 -0
  35. data/io/tcpfns.rb +33 -0
  36. data/io/tcpserver.rb +141 -0
  37. data/lib/debugger.rb +8 -0
  38. data/lib/trepanning.rb +283 -0
  39. data/processor/.gitignore +1 -0
  40. data/processor/command-ruby-debug/breakpoints.rb +155 -0
  41. data/processor/command-ruby-debug/catchpoint.rb +55 -0
  42. data/processor/command-ruby-debug/condition.rb +49 -0
  43. data/processor/command-ruby-debug/control.rb +31 -0
  44. data/processor/command-ruby-debug/display.rb +120 -0
  45. data/processor/command-ruby-debug/enable.rb +202 -0
  46. data/processor/command-ruby-debug/frame.rb +199 -0
  47. data/processor/command-ruby-debug/help.rb +63 -0
  48. data/processor/command-ruby-debug/info.rb +359 -0
  49. data/processor/command-ruby-debug/method.rb +84 -0
  50. data/processor/command-ruby-debug/reload.rb +40 -0
  51. data/processor/command-ruby-debug/save.rb +90 -0
  52. data/processor/command-ruby-debug/set.rb +237 -0
  53. data/processor/command-ruby-debug/show.rb +251 -0
  54. data/processor/command-ruby-debug/source.rb +36 -0
  55. data/processor/command-ruby-debug/threads.rb +189 -0
  56. data/processor/command-ruby-debug/trace.rb +57 -0
  57. data/processor/command-ruby-debug/variables.rb +199 -0
  58. data/processor/command.rb +270 -0
  59. data/processor/command/.gitignore +1 -0
  60. data/processor/command/alias.rb +54 -0
  61. data/processor/command/backtrace.rb +123 -0
  62. data/processor/command/base/cmd.rb +177 -0
  63. data/processor/command/base/subcmd.rb +230 -0
  64. data/processor/command/base/submgr.rb +188 -0
  65. data/processor/command/base/subsubcmd.rb +128 -0
  66. data/processor/command/base/subsubmgr.rb +199 -0
  67. data/processor/command/break.rb +114 -0
  68. data/processor/command/catch.rb +71 -0
  69. data/processor/command/complete.rb +39 -0
  70. data/processor/command/continue.rb +57 -0
  71. data/processor/command/directory.rb +50 -0
  72. data/processor/command/disable.rb +85 -0
  73. data/processor/command/display.rb +78 -0
  74. data/processor/command/down.rb +54 -0
  75. data/processor/command/edit.rb +79 -0
  76. data/processor/command/enable.rb +48 -0
  77. data/processor/command/eval.rb +90 -0
  78. data/processor/command/exit.rb +66 -0
  79. data/processor/command/finish.rb +59 -0
  80. data/processor/command/frame.rb +97 -0
  81. data/processor/command/help.rb +230 -0
  82. data/processor/command/help/.gitignore +1 -0
  83. data/processor/command/help/README +10 -0
  84. data/processor/command/help/command.txt +58 -0
  85. data/processor/command/help/examples.txt +16 -0
  86. data/processor/command/help/filename.txt +40 -0
  87. data/processor/command/help/location.txt +37 -0
  88. data/processor/command/help/suffixes.txt +17 -0
  89. data/processor/command/info.rb +28 -0
  90. data/processor/command/info_subcmd/.gitignore +1 -0
  91. data/processor/command/info_subcmd/args.rb +39 -0
  92. data/processor/command/info_subcmd/breakpoints.rb +80 -0
  93. data/processor/command/info_subcmd/catch.rb +36 -0
  94. data/processor/command/info_subcmd/files.rb +39 -0
  95. data/processor/command/info_subcmd/globals.rb +64 -0
  96. data/processor/command/info_subcmd/line.rb +30 -0
  97. data/processor/command/info_subcmd/locals.rb +69 -0
  98. data/processor/command/info_subcmd/macro.rb +62 -0
  99. data/processor/command/info_subcmd/program.rb +51 -0
  100. data/processor/command/info_subcmd/ruby.rb +57 -0
  101. data/processor/command/info_subcmd/source.rb +74 -0
  102. data/processor/command/info_subcmd/stack.rb +25 -0
  103. data/processor/command/info_subcmd/threads.rb +75 -0
  104. data/processor/command/kill.rb +78 -0
  105. data/processor/command/list.rb +117 -0
  106. data/processor/command/macro.rb +68 -0
  107. data/processor/command/next.rb +79 -0
  108. data/processor/command/parsetree.rb +56 -0
  109. data/processor/command/pp.rb +40 -0
  110. data/processor/command/pr.rb +37 -0
  111. data/processor/command/ps.rb +40 -0
  112. data/processor/command/restart.rb +86 -0
  113. data/processor/command/save.rb +58 -0
  114. data/processor/command/set.rb +47 -0
  115. data/processor/command/set_subcmd/.gitignore +1 -0
  116. data/processor/command/set_subcmd/abbrev.rb +25 -0
  117. data/processor/command/set_subcmd/auto.rb +27 -0
  118. data/processor/command/set_subcmd/auto_subcmd/.gitignore +1 -0
  119. data/processor/command/set_subcmd/auto_subcmd/eval.rb +53 -0
  120. data/processor/command/set_subcmd/auto_subcmd/irb.rb +33 -0
  121. data/processor/command/set_subcmd/auto_subcmd/list.rb +33 -0
  122. data/processor/command/set_subcmd/basename.rb +25 -0
  123. data/processor/command/set_subcmd/callstyle.rb +46 -0
  124. data/processor/command/set_subcmd/confirm.rb +24 -0
  125. data/processor/command/set_subcmd/debug.rb +47 -0
  126. data/processor/command/set_subcmd/different.rb +61 -0
  127. data/processor/command/set_subcmd/highlight.rb +43 -0
  128. data/processor/command/set_subcmd/max.rb +26 -0
  129. data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
  130. data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
  131. data/processor/command/set_subcmd/max_subcmd/string.rb +76 -0
  132. data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
  133. data/processor/command/set_subcmd/reload.rb +42 -0
  134. data/processor/command/set_subcmd/timer.rb +58 -0
  135. data/processor/command/set_subcmd/trace.rb +37 -0
  136. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
  137. data/processor/command/set_subcmd/trace_subcmd/print.rb +41 -0
  138. data/processor/command/shell.rb +139 -0
  139. data/processor/command/show.rb +39 -0
  140. data/processor/command/show_subcmd/.gitignore +1 -0
  141. data/processor/command/show_subcmd/abbrev.rb +20 -0
  142. data/processor/command/show_subcmd/alias.rb +46 -0
  143. data/processor/command/show_subcmd/args.rb +34 -0
  144. data/processor/command/show_subcmd/auto.rb +28 -0
  145. data/processor/command/show_subcmd/auto_subcmd/eval.rb +27 -0
  146. data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
  147. data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
  148. data/processor/command/show_subcmd/basename.rb +20 -0
  149. data/processor/command/show_subcmd/callstyle.rb +22 -0
  150. data/processor/command/show_subcmd/confirm.rb +18 -0
  151. data/processor/command/show_subcmd/debug.rb +26 -0
  152. data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
  153. data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
  154. data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
  155. data/processor/command/show_subcmd/different.rb +26 -0
  156. data/processor/command/show_subcmd/directories.rb +22 -0
  157. data/processor/command/show_subcmd/highlight.rb +24 -0
  158. data/processor/command/show_subcmd/max.rb +27 -0
  159. data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
  160. data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
  161. data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
  162. data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
  163. data/processor/command/show_subcmd/reload.rb +18 -0
  164. data/processor/command/show_subcmd/timer.rb +18 -0
  165. data/processor/command/show_subcmd/trace.rb +29 -0
  166. data/processor/command/show_subcmd/trace_subcmd/buffer.rb +65 -0
  167. data/processor/command/show_subcmd/trace_subcmd/print.rb +23 -0
  168. data/processor/command/show_subcmd/version.rb +23 -0
  169. data/processor/command/source.rb +134 -0
  170. data/processor/command/step.rb +81 -0
  171. data/processor/command/tbreak.rb +19 -0
  172. data/processor/command/unalias.rb +44 -0
  173. data/processor/command/undisplay.rb +59 -0
  174. data/processor/command/up.rb +72 -0
  175. data/processor/default.rb +56 -0
  176. data/processor/display.rb +17 -0
  177. data/processor/eval.rb +113 -0
  178. data/processor/eventbuf.rb +105 -0
  179. data/processor/frame.rb +172 -0
  180. data/processor/help.rb +92 -0
  181. data/processor/helper.rb +76 -0
  182. data/processor/hook.rb +134 -0
  183. data/processor/load_cmds.rb +258 -0
  184. data/processor/location.rb +174 -0
  185. data/processor/main.rb +455 -0
  186. data/processor/mock.rb +136 -0
  187. data/processor/msg.rb +61 -0
  188. data/processor/processor.rb +674 -0
  189. data/processor/running.rb +168 -0
  190. data/processor/stepping.rb +18 -0
  191. data/processor/subcmd.rb +161 -0
  192. data/processor/validate.rb +355 -0
  193. data/processor/virtual.rb +34 -0
  194. data/test/data/.gitignore +1 -0
  195. data/test/data/break_bad.cmd +19 -0
  196. data/test/data/break_bad.right +29 -0
  197. data/test/data/break_loop_bug.cmd +5 -0
  198. data/test/data/break_loop_bug.right +15 -0
  199. data/test/data/dollar-0.right +2 -0
  200. data/test/data/dollar-0a.right +2 -0
  201. data/test/data/dollar-0b.right +2 -0
  202. data/test/data/edit.cmd +14 -0
  203. data/test/data/edit.right +24 -0
  204. data/test/data/file-with-space.cmd +6 -0
  205. data/test/data/file-with-space.right +4 -0
  206. data/test/data/printvar.cmd +17 -0
  207. data/test/data/printvar.right +31 -0
  208. data/test/data/raise.cmd +11 -0
  209. data/test/data/raise.right +19 -0
  210. data/test/data/source.cmd +5 -0
  211. data/test/data/source.right +18 -0
  212. data/test/data/stepping-1.9.right +50 -0
  213. data/test/data/stepping.cmd +21 -0
  214. data/test/data/stepping.right +48 -0
  215. data/test/data/trepan8-save.1 +6 -0
  216. data/test/example/bp_loop_issue.rb +3 -0
  217. data/test/example/break-bug.rb +7 -0
  218. data/test/example/brkpt-class-bug.rb +8 -0
  219. data/test/example/classes.rb +11 -0
  220. data/test/example/dollar-0.rb +5 -0
  221. data/test/example/except-bug1.rb +4 -0
  222. data/test/example/except-bug2.rb +7 -0
  223. data/test/example/file with space.rb +1 -0
  224. data/test/example/gcd.rb +18 -0
  225. data/test/example/info-var-bug.rb +47 -0
  226. data/test/example/info-var-bug2.rb +2 -0
  227. data/test/example/null.rb +1 -0
  228. data/test/example/pm-bug.rb +3 -0
  229. data/test/example/pm.rb +11 -0
  230. data/test/example/raise.rb +3 -0
  231. data/test/integration/.gitignore +4 -0
  232. data/test/integration/config.yaml +8 -0
  233. data/test/integration/helper.rb +154 -0
  234. data/test/integration/test-break_bad.rb +26 -0
  235. data/test/integration/test-dollar-0.rb +31 -0
  236. data/test/integration/test-edit.rb +17 -0
  237. data/test/integration/test-file-with-space.rb +26 -0
  238. data/test/integration/test-printvar.rb +17 -0
  239. data/test/integration/test-raise.rb +21 -0
  240. data/test/integration/test-source.rb +16 -0
  241. data/test/integration/test-stepping.rb +24 -0
  242. data/test/unit/.gitignore +1 -0
  243. data/test/unit/cmd-helper.rb +52 -0
  244. data/test/unit/mock-helper.rb +12 -0
  245. data/test/unit/test-app-cmd_parse.rb +97 -0
  246. data/test/unit/test-app-cmd_parser.rb +23 -0
  247. data/test/unit/test-app-complete.rb +39 -0
  248. data/test/unit/test-app-frame.rb +32 -0
  249. data/test/unit/test-app-options.rb +92 -0
  250. data/test/unit/test-app-run.rb +14 -0
  251. data/test/unit/test-app-util.rb +44 -0
  252. data/test/unit/test-base-cmd.rb +45 -0
  253. data/test/unit/test-base-subcmd.rb +57 -0
  254. data/test/unit/test-base-submgr.rb +23 -0
  255. data/test/unit/test-base-subsubcmd.rb +17 -0
  256. data/test/unit/test-cmd-alias.rb +48 -0
  257. data/test/unit/test-cmd-exit.rb +27 -0
  258. data/test/unit/test-cmd-help.rb +104 -0
  259. data/test/unit/test-cmd-kill.rb +46 -0
  260. data/test/unit/test-cmd-source.rb +34 -0
  261. data/test/unit/test-completion.rb +42 -0
  262. data/test/unit/test-intf-user.rb +46 -0
  263. data/test/unit/test-io-input.rb +27 -0
  264. data/test/unit/test-io-tcp.rb +33 -0
  265. data/test/unit/test-io-tcpclient.rb +54 -0
  266. data/test/unit/test-io-tcpfns.rb +17 -0
  267. data/test/unit/test-io-tcpserver.rb +50 -0
  268. data/test/unit/test-proc-eval.rb +36 -0
  269. data/test/unit/test-proc-hook.rb +30 -0
  270. data/test/unit/test-proc-load_cmds.rb +50 -0
  271. data/test/unit/test-proc-location.rb +79 -0
  272. data/test/unit/test-subcmd-help.rb +44 -0
  273. data/trepan8.gemspec +58 -0
  274. metadata +388 -0
@@ -0,0 +1,230 @@
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
+ require 'rubygems'; require 'require_relative'
3
+ require_relative 'base/cmd'
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
+
25
+ See also 'examine' and 'whatis'.
26
+ HELP
27
+
28
+ ALIASES = %w(?)
29
+ CATEGORIES = {
30
+ 'breakpoints' => 'Making the program stop at certain points',
31
+ 'data' => 'Examining data',
32
+ 'files' => 'Specifying and examining files',
33
+ 'running' => 'Running the program',
34
+ 'status' => 'Status inquiries',
35
+ 'support' => 'Support facilities',
36
+ 'stack' => 'Examining the call stack',
37
+ 'syntax' => 'Debugger command syntax'
38
+ }
39
+ CATEGORY = 'support'
40
+ NEED_STACK = false
41
+ SHORT_HELP = 'Print commands or give help for command(s)'
42
+
43
+ ROOT_DIR = File.dirname(RequireRelative.abs_file)
44
+ HELP_DIR = File.join(ROOT_DIR, 'help')
45
+ end
46
+
47
+ class Syntax
48
+ def initialize(syntax_files); @syntax_files = syntax_files; end
49
+ def complete(prefix)
50
+ matches = Trepan::Complete.complete_token(syntax_files, prefix)
51
+ end
52
+ end
53
+
54
+ def complete(prefix)
55
+ matches = Trepan::Complete.complete_token(CATEGORIES.keys + %w(* all) +
56
+ @proc.commands.keys, prefix)
57
+ aliases = Trepan::Complete.complete_token_filtered(@proc.aliases, prefix,
58
+ matches)
59
+ (matches + aliases).sort
60
+ end
61
+
62
+ def complete_token_with_next(prefix)
63
+ complete(prefix).map do |cmd|
64
+ [cmd, @proc.commands.member?(cmd) ? @proc.commands[cmd] : nil]
65
+ end
66
+ end
67
+
68
+ # List the command categories and a short description of each.
69
+ def list_categories
70
+ section 'Help classes:'
71
+ CATEGORIES.keys.sort.each do |cat|
72
+ msg("%-13s -- %s" % [cat, CATEGORIES[cat]])
73
+ end
74
+ final_msg = '
75
+ Type "help" followed by a class name for a list of help items in that class.
76
+ Type "help aliases" for a list of current aliases.
77
+ Type "help macros" for a list of current macros.
78
+ Type "help *" for the list of all commands, macros and aliases.
79
+ Type "help all" for the list of all commands.
80
+ Type "help REGEXP" for the list of commands matching /^#{REGEXP}/.
81
+ Type "help CLASS *" for the list of all commands in class CLASS.
82
+ Type "help" followed by command name for full documentation.
83
+ '
84
+ msg(final_msg)
85
+ end
86
+
87
+ # This method runs the command
88
+ def run(args) # :nodoc
89
+ if args.size > 1
90
+ cmd_name = args[1]
91
+ if cmd_name == '*'
92
+ section 'All command names:'
93
+ msg columnize_commands(@proc.commands.keys.sort)
94
+ show_aliases unless @proc.aliases.empty?
95
+ show_macros unless @proc.macros.empty?
96
+ elsif cmd_name =~ /^aliases$/i
97
+ show_aliases
98
+ elsif cmd_name =~ /^macros$/i
99
+ show_macros
100
+ elsif cmd_name =~ /^syntax$/i
101
+ show_command_syntax(args)
102
+ elsif cmd_name =~ /^all$/i
103
+ CATEGORIES.sort.each do |category|
104
+ show_category(category[0], [])
105
+ end
106
+ elsif CATEGORIES.member?(cmd_name)
107
+ show_category(args[1], args[2..-1])
108
+ elsif @proc.commands.member?(cmd_name) or @proc.aliases.member?(cmd_name)
109
+ real_name =
110
+ if @proc.commands.member?(cmd_name)
111
+ cmd_name
112
+ else
113
+ @proc.aliases[cmd_name]
114
+ end
115
+ cmd_obj = @proc.commands[real_name]
116
+ help_text =
117
+ cmd_obj.respond_to?(:help) ? cmd_obj.help(args) :
118
+ cmd_obj.class.const_get(:HELP)
119
+ if help_text
120
+ msg(help_text)
121
+ if cmd_obj.class.constants.member?('ALIASES') and
122
+ args.size == 2
123
+ msg "Aliases: #{cmd_obj.class.const_get(:ALIASES).join(', ')}"
124
+ end
125
+ end
126
+ elsif @proc.macros.member?(cmd_name)
127
+ msg "#{cmd_name} is a macro which expands to:"
128
+ msg " #{@proc.macros[cmd_name]}", {:unlimited => true}
129
+ else
130
+ matches = @proc.commands.keys.grep(/^#{cmd_name}/).sort rescue []
131
+ if matches.empty?
132
+ errmsg("No commands found matching /^#{cmd_name}/. Try \"help\".")
133
+ else
134
+ section "Command names matching /^#{cmd_name}/:"
135
+ msg columnize_commands(matches.sort)
136
+ end
137
+ end
138
+ else
139
+ list_categories
140
+ end
141
+ end
142
+
143
+ def show_aliases
144
+ section 'All alias names:'
145
+ msg columnize_commands(@proc.aliases.keys.sort)
146
+ end
147
+
148
+ # Show short help for all commands in `category'.
149
+ def show_category(category, args)
150
+
151
+ if args.size == 1 && args[0] == '*'
152
+ section "Commands in class %s:" % category
153
+
154
+ cmds = @proc.commands.keys.select do |cmd_name|
155
+ category == @proc.commands[cmd_name].category
156
+ end.sort
157
+ width = settings[:maxwidth]
158
+ return columnize_commands(cmds)
159
+ end
160
+
161
+ msg('')
162
+ section "Command class: %s" % category
163
+ msg('')
164
+ @proc.commands.keys.sort.each do |name|
165
+ next if category != @proc.commands[name].category
166
+ msg("%-13s -- %s" % [name, @proc.commands[name].short_help])
167
+ end
168
+ end
169
+
170
+ def syntax_files
171
+ @syntax_files ||= Dir.glob(File.join(HELP_DIR, '*.txt')).map do |txt|
172
+ basename = File.basename(txt, '.txt')
173
+ end
174
+ end
175
+
176
+ def show_command_syntax(args)
177
+ if args.size == 2
178
+ @syntax_summary_help ||= {}
179
+ section "List of syntax help"
180
+ syntax_files.each do |name|
181
+ @syntax_summary_help[name] ||=
182
+ File.open(File.join(HELP_DIR, "#{name}.txt")).readline.chomp
183
+ msg " %-8s -- %s" % [name, @syntax_summary_help[name]]
184
+ end
185
+ else
186
+ args[2..-1].each do |name|
187
+ if syntax_files.member?(name)
188
+ @syntax_help ||= {}
189
+ @syntax_help[name] =
190
+ File.open(File.join(HELP_DIR, "#{name}.txt")).readlines[2..-1].join
191
+ section "Debugger syntax for a #{name}:"
192
+ msg @syntax_help[name]
193
+ else
194
+ errmsg "No syntax help for #{name}"
195
+ end
196
+ end
197
+ end
198
+ end
199
+
200
+ def show_macros
201
+ section 'All macro names:'
202
+ msg columnize_commands(@proc.macros.keys.sort)
203
+ end
204
+
205
+ end
206
+
207
+ if __FILE__ == $0
208
+ # Demo it.
209
+ require_relative '../mock'
210
+ dbgr, cmd = MockDebugger::setup
211
+
212
+ cmd.run %W(#{cmd.name} help)
213
+ puts '=' * 40
214
+ cmd.run %W(#{cmd.name} *)
215
+ puts '=' * 40
216
+ cmd.run %W(#{cmd.name} fdafsasfda)
217
+ puts '=' * 40
218
+ cmd.run [cmd.name]
219
+ puts '=' * 40
220
+ cmd.run %W(#{cmd.name} support)
221
+ puts '=' * 40
222
+ cmd.run %W(#{cmd.name} support *)
223
+ puts '=' * 40
224
+ cmd.run %W(#{cmd.name} s.*)
225
+ puts '=' * 40
226
+ cmd.run %W(#{cmd.name} s<>)
227
+ puts '=' * 40
228
+ p cmd.complete('br')
229
+ p cmd.complete('un')
230
+ 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,28 @@
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
+ dbgr, cmd = MockDebugger::setup
28
+ end