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,251 @@
1
+ module Trepan
2
+ # Mix-in module to showing settings
3
+ module ShowFunctions # :nodoc:
4
+ def show_setting(setting_name)
5
+ case setting_name
6
+ when /^annotate$/
7
+ Debugger.annotate ||= 0
8
+ return ("Annotation level is #{Debugger.annotate}")
9
+ when /^args$/
10
+ if Command.settings[:argv] and Command.settings[:argv].size > 0
11
+ if defined?(Debugger::RDEBUG_SCRIPT)
12
+ # rdebug was called initially. 1st arg is script name.
13
+ args = Command.settings[:argv][1..-1].join(' ')
14
+ else
15
+ # rdebug wasn't called initially. 1st arg is not script name.
16
+ args = Command.settings[:argv].join(' ')
17
+ end
18
+ else
19
+ args = ''
20
+ end
21
+ return "Argument list to give program being debugged when it is started is \"#{args}\"."
22
+ when /^autolist$/
23
+ on_off = Command.settings[:autolist] > 0
24
+ return "autolist is #{show_onoff(on_off)}."
25
+ when /^autoeval$/
26
+ on_off = Command.settings[:autoeval]
27
+ return "autoeval is #{show_onoff(on_off)}."
28
+ when /^autoreload$/
29
+ on_off = Command.settings[:reload_source_on_change]
30
+ return "autoreload is #{show_onoff(on_off)}."
31
+ when /^autoirb$/
32
+ on_off = Command.settings[:autoirb] > 0
33
+ return "autoirb is #{show_onoff(on_off)}."
34
+ when /^basename$/
35
+ on_off = Command.settings[:basename]
36
+ return "basename is #{show_onoff(on_off)}."
37
+ when /^callstyle$/
38
+ style = Command.settings[:callstyle]
39
+ return "Frame call-display style is #{style}."
40
+ when /^commands(:?\s+(\d+))?$/
41
+ return 'No readline support.' unless @state.interface.readline_support?
42
+ s = '';
43
+ args = @match[1].split
44
+ if args[1]
45
+ first_line = args[1].to_i - 4
46
+ last_line = first_line + 10 - 1
47
+ if first_line > Readline::HISTORY.length
48
+ first_line = last_line = Readline::HISTORY.length
49
+ elsif first_line <= 0
50
+ first_line = 1
51
+ end
52
+ if last_line > Readline::HISTORY.length
53
+ last_line = Readline::HISTORY.length
54
+ end
55
+ i = first_line
56
+ commands = Readline::HISTORY.to_a[first_line..last_line]
57
+ else
58
+ if Readline::HISTORY.length > 10
59
+ commands = Readline::HISTORY.to_a[-10..-1]
60
+ i = Readline::HISTORY.length - 10
61
+ else
62
+ commands = Readline::HISTORY.to_a
63
+ i = 1
64
+ end
65
+ end
66
+ commands.each do |cmd|
67
+ s += ("%5d %s\n" % [i, cmd])
68
+ i += 1
69
+ end
70
+ return s
71
+ when /^debuggertesting$/
72
+ on_off = Command.settings[:debuggertesting]
73
+ return "Currently testing the debugger is #{show_onoff(on_off)}."
74
+ when /^forcestep$/
75
+ on_off = self.class.settings[:force_stepping]
76
+ return "force-stepping is #{show_onoff(on_off)}."
77
+ when /^fullpath$/
78
+ on_off = Command.settings[:full_path]
79
+ return "Displaying frame's full file names is #{show_onoff(on_off)}."
80
+ when /^history(:?\s+(filename|save|size))?$/
81
+ return 'No readline support.' unless @state.interface.readline_support?
82
+ args = @match[1].split
83
+ interface = @state.interface
84
+ if args[1]
85
+ show_save = show_size = show_filename = false
86
+ prefix = false
87
+ if args[1] == "save"
88
+ show_save = true
89
+ elsif args[1] == "size"
90
+ show_size = true
91
+ elsif args[1] == "filename"
92
+ show_filename = true
93
+ end
94
+ else
95
+ show_save = show_size = show_filename = true
96
+ prefix = true
97
+ end
98
+ s = []
99
+ if show_filename
100
+ msg = (prefix ? "filename: " : "") +
101
+ "The filename in which to record the command history is " +
102
+ "#{interface.histfile.inspect}"
103
+ s << msg
104
+ end
105
+ if show_save
106
+ msg = (prefix ? "save: " : "") +
107
+ "Saving of history save is #{show_onoff(interface.history_save)}."
108
+ s << msg
109
+ end
110
+ if show_size
111
+ msg = (prefix ? "size: " : "") +
112
+ "Debugger history size is #{interface.history_length}"
113
+ s << msg
114
+ end
115
+ return s.join("\n")
116
+ when /^keep-frame-bindings$/
117
+ on_off = Debugger.keep_frame_binding?
118
+ return "keep-frame-bindings is #{show_onoff(on_off)}."
119
+ when /^linetrace$/
120
+ on_off = Debugger.tracing
121
+ return "line tracing is #{show_onoff(on_off)}."
122
+ when /^linetrace\+$/
123
+ on_off = Command.settings[:tracing_plus]
124
+ if on_off
125
+ return "line tracing style is different consecutive lines."
126
+ else
127
+ return "line tracing style is every line."
128
+ end
129
+ when /^listsize$/
130
+ listlines = Command.settings[:listsize]
131
+ return "Number of source lines to list by default is #{listlines}."
132
+ when /^port$/
133
+ return "server port is #{Debugger::PORT}."
134
+ when /^post-mortem$/
135
+ on_off = Debugger.post_mortem?
136
+ return "post-mortem handling is #{show_onoff(on_off)}."
137
+ when /^trace$/
138
+ on_off = Command.settings[:stack_trace_on_error]
139
+ return "Displaying stack trace is #{show_onoff(on_off)}."
140
+ when /^version$/
141
+ return "ruby-debug #{Debugger::VERSION}"
142
+ when /^width$/
143
+ return "width is #{self.class.settings[:width]}."
144
+ else
145
+ return "Unknown show subcommand #{setting_name}."
146
+ end
147
+ end
148
+ end
149
+
150
+ # Implements debugger "show" command.
151
+ class ShowCommand < OldCommand
152
+
153
+ Subcommands =
154
+ [
155
+ ['annotate', 2, "Show annotation level",
156
+ "0 == normal; 2 == output annotated suitably for use by programs that control
157
+ ruby-debug."],
158
+ ['args', 2,
159
+ "Show argument list to give program being debugged when it is started",
160
+ "Follow this command with any number of args, to be passed to the program."],
161
+ ['autoeval', 4, "Show if unrecognized command are evaluated"],
162
+ ['autolist', 4, "Show if 'list' commands is run on breakpoints"],
163
+ ['autoirb', 4, "Show if IRB is invoked on debugger stops"],
164
+ ['autoreload', 4, "Show if source code is reloaded when changed"],
165
+ ['basename', 1, "Show if basename used in reporting files"],
166
+ ['callstyle', 2, "Show paramater style used showing call frames"],
167
+ ['commands', 2, "Show the history of commands you typed",
168
+ "You can supply a command number to start with."],
169
+ ['forcestep', 1, "Show if sure 'next/step' forces move to a new line"],
170
+ ['fullpath', 2, "Show if full file names are displayed in frames"],
171
+ ['history', 2, "Generic command for showing command history parameters",
172
+ "show history filename -- Show the filename in which to record the command history
173
+ show history save -- Show saving of the history record on exit
174
+ show history size -- Show the size of the command history"],
175
+ ['keep-frame-bindings', 1, "Save frame binding on each call"],
176
+ ['linetrace', 3, "Show line execution tracing"],
177
+ ['linetrace+', 10,
178
+ "Show if consecutive lines should be different are shown in tracing"],
179
+ ['listsize', 3, "Show number of source lines to list by default"],
180
+ ['port', 3, "Show server port"],
181
+ ['post-mortem', 3, "Show whether we go into post-mortem debugging on an uncaught exception"],
182
+ ['trace', 1,
183
+ "Show if a stack trace is displayed when 'eval' raises exception"],
184
+ ['version', 1,
185
+ "Show what version of the debugger this is"],
186
+ ['width', 1,
187
+ "Show the number of characters the debugger thinks are in a line"],
188
+ ].map do |name, min, short_help, long_help|
189
+ SubcmdStruct.new(name, min, short_help, long_help)
190
+ end unless defined?(Subcommands)
191
+
192
+ self.allow_in_control = true
193
+
194
+ def regexp
195
+ /^show (?: \s+ (.+) )?$/xi
196
+ end
197
+
198
+ def execute
199
+ if not @match[1]
200
+ print "\"show\" must be followed by the name of an show command:\n"
201
+ print "List of show subcommands:\n\n"
202
+ for subcmd in Subcommands do
203
+ print "show #{subcmd.name} -- #{subcmd.short_help}\n"
204
+ end
205
+ else
206
+ args = @match[1].split(/[ \t]+/)
207
+ param = args.shift
208
+ subcmd = find(Subcommands, param)
209
+ if subcmd
210
+ print "%s\n" % show_setting(subcmd.name)
211
+ else
212
+ print "Unknown show command #{param}\n"
213
+ end
214
+ end
215
+ end
216
+
217
+ class << self
218
+ def help_command
219
+ "show"
220
+ end
221
+
222
+ def help(args)
223
+ if args[1]
224
+ s = args[1]
225
+ subcmd = Subcommands.find do |try_subcmd|
226
+ (s.size >= try_subcmd.min) and
227
+ (try_subcmd.name[0..s.size-1] == s)
228
+ end
229
+ if subcmd
230
+ str = subcmd.short_help + '.'
231
+ str += "\n" + subcmd.long_help if subcmd.long_help
232
+ return str
233
+ else
234
+ return "Invalid 'show' subcommand '#{args[1]}'."
235
+ end
236
+ end
237
+ s = "
238
+ Generic command for showing things about the debugger.
239
+
240
+ --
241
+ List of show subcommands:
242
+ --
243
+ "
244
+ for subcmd in Subcommands do
245
+ s += "show #{subcmd.name} -- #{subcmd.short_help}\n"
246
+ end
247
+ return s
248
+ end
249
+ end
250
+ end
251
+ end
@@ -0,0 +1,36 @@
1
+ module Trepan
2
+ # Implements debugger "source" command.
3
+ class SourceCommand < OldCommand
4
+ self.allow_in_control = true
5
+
6
+ def regexp
7
+ /^\s* so(?:urce)? \s+ (.+) $/x
8
+ end
9
+
10
+ def execute
11
+ file = File.expand_path(@match[1]).strip
12
+ unless File.exist?(file)
13
+ errmsg "Command file '#{file}' is not found\n"
14
+ return
15
+ end
16
+ if @state and @state.interface
17
+ @state.interface.command_queue += File.open(file).readlines
18
+ else
19
+ Trepan.run_script(file, @state)
20
+ end
21
+ end
22
+
23
+ class << self
24
+ def help_command
25
+ 'source'
26
+ end
27
+
28
+ def help(cmd)
29
+ %{
30
+ source FILE\texecutes a file containing debugger commands
31
+ }
32
+ end
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,189 @@
1
+ module Trepan
2
+ module ThreadFunctions # :nodoc:
3
+ def display_context(c, show_top_frame=true)
4
+ c_flag = c.thread == Thread.current ? '+' : ' '
5
+ c_flag = '$' if c.suspended?
6
+ d_flag = c.ignored? ? '!' : ' '
7
+ print "%s%s", c_flag, d_flag
8
+ print "%d ", c.thnum
9
+ print "%s\t", c.thread.inspect
10
+ if c.stack_size > 0 and show_top_frame
11
+ print "%s:%d", c.frame_file(0), c.frame_line(0)
12
+ end
13
+ print "\n"
14
+ end
15
+
16
+ def parse_thread_num(subcmd, arg)
17
+ if '' == arg
18
+ errmsg "'%s' needs a thread number\n" % subcmd
19
+ nil
20
+ else
21
+ thread_num = get_int(arg, "thread #{subcmd}", 1)
22
+ return nil unless thread_num
23
+ get_context(thread_num)
24
+ end
25
+ end
26
+
27
+ def parse_thread_num_for_cmd(subcmd, arg)
28
+ c = parse_thread_num(subcmd, arg)
29
+ return nil unless c
30
+ case
31
+ when nil == c
32
+ errmsg "No such thread.\n"
33
+ when @state.context == c
34
+ errmsg "It's the current thread.\n"
35
+ when c.ignored?
36
+ errmsg "Can't #{subcmd} to the debugger thread #{arg}.\n"
37
+ else # Everything is okay
38
+ return c
39
+ end
40
+ return nil
41
+ end
42
+ end
43
+
44
+ class ThreadListCommand < OldCommand # :nodoc:
45
+ self.allow_in_control = true
46
+
47
+ def regexp
48
+ /^\s*th(?:read)?\s+l(?:ist)?\s*$/
49
+ end
50
+
51
+ def execute
52
+ threads = Debugger.contexts.sort_by{|c| c.thnum}.each do |c|
53
+ display_context(c)
54
+ end
55
+ end
56
+
57
+ class << self
58
+ def help_command
59
+ 'thread'
60
+ end
61
+
62
+ def help(cmd)
63
+ %{
64
+ th[read] l[ist]\t\t\tlist all threads
65
+ }
66
+ end
67
+ end
68
+ end
69
+
70
+ class ThreadStopCommand < OldCommand # :nodoc:
71
+ self.allow_in_control = true
72
+ self.allow_in_post_mortem = false
73
+ self.need_context = true
74
+
75
+ def regexp
76
+ /^\s*th(?:read)?\s+stop\s*(\S*)\s*$/
77
+ end
78
+
79
+ def execute
80
+ c = parse_thread_num_for_cmd("thread stop", @match[1])
81
+ return unless c
82
+ c.suspend
83
+ display_context(c)
84
+ end
85
+
86
+ class << self
87
+ def help_command
88
+ 'thread'
89
+ end
90
+
91
+ def help(cmd)
92
+ %{
93
+ th[read] stop <nnn>\t\tstop thread nnn
94
+ }
95
+ end
96
+ end
97
+ end
98
+
99
+ class ThreadResumeCommand < OldCommand # :nodoc:
100
+ self.allow_in_post_mortem = false
101
+ self.allow_in_control = true
102
+ self.need_context = true
103
+
104
+ def regexp
105
+ /^\s*th(?:read)?\s+resume\s*(\S*)\s*$/
106
+ end
107
+
108
+ def execute
109
+ c = parse_thread_num_for_cmd("thread resume", @match[1])
110
+ return unless c
111
+ if !c.thread.stop?
112
+ print "Already running."
113
+ return
114
+ end
115
+ c.resume
116
+ display_context(c)
117
+ end
118
+
119
+ class << self
120
+ def help_command
121
+ 'thread'
122
+ end
123
+
124
+ def help(cmd)
125
+ %{
126
+ th[read] resume <nnn>\t\tresume thread nnn
127
+ }
128
+ end
129
+ end
130
+ end
131
+
132
+ # Thread switch Must come after "Thread resume" because "switch" is
133
+ # optional
134
+
135
+ class ThreadSwitchCommand < OldCommand # :nodoc:
136
+ self.allow_in_control = true
137
+ self.allow_in_post_mortem = false
138
+ self.need_context = true
139
+
140
+ def regexp
141
+ /^\s*th(?:read)?\s*(?:sw(?:itch)?)?\s+(\S+)\s*$/
142
+ end
143
+
144
+ def execute
145
+ c = parse_thread_num_for_cmd("thread switch", @match[1])
146
+ return unless c
147
+ display_context(c)
148
+ c.stop_next = 1
149
+ c.thread.run
150
+ @state.proceed
151
+ end
152
+
153
+ class << self
154
+ def help_command
155
+ 'thread'
156
+ end
157
+
158
+ def help(cmd)
159
+ %{
160
+ th[read] [sw[itch]] <nnn>\tswitch thread context to nnn
161
+ }
162
+ end
163
+ end
164
+ end
165
+
166
+ class ThreadCurrentCommand < OldCommand # :nodoc:
167
+ self.need_context = true
168
+
169
+ def regexp
170
+ /^\s*th(?:read)?\s*(?:cur(?:rent)?)?\s*$/
171
+ end
172
+
173
+ def execute
174
+ display_context(@state.context)
175
+ end
176
+
177
+ class << self
178
+ def help_command
179
+ 'thread'
180
+ end
181
+
182
+ def help(cmd)
183
+ %{
184
+ th[read] [cur[rent]]\t\tshow current thread
185
+ }
186
+ end
187
+ end
188
+ end
189
+ end