trepanning 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. data/ChangeLog +4422 -0
  2. data/LICENSE +23 -0
  3. data/NEWS +12 -0
  4. data/README.textile +56 -0
  5. data/Rakefile +171 -0
  6. data/app/Makefile +7 -0
  7. data/app/breakpoint.rb +157 -0
  8. data/app/brkptmgr.rb +149 -0
  9. data/app/condition.rb +22 -0
  10. data/app/core.rb +203 -0
  11. data/app/default.rb +54 -0
  12. data/app/disassemble.rb +61 -0
  13. data/app/display.rb +148 -0
  14. data/app/file.rb +135 -0
  15. data/app/frame.rb +275 -0
  16. data/app/irb.rb +112 -0
  17. data/app/mock.rb +22 -0
  18. data/app/options.rb +122 -0
  19. data/app/run.rb +95 -0
  20. data/app/thread.rb +24 -0
  21. data/app/util.rb +32 -0
  22. data/bin/trepan +63 -0
  23. data/data/custom_require.rb +44 -0
  24. data/data/irbrc +55 -0
  25. data/data/prelude.rb +38 -0
  26. data/interface/base_intf.rb +95 -0
  27. data/interface/script.rb +103 -0
  28. data/interface/user.rb +90 -0
  29. data/io/base_io.rb +92 -0
  30. data/io/input.rb +111 -0
  31. data/io/string_array.rb +155 -0
  32. data/lib/Makefile +7 -0
  33. data/lib/trepanning.rb +277 -0
  34. data/processor/breakpoint.rb +108 -0
  35. data/processor/command/alias.rb +55 -0
  36. data/processor/command/backtrace.rb +95 -0
  37. data/processor/command/base/cmd.rb +97 -0
  38. data/processor/command/base/subcmd.rb +207 -0
  39. data/processor/command/base/submgr.rb +178 -0
  40. data/processor/command/base/subsubcmd.rb +102 -0
  41. data/processor/command/base/subsubmgr.rb +182 -0
  42. data/processor/command/break.rb +85 -0
  43. data/processor/command/condition.rb +64 -0
  44. data/processor/command/continue.rb +61 -0
  45. data/processor/command/debug.rb +85 -0
  46. data/processor/command/delete.rb +54 -0
  47. data/processor/command/directory.rb +43 -0
  48. data/processor/command/disable.rb +65 -0
  49. data/processor/command/disassemble.rb +103 -0
  50. data/processor/command/display.rb +81 -0
  51. data/processor/command/down.rb +56 -0
  52. data/processor/command/enable.rb +43 -0
  53. data/processor/command/exit.rb +54 -0
  54. data/processor/command/finish.rb +81 -0
  55. data/processor/command/frame.rb +117 -0
  56. data/processor/command/help.rb +146 -0
  57. data/processor/command/info.rb +28 -0
  58. data/processor/command/info_subcmd/args.rb +56 -0
  59. data/processor/command/info_subcmd/breakpoints.rb +162 -0
  60. data/processor/command/info_subcmd/file.rb +162 -0
  61. data/processor/command/info_subcmd/frame.rb +39 -0
  62. data/processor/command/info_subcmd/iseq.rb +83 -0
  63. data/processor/command/info_subcmd/locals.rb +88 -0
  64. data/processor/command/info_subcmd/program.rb +54 -0
  65. data/processor/command/info_subcmd/registers.rb +72 -0
  66. data/processor/command/info_subcmd/registers_subcmd/dfp.rb +38 -0
  67. data/processor/command/info_subcmd/registers_subcmd/helper.rb +40 -0
  68. data/processor/command/info_subcmd/registers_subcmd/lfp.rb +54 -0
  69. data/processor/command/info_subcmd/registers_subcmd/pc.rb +44 -0
  70. data/processor/command/info_subcmd/registers_subcmd/sp.rb +75 -0
  71. data/processor/command/info_subcmd/return.rb +40 -0
  72. data/processor/command/info_subcmd/thread.rb +106 -0
  73. data/processor/command/irb.rb +106 -0
  74. data/processor/command/kill.rb +58 -0
  75. data/processor/command/list.rb +327 -0
  76. data/processor/command/macro.rb +65 -0
  77. data/processor/command/next.rb +89 -0
  78. data/processor/command/nocache.rb +33 -0
  79. data/processor/command/print.rb +37 -0
  80. data/processor/command/ps.rb +40 -0
  81. data/processor/command/quit.rb +62 -0
  82. data/processor/command/raise.rb +47 -0
  83. data/processor/command/reload.rb +28 -0
  84. data/processor/command/reload_subcmd/command.rb +34 -0
  85. data/processor/command/restart.rb +57 -0
  86. data/processor/command/save.rb +60 -0
  87. data/processor/command/set.rb +47 -0
  88. data/processor/command/set_subcmd/auto.rb +27 -0
  89. data/processor/command/set_subcmd/auto_subcmd/eval.rb +67 -0
  90. data/processor/command/set_subcmd/auto_subcmd/irb.rb +49 -0
  91. data/processor/command/set_subcmd/auto_subcmd/list.rb +51 -0
  92. data/processor/command/set_subcmd/basename.rb +39 -0
  93. data/processor/command/set_subcmd/debug.rb +27 -0
  94. data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +49 -0
  95. data/processor/command/set_subcmd/debug_subcmd/except.rb +35 -0
  96. data/processor/command/set_subcmd/debug_subcmd/macro.rb +35 -0
  97. data/processor/command/set_subcmd/debug_subcmd/skip.rb +35 -0
  98. data/processor/command/set_subcmd/debug_subcmd/stack.rb +45 -0
  99. data/processor/command/set_subcmd/different.rb +67 -0
  100. data/processor/command/set_subcmd/events.rb +71 -0
  101. data/processor/command/set_subcmd/max.rb +35 -0
  102. data/processor/command/set_subcmd/max_subcmd/list.rb +50 -0
  103. data/processor/command/set_subcmd/max_subcmd/stack.rb +60 -0
  104. data/processor/command/set_subcmd/max_subcmd/string.rb +53 -0
  105. data/processor/command/set_subcmd/max_subcmd/width.rb +50 -0
  106. data/processor/command/set_subcmd/return.rb +66 -0
  107. data/processor/command/set_subcmd/sp.rb +62 -0
  108. data/processor/command/set_subcmd/substitute.rb +25 -0
  109. data/processor/command/set_subcmd/substitute_subcmd/eval.rb +98 -0
  110. data/processor/command/set_subcmd/substitute_subcmd/path.rb +55 -0
  111. data/processor/command/set_subcmd/substitute_subcmd/string.rb +72 -0
  112. data/processor/command/set_subcmd/timer.rb +68 -0
  113. data/processor/command/set_subcmd/trace.rb +43 -0
  114. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +56 -0
  115. data/processor/command/set_subcmd/trace_subcmd/print.rb +54 -0
  116. data/processor/command/set_subcmd/trace_subcmd/var.rb +61 -0
  117. data/processor/command/show.rb +27 -0
  118. data/processor/command/show_subcmd/alias.rb +50 -0
  119. data/processor/command/show_subcmd/args.rb +50 -0
  120. data/processor/command/show_subcmd/auto.rb +27 -0
  121. data/processor/command/show_subcmd/auto_subcmd/eval.rb +38 -0
  122. data/processor/command/show_subcmd/auto_subcmd/irb.rb +34 -0
  123. data/processor/command/show_subcmd/auto_subcmd/list.rb +36 -0
  124. data/processor/command/show_subcmd/basename.rb +28 -0
  125. data/processor/command/show_subcmd/debug.rb +27 -0
  126. data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +31 -0
  127. data/processor/command/show_subcmd/debug_subcmd/except.rb +33 -0
  128. data/processor/command/show_subcmd/debug_subcmd/macro.rb +32 -0
  129. data/processor/command/show_subcmd/debug_subcmd/skip.rb +33 -0
  130. data/processor/command/show_subcmd/debug_subcmd/stack.rb +32 -0
  131. data/processor/command/show_subcmd/different.rb +37 -0
  132. data/processor/command/show_subcmd/events.rb +40 -0
  133. data/processor/command/show_subcmd/macro.rb +45 -0
  134. data/processor/command/show_subcmd/max.rb +31 -0
  135. data/processor/command/show_subcmd/max_subcmd/list.rb +39 -0
  136. data/processor/command/show_subcmd/max_subcmd/stack.rb +35 -0
  137. data/processor/command/show_subcmd/max_subcmd/string.rb +41 -0
  138. data/processor/command/show_subcmd/max_subcmd/width.rb +36 -0
  139. data/processor/command/show_subcmd/trace.rb +29 -0
  140. data/processor/command/show_subcmd/trace_subcmd/buffer.rb +84 -0
  141. data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
  142. data/processor/command/source.rb +74 -0
  143. data/processor/command/step.rb +139 -0
  144. data/processor/command/stepi.rb +63 -0
  145. data/processor/command/unalias.rb +44 -0
  146. data/processor/command/undisplay.rb +63 -0
  147. data/processor/command/up.rb +92 -0
  148. data/processor/default.rb +45 -0
  149. data/processor/display.rb +17 -0
  150. data/processor/eval.rb +88 -0
  151. data/processor/eventbuf.rb +131 -0
  152. data/processor/frame.rb +230 -0
  153. data/processor/help.rb +72 -0
  154. data/processor/hook.rb +128 -0
  155. data/processor/load_cmds.rb +102 -0
  156. data/processor/location.rb +126 -0
  157. data/processor/main.rb +364 -0
  158. data/processor/mock.rb +100 -0
  159. data/processor/msg.rb +26 -0
  160. data/processor/running.rb +170 -0
  161. data/processor/subcmd.rb +159 -0
  162. data/processor/validate.rb +395 -0
  163. data/test/example/fname with blank.rb +1 -0
  164. data/test/example/gcd-xx.rb +18 -0
  165. data/test/example/gcd.rb +19 -0
  166. data/test/example/gcd1.rb +24 -0
  167. data/test/example/null.rb +1 -0
  168. data/test/example/thread1.rb +3 -0
  169. data/test/functional/fn_helper.rb +119 -0
  170. data/test/functional/test-break.rb +87 -0
  171. data/test/functional/test-condition.rb +59 -0
  172. data/test/functional/test-debugger-call-bug.rb +31 -0
  173. data/test/functional/test-delete.rb +71 -0
  174. data/test/functional/test-finish.rb +44 -0
  175. data/test/functional/test-immediate-step-bug.rb +35 -0
  176. data/test/functional/test-next.rb +77 -0
  177. data/test/functional/test-raise.rb +73 -0
  178. data/test/functional/test-return.rb +100 -0
  179. data/test/functional/test-step.rb +274 -0
  180. data/test/functional/test-stepbug.rb +40 -0
  181. data/test/functional/test-trace-var.rb +40 -0
  182. data/test/functional/tmp/b1.rb +5 -0
  183. data/test/functional/tmp/s1.rb +9 -0
  184. data/test/functional/tmp/t2.rb +6 -0
  185. data/test/integration/file-diff.rb +88 -0
  186. data/test/integration/helper.rb +52 -0
  187. data/test/integration/test-fname-with-blank.rb +11 -0
  188. data/test/integration/test-quit.rb +11 -0
  189. data/test/integration/try-test-enable.rb +11 -0
  190. data/test/unit/cmd-helper.rb +44 -0
  191. data/test/unit/test-app-brkpt.rb +30 -0
  192. data/test/unit/test-app-brkptmgr.rb +56 -0
  193. data/test/unit/test-app-disassemble.rb +60 -0
  194. data/test/unit/test-app-file.rb +46 -0
  195. data/test/unit/test-app-frame.rb +49 -0
  196. data/test/unit/test-app-options.rb +60 -0
  197. data/test/unit/test-app-run.rb +19 -0
  198. data/test/unit/test-app-thread.rb +25 -0
  199. data/test/unit/test-app-util.rb +17 -0
  200. data/test/unit/test-base-subcmd.rb +59 -0
  201. data/test/unit/test-bin-trepan.rb +48 -0
  202. data/test/unit/test-cmd-alias.rb +50 -0
  203. data/test/unit/test-cmd-break.rb +80 -0
  204. data/test/unit/test-cmd-endisable.rb +59 -0
  205. data/test/unit/test-cmd-help.rb +100 -0
  206. data/test/unit/test-cmd-kill.rb +47 -0
  207. data/test/unit/test-cmd-quit.rb +26 -0
  208. data/test/unit/test-cmd-step.rb +45 -0
  209. data/test/unit/test-intf-user.rb +45 -0
  210. data/test/unit/test-io-input.rb +26 -0
  211. data/test/unit/test-proc-eval.rb +26 -0
  212. data/test/unit/test-proc-frame.rb +77 -0
  213. data/test/unit/test-proc-help.rb +15 -0
  214. data/test/unit/test-proc-hook.rb +29 -0
  215. data/test/unit/test-proc-load_cmds.rb +40 -0
  216. data/test/unit/test-proc-main.rb +99 -0
  217. data/test/unit/test-proc-validate.rb +90 -0
  218. data/test/unit/test-subcmd-help.rb +48 -0
  219. metadata +358 -0
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../base/subcmd'
4
+
5
+ class Trepan::Subcommand::ShowBasename < Trepan::ShowBoolSubcommand
6
+ unless defined?(HELP)
7
+ HELP = "Show only file basename in showing file names"
8
+ MIN_ABBREV = 'ba'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show basename)
11
+ end
12
+
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../mock'
18
+ name = File.basename(__FILE__, '.rb')
19
+
20
+ # FIXME: DRY the below code
21
+ dbgr, cmd = MockDebugger::setup('show')
22
+ subcommand = Trepan::Subcommand::ShowBasename.new(cmd)
23
+ testcmdMgr = Trepan::Subcmd.new(subcommand)
24
+
25
+ subcommand.run_show_bool
26
+ name = File.basename(__FILE__, '.rb')
27
+ subcommand.summary_help(name)
28
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../base/subsubcmd'
4
+ require_relative '../base/subsubmgr'
5
+
6
+ class Trepan::SubSubcommand::ShowDebug < Trepan::SubSubcommandMgr
7
+ unless defined?(HELP)
8
+ HELP = 'Show internal debugger settings.'
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show debug)
11
+ end
12
+ end
13
+
14
+ if __FILE__ == $0
15
+ require_relative '../../mock'
16
+ dbgr = MockDebugger::MockDebugger.new
17
+ cmds = dbgr.core.processor.commands
18
+ show_cmd = cmds['show']
19
+ command = Trepan::SubSubcommand::ShowDebug.new(dbgr.core.processor,
20
+ show_cmd)
21
+ name = File.basename(__FILE__, '.rb')
22
+ cmd_args = ['show', name]
23
+ show_cmd.instance_variable_set('@last_args', cmd_args)
24
+ # require_relative '../../../lib/trepanning'
25
+ # Trepan.debug(:set_restart => true)
26
+ command.run(cmd_args)
27
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::SubSubcommand::ShowDebugDbgr < Trepan::ShowBoolSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = "Show debugging the debugger"
8
+ NAME = File.basename(__FILE__, '.rb')
9
+ PREFIX = %w(show debug dbgr)
10
+ end
11
+
12
+ end
13
+
14
+ if __FILE__ == $0
15
+ # Demo it.
16
+ require_relative '../../../mock'
17
+ name = File.basename(__FILE__, '.rb')
18
+
19
+ # FIXME: DRY the below code
20
+ dbgr, show_cmd = MockDebugger::setup('show')
21
+ debug_cmd = Trepan::SubSubcommand::ShowDebug.new(dbgr.core.processor,
22
+ show_cmd)
23
+
24
+ # FIXME: remove the 'join' below
25
+ cmd_name = Trepan::SubSubcommand::ShowDebugDbgr::PREFIX.join('')
26
+ debugx_cmd = Trepan::SubSubcommand::ShowDebugDbgr.new(show_cmd.proc,
27
+ debug_cmd,
28
+ cmd_name)
29
+
30
+ debugx_cmd.run([])
31
+ end
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::SubSubcommand::ShowDebugExcept < Trepan::ShowBoolSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = 'Show excecution traceback on debugger command exception'
8
+ MIN_ABBREV = 'st'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show debug except)
11
+ end
12
+
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ require_relative '../../../subcmd'
19
+ name = File.basename(__FILE__, '.rb')
20
+
21
+ # FIXME: DRY the below code
22
+ dbgr, show_cmd = MockDebugger::setup('show')
23
+ debug_cmd = Trepan::SubSubcommand::ShowDebug.new(dbgr.core.processor,
24
+ show_cmd)
25
+
26
+ # FIXME: remove the 'join' below
27
+ cmd_name = Trepan::SubSubcommand::ShowDebugExcept::PREFIX.join('')
28
+ debugx_cmd = Trepan::SubSubcommand::ShowDebugExcept.new(show_cmd.proc,
29
+ debug_cmd,
30
+ cmd_name)
31
+
32
+ debugx_cmd.run([])
33
+ end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::SubSubcommand::ShowDebugMacro < Trepan::ShowBoolSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = "Show debugging macros"
8
+ MIN_ABBREV = 'st'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show debug macro)
11
+ end
12
+
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ name = File.basename(__FILE__, '.rb')
19
+
20
+ # FIXME: DRY the below code
21
+ dbgr, show_cmd = MockDebugger::setup('show')
22
+ debug_cmd = Trepan::SubSubcommand::ShowDebug.new(dbgr.core.processor,
23
+ show_cmd)
24
+
25
+ # FIXME: remove the 'join' below
26
+ cmd_name = Trepan::SubSubcommand::ShowDebugMacro::PREFIX.join('')
27
+ debugx_cmd = Trepan::SubSubcommand::ShowDebugMacro.new(show_cmd.proc,
28
+ debug_cmd,
29
+ cmd_name)
30
+
31
+ debugx_cmd.run([])
32
+ end
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::SubSubcommand::ShowDebugSkip < Trepan::ShowBoolSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = 'Show debugging of statement skip logic'
8
+ MIN_ABBREV = 'st'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show debug skip)
11
+ end
12
+
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ require_relative '../../../subcmd'
19
+ name = File.basename(__FILE__, '.rb')
20
+
21
+ # FIXME: DRY the below code
22
+ dbgr, show_cmd = MockDebugger::setup('show')
23
+ debug_cmd = Trepan::SubSubcommand::ShowDebug.new(dbgr.core.processor,
24
+ show_cmd)
25
+
26
+ # FIXME: remove the 'join' below
27
+ cmd_name = Trepan::SubSubcommand::ShowDebugSkip::PREFIX.join('')
28
+ debugx_cmd = Trepan::SubSubcommand::ShowDebugSkip.new(show_cmd.proc,
29
+ debug_cmd,
30
+ cmd_name)
31
+
32
+ debugx_cmd.run([])
33
+ end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::SubSubcommand::ShowDebugStack < Trepan::ShowBoolSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = "Show complete stack including possibly setup stack from trepanning"
8
+ MIN_ABBREV = 'st'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show debug stack)
11
+ end
12
+
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ name = File.basename(__FILE__, '.rb')
19
+
20
+ # FIXME: DRY the below code
21
+ dbgr, show_cmd = MockDebugger::setup('show')
22
+ debug_cmd = Trepan::SubSubcommand::ShowDebug.new(dbgr.core.processor,
23
+ show_cmd)
24
+
25
+ # FIXME: remove the 'join' below
26
+ cmd_name = Trepan::SubSubcommand::ShowDebugStack::PREFIX.join('')
27
+ debugx_cmd = Trepan::SubSubcommand::ShowDebugStack.new(show_cmd.proc,
28
+ debug_cmd,
29
+ cmd_name)
30
+
31
+ debugx_cmd.run([])
32
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../base/subcmd'
4
+
5
+ class Trepan::Subcommand::ShowDifferent < Trepan::ShowBoolSubcommand
6
+ unless defined?(HELP)
7
+ HELP = "Show status of 'set different'"
8
+ MIN_ABBREV = 'dif'.size
9
+ PREFIX = %w(show different)
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ end
12
+
13
+ def run(args)
14
+ if 'nostack' == @proc.settings[:different]
15
+ msg("different is nostack.")
16
+ else
17
+ super
18
+ end
19
+ end
20
+
21
+
22
+ end
23
+
24
+ if __FILE__ == $0
25
+ # Demo it.
26
+ require_relative '../../mock'
27
+ name = File.basename(__FILE__, '.rb')
28
+
29
+ # FIXME: DRY the below code
30
+ dbgr, cmd = MockDebugger::setup('exit')
31
+ subcommand = Trepan::Subcommand::ShowDifferent.new(cmd)
32
+ testcmdMgr = Trepan::Subcmd.new(subcommand)
33
+
34
+ subcommand.run_show_bool
35
+ name = File.basename(__FILE__, '.rb')
36
+ subcommand.summary_help(name)
37
+ end
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../base/subcmd'
4
+
5
+ class Trepan::Subcommand::ShowEvents < Trepan::Subcommand
6
+ unless defined?(HELP)
7
+ HELP = 'Show trace events we may stop on.'
8
+ MIN_ABBREV = 'ev'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show events)
11
+ end
12
+
13
+ # FIXME: this really should be a subcommand of "set trace"
14
+ def run(args)
15
+ step_events_list = @proc.core.step_events_list
16
+ if step_events_list
17
+ msg 'Trace events we may stop on:'
18
+ msg "\t" + step_events_list
19
+ else
20
+ msg 'No events trapped.'
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ if __FILE__ == $0
27
+ # Demo it.
28
+ require_relative '../../mock'
29
+ name = File.basename(__FILE__, '.rb')
30
+
31
+ # FIXME: DRY the below code
32
+ dbgr, cmd = MockDebugger::setup('exit')
33
+ subcommand = Trepan::Subcommand::ShowEvents.new(cmd)
34
+ testcmdMgr = Trepan::Subcmd.new(subcommand)
35
+
36
+ name = File.basename(__FILE__, '.rb')
37
+ subcommand.summary_help(name)
38
+ puts
39
+ subcommand.run([name])
40
+ end
@@ -0,0 +1,45 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../base/subcmd'
4
+
5
+ class Trepan::Subcommand::ShowMacro < Trepan::Subcommand
6
+ unless defined?(HELP)
7
+ HELP = "Show defined macros"
8
+ MIN_ABBREV = 'ma'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show macro)
11
+ end
12
+
13
+ def run(args)
14
+ if args.size > 2
15
+ args[2..-1].each do |macro_name|
16
+ if @proc.macros.member?(macro_name)
17
+ msg "%s: %s" % [macro_name, @proc.macros[macro_name]]
18
+ else
19
+ msg "%s is not a defined macro" % macro_name
20
+ end
21
+ end
22
+ elsif @proc.macros.empty?
23
+ msg "No macros defined."
24
+ else
25
+ msg columnize_commands(@proc.macros.keys.sort)
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ if __FILE__ == $0
32
+ # Demo it.
33
+ require_relative '../../mock'
34
+ name = File.basename(__FILE__, '.rb')
35
+
36
+ # FIXME: DRY the below code
37
+ dbgr, cmd = MockDebugger::setup('show')
38
+ subcommand = Trepan::Subcommand::ShowMacro.new(cmd)
39
+ testcmdMgr = Trepan::Subcmd.new(subcommand)
40
+
41
+ name = File.basename(__FILE__, '.rb')
42
+ subcommand.summary_help(name)
43
+ subcommand.run(%w(show macro))
44
+ subcommand.run(%w(show macro u foo))
45
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../base/subsubcmd'
4
+ require_relative '../base/subsubmgr'
5
+
6
+ class Trepan::SubSubcommand::ShowMax < Trepan::SubSubcommandMgr
7
+ unless defined?(HELP)
8
+ HELP = 'Show "maximum length" settings'
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show max)
11
+ end
12
+
13
+ def run(args)
14
+ super
15
+ end
16
+ end
17
+
18
+ if __FILE__ == $0
19
+ require_relative '../../mock'
20
+ dbgr = MockDebugger::MockDebugger.new
21
+ cmds = dbgr.core.processor.commands
22
+ show_cmd = cmds['show']
23
+ command = Trepan::SubSubcommand::ShowMax.new(dbgr.core.processor,
24
+ show_cmd)
25
+ name = File.basename(__FILE__, '.rb')
26
+ cmd_args = ['show', name]
27
+ show_cmd.instance_variable_set('@last_args', cmd_args)
28
+ # require_relative '../../../lib/trepanning'
29
+ # Trepan.debug(:set_restart => true)
30
+ command.run(cmd_args)
31
+ end
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::Subcommand::ShowMaxList < Trepan::ShowIntSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = 'Show the number of source file lines to list.'
8
+ MIN_ABBREV = 'lis'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show max list)
11
+ end
12
+
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ name = File.basename(__FILE__, '.rb')
19
+
20
+ # FIXME: DRY the below code
21
+ dbgr, show_cmd = MockDebugger::setup('show')
22
+ testcmdMgr = Trepan::Subcmd.new(show_cmd)
23
+ max_cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.core.processor,
24
+ show_cmd)
25
+ cmd_ary = Trepan::SubSubcommand::ShowMaxList::PREFIX
26
+ cmd_name = cmd_ary.join('')
27
+ subcmd = Trepan::SubSubcommand::ShowMaxList.new(show_cmd.proc,
28
+ max_cmd,
29
+ cmd_name)
30
+ prefix_run = cmd_ary[1..-1]
31
+ subcmd.run(prefix_run)
32
+
33
+ # require_relative '../../../../lib/trepanning'
34
+ # dbgr = Trepan.new(:set_restart => true)
35
+ # dbgr.debugger
36
+ puts subcmd.summary_help(name)
37
+ puts
38
+ puts '-' * 20
39
+ end
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::Subcommand::ShowMaxStack < Trepan::ShowIntSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = 'Show the number of backtrace lines the debugger will show'
8
+ MIN_ABBREV = 'sta'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show max stack)
11
+ end
12
+
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+
19
+ # FIXME: DRY the below code
20
+ dbgr, show_cmd = MockDebugger::setup('show')
21
+ testcmdMgr = Trepan::Subcmd.new(show_cmd)
22
+ max_cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.core.processor,
23
+ show_cmd)
24
+
25
+ cmd_name = Trepan::SubSubcommand::ShowMaxStack::PREFIX.join('')
26
+ maxx_cmd = Trepan::SubSubcommand::ShowMaxStack.new(show_cmd.proc,
27
+ max_cmd,
28
+ cmd_name)
29
+ # require_relative '../../../../lib/trepanning'
30
+ # dbgr = Trepan.new(:set_restart => true)
31
+ # dbgr.debugger
32
+ puts max_cmd.summary_help(maxx_cmd)
33
+ puts
34
+ maxx_cmd.run([])
35
+ end
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::Subcommand::ShowMaxString < Trepan::ShowIntSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = 'Show the number of characters in a string before truncating.
8
+
9
+ Sometimes the string representation of an object is very long. This
10
+ setting limits how much of the string representation you want to
11
+ see. However if the string has an embedded newline then we will assume
12
+ the output is intended to be formated as.'
13
+ MIN_ABBREV = 'st'.size
14
+ NAME = File.basename(__FILE__, '.rb')
15
+ PREFIX = %w(show max string)
16
+ end
17
+
18
+ end
19
+
20
+ if __FILE__ == $0
21
+ # Demo it.
22
+ require_relative '../../../mock'
23
+
24
+ # FIXME: DRY the below code
25
+ dbgr, show_cmd = MockDebugger::setup('show')
26
+ testcmdMgr = Trepan::Subcmd.new(show_cmd)
27
+ max_cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.core.processor,
28
+ show_cmd)
29
+
30
+ cmd_name = Trepan::SubSubcommand::ShowMaxString::PREFIX.join('')
31
+ maxx_cmd = Trepan::SubSubcommand::ShowMaxString.new(show_cmd.proc,
32
+ max_cmd,
33
+ cmd_name)
34
+
35
+ # require_relative '../../../../lib/trepanning'
36
+ # dbgr = Trepan.new(:set_restart => true)
37
+ # dbgr.debugger
38
+ puts max_cmd.summary_help(maxx_cmd)
39
+ puts
40
+ maxx_cmd.run([])
41
+ end
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::Subcommand::ShowMaxWidth < Trepan::ShowIntSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP = 'Show the number of characters the debugger thinks are in a line.'
8
+ MIN_ABBREV = 'wid'.size
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %w(show max width)
11
+ end
12
+
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+
19
+ # FIXME: DRY the below code
20
+ dbgr, show_cmd = MockDebugger::setup('show')
21
+ testcmdMgr = Trepan::Subcmd.new(show_cmd)
22
+ max_cmd = Trepan::SubSubcommand::ShowMax.new(dbgr.core.processor,
23
+ show_cmd)
24
+ cmd_name = Trepan::SubSubcommand::ShowMaxWidth::PREFIX.join('')
25
+ maxx_cmd = Trepan::SubSubcommand::ShowMaxWidth.new(show_cmd.proc,
26
+ max_cmd,
27
+ cmd_name)
28
+
29
+ name = File.basename(__FILE__, '.rb')
30
+ # require_relative '../../../../lib/trepanning'
31
+ # dbgr = Trepan.new(:set_restart => true)
32
+ # dbgr.debugger
33
+ puts max_cmd.summary_help(maxx_cmd)
34
+ puts
35
+ maxx_cmd.run([])
36
+ end
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../base/subsubcmd'
4
+ require_relative '../base/subsubmgr'
5
+
6
+ class Trepan::SubSubcommand::ShowTrace < Trepan::SubSubcommandMgr
7
+
8
+ unless defined?(HELP)
9
+ HELP = "Show event tracing printing"
10
+ MIN_ABBREV = 'tr'.size
11
+ NAME = File.basename(__FILE__, '.rb')
12
+ PREFIX = %w(show trace)
13
+ SHORT_HELP = HELP
14
+ end
15
+ end
16
+
17
+ if __FILE__ == $0
18
+ # Demo it.
19
+ require_relative '../../mock'
20
+ dbgr = MockDebugger::MockDebugger.new
21
+ cmds = dbgr.core.processor.commands
22
+ show_cmd = cmds['show']
23
+ command = Trepan::SubSubcommand::ShowTrace.new(dbgr.core.processor,
24
+ show_cmd)
25
+
26
+ name = File.basename(__FILE__, '.rb')
27
+ cmd_args = ['show', name]
28
+ command.run(cmd_args)
29
+ end
@@ -0,0 +1,84 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../../base/subsubcmd'
4
+
5
+ class Trepan::SubSubcommand::ShowTraceBuffer < Trepan::ShowBoolSubSubcommand
6
+ unless defined?(HELP)
7
+ HELP =
8
+ "show trace buffer [NUM]
9
+
10
+ Show the events recorded in the event buffer. If NUM is a negative
11
+ number, events run starting from that many debugger stops back. If NUM
12
+ is a positive number, we print starting from that (adjusted) position
13
+ in the event buffer with Since the event buffer may be a ring, its
14
+ zero being the first position. (Since the event buffer may be a ring
15
+ the earliest position recorded may move around.)
16
+ "
17
+ MIN_ABBREV = 'b'.size
18
+ NAME = File.basename(__FILE__, '.rb')
19
+ PREFIX = %w(show trace buffer)
20
+ SHORT_HELP = "Show tracing buffer"
21
+ end
22
+
23
+ def parse_show_buffer_args(args)
24
+ marksize = @proc.eventbuf.marks.size
25
+ opts = {
26
+ :max_value => @proc.eventbuf.size,
27
+ :min_value => - marksize,
28
+ :msg_on_error =>
29
+ 'Positive or negative number expected, got %s.' % args[0]
30
+ }
31
+ num = @proc.get_an_int(args[0], opts)
32
+ return nil, nil unless num
33
+ first =
34
+ if num < 0
35
+ @proc.eventbuf.marks[marksize+num]
36
+ else
37
+ @proc.eventbuf.zero_pos + num
38
+ end
39
+ return first, nil
40
+ end
41
+
42
+ def run(args)
43
+ if args.size > 1
44
+ if @proc.eventbuf.size == 0
45
+ msg 'no events recorded.'
46
+ errmsg 'event buffer tracing is off. ' +
47
+ 'use "set trace buffer on" to turn on.' unless
48
+ settings[:tracebuffer]
49
+ return
50
+ end
51
+ first, last = parse_show_buffer_args(args[1..-1])
52
+
53
+ return unless first
54
+ @proc.eventbuf_print(first, last, settings[:maxwidth])
55
+ else
56
+ super
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ if __FILE__ == $0
63
+ # Demo it.
64
+ require_relative '../../../mock'
65
+ require_relative '../../../subcmd'
66
+ name = File.basename(__FILE__, '.rb')
67
+
68
+ # FIXME: DRY the below code
69
+ dbgr, show_cmd = MockDebugger::setup('show')
70
+ testcmdMgr = Trepan::Subcmd.new(show_cmd)
71
+ trace_cmd = Trepan::SubSubcommand::ShowTrace.new(dbgr.core.processor,
72
+ show_cmd)
73
+
74
+ # FIXME: remove the 'join' below
75
+ cmd_name = Trepan::SubSubcommand::ShowTraceBuffer::PREFIX.join('')
76
+ tb_cmd = Trepan::SubSubcommand::ShowTraceBuffer.new(show_cmd.proc,
77
+ trace_cmd,
78
+ cmd_name)
79
+ # require_relative '../../../../lib/trepanning'
80
+ # dbgr = Trepan.new(:set_restart => true)
81
+ # dbgr.debugger
82
+ tb_cmd.run([])
83
+
84
+ end