rbx-trepanning 0.0.8-universal-rubinius-1.2 → 0.1.0-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/ChangeLog +762 -238
  2. data/NEWS +44 -0
  3. data/Rakefile +61 -32
  4. data/app/breakpoint.rb +2 -0
  5. data/app/brkptmgr.rb +9 -11
  6. data/app/client.rb +0 -1
  7. data/app/cmd_parse.kpeg +21 -4
  8. data/app/cmd_parse.rb +10 -10
  9. data/app/cmd_parser.rb +1029 -840
  10. data/app/complete.rb +1 -1
  11. data/app/display.rb +38 -0
  12. data/app/file.rb +24 -0
  13. data/app/frame.rb +11 -4
  14. data/app/irb.rb +41 -39
  15. data/app/iseq.rb +71 -0
  16. data/app/options.rb +55 -30
  17. data/app/rbx-llvm.rb +0 -2
  18. data/app/run.rb +13 -9
  19. data/app/util.rb +55 -5
  20. data/bin/trepanx +3 -3
  21. data/data/irbrc +13 -13
  22. data/{interface/base_intf.rb → interface.rb} +5 -1
  23. data/interface/client.rb +4 -0
  24. data/interface/script.rb +13 -5
  25. data/interface/server.rb +5 -1
  26. data/interface/user.rb +8 -1
  27. data/{io/base_io.rb → io.rb} +0 -0
  28. data/io/input.rb +1 -1
  29. data/io/null_output.rb +28 -24
  30. data/io/string_array.rb +2 -3
  31. data/io/tcpclient.rb +1 -1
  32. data/io/tcpserver.rb +1 -1
  33. data/lib/trepanning.rb +11 -13
  34. data/{processor/main.rb → processor.rb} +50 -54
  35. data/processor/breakpoint.rb +150 -137
  36. data/processor/{command/base/cmd.rb → command.rb} +1 -1
  37. data/processor/command/alias.rb +14 -3
  38. data/processor/command/backtrace.rb +2 -1
  39. data/processor/command/base/subcmd.rb +1 -5
  40. data/processor/command/base/submgr.rb +5 -2
  41. data/processor/command/base/subsubcmd.rb +1 -1
  42. data/processor/command/base/subsubmgr.rb +4 -4
  43. data/processor/command/break.rb +1 -1
  44. data/processor/command/complete.rb +2 -1
  45. data/processor/command/condition.rb +2 -2
  46. data/processor/command/continue.rb +4 -4
  47. data/processor/command/delete.rb +34 -20
  48. data/processor/command/directory.rb +4 -4
  49. data/processor/command/disable.rb +71 -0
  50. data/processor/command/disassemble.rb +55 -22
  51. data/processor/command/display.rb +3 -1
  52. data/processor/command/down.rb +8 -8
  53. data/processor/command/edit.rb +74 -0
  54. data/processor/command/enable.rb +43 -0
  55. data/processor/command/eval.rb +37 -15
  56. data/processor/command/exit.rb +25 -6
  57. data/processor/command/finish.rb +5 -5
  58. data/processor/command/frame.rb +2 -2
  59. data/processor/command/help.rb +7 -9
  60. data/processor/command/help/README +10 -0
  61. data/processor/command/help/command.txt +37 -27
  62. data/processor/command/help/examples.txt +16 -0
  63. data/processor/command/help/filename.txt +1 -1
  64. data/processor/command/help/suffixes.txt +17 -0
  65. data/processor/command/info.rb +3 -1
  66. data/processor/command/info_subcmd/files.rb +3 -2
  67. data/processor/command/info_subcmd/frame.rb +2 -1
  68. data/processor/command/info_subcmd/line.rb +17 -28
  69. data/processor/command/info_subcmd/locals.rb +22 -0
  70. data/processor/command/{show_subcmd → info_subcmd}/macro.rb +4 -4
  71. data/processor/command/info_subcmd/program.rb +2 -0
  72. data/processor/command/info_subcmd/ruby.rb +2 -0
  73. data/processor/command/info_subcmd/source.rb +75 -0
  74. data/processor/command/info_subcmd/stack.rb +25 -0
  75. data/processor/command/info_subcmd/variables.rb +23 -36
  76. data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
  77. data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
  78. data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
  79. data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
  80. data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
  81. data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
  82. data/processor/command/kill.rb +8 -9
  83. data/processor/command/list.rb +101 -167
  84. data/processor/command/macro.rb +28 -10
  85. data/processor/command/next.rb +2 -1
  86. data/processor/command/nexti.rb +1 -1
  87. data/processor/command/parsetree.rb +51 -0
  88. data/processor/command/pr.rb +1 -2
  89. data/processor/command/ps.rb +1 -1
  90. data/processor/command/restart.rb +2 -2
  91. data/processor/command/save.rb +1 -1
  92. data/processor/command/server.rb +1 -1
  93. data/processor/command/set_subcmd/abbrev.rb +25 -0
  94. data/processor/command/set_subcmd/auto.rb +7 -1
  95. data/processor/command/set_subcmd/auto_subcmd/eval.rb +1 -2
  96. data/processor/command/set_subcmd/auto_subcmd/irb.rb +2 -3
  97. data/processor/command/set_subcmd/auto_subcmd/list.rb +2 -3
  98. data/processor/command/set_subcmd/different.rb +1 -1
  99. data/processor/command/set_subcmd/highlight.rb +7 -1
  100. data/processor/command/set_subcmd/reload.rb +42 -0
  101. data/processor/command/set_subcmd/timer.rb +58 -0
  102. data/processor/command/set_subcmd/trace.rb +4 -3
  103. data/processor/command/{irb.rb → shell.rb} +22 -19
  104. data/processor/command/show_subcmd/abbrev.rb +20 -0
  105. data/processor/command/show_subcmd/{alias.rb → aliases.rb} +2 -2
  106. data/processor/command/show_subcmd/auto_subcmd/eval.rb +2 -6
  107. data/processor/command/show_subcmd/directories.rb +22 -0
  108. data/processor/command/show_subcmd/hidelevel.rb +1 -1
  109. data/processor/command/show_subcmd/highlight.rb +2 -1
  110. data/processor/command/show_subcmd/reload.rb +18 -0
  111. data/processor/command/show_subcmd/timer.rb +18 -0
  112. data/processor/command/source.rb +9 -9
  113. data/processor/command/step.rb +1 -1
  114. data/processor/command/tbreak.rb +3 -2
  115. data/processor/command/unalias.rb +11 -6
  116. data/processor/command/undisplay.rb +13 -9
  117. data/processor/command/up.rb +13 -14
  118. data/processor/default.rb +47 -44
  119. data/processor/disassemble.rb +48 -35
  120. data/processor/display.rb +38 -3
  121. data/processor/eval.rb +54 -53
  122. data/processor/eventbuf.rb +69 -69
  123. data/processor/frame.rb +186 -187
  124. data/processor/help.rb +6 -4
  125. data/processor/hook.rb +103 -102
  126. data/processor/list.rb +123 -0
  127. data/processor/load_cmds.rb +9 -1
  128. data/processor/location.rb +193 -188
  129. data/processor/mock.rb +1 -7
  130. data/processor/msg.rb +56 -42
  131. data/processor/running.rb +26 -15
  132. data/processor/stepping.rb +2 -1
  133. data/processor/subcmd.rb +18 -43
  134. data/processor/validate.rb +41 -30
  135. data/processor/virtual.rb +33 -0
  136. data/rbx-trepanning.gemspec +7 -8
  137. data/sample/rocky-trepanx-colors.rb +0 -1
  138. data/test/data/fname-with-blank.right +2 -0
  139. data/test/data/inline-call.right +11 -10
  140. data/test/data/quit.right +1 -0
  141. data/test/example/debugger-stop.rb +1 -1
  142. data/test/example/goto2goto.rb +11 -0
  143. data/test/functional/fn_helper.rb +2 -2
  144. data/test/functional/test-list.rb +7 -6
  145. data/test/integration/helper.rb +5 -5
  146. data/test/unit/cmd-helper.rb +2 -6
  147. data/test/unit/test-app-cmd_parser.rb +3 -2
  148. data/test/unit/test-app-display.rb +22 -0
  149. data/test/unit/test-app-options.rb +14 -10
  150. data/test/unit/test-app-run.rb +0 -2
  151. data/test/unit/test-app-util.rb +21 -4
  152. data/test/unit/test-base-cmd.rb +5 -7
  153. data/test/unit/test-base-subcmd.rb +1 -5
  154. data/test/unit/test-base-submgr.rb +1 -1
  155. data/test/unit/test-base-subsubcmd.rb +0 -4
  156. data/test/unit/test-bin-trepanx.rb +2 -2
  157. data/test/unit/test-cmd-break.rb +2 -0
  158. data/test/unit/test-cmd-edit.rb +34 -0
  159. data/test/unit/test-cmd-kill.rb +11 -4
  160. data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
  161. data/test/unit/test-command.rb +45 -0
  162. data/test/unit/test-completion.rb +1 -1
  163. data/test/unit/test-proc-eval.rb +1 -2
  164. data/test/unit/test-proc-frame.rb +5 -3
  165. data/test/unit/test-proc-list.rb +55 -0
  166. data/test/unit/test-proc-load_cmds.rb +4 -3
  167. data/test/unit/test-proc-location.rb +32 -29
  168. data/test/unit/test-proc-main.rb +1 -5
  169. data/test/unit/test-proc-validate.rb +14 -4
  170. data/test/unit/test-subcmd-help.rb +1 -5
  171. metadata +73 -107
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative 'base/cmd'
4
+ require_relative '../command'
5
5
  require_relative '../eval'
6
6
  class Trepan::Command::MacroCommand < Trepan::Command
7
7
 
@@ -11,26 +11,44 @@ class Trepan::Command::MacroCommand < Trepan::Command
11
11
  #{NAME} MACRO-NAME PROC-OBJECT
12
12
 
13
13
  Define MACRO-NAME as a debugger macro. Debugger macros get a list of
14
- arguments.
14
+ arguments. Debugger macros get a list of arguments which you supply
15
+ without parenthesis or commas. See below for an example.
15
16
 
16
- The macro should return either a String or an Array of Strings which
17
- is substituted for the command. If the return is a String, that gets
18
- tokenized by a simple String#split . Note that macro processing is
19
- done right after splitting on ;; so if the macro returns a string
20
- containing ;; this will not be handled on the string returned.
17
+ The macro (really a Ruby Proc) should return either a String or an
18
+ Array of Strings. The string in both cases are strings of debugger
19
+ commands. If the return is a String, that gets tokenized by a simple
20
+ String#split . Note that macro processing is done right after
21
+ splitting on ;; so if the macro returns a string containing ;; this
22
+ will not be handled on the string returned.
21
23
 
22
24
  If instead, Array of Strings is returned, then the first string is
23
- unshifted from the array and executed. The remaning strings are pushed
25
+ shifted from the array and executed. The remaining strings are pushed
24
26
  onto the command queue. In contrast to the first string, subsequent
25
27
  strings can contain other macros, and ;; in those strings will be
26
28
  split into separate commands.
27
29
 
28
- Here is an example. The below creates a macro called finish+ which
30
+ Here is an example. The below creates a macro called fin+ which
29
31
  issues two commands 'finish' followed by 'step':
30
32
 
31
33
  macro fin+ Proc.new{|*args| %w(finish step)}
32
34
 
33
- See also 'show macro'.
35
+ If you wanted to parameterize the argument of the 'finish' command
36
+ you could do that this way:
37
+
38
+ macro fin+ Proc.new{|*args| ['finish \#{args[0]}' 'step']}
39
+
40
+ Invoking with
41
+ fin+ 3
42
+
43
+ would expand to ["finish 3", "step"]
44
+
45
+ If you were to add another parameter for 'step', the note that the
46
+ invocation might be
47
+ fin+ 3 2
48
+
49
+ rather than 'fin+(3,2)' or 'fin+ 3, 2'.
50
+
51
+ See also 'info macro'.
34
52
  HELP
35
53
 
36
54
  CATEGORY = 'support'
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'; require 'require_relative'
2
- require_relative 'base/cmd'
2
+ require_relative '../command'
3
3
  require_relative '../stepping'
4
4
  require_relative '../../app/breakpoint'
5
5
 
@@ -42,6 +42,7 @@ See also 'step' and 'nexti'.
42
42
  end
43
43
 
44
44
  @proc.step('next', step_count)
45
+ # @proc.next(step_count)
45
46
  end
46
47
 
47
48
  end
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'; require 'require_relative'
2
- require_relative 'base/cmd'
2
+ require_relative '../command'
3
3
  require_relative '../stepping'
4
4
  require_relative '../../app/breakpoint'
5
5
  require_relative '../../app/iseq'
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require 'pp'
5
+ require_relative '../command'
6
+ require_relative '../../app/cmd_parse'
7
+ class Trepan::Command::ParseTreeCommand < Trepan::Command
8
+
9
+ unless defined?(HELP)
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ HELP = <<-HELP
12
+ #{NAME} [FILE]
13
+ #{NAME}
14
+
15
+ In the first form, print a ParseTree S-expression of the current file
16
+ or FILE.
17
+ HELP
18
+
19
+ # ALIASES = %w(p)
20
+ MAX_ARGS = 1
21
+ CATEGORY = 'data'
22
+ SHORT_HELP = 'PrettyPrint a ParseTree S-expression for a file'
23
+ end
24
+
25
+ def run(args)
26
+ meth = nil
27
+ case args.size
28
+ when 1
29
+ file = @proc.frame.file
30
+ when 2
31
+ file = args[1]
32
+ else
33
+ errmsg 'Expecting a file name'
34
+ end
35
+ expanded_file = @proc.canonic_file(file)
36
+ if File.readable?(expanded_file)
37
+ section "ParseTree for file: #{expanded_file}"
38
+ msg File.to_sexp(expanded_file).pretty_inspect
39
+ else
40
+ errmsg "File #{expanded_file} is not readable."
41
+ end
42
+ end
43
+
44
+ if __FILE__ == $0
45
+ require 'pp'
46
+ require_relative '../mock'
47
+ dbgr, cmd = MockDebugger::setup
48
+ cmd.run([cmd.name, __FILE__])
49
+ end
50
+
51
+ end
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative 'base/cmd'
5
- require_relative '../eval'
4
+ require_relative '../command'
6
5
  class Trepan::Command::PrCommand < Trepan::Command
7
6
 
8
7
  unless defined?(HELP)
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative 'base/cmd'
4
+ require_relative '../command'
5
5
  require_relative '../eval'
6
6
  class Trepan::Command::PsCommand < Trepan::Command
7
7
 
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative 'base/cmd'
4
+ require_relative '../command'
5
5
  require_relative '../../app/run'
6
6
  class Trepan::Command::RestartCommand < Trepan::Command
7
7
 
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative 'base/cmd'
4
+ require_relative '../command'
5
5
  class Trepan::Command::SaveCommand < Trepan::Command
6
6
 
7
7
  unless defined?(HELP)
@@ -2,7 +2,7 @@
2
2
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'optparse'
4
4
  require 'rubygems'; require 'require_relative'
5
- require_relative 'base/cmd'
5
+ require_relative '../command'
6
6
  require_relative '../../app/default'
7
7
  require_relative '../../interface/server' # server interface (remote debugging)
8
8
  class Trepan::Command::ServerCommand < Trepan::Command
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::SetAbbrev < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ HELP = "Set to allow unique abbreviations of commands"
9
+ IN_LIST = true
10
+ MIN_ABBREV = 'ab'.size
11
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
12
+ end
13
+
14
+ end
15
+
16
+ if __FILE__ == $0
17
+ # Demo it.
18
+ $0 = __FILE__ + 'notagain' # So we don't run this again
19
+ require_relative '../../mock'
20
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetAbbrev, false)
21
+ cmd.run(cmd.prefix + ['off'])
22
+ cmd.run(cmd.prefix + ['ofn'])
23
+ cmd.run(cmd.prefix)
24
+ puts cmd.save_command
25
+ end
@@ -6,8 +6,14 @@ require_relative '../base/subsubmgr'
6
6
 
7
7
  class Trepan::SubSubcommand::SetAuto < Trepan::SubSubcommandMgr
8
8
  unless defined?(HELP)
9
- HELP = 'Set controls for things with some sort of "automatic" default behavior'
10
9
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
+ HELP = <<-EOH
11
+ Set controls for things with some sort of "automatic" default behavior.
12
+
13
+ See "#{PREFIX.join(' ')} *" for a list of subcommands or "#{PREFIX.join(' ')} <name>"
14
+ for help on a particular trace subcommand.
15
+ EOH
16
+ SHORT_HELP = 'Set controls for some "automatic" default behaviors';
11
17
  end
12
18
  end
13
19
 
@@ -5,6 +5,7 @@ require_relative '../../base/subsubcmd'
5
5
 
6
6
  class Trepan::SubSubcommand::SetAutoEval < Trepan::SetBoolSubSubcommand
7
7
  unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
9
  HELP = "Evaluate unrecognized debugger commands.
9
10
 
10
11
  Often inside the debugger, one would like to be able to run arbitrary
@@ -36,8 +37,6 @@ problem. Another possibility is to go into a real Ruby shell via the
36
37
  'irb' command.
37
38
  "
38
39
  MIN_ABBREV = 'ev'.size
39
- NAME = File.basename(__FILE__, '.rb')
40
- PREFIX = %W(set auto #{NAME})
41
40
  SHORT_HELP = "Set evaluation of unrecognized debugger commands"
42
41
  end
43
42
 
@@ -1,14 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
4
  require_relative '../../base/subsubcmd'
5
5
 
6
6
  class Trepan::Subcommand::SetAutoIrb < Trepan::SetBoolSubSubcommand
7
7
  unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
9
  HELP = "Set to automatically go into irb each time we enter the debugger"
9
10
  MIN_ABBREV = 'ir'.size
10
- NAME = File.basename(__FILE__, '.rb')
11
- PREFIX = %w(set auto irb)
12
11
  end
13
12
 
14
13
  def run(args)
@@ -1,14 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
4
  require_relative '../../base/subsubcmd'
5
5
 
6
6
  class Trepan::Subcommand::SetAutoList < Trepan::SetBoolSubSubcommand
7
7
  unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
9
  HELP = "Set to run a 'list' command each time we enter the debugger"
9
10
  MIN_ABBREV = 'l'.size
10
- NAME = File.basename(__FILE__, '.rb')
11
- PREFIX = %w(set auto list)
12
11
  SHORT_HELP = "Set running a 'list' command each time we enter the debugger"
13
12
  end
14
13
 
@@ -9,7 +9,7 @@ class Trepan::Subcommand::SetDifferent < Trepan::SetBoolSubcommand
9
9
  HELP = <<-EOH
10
10
  #{PREFIX.join(' ')} [on|off|nostack]
11
11
 
12
- Set to make sure 'next/step' move to a new position.
12
+ Set to make sure 'next' or 'step' moves to a new position.
13
13
 
14
14
  Due to the interpretive, expression-oriented nature of the Ruby
15
15
  Language and implementation, each line often may contain many possible
@@ -8,11 +8,17 @@ class Trepan::Subcommand::SetHighlight < Trepan::SetBoolSubcommand
8
8
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
9
  HELP = 'Set whether we use terminal highlighting'
10
10
  IN_LIST = true
11
- MIN_ABBREV = 'ba'.size
11
+ MIN_ABBREV = 'hi'.size
12
12
  end
13
+
14
+ def complete(prefix)
15
+ Trepan::Complete.complete_token(%w(on off reset), prefix)
16
+ end
17
+
13
18
  def run(args)
14
19
  if args.size == 3 && 'reset' == args[2]
15
20
  LineCache::clear_file_format_cache
21
+ @proc.settings[:highlight] = :term
16
22
  else
17
23
  super
18
24
  @proc.settings[:highlight] = :term if @proc.settings[:highlight]
@@ -0,0 +1,42 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::SetReload < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ SHORT_HELP = "Set whether to reread source text when it changes."
10
+ IN_LIST = true
11
+ MIN_ABBREV = 're'.size
12
+ HELP = <<-EOH
13
+ #{CMD} {on|off}
14
+
15
+ Source text is cached on the first read. This ensures that if you
16
+ change the source text after the debugged program is runnning you will
17
+ still see the source code as pertains to the running program rather
18
+ than what is in the filesystem.
19
+
20
+ However sometimes this may not be what you want. In particular in running
21
+ Ruby on Rails in development, Rails will also detect file changes and
22
+ will reload the source code. So here the debugger will be out of sync.
23
+
24
+ Set this to true, and the debugger will notice such changes and reread
25
+ the source text when it discovers it has changed.
26
+
27
+ See also "info source" and "info files" and note the SHA1
28
+ and file modification time.
29
+ EOH
30
+ end
31
+ end
32
+
33
+ if __FILE__ == $0
34
+ # Demo it.
35
+ $0 = __FILE__ + 'notagain' # So we don't run this agin
36
+ require_relative '../../mock'
37
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetReload, false)
38
+ cmd.run(cmd.prefix + ['off'])
39
+ cmd.run(cmd.prefix + ['ofn'])
40
+ cmd.run(cmd.prefix)
41
+ puts cmd.save_command
42
+ end
@@ -0,0 +1,58 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subsubcmd'
5
+
6
+ class Trepan::Subcommand::SetTimer < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{PREFIX.join(' ')} [on|off]
11
+
12
+ Tracks and shows elapsed time between debugger events.
13
+
14
+ Since debugger overhead can be large depending on what you are doing,
15
+ there are many ways to customize the debugger to take less time (and
16
+ do less).
17
+
18
+ Stepping is slow, running to a breakpoint without stepping is
19
+ relatively fast compared to previous versions of the debugger and
20
+ compared to stepping.
21
+
22
+ Stopping at fewer events can also speed things up. Trace event
23
+ buffering slows things down.
24
+
25
+ Buy turning this setting on, you may be able to get a feel for what
26
+ how expensive the various settings.
27
+
28
+ See also: 'set events', 'set trace buffer', 'step', and 'break'.
29
+ EOH
30
+
31
+ MIN_ABBREV = 'ti'.size
32
+ SHORT_HELP = "Set to show elapsed time between debugger events"
33
+ end
34
+
35
+ def run(args)
36
+ super
37
+ if @proc.settings[:timer]
38
+ @proc.cmdloop_posthooks.insert_if_new(-1, 'timer', @proc.timer_hook[1])
39
+ @proc.cmdloop_prehooks.insert_if_new(-1, 'timer', @proc.timer_hook[1])
40
+ else
41
+ @proc.cmdloop_posthooks.delete_by_name('timer')
42
+ @proc.cmdloop_prehooks.delete_by_name('timer')
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ if __FILE__ == $0
49
+ # Demo it.
50
+ require_relative '../../mock'
51
+ require_relative '../../hook'
52
+
53
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetTimer)
54
+ cmd.run(cmd.prefix)
55
+ %w(off on).each do |arg|
56
+ cmd.run(cmd.prefix + [arg])
57
+ end
58
+ end
@@ -7,14 +7,15 @@ require_relative '../base/subsubmgr'
7
7
  class Trepan::SubSubcommand::SetTrace < Trepan::SubSubcommandMgr
8
8
  unless defined?(HELP)
9
9
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
- HELP = "Set tracing of various sorts.
10
+ HELP = <<-EOH
11
+ Set tracing of various sorts.
11
12
 
12
13
  The types of tracing include global variables, events from the trace
13
14
  buffer, or printing those events.
14
15
 
15
16
  See 'help #{PREFIX.join(' ')} *' for a list of subcommands or 'help set trace
16
- <name>' for help on a particular trace subcommand."
17
-
17
+ <name>' for help on a particular trace subcommand.
18
+ EOH
18
19
  IN_LIST = true
19
20
  MIN_ABBREV = 'tr'.size
20
21
  SHORT_HELP = 'Set tracing of various sorts.'
@@ -1,17 +1,19 @@
1
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'irb'
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative 'base/cmd'
5
- require_relative '../../app/irb'
4
+ require_relative '../command'
6
5
  class Trepan::Command::IRBCommand < Trepan::Command
7
6
 
8
7
  unless defined?(HELP)
8
+ require_relative '../../app/irb'
9
9
  NAME = File.basename(__FILE__, '.rb')
10
- HELP = <<-HELP
11
- #{NAME} [-d]\tstarts an Interactive Ruby (IRB) session.
10
+ HELP = <<-HELP
11
+ #{NAME} [-d]
12
+
13
+ starts an Interactive Ruby (IRB) session.
12
14
 
13
15
  If -d is added you can get access to debugger frame the global variables
14
- $trepanx_frame and $trepanx_cmdproc.
16
+ $trepan_frame and $trepan_cmdproc.
15
17
 
16
18
  #{NAME} is extended with methods 'cont', 'ne', and, 'q', 'step' which
17
19
  run the corresponding debugger commands 'continue', 'next', 'exit' and 'step'.
@@ -33,9 +35,10 @@ Here then is a loop to query VM stack values:
33
35
  (-1..1).each {|i| dbgr(\"info reg sp \#{i}\")}
34
36
  HELP
35
37
 
36
- CATEGORY = 'support'
37
- MAX_ARGS = 1 # Need at most this many
38
- SHORT_HELP = "Run #{NAME} as a command subshell"
38
+ ALIASES = %w(irb)
39
+ CATEGORY = 'support'
40
+ MAX_ARGS = 1 # Need at most this many
41
+ SHORT_HELP = "Run #{NAME} as a command subshell"
39
42
  end
40
43
 
41
44
  # This method runs the command
@@ -53,17 +56,17 @@ Here then is a loop to query VM stack values:
53
56
  # end
54
57
 
55
58
  save_trap = trap('SIGINT') do
56
- throw :IRB_EXIT, :cont if $trepanx_in_irb
59
+ throw :IRB_EXIT, :cont if $trepan_in_irb
57
60
  end
58
61
 
59
- $trepanx = @proc.dbgr
62
+ $trepan = @proc.dbgr
60
63
  if add_debugging
61
- $trepanx_cmdproc = @proc
62
- $trepanx_frame = @proc.frame
64
+ $trepan_cmdproc = @proc
65
+ $trepan_frame = @proc.frame
63
66
  end
64
- $trepanx_in_irb = true
65
- $trepanx_irb_statements = nil
66
- $trepanx_command = nil
67
+ $trepan_in_irb = true
68
+ $trepan_irb_statements = nil
69
+ $trepan_command = nil
67
70
 
68
71
  conf = {:BACK_TRACE_LIMIT => settings[:maxstack],
69
72
  :RC => true}
@@ -105,16 +108,16 @@ Here then is a loop to query VM stack values:
105
108
  when :finish
106
109
  @proc.finish
107
110
  when :next
108
- @proc.next # (1, {})
111
+ @proc.step ('next', 1, {})
109
112
  when :quit
110
113
  @proc.quit
111
114
  when :step
112
- @proc.step # (1, {})
115
+ @proc.step ('step', 1, {})
113
116
  else
114
117
  @proc.print_location
115
118
  end
116
119
  ensure
117
- $trepanx_in_irb = false
120
+ $trepan_in_irb = false
118
121
  # restore old trap if any
119
122
  trap('SIGINT', save_trap) if save_trap
120
123
  end