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
data/processor.rb ADDED
@@ -0,0 +1,404 @@
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
+ # The main "driver" class for a command processor. Other parts of the
3
+ # command class and debugger command objects are pulled in from here.
4
+
5
+ require 'set'
6
+
7
+ require 'rubygems'; require 'require_relative'
8
+ ## %w(default display eventbuf eval load_cmds location frame hook msg
9
+ ## validate).each do
10
+ %w(default breakpoint disassemble display eval eventbuf load_cmds location
11
+ frame hook msg running stepping validate).each do
12
+ |mod_str|
13
+ require_relative "processor/#{mod_str}"
14
+ end
15
+ require_relative 'app/brkptmgr'
16
+
17
+ class Trepan
18
+ class CmdProcessor < VirtualCmdProcessor
19
+
20
+ # SEE ALSO attr's in require_relative's of loop above.
21
+
22
+ attr_reader :cmd_argstr # Current command args, a String.
23
+ # This is current_command with the command
24
+ # name removed from the beginning.
25
+ attr_reader :cmd_name # command name before alias or macro resolution
26
+ attr_reader :cmd_queue # queue of commands to run
27
+ ## attr_reader :core # Trepan core object
28
+ attr_reader :current_command # Current command getting run, a String.
29
+ attr_accessor :dbgr # Trepan instance (via
30
+ # Trepan::Core instance)
31
+ ## FIXME 1.9.2 has attr_reader !
32
+ attr_accessor :debug_nest # Number of nested debugs. Used in showing
33
+ # prompt.
34
+ attr_accessor :different_pos # Same type as settings[:different]
35
+ # this is the temporary value for the
36
+ # next stop while settings is the default
37
+ # value to use.
38
+ attr_accessor :event # Stop event
39
+ attr_reader :intf # Current interface
40
+ # Trepan::Core instance)
41
+ attr_accessor :leave_cmd_loop # Commands set this to signal to leave
42
+ # the command loop (which often continues to
43
+ # run the debugged program).
44
+ attr_accessor :line_no # Last line shown in "list" command
45
+ attr_accessor :next_level # Fixnum. frame.stack_size has to
46
+ # be <= than this. If next'ing,
47
+ # this will be > 0.
48
+ attr_accessor :next_thread # Thread. If non-nil then in
49
+ # stepping the thread has to be
50
+ # this thread.
51
+ attr_accessor :pass_exception # Pass an exception back
52
+ attr_accessor :prompt # String print before requesting input
53
+ attr_reader :settings # Hash[:symbol] of command
54
+ # processor settings
55
+ attr_reader :step_bp
56
+
57
+ # The following are used in to force stopping at a different line
58
+ # number. FIXME: could generalize to a position object.
59
+ attr_accessor :last_pos # Last position. 6-Tuple: of
60
+ # [location, container, stack_size,
61
+ # current_thread, pc_offset]
62
+
63
+
64
+ def initialize(dbgr, settings={})
65
+ @cmd_queue = []
66
+ @dbgr = dbgr
67
+ @debug_nest = 1
68
+ @hidelevels = {}
69
+ @last_command = nil
70
+ @last_pos = [nil, nil, nil, nil, nil, nil]
71
+ @next_level = 32000
72
+ @next_thread = nil
73
+ @user_variables = 0
74
+
75
+
76
+ start_cmds = settings.delete(:start_cmds)
77
+ start_file = settings.delete(:start_file)
78
+
79
+ @settings = DEFAULT_SETTINGS.merge(settings)
80
+ @different_pos = @settings[:different]
81
+
82
+ # FIXME: Rework using a general "set substitute file" command and
83
+ # a global default profile which gets read.
84
+ prelude_file = File.expand_path(File.join(File.dirname(__FILE__),
85
+ %w(.. data prelude.rb)))
86
+
87
+ # Start with empty thread and frame info.
88
+ frame_teardown
89
+
90
+ # Run initialization routines for each of the "submodule"s.
91
+ # load_cmds has to come first.
92
+ ## %w(load_cmds breakpoint display eventbuf frame running validate
93
+ ## ).each do |submod|
94
+ %w(load_cmds breakpoint display eventbuf frame running
95
+ stepping validate).each do
96
+ |submod|
97
+ self.send("#{submod}_initialize")
98
+ end
99
+ hook_initialize(commands)
100
+ # unconditional_prehooks.insert_if_new(-1, *@trace_hook) if
101
+ # settings[:traceprint]
102
+ end
103
+
104
+ def compute_prompt
105
+ "(#{@settings[:prompt]}): "
106
+ end
107
+
108
+ def finalize
109
+ breakpoint_finalize
110
+ stepping_breakpoint_finalize
111
+ end
112
+
113
+ def canonic_container(container)
114
+ [container[0], canonic_file(container[1])]
115
+ end
116
+
117
+ def compute_prompt
118
+ "(#{@settings[:prompt]}): "
119
+ end
120
+
121
+ # Check that we meed the criteria that cmd specifies it needs
122
+ def ok_for_running(cmd, name, nargs)
123
+ # TODO check execution_set against execution status.
124
+ # Check we have frame is not null
125
+ min_args = cmd.class.const_get(:MIN_ARGS)
126
+ if nargs < min_args
127
+ errmsg(("Command '%s' needs at least %d argument(s); " +
128
+ "got %d.") % [name, min_args, nargs])
129
+ return false
130
+ end
131
+ max_args = cmd.class.const_get(:MAX_ARGS)
132
+ if max_args and nargs > max_args
133
+ errmsg(("Command '%s' needs at most %d argument(s); " +
134
+ "got %d.") % [name, max_args, nargs])
135
+ return false
136
+ end
137
+ # if cmd.class.const_get(:NEED_RUNNING) && !...
138
+ # errmsg "Command '%s' requires a running program." % name
139
+ # return false
140
+ # end
141
+
142
+ if cmd.class.const_get(:NEED_STACK) && !@frame
143
+ errmsg "Command '%s' requires a running stack frame." % name
144
+ return false
145
+ end
146
+
147
+ return true
148
+ end
149
+
150
+ # Run one debugger command. True is returned if we want to quit.
151
+ def process_command_and_quit?()
152
+ intf_size = @dbgr.intf.size
153
+ @intf = @dbgr.intf[-1]
154
+ return true if @intf.input_eof? && intf_size == 1
155
+ while intf_size > 1 || !@intf.input_eof?
156
+ begin
157
+ @current_command =
158
+ if @cmd_queue.empty?
159
+ # Leave trailing blanks on for the "complete" command
160
+ read_command.chomp
161
+ else
162
+ @cmd_queue.shift
163
+ end
164
+ if @current_command.empty?
165
+ next unless @last_command && intf.interactive?;
166
+ end
167
+ next if @current_command[0..0] == '#' # Skip comment lines
168
+ break
169
+ rescue IOError, Errno::EPIPE => e
170
+ if intf_size > 1
171
+ @dbgr.intf.pop
172
+ intf_size = @dbgr.intf.size
173
+ @intf = @dbgr.intf[-1]
174
+ @last_command = nil
175
+ print_location
176
+ else
177
+ ## FIXME: think of something better.
178
+ quit('exit!')
179
+ return true
180
+ end
181
+ rescue Exception => exc
182
+ errmsg("Internal debugger error in read: #{exc.inspect}")
183
+ exception_dump(exc, @settings[:debugexcept], $!.backtrace)
184
+ end
185
+ end
186
+ run_command(@current_command)
187
+
188
+ # Save it to the history.
189
+ @intf.history_io.puts @last_command if @last_command && @intf.history_io
190
+ end
191
+
192
+ def after_cmdloop
193
+ @cmdloop_posthooks.run
194
+ end
195
+
196
+ def before_cmdloop
197
+
198
+ frame_setup
199
+
200
+ @unconditional_prehooks.run
201
+ if breakpoint?
202
+ delete_breakpoint(@brkpt) if @brkpt.temp?
203
+ @last_pos = [@frame.vm_location, @stack_size, @current_thread, @event]
204
+ end
205
+
206
+ if stepping_skip? # || @stack_size <= @hide_level
207
+ if @next_thread
208
+ self.next(@step_count, :next_level => @next_level)
209
+ else
210
+ step(@return_to_program, @step_count, {}, @stop_condition)
211
+ end
212
+ return true
213
+ elsif @event == 'start'
214
+ step('step', 0)
215
+ return true
216
+ end
217
+
218
+ @prompt = compute_prompt
219
+
220
+ @leave_cmd_loop = false
221
+ print_location unless @settings[:traceprint]
222
+ # if 'trace-var' == @event
223
+ # msg "Note: we are stopped *after* the above location."
224
+ # end
225
+
226
+ @eventbuf.add_mark if @settings[:tracebuffer]
227
+
228
+ @return_to_program = false
229
+ @cmdloop_prehooks.run
230
+ return false
231
+ end
232
+
233
+
234
+ # This is the main entry point.
235
+ def process_commands
236
+ skip_command = before_cmdloop
237
+ while not @leave_cmd_loop do
238
+ begin
239
+ # if settings[:traceprint]
240
+ # @return_to_program = 'step'
241
+ # else
242
+ if !skip_command
243
+ break if process_command_and_quit?()
244
+ end
245
+ # end
246
+ if @return_to_program
247
+ after_cmdloop
248
+ if @step_count >= 0 && 'finish' != @return_to_program
249
+ @step_bp = step_over_by(1)
250
+ run_command('disassemble all') if settings[:debugstep]
251
+ dbgr.listen('step' == @return_to_program)
252
+ else
253
+ @step_bp = nil
254
+ dbgr.listen
255
+ end
256
+ skip_command = before_cmdloop
257
+ end
258
+ rescue SystemExit
259
+ @dbgr.stop
260
+ raise
261
+ rescue Exception => exc
262
+ # If we are inside the script interface errmsg may fail.
263
+ begin
264
+ errmsg("Internal debugger error: #{exc.inspect}")
265
+ rescue IOError
266
+ $stderr.puts "Internal debugger error: #{exc.inspect}"
267
+ end
268
+ exception_dump(exc, @settings[:debugexcept], $!.backtrace)
269
+ end
270
+ end
271
+ after_cmdloop
272
+ end
273
+
274
+ # Run current_command, a String. @last_command is set after the
275
+ # command is run if it is a command.
276
+ def run_command(current_command)
277
+ eval_command =
278
+ if current_command[0..0] == '!'
279
+ current_command[0] = ''
280
+ else
281
+ false
282
+ end
283
+
284
+ unless eval_command
285
+ commands = current_command.split(';;')
286
+ if commands.size > 1
287
+ current_command = commands.shift
288
+ @cmd_queue.unshift *commands
289
+ end
290
+ args = current_command.split
291
+ # Expand macros. FIXME: put in a procedure
292
+ while true do
293
+ macro_cmd_name = args[0]
294
+ return false if args.size == 0
295
+ break unless @macros.member?(macro_cmd_name)
296
+ current_command = @macros[macro_cmd_name][0].call(*args[1..-1])
297
+ msg current_command.inspect if settings[:debugmacro]
298
+ if current_command.is_a?(Array) &&
299
+ current_command.all? {|val| val.is_a?(String)}
300
+ args = (first=current_command.shift).split
301
+ @cmd_queue += current_command
302
+ current_command = first
303
+ elsif current_command.is_a?(String)
304
+ args = current_command.split
305
+ else
306
+ errmsg("macro #{macro_cmd_name} should return an Array " +
307
+ "of Strings or a String. Got #{current_command.inspect}")
308
+ return false
309
+ end
310
+ end
311
+
312
+ @cmd_name = args[0]
313
+ run_cmd_name =
314
+ if @aliases.member?(@cmd_name)
315
+ @aliases[@cmd_name]
316
+ else
317
+ @cmd_name
318
+ end
319
+
320
+ run_cmd_name = uniq_abbrev(@commands.keys, run_cmd_name) if
321
+ !@commands.member?(run_cmd_name) && @settings[:abbrev]
322
+
323
+ if @commands.member?(run_cmd_name)
324
+ cmd = @commands[run_cmd_name]
325
+ if ok_for_running(cmd, run_cmd_name, args.size-1)
326
+ @cmd_argstr = current_command[@cmd_name.size..-1].lstrip
327
+ cmd.run(args)
328
+ @last_command = current_command
329
+ end
330
+ return false
331
+ end
332
+ end
333
+
334
+ # Eval anything that's not a command or has been
335
+ # requested to be eval'd
336
+ if settings[:autoeval] || eval_command
337
+ begin
338
+ eval_code(current_command, @settings[:maxstring])
339
+ return false
340
+ rescue NameError
341
+ end
342
+ end
343
+ undefined_command(cmd_name)
344
+ return false
345
+ end
346
+
347
+ # Error message when a command doesn't exist
348
+ def undefined_command(cmd_name)
349
+ begin
350
+ errmsg('Undefined command: "%s". Try "help".' % cmd_name)
351
+ rescue
352
+ $stderr.puts 'Undefined command: "%s". Try "help".' % cmd_name
353
+ end
354
+ end
355
+
356
+ # FIXME: Allow access to both Trepan::CmdProcessor and Trepan
357
+ # for index [] and []=.
358
+ # If there is a Trepan::CmdProcessor setting that would take precidence.
359
+ # def settings
360
+ # @settings.merge(@dbgr.settings) # wrong because this doesn't allow []=
361
+ # end
362
+ end
363
+ end
364
+
365
+ if __FILE__ == $0
366
+ $0 = 'foo' # So we don't get here again
367
+ require_relative 'lib/trepanning'
368
+ dbg = Trepan.new(:nx => true)
369
+ cmdproc = dbg.instance_variable_get('@processor')
370
+ cmdproc.msg('I am main')
371
+ cmdproc.errmsg('Whoa!')
372
+ cmds = cmdproc.commands
373
+ p cmdproc.aliases
374
+ p cmdproc.commands.keys.sort
375
+ cmd_name, cmd_obj = cmds.first
376
+ puts cmd_obj.class.const_get(:HELP)
377
+ puts cmd_obj.class.const_get(:SHORT_HELP)
378
+
379
+ cmdproc.instance_variable_set('@current_thread', Thread.current)
380
+ puts cmdproc.compute_prompt
381
+ Thread.new{ puts cmdproc.compute_prompt }.join
382
+
383
+ x = Thread.new{ Thread.pass; x = 1 }
384
+ puts cmdproc.compute_prompt
385
+ x.join
386
+ cmdproc.debug_nest += 1
387
+ puts cmdproc.compute_prompt
388
+
389
+ # if ARGV.size > 0
390
+ # cmdproc.msg('Enter "q" to quit')
391
+ # cmdproc.process_commands
392
+ # else
393
+ # $input = []
394
+ # class << cmdproc
395
+ # def read_command
396
+ # $input.shift
397
+ # end
398
+ # end
399
+ # $input = ['1+2']
400
+ # cmdproc.process_command_and_quit?
401
+ # $input = ['!s = 5'] # ! means eval line
402
+ # cmdproc.process_command_and_quit?
403
+ # end
404
+ end
@@ -0,0 +1,39 @@
1
+ # -*- Ruby -*-
2
+ # -*- encoding: utf-8 -*-
3
+ require 'rake'
4
+ require 'rubygems' unless
5
+ Object.const_defined?(:Gem)
6
+ require File.dirname(__FILE__) + "/app/options"
7
+ Gem::Specification.new do |s|
8
+ s.add_dependency('columnize')
9
+ s.add_development_dependency('diff-lcs') # For testing only
10
+ s.add_dependency('rbx-require-relative', '>=0.0.4')
11
+ s.add_dependency('rbx-linecache', '~>1.3')
12
+ s.add_dependency('coderay', '>=1.0')
13
+ s.authors = ['R. Bernstein']
14
+ s.date = Time.now
15
+ s.description = <<-EOF
16
+ A modular, testable, Ruby debugger using some of good ideas from
17
+ ruby-debug, other debuggers, and Ruby Rails.
18
+
19
+ Some of the core debugger concepts have been rethought. As a result,
20
+ some of this may be experimental.
21
+
22
+ This version works only on Rubinus 1.2.1 or higher.
23
+ EOF
24
+ ## s.add_dependency('diff-lcs') # For testing only
25
+ s.authors = ['R. Bernstein']
26
+ s.email = 'rockyb@rubyforge.net'
27
+ s.executables = `git ls-files -- bin/*`.split("\n").map{
28
+ |f| File.basename(f) }
29
+ s.files = `git ls-files`.split("\n")
30
+ s.homepage = 'http://wiki.github.com/rocky/rbx-trepanning'
31
+ s.name = 'rbx-trepanning'
32
+ s.license = 'MIT'
33
+ s.platform = Gem::Platform::new ['universal', 'rubinius', '1.2']
34
+ s.require_paths = ['lib']
35
+ # s.required_ruby_version = '~> 1.8.7'
36
+ s.summary = 'Trepan Ruby Debugger for Rubinius 1.2.4 and higher'
37
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
38
+ s.version = Trepan::VERSION
39
+ end
data/sample/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env ruby
2
+ # Run this program in a terminal window to see a list of terminal colors
3
+ # the assignments are the defaults as of Jan 18, 2011, but you may want to
4
+ # double check.
5
+ require 'rubygems'
6
+ require 'coderay'
7
+ require 'term/ansicolor'
8
+
9
+ TOKEN_COLORS = {
10
+ :annotation => '35',
11
+ :attribute_name => '33',
12
+ :attribute_name_fat => '33',
13
+ :attribute_value => '31',
14
+ :attribute_value_fat => '31',
15
+ :bin => '1;35',
16
+ :char => {:self => '36', :delimiter => '34'},
17
+ :class => '1;35',
18
+ :class_variable => '36',
19
+ :color => '32',
20
+ :comment => '37',
21
+ :complex => '34',
22
+ :constant => ['34', '4'],
23
+ :decoration => '35',
24
+ :definition => '1;32',
25
+ :directive => ['32', '4'],
26
+ :doc => '46',
27
+ :doctype => '1;30',
28
+ :doc_string => ['31', '4'],
29
+ :entity => '33',
30
+ :error => ['1;33', '41'],
31
+ :exception => '1;31',
32
+ :float => '1;35',
33
+ :function => '1;34',
34
+ :global_variable => '42',
35
+ :hex => '1;36',
36
+ :important => '1;31',
37
+ :include => '33',
38
+ :integer => '1;34',
39
+ :interpreted => '1;35',
40
+ :key => '35',
41
+ :label => '1;4',
42
+ :local_variable => '33',
43
+ :oct => '1;35',
44
+ :operator_name => '1;29',
45
+ :pre_constant => '1;36',
46
+ :pre_type => '1;30',
47
+ :predefined => ['4', '1;34'],
48
+ :preprocessor => '36',
49
+ :pseudo_class => '34',
50
+ :regexp => {
51
+ :content => '31',
52
+ :delimiter => '1;29',
53
+ :modifier => '35',
54
+ :function => '1;29'
55
+ },
56
+ :reserved => '1;31',
57
+ :shell => {
58
+ :self => '42',
59
+ :content => '1;29',
60
+ :delimiter => '37',
61
+ },
62
+ :string => {
63
+ :self => '32',
64
+ :modifier => '1;32',
65
+ :escape => '1;36',
66
+ :delimiter => '1;32',
67
+ },
68
+ :symbol => '1;32',
69
+ :tag => '34',
70
+ :tag_fat => '1;34',
71
+ :tag_special => ['34', '4'],
72
+ :type => '1;34',
73
+ :value => '36',
74
+ :variable => '34',
75
+ :insert => '42',
76
+ :delete => '41',
77
+ :change => '44',
78
+ :head => '45',
79
+ }
80
+ TOKEN_COLORS[:keyword] = TOKEN_COLORS[:reserved]
81
+ TOKEN_COLORS[:method] = TOKEN_COLORS[:function]
82
+ TOKEN_COLORS[:imaginary] = TOKEN_COLORS[:complex]
83
+ TOKEN_COLORS[:open] = TOKEN_COLORS[:close] = TOKEN_COLORS[:nesting_delimiter] = TOKEN_COLORS[:escape] = TOKEN_COLORS[:delimiter]
84
+
85
+ # require 'trepanning'; debugger
86
+ %w(annotation
87
+ attribute_name
88
+ attribute_name_fat
89
+ attribute_value
90
+ attribute_value_fat
91
+ bin
92
+ class
93
+ class_variable
94
+ color
95
+ comment
96
+ complex
97
+ constant
98
+ decoration
99
+ definition
100
+ doc
101
+ doctype
102
+ entity
103
+ exception
104
+ float
105
+ function
106
+ global_variable
107
+ hex
108
+ important
109
+ include
110
+ integer
111
+ interpreted
112
+ key
113
+ label
114
+ local_variable
115
+ oct
116
+ operator_name
117
+ pre_constant
118
+ pre_type
119
+ predefined
120
+ preprocessor
121
+ pseudo_class
122
+ reserved
123
+ symbol
124
+ tag
125
+ tag_fat
126
+ type
127
+ value
128
+ variable
129
+ insert
130
+ delete
131
+ change
132
+ head
133
+ ).each do |name|
134
+ puts "\e[#{TOKEN_COLORS[name.to_sym]}m#{name} - #{TOKEN_COLORS[name.to_sym].inspect}\e[0m"
135
+ end
136
+ %w(bold italic underline).each do |name|
137
+ attrib=Term::ANSIColor.send(name)
138
+ puts "#{attrib}#{name} - #{attrib.inspect}\e[0m"
139
+ end
@@ -0,0 +1,14 @@
1
+ # Rocky's trepanx profile for Rubinius.
2
+
3
+ # Place where I have Rubinius source (in rvm)
4
+ dir /home/rocky-rvm/.rvm/src/rbx-head/
5
+
6
+ set autoeval on # Is default, but just in case
7
+ # set terminal on # turn on syntax highlight by default
8
+
9
+ # My customization to the default syntax coloring
10
+ load "#{ENV['HOME']}/.trepanx-colors.rb"
11
+
12
+ # let me know that this ran...
13
+ puts "Rocky's .trepanxrc loaded"
14
+
@@ -0,0 +1,46 @@
1
+ # Terminal color settings I use. I doubt terminal colors are
2
+ # standardized let alone what colors you want for the various
3
+ # syntax elements. So you should adjust as desired.
4
+
5
+ # Values are either a number string, e.g. '36' or a pair of number
6
+ # semicolon and number, e.g. '3;36'.
7
+ #
8
+ # The first number before a semicolon is a font modifier from the
9
+ # following table:
10
+ #
11
+ # 1 - bold
12
+ # 3 - italic
13
+ # 4 - underline
14
+
15
+ require 'rubygems'
16
+ require 'coderay'
17
+ TERM_TOKEN_COLORS = {
18
+ :comment => '3;37', # sienna #8b4726
19
+ :constant => '1;34', # Bold Midnight Blue #191970
20
+ :class => '1;2', #
21
+ :doctype => '1;2', #
22
+ :global_variable => '36', # yellow brownish
23
+ :integer => '29', # black #00000
24
+ :label => '4', # black underline
25
+ :method => '34', # blue #0000FF
26
+ :pre_constant => '3;33', # goldenrod4 #8b6914
27
+ :regexp => {
28
+ :content => '36', # dark cyan #008b8b
29
+ :delimiter => '1;29', # bold black
30
+ :modifier => '35',
31
+ :function => '1;29'
32
+ },
33
+ :string => {
34
+ :content => '1;37', # ivory4 (grey) #8b8b83
35
+ :delimiter => '1;29', # bold black
36
+ },
37
+ :reserved => '1;32', # bold dark olive green #556b2f RGB: 85, 107, 47
38
+ :symbol => '35', # purple4 #551A8B RGB: 85, 26, 139
39
+ }
40
+ module CodeRay::Encoders
41
+ class Terminal < Encoder
42
+ TERM_TOKEN_COLORS.each_pair do |key, value|
43
+ TOKEN_COLORS[key] = value
44
+ end
45
+ end
46
+ end
@@ -0,0 +1 @@
1
+ /*~
@@ -0,0 +1,36 @@
1
+ gcd.rb:4
2
+ def gcd(a, b)
3
+ # # ********************************************************
4
+ # # This tests the enable command.
5
+ # # ********************************************************
6
+ # set debuggertesting on
7
+ Currently testing the debugger is on.
8
+ # set callstyle last
9
+ Frame call-display style is last.
10
+ # set autoeval off
11
+ autoeval is off.
12
+ # break Object.gcd
13
+ Breakpoint 1 at Object::gcd
14
+ # # Should have a breakpoint 1
15
+ # enable br 1
16
+ # # Get help on enable
17
+ # help enable
18
+ Enable some things.
19
+ This is used to cancel the effect of the "disable" command.
20
+ --
21
+ List of enable subcommands:
22
+ --
23
+ enable breakpoints -- Enable specified breakpoints
24
+ enable display -- Enable some expressions to be displayed when program stops
25
+ # # Get help on just enable break
26
+ # help enable break
27
+ Enable specified breakpoints.
28
+ Give breakpoint numbers (separated by spaces) as arguments.
29
+ This is used to cancel the effect of the "disable" command.
30
+ # # Plain enable should work
31
+ # enable
32
+ *** "enable" must be followed "display", "breakpoints" or breakpoint numbers.
33
+ # # An invalid enable command
34
+ # enable foo
35
+ Enable breakpoints argument 'foo' needs to be a number.
36
+ # quit
@@ -0,0 +1,6 @@
1
+ # *******************************************************************
2
+ # Just to see that we can load a filename with an blank in it
3
+ # *******************************************************************
4
+ set basename off
5
+ continue
6
+