rbx-trepanning 0.0.5-universal-rubinius-1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. data/ChangeLog +2002 -0
  2. data/LICENSE +25 -0
  3. data/NEWS +31 -0
  4. data/README.textile +34 -0
  5. data/Rakefile +165 -0
  6. data/THANKS +14 -0
  7. data/app/breakpoint.rb +219 -0
  8. data/app/breakpoint.rbc +3551 -0
  9. data/app/brkptmgr.rb +140 -0
  10. data/app/brkptmgr.rbc +2903 -0
  11. data/app/client.rb +61 -0
  12. data/app/client.rbc +1225 -0
  13. data/app/complete.rb +52 -0
  14. data/app/complete.rbc +1288 -0
  15. data/app/default.rb +71 -0
  16. data/app/default.rbc +1132 -0
  17. data/app/display.rb +148 -0
  18. data/app/display.rbc +2578 -0
  19. data/app/frame.rb +98 -0
  20. data/app/frame.rbc +1808 -0
  21. data/app/irb.rb +111 -0
  22. data/app/irb.rbc +2094 -0
  23. data/app/iseq.rb +117 -0
  24. data/app/iseq.rbc +2192 -0
  25. data/app/llvm.rbc +2478 -0
  26. data/app/method.rb +173 -0
  27. data/app/method.rbc +2492 -0
  28. data/app/method_name.rbc +2467 -0
  29. data/app/mock.rb +13 -0
  30. data/app/mock.rbc +398 -0
  31. data/app/options.rb +137 -0
  32. data/app/options.rbc +2898 -0
  33. data/app/rbx-llvm.rb +165 -0
  34. data/app/rbx-llvm.rbc +2478 -0
  35. data/app/run.rb +86 -0
  36. data/app/run.rbc +1244 -0
  37. data/app/util.rb +49 -0
  38. data/app/util.rbc +1146 -0
  39. data/app/validate.rb +30 -0
  40. data/app/validate.rbc +676 -0
  41. data/bin/trepan.compiled.rbc +1043 -0
  42. data/bin/trepanx +69 -0
  43. data/bin/trepanx.compiled.rbc +1049 -0
  44. data/data/irbrc +41 -0
  45. data/data/irbrc.compiled.rbc +640 -0
  46. data/interface/base_intf.rb +105 -0
  47. data/interface/base_intf.rbc +1899 -0
  48. data/interface/client.rb +80 -0
  49. data/interface/client.rbc +1072 -0
  50. data/interface/comcodes.rb +20 -0
  51. data/interface/comcodes.rbc +385 -0
  52. data/interface/script.rb +104 -0
  53. data/interface/script.rbc +1642 -0
  54. data/interface/server.rb +143 -0
  55. data/interface/server.rbc +2213 -0
  56. data/interface/user.rb +150 -0
  57. data/interface/user.rbc +2867 -0
  58. data/io/base_io.rb +148 -0
  59. data/io/base_io.rbc +2111 -0
  60. data/io/input.rb +135 -0
  61. data/io/input.rbc +2528 -0
  62. data/io/null_output.rb +42 -0
  63. data/io/null_output.rbc +730 -0
  64. data/io/string_array.rb +156 -0
  65. data/io/string_array.rbc +2466 -0
  66. data/io/tcpclient.rb +129 -0
  67. data/io/tcpclient.rbc +2419 -0
  68. data/io/tcpfns.rb +33 -0
  69. data/io/tcpfns.rbc +694 -0
  70. data/io/tcpserver.rb +141 -0
  71. data/io/tcpserver.rbc +2638 -0
  72. data/lib/trepanning.rb +474 -0
  73. data/lib/trepanning.rbc +7705 -0
  74. data/lib/trepanning2.rb +441 -0
  75. data/processor/breakpoint.rb +164 -0
  76. data/processor/command/alias.rb +55 -0
  77. data/processor/command/backtrace.rb +76 -0
  78. data/processor/command/base/cmd.rb +173 -0
  79. data/processor/command/base/subcmd.rb +229 -0
  80. data/processor/command/base/submgr.rb +182 -0
  81. data/processor/command/base/subsubcmd.rb +103 -0
  82. data/processor/command/base/subsubmgr.rb +195 -0
  83. data/processor/command/break.rb +100 -0
  84. data/processor/command/complete.rb +37 -0
  85. data/processor/command/continue.rb +91 -0
  86. data/processor/command/delete.rb +30 -0
  87. data/processor/command/directory.rb +51 -0
  88. data/processor/command/disassemble.rb +145 -0
  89. data/processor/command/display.rb +82 -0
  90. data/processor/command/down.rb +54 -0
  91. data/processor/command/eval.rb +51 -0
  92. data/processor/command/exit.rb +62 -0
  93. data/processor/command/finish.rb +80 -0
  94. data/processor/command/frame.rb +89 -0
  95. data/processor/command/help.rb +251 -0
  96. data/processor/command/info.rb +28 -0
  97. data/processor/command/info_subcmd/breakpoints.rb +73 -0
  98. data/processor/command/info_subcmd/files.rb +209 -0
  99. data/processor/command/info_subcmd/line.rb +86 -0
  100. data/processor/command/info_subcmd/method.rb +71 -0
  101. data/processor/command/info_subcmd/program.rb +49 -0
  102. data/processor/command/info_subcmd/ruby.rb +62 -0
  103. data/processor/command/info_subcmd/variables.rb +48 -0
  104. data/processor/command/irb.rb +128 -0
  105. data/processor/command/kill.rb +70 -0
  106. data/processor/command/list.rb +300 -0
  107. data/processor/command/macro.rb +76 -0
  108. data/processor/command/next.rb +66 -0
  109. data/processor/command/nexti.rb +59 -0
  110. data/processor/command/pr.rb +38 -0
  111. data/processor/command/ps.rb +40 -0
  112. data/processor/command/restart.rb +60 -0
  113. data/processor/command/server.rb +72 -0
  114. data/processor/command/set.rb +47 -0
  115. data/processor/command/set_subcmd/auto.rb +27 -0
  116. data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
  117. data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
  118. data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
  119. data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -0
  120. data/processor/command/set_subcmd/basename.rb +25 -0
  121. data/processor/command/set_subcmd/confirm.rb +24 -0
  122. data/processor/command/set_subcmd/debug.rb +26 -0
  123. data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
  124. data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
  125. data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
  126. data/processor/command/set_subcmd/different.rb +59 -0
  127. data/processor/command/set_subcmd/hidelevel.rb +62 -0
  128. data/processor/command/set_subcmd/highlight.rb +33 -0
  129. data/processor/command/set_subcmd/kernelstep.rb +60 -0
  130. data/processor/command/set_subcmd/max.rb +26 -0
  131. data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
  132. data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
  133. data/processor/command/set_subcmd/max_subcmd/string.rb +76 -0
  134. data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
  135. data/processor/command/set_subcmd/substitute.rb +24 -0
  136. data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
  137. data/processor/command/set_subcmd/trace.rb +36 -0
  138. data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
  139. data/processor/command/show.rb +38 -0
  140. data/processor/command/show_subcmd/alias.rb +42 -0
  141. data/processor/command/show_subcmd/args.rb +25 -0
  142. data/processor/command/show_subcmd/auto.rb +28 -0
  143. data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
  144. data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -0
  145. data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
  146. data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
  147. data/processor/command/show_subcmd/basename.rb +20 -0
  148. data/processor/command/show_subcmd/confirm.rb +18 -0
  149. data/processor/command/show_subcmd/debug.rb +26 -0
  150. data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
  151. data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
  152. data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
  153. data/processor/command/show_subcmd/different.rb +26 -0
  154. data/processor/command/show_subcmd/hidelevel.rb +41 -0
  155. data/processor/command/show_subcmd/highlight.rb +24 -0
  156. data/processor/command/show_subcmd/kernelstep.rb +34 -0
  157. data/processor/command/show_subcmd/max.rb +27 -0
  158. data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
  159. data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
  160. data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
  161. data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
  162. data/processor/command/show_subcmd/trace.rb +27 -0
  163. data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
  164. data/processor/command/show_subcmd/version.rb +23 -0
  165. data/processor/command/source.rb +126 -0
  166. data/processor/command/step.rb +84 -0
  167. data/processor/command/tbreak.rb +19 -0
  168. data/processor/command/unalias.rb +44 -0
  169. data/processor/command/undisplay.rb +59 -0
  170. data/processor/command/up.rb +86 -0
  171. data/processor/default.rb +58 -0
  172. data/processor/disassemble.rb +46 -0
  173. data/processor/display.rb +18 -0
  174. data/processor/eval.rb +96 -0
  175. data/processor/frame.rb +211 -0
  176. data/processor/help.rb +72 -0
  177. data/processor/hook.rb +133 -0
  178. data/processor/load_cmds.rb +185 -0
  179. data/processor/location.rb +137 -0
  180. data/processor/main.rb +412 -0
  181. data/processor/mock.rb +144 -0
  182. data/processor/msg.rb +43 -0
  183. data/processor/running.rb +234 -0
  184. data/processor/stepping.rb +114 -0
  185. data/processor/subcmd.rb +161 -0
  186. data/processor/validate.rb +355 -0
  187. data/sample/list-terminal-colors.rb +139 -0
  188. data/sample/list-terminal-colors.rbc +2318 -0
  189. data/sample/rocky-dot-trepanxrc +14 -0
  190. data/sample/rocky-trepanx-colors.rb +47 -0
  191. data/sample/rocky-trepanx-colors.rbc +530 -0
  192. data/test/data/enable.right +36 -0
  193. data/test/data/fname-with-blank.cmd +6 -0
  194. data/test/data/fname-with-blank.right +4 -0
  195. data/test/data/inline-call.cmd +6 -0
  196. data/test/data/inline-call.right +13 -0
  197. data/test/data/quit-Xdebug.right +3 -0
  198. data/test/data/quit.cmd +5 -0
  199. data/test/data/quit.right +2 -0
  200. data/test/data/quit2.cmd +6 -0
  201. data/test/data/quit2.right +3 -0
  202. data/test/data/step-bug.cmd +11 -0
  203. data/test/data/step-bug.right +3 -0
  204. data/test/example/fname with blank.rb +1 -0
  205. data/test/example/gcd-server.rb +22 -0
  206. data/test/example/gcd.rb +19 -0
  207. data/test/example/inline-call.rb +23 -0
  208. data/test/example/null.rb +1 -0
  209. data/test/example/step-bug.rb +14 -0
  210. data/test/example/thread1.rb +3 -0
  211. data/test/functional/fn_helper.rb +112 -0
  212. data/test/functional/test-break-name.rb +52 -0
  213. data/test/functional/test-break.rb +51 -0
  214. data/test/functional/test-finish.rb +70 -0
  215. data/test/functional/test-fn_helper.rb +43 -0
  216. data/test/functional/test-list.rb +55 -0
  217. data/test/functional/test-next-bug.rb +49 -0
  218. data/test/functional/test-next.rb +101 -0
  219. data/test/functional/test-step.rb +272 -0
  220. data/test/functional/test-step2.rb +35 -0
  221. data/test/functional/test-tbreak.rb +41 -0
  222. data/test/integration/file-diff.rb +89 -0
  223. data/test/integration/helper.rb +78 -0
  224. data/test/integration/skip-test-step-bug.rb +17 -0
  225. data/test/integration/test-fname-with-blank.rb +16 -0
  226. data/test/integration/test-inline-call.rb +20 -0
  227. data/test/integration/test-quit.rb +47 -0
  228. data/test/unit/cmd-helper.rb +50 -0
  229. data/test/unit/mock-helper.rb +10 -0
  230. data/test/unit/test-app-brkpt.rb +29 -0
  231. data/test/unit/test-app-brkptmgr.rb +51 -0
  232. data/test/unit/test-app-iseq.rb +64 -0
  233. data/test/unit/test-app-method.rb +54 -0
  234. data/test/unit/test-app-options.rb +82 -0
  235. data/test/unit/test-app-run.rb +16 -0
  236. data/test/unit/test-app-util.rb +27 -0
  237. data/test/unit/test-app-validate.rb +18 -0
  238. data/test/unit/test-base-cmd.rb +47 -0
  239. data/test/unit/test-base-subcmd.rb +61 -0
  240. data/test/unit/test-base-submgr.rb +24 -0
  241. data/test/unit/test-bin-trepanx.rb +48 -0
  242. data/test/unit/test-cmd-alias.rb +48 -0
  243. data/test/unit/test-cmd-break.rb +22 -0
  244. data/test/unit/test-cmd-exit.rb +27 -0
  245. data/test/unit/test-cmd-finish.rb +27 -0
  246. data/test/unit/test-cmd-help.rb +104 -0
  247. data/test/unit/test-cmd-kill.rb +47 -0
  248. data/test/unit/test-cmd-source.rb +34 -0
  249. data/test/unit/test-cmd-step.rb +29 -0
  250. data/test/unit/test-completion.rb +38 -0
  251. data/test/unit/test-intf-user.rb +46 -0
  252. data/test/unit/test-io-input.rb +27 -0
  253. data/test/unit/test-io-tcp.rb +33 -0
  254. data/test/unit/test-io-tcpclient.rb +54 -0
  255. data/test/unit/test-io-tcpfns.rb +17 -0
  256. data/test/unit/test-io-tcpserver.rb +50 -0
  257. data/test/unit/test-proc-eval.rb +36 -0
  258. data/test/unit/test-proc-frame.rb +79 -0
  259. data/test/unit/test-proc-help.rb +16 -0
  260. data/test/unit/test-proc-hook.rb +30 -0
  261. data/test/unit/test-proc-load_cmds.rb +50 -0
  262. data/test/unit/test-proc-location.rb +53 -0
  263. data/test/unit/test-proc-main.rb +99 -0
  264. data/test/unit/test-proc-validate.rb +91 -0
  265. data/test/unit/test-subcmd-help.rb +47 -0
  266. metadata +398 -0
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'base/submgr'
5
+
6
+ class Trepan::Command::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
@@ -0,0 +1,73 @@
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
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
+ HELP = <<-EOH
9
+ #{PREFIX.join(' ')} [num1 ...] [verbose]
10
+
11
+ Show status of user-settable breakpoints. If no breakpoint numbers are
12
+ given, the show all breakpoints. Otherwise only those breakpoints
13
+ listed are shown and the order given. If VERBOSE is given, more
14
+ information provided about each breakpoint.
15
+
16
+ The "Disp" column contains one of "keep", "del", the disposition of
17
+ the breakpoint after it gets hit.
18
+
19
+ The "enb" column indicates whether the breakpoint is enabled.
20
+
21
+ The "Where" column indicates where the breakpoint is located.
22
+ EOH
23
+ MIN_ABBREV = 'br'.size
24
+ SHORT_HELP = 'Status of user-settable breakpoints'
25
+
26
+ def run(args)
27
+ show_all =
28
+ if args.size > 2
29
+ opts = {
30
+ :msg_on_error =>
31
+ "An '#{PREFIX.join(' ')}' argument must eval to a breakpoint between 1..#{@proc.brkpts.max}.",
32
+ :min_value => 1,
33
+ :max_value => @proc.brkpts.max
34
+ }
35
+ bp_nums = @proc.get_int_list(args[2..-1])
36
+ false
37
+ else
38
+ true
39
+ end
40
+
41
+ bpmgr = @proc.brkpts
42
+ if bpmgr.empty? && @proc.dbgr.deferred_breakpoints.empty?
43
+ msg('No breakpoints.')
44
+ else
45
+ # There's at least one
46
+ section "Num Breakpoint"
47
+ bpmgr.list.each do |bp|
48
+ msg "%3d: %s" % [bp.id, bp.describe]
49
+ end
50
+ section 'Deferred breakpoints...'
51
+ @proc.dbgr.deferred_breakpoints.each_with_index do |bp, i|
52
+ if bp
53
+ msg "%3d: %s" % [i+1, bp.describe]
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ if __FILE__ == $0
61
+ # Demo it.
62
+ require_relative '../../mock'
63
+ name = File.basename(__FILE__, '.rb')
64
+ dbgr, cmd = MockDebugger::setup('info')
65
+ subcommand = Trepan::Subcommand::InfoBreakpoints.new(cmd)
66
+
67
+ puts '-' * 20
68
+ subcommand.run(%w(info break))
69
+ puts '-' * 20
70
+ subcommand.summary_help(name)
71
+ puts
72
+ puts '-' * 20
73
+ end
@@ -0,0 +1,209 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require 'linecache'
5
+ require 'columnize'
6
+ require_relative '../base/subcmd'
7
+ require_relative '../../../app/complete'
8
+
9
+ class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
10
+ unless defined?(HELP)
11
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
12
+ DEFAULT_FILE_ARGS = %w(size mtime sha1)
13
+
14
+ HELP = <<-EOH
15
+ #{CMD=PREFIX.join(' ')} [{FILENAME|.|*} [all|ctime|brkpts|mtime|sha1|size|stat]]
16
+
17
+ Show information about the current file. If no filename is given and
18
+ the program is running, then the current file associated with the
19
+ current stack entry is used. Giving . has the same effect.
20
+
21
+ Given * gives a list of all files we know about.
22
+
23
+ Sub options which can be shown about a file are:
24
+
25
+ brkpts -- Line numbers where there are statement boundaries.
26
+ These lines can be used in breakpoint commands.
27
+ ctime -- File creation time
28
+ mtime -- File modification time
29
+ sha1 -- A SHA1 hash of the source text. This may be useful in comparing
30
+ source code.
31
+ size -- The number of lines in the file.
32
+ stat -- File.stat information
33
+
34
+ all -- All of the above information.
35
+
36
+ If no sub-options are given, "#{DEFAULT_FILE_ARGS.join(' ')}" are assumed.
37
+
38
+ Examples:
39
+
40
+ #{CMD} # Show #{DEFAULT_FILE_ARGS.join(' ')} information about current file
41
+ #{CMD} . # same as above
42
+ #{CMD} brkpts # show the number of lines in the current file
43
+ #{CMD} brkpts size # same as above but also list breakpoint line numbers
44
+ #{CMD} * # Give a list of files we know about
45
+ EOH
46
+ MIN_ABBREV = 'fi'.size # Note we have "info frame"
47
+ NEED_STACK = false
48
+ end
49
+
50
+ # completion %w(all brkpts iseq sha1 size stat)
51
+
52
+ include Trepanning
53
+
54
+ def file_list
55
+ (LineCache.class_variable_get('@@file_cache').keys +
56
+ LineCache.class_variable_get('@@file2file_remap').keys).uniq
57
+ end
58
+ def complete(prefix)
59
+ completions = ['.'] + file_list
60
+ Trepan::Complete.complete_token(completions, prefix)
61
+ end
62
+
63
+ # Get file information
64
+ def run(args)
65
+ return if args.size < 2
66
+ args << '.' if 2 == args.size
67
+ if '*' == args[2]
68
+ section 'Files names cached:'
69
+ msg columnize_commands(file_list.sort)
70
+ return
71
+ end
72
+ filename =
73
+ if '.' == args[2]
74
+ if not @proc.frame
75
+ errmsg("No frame - no default file.")
76
+ return false
77
+ nil
78
+ else
79
+ File.expand_path(@proc.frame.file)
80
+ end
81
+ else
82
+ args[2]
83
+ end
84
+ args += DEFAULT_FILE_ARGS if args.size == 3
85
+
86
+ m = filename + ' is'
87
+ canonic_name = LineCache::map_file(filename) || filename
88
+ if LineCache::cached?(canonic_name)
89
+ m += " cached in debugger"
90
+ if canonic_name != filename
91
+ m += (' as:' + canonic_name)
92
+ end
93
+ m += '.'
94
+ msg(m)
95
+ # elsif !(matches = find_scripts(filename)).empty?
96
+ # if (matches.size > 1)
97
+ # msg("Multiple files found:")
98
+ # matches.each { |filename| msg("\t%s" % filename) }
99
+ # return
100
+ # else
101
+ # msg('File "%s" just now cached.' % filename)
102
+ # LineCache::cache(matches[0])
103
+ # LineCache::remap_file(matches[0], filename)
104
+ # canonic_name = matches[0]
105
+ # end
106
+ else
107
+ matches = file_list.select{|try| try.end_with?(filename)}
108
+ if (matches.size > 1)
109
+ msg("Multiple files found ending filename string:")
110
+ matches.sort.each { |match_file| msg "\t%s" % match_file }
111
+ return
112
+ elsif 1 == matches.size
113
+ canonic_name = LineCache::map_file(matches[1])
114
+ else
115
+ msg(m + ' not cached in debugger.')
116
+ return
117
+ end
118
+ end
119
+ seen = {}
120
+ args[3..-1].each do |arg|
121
+ processed_arg = false
122
+
123
+ if %w(all size).member?(arg)
124
+ unless seen[:size]
125
+ max_line = LineCache::size(canonic_name)
126
+ msg "File has %d lines." % max_line if max_line
127
+ end
128
+ processed_arg = seen[:size] = true
129
+ end
130
+
131
+ if %w(all sha1).member?(arg)
132
+ unless seen[:sha1]
133
+ msg("SHA1 is %s." % LineCache::sha1(canonic_name))
134
+ end
135
+ processed_arg = seen[:sha1] = true
136
+ end
137
+
138
+ if %w(all brkpts).member?(arg)
139
+ unless seen[:brkpts]
140
+ msg("Possible breakpoint line numbers:")
141
+ lines = LineCache::trace_line_numbers(canonic_name)
142
+ fmt_lines = columnize_numbers(lines)
143
+ msg(fmt_lines)
144
+ end
145
+ processed_arg = seen[:brkpts] = true
146
+ end
147
+
148
+ if %w(all ctime).member?(arg)
149
+ unless seen[:ctime]
150
+ msg("create time:\t%s." %
151
+ LineCache::stat(canonic_name).ctime.to_s)
152
+ end
153
+ processed_arg = seen[:ctime] = true
154
+ end
155
+
156
+ # if %w(all iseq).member?(arg)
157
+ # unless seen[:iseq]
158
+ # if SCRIPT_ISEQS__.member?(canonic_name)
159
+ # msg("File contains instruction sequences:")
160
+ # SCRIPT_ISEQS__[canonic_name].each do |iseq|
161
+ # msg("\t %s %s" % [iseq, iseq.name.inspect])
162
+ # end
163
+ # else
164
+ # msg("Instruction sequences not recorded; there may be some, though.")
165
+ # end
166
+ # end
167
+ # processed_arg = seen[:iseq] = true
168
+ # end
169
+
170
+ if %w(all mtime).member?(arg)
171
+ unless seen[:mtime]
172
+ msg("modify time:\t%s." %
173
+ LineCache::stat(canonic_name).mtime.to_s)
174
+ end
175
+ processed_arg = seen[:mtime] = true
176
+ end
177
+
178
+ if %w(all stat).member?(arg)
179
+ unless seen[:stat]
180
+ msg("Stat info:\n\t%s." % LineCache::stat(canonic_name).inspect)
181
+ end
182
+ processed_arg = seen[:stat] = true
183
+ end
184
+
185
+ if not processed_arg
186
+ errmsg("I don't understand sub-option \"%s\"." % arg)
187
+ end
188
+ end unless args.empty?
189
+ end
190
+ end
191
+
192
+ if __FILE__ == $0
193
+ require_relative '../../mock'
194
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFiles, false)
195
+ LineCache::cache(__FILE__)
196
+ LineCache::cache('../../mock.rb')
197
+
198
+ [%w(info file nothere),
199
+ %w(info file .),
200
+ %w(info file *),
201
+ %w(info file),
202
+ %W(info file #{__FILE__}),
203
+ %W(info file #{__FILE__} all),
204
+ %W(info file #{__FILE__} brkpts bad size sha1 sha1)].each do |args|
205
+ cmd.run(args)
206
+ puts '-' * 40
207
+ end
208
+ p cmd.complete('')
209
+ end
@@ -0,0 +1,86 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::InfoLine < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{CMD=PREFIX.join(' ')} [LINE-NUMBER]
11
+
12
+ Show bytecode offset for LINE-NUMBER. If no LINE-NUMBER is given,
13
+ then we use the current line that we are stopped in.
14
+
15
+ Examples:
16
+ #{CMD}
17
+ #{CMD} 10
18
+ EOH
19
+ MIN_ABBREV = 'li'.size
20
+ NEED_STACK = true
21
+ SHORT_HELP = 'Byte code offsets for source code line'
22
+ end
23
+
24
+ def ip_ranges_for_line(lines, line)
25
+ result = []
26
+ in_range = false
27
+ start_ip = nil
28
+ total = lines.size
29
+ i = 1
30
+ while i < total
31
+ cur_line = lines.at(i)
32
+ if cur_line == line
33
+ start_ip = lines.at(i-1)
34
+ in_range = true
35
+ elsif cur_line > line && in_range
36
+ result << [start_ip, lines.at(i-1)]
37
+ start_ip = nil
38
+ in_range = false
39
+ end
40
+ i += 2
41
+ end
42
+ if in_range && start_ip
43
+ result << [start_ip, lines.at(total-1)]
44
+ end
45
+ result
46
+ end
47
+
48
+ def run(args)
49
+ frame = @proc.frame
50
+ vm_location = frame.vm_location
51
+ cm = frame.method
52
+ filename = cm.file
53
+ lines = cm.lines
54
+ if args.size == 2
55
+ line_no = vm_location.line
56
+ else
57
+ lineno_str = args[2]
58
+ opts = {
59
+ :msg_on_error =>
60
+ "The 'info line' line number must be an integer. Got: %s" % lineno_str,
61
+ :min_value => lines.at(1),
62
+ :max_value => lines.at(lines.size-2)
63
+ }
64
+ line_no = @proc.get_an_int(lineno_str, opts)
65
+ return false unless line_no
66
+ end
67
+
68
+ ranges = ip_ranges_for_line(lines, line_no)
69
+ if ranges.empty?
70
+ msg "Line %s of %s:\n\tno bytecode offsets" % [line_no, filename]
71
+ else
72
+ msg "Line %s of %s:" % [line_no, filename]
73
+ ranges.each do |tuple|
74
+ msg "\t starts at offset %d and ends before offset %d" % tuple
75
+ end
76
+ end
77
+ end
78
+
79
+ end
80
+
81
+ if __FILE__ == $0
82
+ # Demo it.
83
+ require_relative '../../mock'
84
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoLine, false)
85
+ cmd.run(cmd.prefix)
86
+ end
@@ -0,0 +1,71 @@
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::InfoMethod < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{PREFIX.join(' ')} [METHOD|.]
11
+
12
+ Show information about a method.
13
+
14
+ Examples:
15
+ #{PREFIX.join(' ')}
16
+ #{PREFIX.join(' ')} .
17
+ #{PREFIX.join(' ')} require_relative
18
+ EOH
19
+
20
+ MIN_ABBREV = 'me'.size
21
+ NEED_STACK = true
22
+ SHORT_HELP = 'Information about a (compiled) method'
23
+ end
24
+
25
+ def run(args)
26
+ if args.size <= 2
27
+ method_name = '.'
28
+ else
29
+ method_name = args[2]
30
+ end
31
+ if '.' == method_name
32
+ meth = @proc.frame.method
33
+ # elsif ...
34
+ # # FIXME: do something if there is more than one
35
+ else
36
+ meth = nil
37
+ end
38
+
39
+ if meth
40
+ msg("Method #{meth.name}():")
41
+ %w(arity child_methods describe
42
+ file first_line lines local_count
43
+ required_args splat stack_size total_args
44
+ ).each do |field|
45
+ msg " %-15s: %s" % [field, meth.send(field).inspect]
46
+ end
47
+ else
48
+ mess = "Can't find method"
49
+ mess += " for #{args.join(' ')}" unless args.empty?
50
+ errmsg mess
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ if __FILE__ == $0
57
+ # Demo it.
58
+
59
+ require_relative '../../mock'
60
+ require_relative '../../subcmd'
61
+ name = File.basename(__FILE__, '.rb')
62
+
63
+ # FIXME: DRY the below code
64
+ dbgr, cmd = MockDebugger::setup('info')
65
+ subcommand = Trepan::Subcommand::InfoMethod.new(cmd)
66
+ testcmdMgr = Trepan::Subcmd.new(subcommand)
67
+
68
+ subcommand.run([name])
69
+ name = File.basename(__FILE__, '.rb')
70
+ subcommand.summary_help(name)
71
+ end