rbx-trepanning 0.0.2-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/ChangeLog +376 -0
  2. data/LICENSE +25 -0
  3. data/NEWS +2 -0
  4. data/README.textile +35 -0
  5. data/Rakefile +165 -0
  6. data/THANKS +14 -0
  7. data/app/breakpoint.rb +218 -0
  8. data/app/breakpoint.rbc +3564 -0
  9. data/app/brkptmgr.rb +138 -0
  10. data/app/brkptmgr.rbc +2827 -0
  11. data/app/default.rb +61 -0
  12. data/app/default.rbc +1011 -0
  13. data/app/display.rb +35 -0
  14. data/app/display.rbc +968 -0
  15. data/app/frame.rb +98 -0
  16. data/app/frame.rbc +1808 -0
  17. data/app/irb.rb +112 -0
  18. data/app/irb.rbc +2111 -0
  19. data/app/iseq.rb +95 -0
  20. data/app/iseq.rbc +1801 -0
  21. data/app/method.rb +173 -0
  22. data/app/method.rbc +2492 -0
  23. data/app/mock.rb +13 -0
  24. data/app/mock.rbc +398 -0
  25. data/app/options.rb +123 -0
  26. data/app/options.rbc +2183 -0
  27. data/app/run.rb +86 -0
  28. data/app/run.rbc +1244 -0
  29. data/app/util.rb +49 -0
  30. data/app/util.rbc +1144 -0
  31. data/app/validate.rb +30 -0
  32. data/app/validate.rbc +676 -0
  33. data/bin/trepan.compiled.rbc +1043 -0
  34. data/bin/trepanx +63 -0
  35. data/bin/trepanx.compiled.rbc +985 -0
  36. data/interface/base_intf.rb +95 -0
  37. data/interface/base_intf.rbc +1742 -0
  38. data/interface/script.rb +104 -0
  39. data/interface/script.rbc +1642 -0
  40. data/interface/user.rb +91 -0
  41. data/interface/user.rbc +1418 -0
  42. data/io/base_io.rb +94 -0
  43. data/io/base_io.rbc +1404 -0
  44. data/io/input.rb +112 -0
  45. data/io/input.rbc +1979 -0
  46. data/io/null_output.rb +42 -0
  47. data/io/null_output.rbc +730 -0
  48. data/io/string_array.rb +156 -0
  49. data/io/string_array.rbc +2466 -0
  50. data/lib/trepanning.rb +398 -0
  51. data/lib/trepanning.rbc +6661 -0
  52. data/processor/breakpoint.rb +161 -0
  53. data/processor/command/alias.rb +55 -0
  54. data/processor/command/backtrace.rb +46 -0
  55. data/processor/command/base/cmd.rb +124 -0
  56. data/processor/command/base/subcmd.rb +213 -0
  57. data/processor/command/base/submgr.rb +179 -0
  58. data/processor/command/base/subsubcmd.rb +103 -0
  59. data/processor/command/base/subsubmgr.rb +184 -0
  60. data/processor/command/break.rb +100 -0
  61. data/processor/command/continue.rb +82 -0
  62. data/processor/command/delete.rb +30 -0
  63. data/processor/command/directory.rb +43 -0
  64. data/processor/command/disassemble.rb +103 -0
  65. data/processor/command/down.rb +54 -0
  66. data/processor/command/eval.rb +31 -0
  67. data/processor/command/exit.rb +58 -0
  68. data/processor/command/finish.rb +78 -0
  69. data/processor/command/frame.rb +89 -0
  70. data/processor/command/help.rb +146 -0
  71. data/processor/command/info.rb +28 -0
  72. data/processor/command/info_subcmd/breakpoints.rb +75 -0
  73. data/processor/command/info_subcmd/file.rb +153 -0
  74. data/processor/command/info_subcmd/method.rb +71 -0
  75. data/processor/command/info_subcmd/program.rb +59 -0
  76. data/processor/command/info_subcmd/variables.rb +40 -0
  77. data/processor/command/irb.rb +96 -0
  78. data/processor/command/kill.rb +70 -0
  79. data/processor/command/list.rb +296 -0
  80. data/processor/command/next.rb +66 -0
  81. data/processor/command/nexti.rb +59 -0
  82. data/processor/command/pr.rb +38 -0
  83. data/processor/command/ps.rb +40 -0
  84. data/processor/command/restart.rb +60 -0
  85. data/processor/command/set.rb +47 -0
  86. data/processor/command/set_subcmd/auto.rb +28 -0
  87. data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
  88. data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
  89. data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
  90. data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -0
  91. data/processor/command/set_subcmd/basename.rb +26 -0
  92. data/processor/command/set_subcmd/debug.rb +27 -0
  93. data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
  94. data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
  95. data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
  96. data/processor/command/set_subcmd/different.rb +60 -0
  97. data/processor/command/set_subcmd/hidelevel.rb +63 -0
  98. data/processor/command/set_subcmd/kernelstep.rb +61 -0
  99. data/processor/command/set_subcmd/max.rb +29 -0
  100. data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
  101. data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
  102. data/processor/command/set_subcmd/max_subcmd/string.rb +54 -0
  103. data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
  104. data/processor/command/set_subcmd/substitute.rb +25 -0
  105. data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
  106. data/processor/command/set_subcmd/trace.rb +37 -0
  107. data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
  108. data/processor/command/show.rb +27 -0
  109. data/processor/command/show_subcmd/alias.rb +43 -0
  110. data/processor/command/show_subcmd/args.rb +26 -0
  111. data/processor/command/show_subcmd/auto.rb +28 -0
  112. data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
  113. data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -0
  114. data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
  115. data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
  116. data/processor/command/show_subcmd/basename.rb +22 -0
  117. data/processor/command/show_subcmd/debug.rb +27 -0
  118. data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
  119. data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
  120. data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
  121. data/processor/command/show_subcmd/different.rb +27 -0
  122. data/processor/command/show_subcmd/hidelevel.rb +42 -0
  123. data/processor/command/show_subcmd/kernelstep.rb +37 -0
  124. data/processor/command/show_subcmd/max.rb +30 -0
  125. data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
  126. data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
  127. data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
  128. data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
  129. data/processor/command/show_subcmd/trace.rb +29 -0
  130. data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
  131. data/processor/command/source.rb +83 -0
  132. data/processor/command/step.rb +49 -0
  133. data/processor/command/tbreak.rb +19 -0
  134. data/processor/command/unalias.rb +44 -0
  135. data/processor/command/up.rb +87 -0
  136. data/processor/default.rb +56 -0
  137. data/processor/disassemble.rb +32 -0
  138. data/processor/eval.rb +96 -0
  139. data/processor/frame.rb +211 -0
  140. data/processor/help.rb +72 -0
  141. data/processor/hook.rb +133 -0
  142. data/processor/load_cmds.rb +101 -0
  143. data/processor/location.rb +128 -0
  144. data/processor/main.rb +394 -0
  145. data/processor/mock.rb +137 -0
  146. data/processor/msg.rb +28 -0
  147. data/processor/running.rb +230 -0
  148. data/processor/stepping.rb +115 -0
  149. data/processor/subcmd.rb +160 -0
  150. data/processor/validate.rb +355 -0
  151. data/test/data/enable.right +36 -0
  152. data/test/data/fname-with-blank.cmd +6 -0
  153. data/test/data/fname-with-blank.right +1 -0
  154. data/test/data/quit-Xdebug.right +3 -0
  155. data/test/data/quit.cmd +5 -0
  156. data/test/data/quit.right +0 -0
  157. data/test/example/fname with blank.rb +1 -0
  158. data/test/example/gcd-xx.rb +18 -0
  159. data/test/example/gcd.rb +19 -0
  160. data/test/example/gcd1.rb +24 -0
  161. data/test/example/null.rb +1 -0
  162. data/test/example/thread1.rb +3 -0
  163. data/test/functional/fn_helper.rb +112 -0
  164. data/test/functional/test-break-name.rb +52 -0
  165. data/test/functional/test-break.rb +51 -0
  166. data/test/functional/test-finish.rb +70 -0
  167. data/test/functional/test-fn_helper.rb +43 -0
  168. data/test/functional/test-list.rb +55 -0
  169. data/test/functional/test-next-bug.rb +49 -0
  170. data/test/functional/test-next.rb +101 -0
  171. data/test/functional/test-step.rb +272 -0
  172. data/test/functional/test-step2.rb +35 -0
  173. data/test/functional/test-tbreak.rb +41 -0
  174. data/test/integration/file-diff.rb +89 -0
  175. data/test/integration/helper.rb +78 -0
  176. data/test/integration/test-fname-with-blank.rb +12 -0
  177. data/test/integration/test-quit.rb +25 -0
  178. data/test/unit/cmd-helper.rb +46 -0
  179. data/test/unit/test-app-brkpt.rb +30 -0
  180. data/test/unit/test-app-brkptmgr.rb +51 -0
  181. data/test/unit/test-app-iseq.rb +49 -0
  182. data/test/unit/test-app-method.rb +54 -0
  183. data/test/unit/test-app-options.rb +61 -0
  184. data/test/unit/test-app-run.rb +16 -0
  185. data/test/unit/test-app-util.rb +28 -0
  186. data/test/unit/test-app-validate.rb +18 -0
  187. data/test/unit/test-base-subcmd.rb +61 -0
  188. data/test/unit/test-bin-trepanx.rb +48 -0
  189. data/test/unit/test-cmd-alias.rb +49 -0
  190. data/test/unit/test-cmd-break.rb +23 -0
  191. data/test/unit/test-cmd-exit.rb +27 -0
  192. data/test/unit/test-cmd-help.rb +101 -0
  193. data/test/unit/test-cmd-kill.rb +48 -0
  194. data/test/unit/test-intf-user.rb +46 -0
  195. data/test/unit/test-io-input.rb +27 -0
  196. data/test/unit/test-proc-eval.rb +37 -0
  197. data/test/unit/test-proc-frame.rb +79 -0
  198. data/test/unit/test-proc-help.rb +16 -0
  199. data/test/unit/test-proc-hook.rb +30 -0
  200. data/test/unit/test-proc-load_cmds.rb +41 -0
  201. data/test/unit/test-proc-location.rb +48 -0
  202. data/test/unit/test-proc-main.rb +96 -0
  203. data/test/unit/test-proc-validate.rb +91 -0
  204. data/test/unit/test-subcmd-help.rb +51 -0
  205. metadata +337 -0
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::SetAutoEval < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Evaluate unrecognized debugger commands.
9
+
10
+ Often inside the debugger, one would like to be able to run arbitrary
11
+ Ruby commands without having to preface Python expressions with \"print\" or
12
+ \"eval\". Setting \"auto eval\" on will cause unrecognized debugger
13
+ commands to be eval'd as a Ruby expression.
14
+
15
+ Note that if this is set, on error the message shown on type a bad
16
+ debugger command changes from:
17
+
18
+ Undefined command: \"fdafds\". Try \"help\".
19
+
20
+ to something more Ruby-eval-specific such as:
21
+
22
+ NameError: name 'fdafds' is not defined
23
+
24
+ One other thing that trips people up is when setting auto eval is that
25
+ there are some short debugger commands that sometimes one wants to use
26
+ as a variable, such as in an assignment statement. For example:
27
+
28
+ s = 5
29
+
30
+ which produce when 'auto eval' is on:
31
+ *** Command 'step' can take at most 1 argument(s); got 2.
32
+
33
+ because by default, 's' is an alias for the debugger 'step'
34
+ command. It is possible to remove that alias if this causes constant
35
+ problem. Another possibility is to go into a real Ruby shell via the
36
+ 'irb' command.
37
+ "
38
+ MIN_ABBREV = 'ev'.size
39
+ NAME = File.basename(__FILE__, '.rb')
40
+ PREFIX = %W(set auto #{NAME})
41
+ SHORT_HELP = "Set evaluation of unrecognized debugger commands"
42
+ end
43
+
44
+ end
45
+
46
+ if __FILE__ == $0
47
+ # Demo it.
48
+ require_relative '../../../mock'
49
+ require_relative '../auto'
50
+
51
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
52
+ Trepan::SubSubcommand::SetAutoEval)
53
+ cmd.run([cmd.name, 'off'])
54
+ end
@@ -0,0 +1,34 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::Subcommand::SetAutoIrb < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Set to automatically go into irb each time we enter the debugger"
9
+ MIN_ABBREV = 'ir'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %w(set auto irb)
12
+ end
13
+
14
+ def run(args)
15
+ super
16
+ if @proc.settings[:autoirb]
17
+ @proc.cmdloop_prehooks.insert_if_new(-1, *@proc.autoirb_hook)
18
+ else
19
+ @proc.cmdloop_prehooks.delete_by_name('autoirb')
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ if __FILE__ == $0
26
+ # Demo it.
27
+ require_relative '../../../mock'
28
+ require_relative '../auto'
29
+
30
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
31
+ Trepan::SubSubcommand::SetAutoIrb)
32
+ cmd.run([cmd.name, 'off'])
33
+ cmd.run([cmd.name, 'on'])
34
+ end
@@ -0,0 +1,34 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::Subcommand::SetAutoList < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Set to run a 'list' command each time we enter the debugger"
9
+ MIN_ABBREV = 'l'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %w(set auto list)
12
+ SHORT_HELP = "Set running a 'list' command each time we enter the debugger"
13
+ end
14
+
15
+ def run(args)
16
+ super
17
+ if @proc.settings[:autolist]
18
+ @proc.cmdloop_prehooks.insert_if_new(10, *@proc.autolist_hook)
19
+ else
20
+ @proc.cmdloop_prehooks.delete_by_name('autolist')
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ if __FILE__ == $0
27
+ # Demo it.
28
+ require_relative '../../../mock'
29
+ require_relative '../auto'
30
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
31
+ Trepan::SubSubcommand::SetAutoList)
32
+ cmd.run([cmd.name, 'off'])
33
+ cmd.run([cmd.name, 'on'])
34
+ end
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::SetBasename < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Set to show only file basename in showing file names"
9
+ IN_LIST = true
10
+ MIN_ABBREV = 'ba'.size
11
+ NAME = File.basename(__FILE__, '.rb')
12
+ PREFIX = %w(set basename)
13
+ end
14
+
15
+ end
16
+
17
+ if __FILE__ == $0
18
+ # Demo it.
19
+ $0 = __FILE__ + 'notagain' # So we don't run this agin
20
+ require_relative '../../mock'
21
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetBasename, false)
22
+ cmd.run(cmd.prefix + ['off'])
23
+ cmd.run(cmd.prefix + ['ofn'])
24
+ cmd.run(cmd.prefix)
25
+ puts cmd.save_command
26
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subsubcmd'
5
+ require_relative '../base/subsubmgr'
6
+
7
+ class Trepan::SubSubcommand::SetDebug < Trepan::SubSubcommandMgr
8
+ unless defined?(HELP)
9
+ HELP = 'Set internal debugger settings'
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %W(set #{NAME})
12
+ end
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ require_relative '../../mock'
17
+ dbgr, cmd = MockDebugger::setup('set')
18
+ set_cmd = cmds['set']
19
+ # command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
20
+ # set_cmd)
21
+ # name = File.basename(__FILE__, '.rb')
22
+ # cmd_args = ['set', name]
23
+ # set_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,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::SetDebugDbgr < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'set debug dbgr [on|off]
9
+
10
+ Facilitates debugging the debugger. Global variables $trepan_cmdproc
11
+ and $trepan_frame are set to the current values of @frame and self
12
+ when the command processor was entered. '
13
+
14
+ MIN_ABBREV = 'db'.size
15
+ NAME = File.basename(__FILE__, '.rb')
16
+ PREFIX = %W(set debug #{NAME})
17
+ SHORT_HELP = 'Set debugging debugger'
18
+ end
19
+
20
+ def run(args)
21
+ super
22
+ @proc.cmdloop_prehooks.insert_if_new(-1, *@proc.debug_dbgr_hook)
23
+ @proc.debug_dbgr_hook[1].call
24
+ end
25
+
26
+ end
27
+
28
+ if __FILE__ == $0
29
+ # Demo it.
30
+ require_relative '../../../mock'
31
+ require_relative '../debug'
32
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
33
+ Trepan::SubSubcommand::SetDebugDbgr)
34
+ cmd.run([cmd.name, 'off'])
35
+ cmd.run([cmd.name, 'on'])
36
+ end
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::SetDebugSkip < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Set debugging of statement skip logic'
9
+ MIN_ABBREV = 'sk'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %W(set debug #{NAME})
12
+ end
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ require_relative '../debug'
19
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
20
+ Trepan::SubSubcommand::SetDebugSkip)
21
+ cmd.run([cmd.name, 'off'])
22
+ cmd.run([cmd.name, 'on'])
23
+ end
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::SetDebugStep < Trepan::SetBoolSubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Set debugging of statement step logic'
9
+ MIN_ABBREV = 'st'.size
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ PREFIX = %W(set debug #{NAME})
12
+ end
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ require_relative '../../../mock'
18
+ require_relative '../debug'
19
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
20
+ Trepan::SubSubcommand::SetDebugStep)
21
+ cmd.run([cmd.name, 'off'])
22
+ cmd.run([cmd.name, 'on'])
23
+ end
@@ -0,0 +1,60 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::SetDifferent < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ NAME = File.basename(__FILE__, '.rb')
9
+ HELP = <<-EOH
10
+ set #{NAME} [on|off|nostack]
11
+
12
+ Set to make sure 'next/step' move to a new position.
13
+
14
+ Due to the interpretive, expression-oriented nature of the Ruby
15
+ Language and implementation, each line often may contain many possible
16
+ stopping points with possibly different event type. In a debugger it
17
+ is sometimes desirable to continue but stop only when the position
18
+ next changes.
19
+
20
+ Setting 'different' to on will cause each 'step' or 'next' command to
21
+ stop at a different position.
22
+
23
+ Note though that the notion of different does take into account stack
24
+ nesting. So in ARGV.map {|arg| arg.to_i} you get a stop before ARGV as
25
+ well as one in the block.
26
+
27
+ If you to ignore stopping at added nesting levels, there are two
28
+ possibilities. 'set step nostack' will ignore stack nestings levels on
29
+ a given line. Also you can use 'next', but that also stepping into
30
+ functions on different lines to also be skipped.
31
+
32
+ See also 'step', 'next' which have suffixes '+' and '-' which
33
+ override this setting.
34
+ EOH
35
+
36
+ IN_LIST = true
37
+ MIN_ABBREV = 'dif'.size
38
+ PREFIX = %W(set #{NAME})
39
+ SHORT_HELP = "Set to make sure 'next/step' move to a new position."
40
+ end
41
+
42
+ def run(args)
43
+ if args.size == 3 && 'nostack' == args[2]
44
+ @proc.settings[:different] = 'nostack'
45
+ msg("different is nostack.")
46
+ else
47
+ super
48
+ end
49
+ @proc.different_pos = @proc.settings[:different]
50
+ end
51
+
52
+ end
53
+
54
+ if __FILE__ == $0
55
+ # Demo it.
56
+ require_relative '../../mock'
57
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetDifferent)
58
+ cmd.run(cmd.prefix + ['off'])
59
+ puts cmd.save_command
60
+ end
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::SetHidelevel < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ NAME = File.basename(__FILE__, '.rb')
9
+ HELP = <<-EOH
10
+ set #{NAME} [NUM]
11
+
12
+ Hide this many stack frames from the bottom (or least-recent) frame.
13
+
14
+ Often the bottom-most frames are setup frames that one doesn't think
15
+ of as being part of one's program but are part of the overhead loading
16
+ or debugging the program. As such generally they are unintersting in
17
+ a backtrace command and one wants these omitted.
18
+
19
+ If NUM is 0, no stack frames are hidden. If NUM is < 0 or omitted,
20
+ then use value the program sets automatically. If the value is larger
21
+ than the current number of entries in the stack, i.e. the stack shown
22
+ would be otherwise be, empty then we show all entries, or take NUM to
23
+ be 0.
24
+
25
+ Examples:
26
+ set #{NAME} # Use the default value and hide 'uninteresting' ones
27
+ set #{NAME} 0 # Show all stack entries, even from loading the program
28
+ # or initial stack entries the debugger created to
29
+ # debug the program.
30
+ set #{NAME} 1 # Hide only the bottom-most or least-recent stack frame.
31
+
32
+ See also 'backtrace' and 'show hidelevel'.
33
+ .
34
+ EOH
35
+
36
+ IN_LIST = true
37
+ MIN_ABBREV = 'hide'.size
38
+ PREFIX = %W(set #{NAME})
39
+ SHORT_HELP = "Set the number of bottom frames to hide."
40
+ end
41
+
42
+ def run(args)
43
+ if args.size == 2
44
+ val = nil
45
+ else
46
+ val = @proc.get_an_int(args[2])
47
+ return unless val
48
+ end
49
+ @proc.hidelevels[@current_thread] = nil
50
+ @proc.settings[:hidelevel] = val
51
+ @proc.set_hide_level
52
+ @proc.run_command('show hidelevel')
53
+ end
54
+
55
+ end
56
+
57
+ if __FILE__ == $0
58
+ # Demo it.
59
+ require_relative '../../mock'
60
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetHidelevel, false)
61
+ cmd.run(cmd.prefix + %w(10))
62
+ cmd.run(cmd.prefix)
63
+ end
@@ -0,0 +1,61 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../show_subcmd/kernelstep'
5
+
6
+ class Trepan::Subcommand::SetKernelstep < Trepan::Subcommand::ShowKernelstep
7
+ unless defined?(HELP)
8
+ NAME = File.basename(__FILE__, '.rb')
9
+ HELP = <<-EOH
10
+ set #{NAME} [on|off]
11
+
12
+ Allow/disallow stepping into kernel methods.
13
+ EOH
14
+
15
+ IN_LIST = true
16
+ MIN_ABBREV = 'kern'.size
17
+ PREFIX = %W(set #{NAME})
18
+ SHORT_HELP = "Set stepping into kernel methods."
19
+ end
20
+
21
+ def run(args)
22
+ onoff_arg = args.size < 3 ? 'on' : args[2]
23
+ begin
24
+ on = @proc.get_onoff(onoff_arg)
25
+ rescue NameError, TypeError
26
+ return
27
+ end
28
+
29
+ if on
30
+ if ignore?
31
+ @proc.ignore_file_re.delete(KERNEL_METHOD_FILE_RE)
32
+ else
33
+ errmsg("We aren't ignoring kernel methods for stepping.")
34
+ return
35
+ end
36
+ else
37
+ if ignore?
38
+ errmsg("We already should be ignoring kernel methods for stepping.")
39
+ return
40
+ else
41
+ @proc.ignore_file_re[KERNEL_METHOD_FILE_RE] = 'step-finish'
42
+ end
43
+ end
44
+ show
45
+ end
46
+
47
+ def save_command
48
+ PREFIX.join(' ') + (ignore? ? ' on' : ' off')
49
+ end
50
+
51
+ end
52
+
53
+ if __FILE__ == $0
54
+ # Demo it.
55
+ require_relative '../../mock'
56
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetKernelstep)
57
+ cmd.run(cmd.prefix + ['off'])
58
+ puts cmd.save_command
59
+ cmd.run(cmd.prefix + ['on'])
60
+ puts cmd.save_command
61
+ end
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subsubcmd'
5
+ require_relative '../base/subsubmgr'
6
+
7
+ class Trepan::SubSubcommand::SetMax < Trepan::SubSubcommandMgr
8
+ HELP = 'Set maximum length for things which may have unbounded size'
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ PREFIX = %W(set #{NAME})
11
+
12
+ end
13
+
14
+ if __FILE__ == $0
15
+ # Demo it.
16
+ require_relative '../../mock'
17
+ cmd_ary = Trepan::SubSubcommand::SetMax::PREFIX
18
+ dbgr, parent_cmd = MockDebugger::setup(cmd_ary[0], false)
19
+ cmd = Trepan::SubSubcommand::SetMax.new(dbgr.processor,
20
+ parent_cmd)
21
+ cmd_name = cmd_ary.join('')
22
+ prefix_run = cmd_ary[1..-1]
23
+ cmd.run(prefix_run)
24
+ # require_relative '../../../lib/trepanning'
25
+ # # Trepan.debug(:set_restart => true)
26
+ ## puts cmd.summary_help(cmd.name)
27
+ ## puts
28
+ ## puts '-' * 20
29
+ end
@@ -0,0 +1,49 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::SetMaxList < Trepan::SubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Set max[imum] list NUMBER
9
+
10
+ Set number of source-code lines to list by default.'
11
+ IN_LIST = true
12
+ MIN_ABBREV = 'lis'.size
13
+ NAME = File.basename(__FILE__, '.rb')
14
+ PREFIX = %w(set max list)
15
+ SHORT_HELP = 'Set number of lines to list'
16
+ end
17
+
18
+ def run(args)
19
+ args.shift
20
+ run_set_int(args.join(' '),
21
+ "The '#{PREFIX.join(' ')}' command requires a list size",
22
+ 0, nil)
23
+ end
24
+
25
+ alias save_command save_command_from_settings
26
+
27
+ end
28
+
29
+ if __FILE__ == $0
30
+ # Demo it.
31
+ require_relative '../../../mock'
32
+
33
+ dbgr, set_cmd = MockDebugger::setup('set', false)
34
+ max_cmd = Trepan::SubSubcommand::SetMax.new(dbgr.processor,
35
+ set_cmd)
36
+ cmd_ary = Trepan::SubSubcommand::SetMaxWidth::PREFIX
37
+ cmd_name = cmd_ary.join('')
38
+ subcmd = Trepan::SubSubcommand::SetMaxList.new(set_cmd.proc,
39
+ max_cmd,
40
+ cmd_name)
41
+ prefix_run = cmd_ary[1..-1]
42
+ subcmd.run(prefix_run)
43
+ subcmd.run(prefix_run + %w(0))
44
+ subcmd.run(prefix_run + %w(20))
45
+ subcmd.summary_help(subcmd.name)
46
+ puts
47
+ puts '-' * 20
48
+ puts subcmd.save_command
49
+ end
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::Subcommand::SetMaxStack < Trepan::SubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Set number of backtrace lines the debugger will show'
9
+ DEFAULT_MIN = 3
10
+ MIN_ABBREV = 'sta'.size
11
+ NAME = File.basename(__FILE__, '.rb')
12
+ PREFIX = %w(set max stack)
13
+ end
14
+
15
+ def run(args)
16
+ args.shift
17
+ args = %W(#{DEFAULT_MIN}) if args.empty?
18
+ run_set_int(args.join(' '),
19
+ "The '#{PREFIX.join(' ')}' command requires a list size",
20
+ DEFAULT_MIN, nil)
21
+ end
22
+
23
+ alias save_command save_command_from_settings
24
+
25
+ end
26
+
27
+ if __FILE__ == $0
28
+ # Demo it.
29
+ require_relative '../../../mock'
30
+ dbgr, set_cmd = MockDebugger::setup('set')
31
+ name = File.basename(__FILE__, '.rb')
32
+
33
+ dbgr, set_cmd = MockDebugger::setup('set')
34
+ max_cmd = Trepan::SubSubcommand::SetMax.new(dbgr.processor,
35
+ set_cmd)
36
+ cmd_ary = Trepan::SubSubcommand::SetMaxStack::PREFIX
37
+ cmd_name = cmd_ary.join('')
38
+ subcmd = Trepan::SubSubcommand::SetMaxStack.new(set_cmd.proc,
39
+ max_cmd,
40
+ cmd_name)
41
+ prefix_run = cmd_ary[1..-1]
42
+ subcmd.run(prefix_run)
43
+ subcmd.run(prefix_run + %w(0))
44
+ subcmd.run(prefix_run + %w(20))
45
+ name = File.basename(__FILE__, '.rb')
46
+ subcmd.summary_help(name)
47
+ puts
48
+ puts '-' * 20
49
+ puts subcmd.save_command
50
+ end
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::SetMaxString < Trepan::SubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Set max st[ring] NUMBER
9
+
10
+ Sometimes the string representation of an object is very long. This
11
+ setting limits how much of the string representation you want to
12
+ see. However if the string has an embedded newline then we will assume
13
+ the output is intended to be formated as is.
14
+ '
15
+ DEFAULT_MIN = 10
16
+ MIN_ABBREV = 'str'.size
17
+ NAME = File.basename(__FILE__, '.rb')
18
+ PREFIX = %w(set max string)
19
+ SHORT_HELP = "Set maximum # chars in a string before truncation"
20
+ end
21
+
22
+ def run(args)
23
+ args.shift
24
+ args = %W(#{DEFAULT_MIN}) if args.empty?
25
+ run_set_int(args.join(' '),
26
+ "The 'set maximum string' command requires number at least #{DEFAULT_MIN}",
27
+ DEFAULT_MIN, nil)
28
+ end
29
+
30
+ alias save_command save_command_from_settings
31
+
32
+ end
33
+
34
+ if __FILE__ == $0
35
+ # Demo it.
36
+ require_relative '../../../mock'
37
+ dbgr, set_cmd = MockDebugger::setup('set')
38
+ # max_cmd = Trepan::SubSubcommand::SetMax.new(dbgr.core.processor,
39
+ # set_cmd)
40
+ # # FIXME: remove the 'join' below
41
+ # cmd_name = Trepan::SubSubcommand::SetMaxString::PREFIX.join('')
42
+ # subcmd = Trepan::SubSubcommand::SetMaxString.new(set_cmd.proc,
43
+ # max_cmd,
44
+ # cmd_name)
45
+ # subcmd.run([])
46
+ # subcmd.run(%w(0))
47
+ # subcmd.run(%w(20))
48
+ # subcmd.run(%w(100))
49
+ name = File.basename(__FILE__, '.rb')
50
+ subcmd.summary_help(name)
51
+ puts
52
+ # puts '-' * 20
53
+ # puts subcmd.save_command
54
+ end
@@ -0,0 +1,49 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../../base/subsubcmd'
5
+
6
+ class Trepan::SubSubcommand::SetMaxWidth < Trepan::SubSubcommand
7
+ unless defined?(HELP)
8
+ HELP = 'Set max[imum] width NUMBER
9
+
10
+ Set number of characters the debugger thinks are in a line.'
11
+ IN_LIST = true
12
+ MIN_ABBREV = 'wid'.size
13
+ NAME = File.basename(__FILE__, '.rb')
14
+ PREFIX = %w(set max width)
15
+ SHORT_HELP = 'Set number of characters the debugger thinks are in a line'
16
+ end
17
+
18
+ def run(args)
19
+ args.shift
20
+ run_set_int(args.join(' '),
21
+ "The 'width' command requires a line width",
22
+ 0, nil)
23
+ end
24
+
25
+ alias save_command save_command_from_settings
26
+
27
+ end
28
+
29
+ if __FILE__ == $0
30
+ # Demo it.
31
+ require_relative '../../../mock'
32
+ name = File.basename(__FILE__, '.rb')
33
+
34
+ dbgr, set_cmd = MockDebugger::setup('set')
35
+ # max_cmd = Trepan::SubSubcommand::SetMax.new(dbgr.core.processor,
36
+ # set_cmd)
37
+ # cmd_name = Trepan::SubSubcommand::SetMaxWidth::PREFIX.join('')
38
+ # subcmd = Trepan::SubSubcommand::SetMaxWidth.new(set_cmd.proc,
39
+ # max_cmd,
40
+ # cmd_name)
41
+ # subcmd.run(['max', 'width'])
42
+ # subcmd.run(%w(set max width 0))
43
+ # subcmd.run(%w(set max width 20))
44
+ name = File.basename(__FILE__, '.rb')
45
+ subcmd.summary_help(name)
46
+ # puts
47
+ # puts '-' * 20
48
+ # puts subcmd.save_command
49
+ end