rb8-trepanning 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/CHANGES +10 -0
  2. data/ChangeLog +276 -0
  3. data/Makefile +13 -0
  4. data/Rakefile +1 -2
  5. data/app/display.rb +41 -1
  6. data/app/irb.rb +55 -49
  7. data/app/options.rb +3 -2
  8. data/app/run.rb +25 -7
  9. data/app/util.rb +19 -1
  10. data/bin/trepan8 +0 -2
  11. data/data/perldb.bindings +17 -0
  12. data/interface/script.rb +1 -1
  13. data/interface/server.rb +1 -1
  14. data/interface/user.rb +3 -1
  15. data/{interface/base_intf.rb → interface.rb} +1 -1
  16. data/io/input.rb +1 -1
  17. data/io/null_output.rb +1 -1
  18. data/io/string_array.rb +2 -2
  19. data/io/tcpclient.rb +1 -1
  20. data/io/tcpserver.rb +1 -1
  21. data/{io/base_io.rb → io.rb} +0 -0
  22. data/lib/debugger.rb +0 -1
  23. data/lib/trepanning.rb +3 -1
  24. data/processor/command/alias.rb +13 -2
  25. data/processor/command/backtrace.rb +2 -1
  26. data/processor/command/base/subcmd.rb +1 -5
  27. data/processor/command/base/submgr.rb +1 -1
  28. data/processor/command/base/subsubcmd.rb +1 -1
  29. data/processor/command/base/subsubmgr.rb +4 -4
  30. data/processor/command/break.rb +19 -11
  31. data/processor/command/catch.rb +1 -1
  32. data/processor/command/complete.rb +1 -1
  33. data/processor/command/continue.rb +7 -1
  34. data/processor/command/directory.rb +2 -2
  35. data/processor/command/disable.rb +13 -14
  36. data/processor/command/display.rb +3 -1
  37. data/processor/command/down.rb +8 -8
  38. data/processor/command/edit.rb +1 -1
  39. data/processor/command/enable.rb +21 -22
  40. data/processor/command/eval.rb +1 -2
  41. data/processor/command/exit.rb +25 -8
  42. data/processor/command/finish.rb +7 -2
  43. data/processor/command/frame.rb +1 -1
  44. data/processor/command/help.rb +3 -4
  45. data/processor/command/info.rb +2 -0
  46. data/processor/command/info_subcmd/files.rb +2 -2
  47. data/processor/command/info_subcmd/locals.rb +6 -53
  48. data/processor/command/info_subcmd/source.rb +10 -4
  49. data/processor/command/info_subcmd/variables.rb +35 -0
  50. data/processor/command/info_subcmd/variables_subcmd/.gitignore +1 -0
  51. data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
  52. data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
  53. data/processor/command/info_subcmd/{globals.rb → variables_subcmd/globals.rb} +22 -17
  54. data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
  55. data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
  56. data/processor/command/kill.rb +8 -7
  57. data/processor/command/list.rb +2 -2
  58. data/processor/command/macro.rb +27 -9
  59. data/processor/command/next.rb +1 -1
  60. data/processor/command/parsetree.rb +1 -1
  61. data/processor/command/pp.rb +1 -1
  62. data/processor/command/pr.rb +1 -1
  63. data/processor/command/ps.rb +1 -1
  64. data/processor/command/restart.rb +1 -1
  65. data/processor/command/save.rb +1 -1
  66. data/processor/command/set_subcmd/auto.rb +7 -1
  67. data/processor/command/set_subcmd/different.rb +1 -1
  68. data/processor/command/set_subcmd/trace.rb +5 -4
  69. data/processor/command/set_subcmd/trace_subcmd/print.rb +4 -3
  70. data/processor/command/shell.rb +5 -4
  71. data/processor/command/show_subcmd/{alias.rb → aliases.rb} +2 -2
  72. data/processor/command/source.rb +1 -1
  73. data/processor/command/step.rb +2 -5
  74. data/processor/command/tbreak.rb +1 -1
  75. data/processor/command/unalias.rb +13 -8
  76. data/processor/command/undisplay.rb +13 -9
  77. data/processor/command/up.rb +12 -14
  78. data/processor/command.rb +138 -230
  79. data/processor/display.rb +46 -10
  80. data/processor/help.rb +5 -3
  81. data/processor/hook.rb +2 -2
  82. data/processor/location.rb +25 -0
  83. data/processor/mock.rb +3 -2
  84. data/processor/msg.rb +55 -42
  85. data/processor/old-command.rb +270 -0
  86. data/processor/{processor.rb → old-processor.rb} +7 -8
  87. data/processor/running.rb +7 -12
  88. data/processor/subcmd.rb +15 -41
  89. data/processor/validate.rb +240 -238
  90. data/{processor/main.rb → processor.rb} +20 -42
  91. data/test/data/trace.cmd +6 -0
  92. data/test/data/trace.right +46 -0
  93. data/test/integration/helper.rb +2 -0
  94. data/test/integration/test-trace.rb +29 -0
  95. data/test/unit/cmd-helper.rb +2 -3
  96. data/test/unit/test-app-options.rb +13 -11
  97. data/test/unit/test-app-run.rb +7 -1
  98. data/test/unit/test-base-cmd.rb +1 -1
  99. data/test/unit/test-cmd-kill.rb +11 -4
  100. data/test/unit/test-io-tcpserver.rb +9 -4
  101. data/test/unit/test-proc-eval.rb +1 -2
  102. data/test/unit/test-proc-location.rb +26 -32
  103. data/test/unit/test-subcmd-help.rb +1 -1
  104. data/trepan8.gemspec +9 -1
  105. metadata +60 -17
  106. data/processor/command/base/cmd.rb +0 -177
data/interface/script.rb CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  # Our local modules
7
7
  require 'rubygems'; require 'require_relative'
8
- require_relative 'base_intf'
8
+ require_relative '../interface'
9
9
  require_relative '../io/input'
10
10
  require_relative '../io/string_array'
11
11
 
data/interface/server.rb CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Our local modules
5
5
  require 'rubygems'; require 'require_relative'
6
- require_relative 'base_intf'
6
+ require_relative '../interface'
7
7
  require_relative 'comcodes'
8
8
  require_relative '../io/input'
9
9
  require_relative '../io/tcpserver'
data/interface/user.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # Our local modules
7
7
 
8
8
  require 'rubygems'; require 'require_relative'
9
- require_relative 'base_intf'
9
+ require_relative '../interface'
10
10
  require_relative '../io/input'
11
11
 
12
12
  # Interface when communicating with the user.
@@ -162,4 +162,6 @@ if __FILE__ == $0
162
162
  end
163
163
  end
164
164
  puts "User interface closed?: #{intf.closed?}"
165
+ intf.close
166
+ STDERR.puts "User interface closed?: #{intf.closed?}"
165
167
  end
@@ -16,7 +16,7 @@ module Trepan
16
16
  # - another interface in another process or computer
17
17
  class Interface
18
18
 
19
- attr_accessor :interactive, :history_io, :history_save, :input, :output
19
+ attr_accessor :history_io, :history_save, :interactive, :input, :output
20
20
 
21
21
  unless defined?(YES)
22
22
  YES = %w(y yes oui si yep ja)
data/io/input.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  #
7
7
 
8
8
  require 'rubygems'; require 'require_relative'
9
- require_relative 'base_io'
9
+ require_relative '../io'
10
10
 
11
11
  module Trepan
12
12
 
data/io/null_output.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  #
7
7
 
8
8
  require 'rubygems'; require 'require_relative'
9
- require_relative 'base_io'
9
+ require_relative '../io'
10
10
 
11
11
  class Trepan::OutputNull < Trepan::OutputBase
12
12
  def initialize(out, opts={})
data/io/string_array.rb CHANGED
@@ -1,10 +1,10 @@
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
 
4
4
  # Simulate I/O using lists of strings.
5
5
 
6
6
  require 'rubygems'; require 'require_relative'
7
- require_relative 'base_io'
7
+ require_relative '../io'
8
8
 
9
9
  # Simulate I/O using an array of strings. Sort of like StringIO, but
10
10
  # even simplier.
data/io/tcpclient.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'socket'
6
6
  require 'rubygems'; require 'require_relative'
7
- require_relative 'base_io'
7
+ require_relative '../io'
8
8
  require_relative 'tcpfns'
9
9
 
10
10
  module Trepan
data/io/tcpserver.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  require 'socket'
6
6
  require 'rubygems'; require 'require_relative'
7
7
  require_relative '../app/default' # For host and port
8
- require_relative 'base_io'
8
+ require_relative '../io'
9
9
  require_relative 'tcpfns'
10
10
 
11
11
  module Trepan
File without changes
data/lib/debugger.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  # minimal fuss. Compare with: require "debug"
3
3
  require 'rubygems'
4
4
  require 'require_relative'
5
- require_relative "rubygems"
6
5
  require './trepanning'
7
6
  Trepan.start
8
7
  debugger
data/lib/trepanning.rb CHANGED
@@ -7,7 +7,8 @@ require 'ruby-debug-base'
7
7
  require 'require_relative'
8
8
  require_relative '../interface/script'
9
9
  require_relative '../interface/user'
10
- require_relative '../processor/processor'
10
+ require_relative '../processor/old-processor'
11
+ require_relative '../processor'
11
12
 
12
13
  module Trepan
13
14
 
@@ -58,6 +59,7 @@ module Trepan
58
59
  @@intf = [Trepan::UserInterface.new(nil, nil, opts)]
59
60
 
60
61
  attr_accessor :handler
62
+
61
63
  Trepan.handler = Debugger.handler = CommandProcessor.new(@@intf)
62
64
 
63
65
  # gdb-style annotation mode. Used in GNU Emacs interface
@@ -1,6 +1,6 @@
1
1
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
 
5
5
  class Trepan::Command::AliasCommand < Trepan::Command
6
6
 
@@ -9,7 +9,18 @@ class Trepan::Command::AliasCommand < Trepan::Command
9
9
  HELP = <<-HELP
10
10
  #{NAME} ALIAS COMMAND
11
11
 
12
- Add an alias for a COMMAND
12
+ Add alias ALIAS for a debugger command COMMAND.
13
+
14
+ Add an alias when you want to use a command abbreviation for a command
15
+ that would otherwise be ambigous. For example, by default we make 's'
16
+ be an alias of 'step' to force it to be used. Without the alias, "s"
17
+ might be "step", "show", or "set" among others
18
+
19
+ Example:
20
+
21
+ alias cat list # "cat rubyfile.rb" is the same as "list rubyfile.rb"
22
+ alias s step # "s" is now an alias for "step".
23
+ # The above examples done by default.
13
24
 
14
25
  See also 'unalias' and 'show #{NAME}'.
15
26
  HELP
@@ -1,5 +1,6 @@
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
1
2
  require 'rubygems'; require 'require_relative'
2
- require_relative './base/cmd'
3
+ require_relative '../command'
3
4
 
4
5
  class Trepan::Command::BacktraceCommand < Trepan::Command
5
6
  unless defined?(ALIASES)
@@ -10,7 +10,7 @@
10
10
  # functions for command from module cmdfns.
11
11
 
12
12
  require 'rubygems'; require 'require_relative'
13
- require_relative 'cmd'
13
+ require_relative '../../command'
14
14
 
15
15
  module Trepan
16
16
 
@@ -131,10 +131,6 @@ module Trepan
131
131
  ["#{subcmd_prefix_string} #{settings[subcmd_setting_key]}"]
132
132
  end
133
133
 
134
- def settings
135
- @proc.settings
136
- end
137
-
138
134
  def subcmd_prefix_string
139
135
  self.class.const_get(:PREFIX).join(' ')
140
136
  end
@@ -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 'cmd'
4
+ require_relative '../../command'
5
5
  require_relative '../../subcmd'
6
6
  require_relative '../../help'
7
7
  require_relative '../../../app/complete'
@@ -10,7 +10,7 @@
10
10
  # functions for command from module cmdfns.
11
11
 
12
12
  require 'rubygems'; require 'require_relative'
13
- require_relative 'cmd'
13
+ require_relative '../../command'
14
14
  require_relative 'subcmd'
15
15
 
16
16
  module Trepan
@@ -163,19 +163,19 @@ class Trepan::SubSubcommandMgr < Trepan::Subcommand
163
163
 
164
164
  def run(args)
165
165
  args = @parent.last_args if args.size == 0
166
- if args.size < 3 || args.size == 3 && args[-1] == '*'
166
+ if args.size < 3 || args.size == 3 && args[2] == '*'
167
167
  summary_list(obj_const(self, :NAME), @subcmds)
168
168
  return false
169
169
  end
170
170
 
171
- subcmd_prefix = args[0..2].join('')
171
+ subcmd_prefix = obj_const(self, :PREFIX).join('')
172
172
  # We were given: cmd subcmd ...
173
173
  # Run that.
174
- subcmd = @subcmds.lookup(subcmd_prefix)
174
+ subcmd = @subcmds.lookup(subcmd_prefix + args[2])
175
175
  if subcmd
176
176
  subcmd.run(args[2..-1])
177
177
  else
178
- undefined_subcmd(obj_const(self, :PREFIX).join(' '), args[-1])
178
+ undefined_subcmd(obj_const(self, :PREFIX).join(' '), args[2])
179
179
  end
180
180
  end
181
181
 
@@ -1,13 +1,13 @@
1
1
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative './base/cmd'
3
+ require_relative '../command'
4
4
 
5
5
  class Trepan::Command::BreakCommand < Trepan::Command
6
-
7
- ALIASES = %w(b)
8
- CATEGORY = 'breakpoints'
9
- NAME = File.basename(__FILE__, '.rb')
10
- HELP = <<-HELP
6
+ Trepan::Util::suppress_warnings {
7
+ ALIASES = %w(b)
8
+ CATEGORY = 'breakpoints'
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ HELP = <<-HELP
11
11
  #{NAME} LOCATION [ {if|unless} CONDITION ]
12
12
 
13
13
  Set a breakpoint. In the second form where CONDITIOn is given, the
@@ -25,7 +25,8 @@ Examples:
25
25
 
26
26
  See also condition, continue and "help location".
27
27
  HELP
28
- SHORT_HELP = 'Set a breakpoint at a point in a method'
28
+ SHORT_HELP = 'Set a breakpoint at a point in a method'
29
+ }
29
30
 
30
31
  # This method runs the command
31
32
  def run(args, temp=false)
@@ -53,10 +54,17 @@ See also condition, continue and "help location".
53
54
  @proc.canonic_file(file)])
54
55
  return
55
56
  end
56
- unless LineCache.trace_line_numbers(file).member?(line)
57
- errmsg('Line %d is not a stopping point in file "%s".' %
58
- [line, @proc.canonic_file(file)])
59
- return
57
+ syntax_errors = Trepan::ruby_syntax_errors(file)
58
+ if syntax_errors
59
+ msg ["File #{file} is not a syntactically correct Ruby program.",
60
+ "Therefore we can't check line numbers."]
61
+ return unless confirm('Set breakpoint anyway?', false)
62
+ else
63
+ unless LineCache.trace_line_numbers(file).member?(line)
64
+ errmsg('Line %d is not a stopping point in file "%s".' %
65
+ [line, @proc.canonic_file(file)])
66
+ return
67
+ end
60
68
  end
61
69
  else
62
70
  errmsg('No source file named %s' % @proc.canonic_file(file))
@@ -1,6 +1,6 @@
1
1
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  require_relative '../stepping'
5
5
 
6
6
  class Trepan::Command::CatchCommand < Trepan::Command
@@ -1,6 +1,6 @@
1
1
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  require_relative '../load_cmds'
5
5
  class Trepan::Command::CompleteCommand < Trepan::Command
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  require_relative '../stepping'
5
5
 
6
6
  class Trepan::Command::ContinueCommand < Trepan::Command
@@ -38,6 +38,12 @@ See also 'step', 'next', 'finish', 'nexti' commands and "help location".
38
38
  filename = @proc.frame.file
39
39
  line_number = @proc.get_an_int(args[1])
40
40
  return unless line_number
41
+ syntax_errors = Trepan::ruby_syntax_errors(filename)
42
+ if syntax_errors
43
+ msg ["File #{filename} is not a syntactically correct Ruby program.",
44
+ "Therefore we can't check line numbers."]
45
+ return unless confirm('Set breakpoint anyway?', false)
46
+ end
41
47
  unless LineCache.trace_line_numbers(filename).member?(line_number)
42
48
  errmsg("Line %d is not a stopping point in file \"%s\".\n" %
43
49
  [line_number, filename])
@@ -1,6 +1,6 @@
1
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  class Trepan::Command::DirectoryCommand < Trepan::Command
5
5
 
6
6
  unless defined?(HELP)
@@ -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 '../breakpoint'
6
6
  # require_relative '../../app/breakpoint'
7
7
 
@@ -12,21 +12,20 @@ require_relative 'base/cmd'
12
12
  # NOTE: The enable command subclasses this, so beware when changing!
13
13
  class Trepan::Command::DisableCommand < Trepan::Command
14
14
 
15
- # Silence already initialized constant .. warnings
16
- old_verbose = $VERBOSE
17
- $VERBOSE = nil
18
- NAME = File.basename(__FILE__, '.rb')
19
- HELP = <<-HELP
20
- #{NAME} bpnumber [bpnumber ...]
15
+ Trepan::Util.suppress_warnings {
16
+ NAME = File.basename(__FILE__, '.rb')
17
+ HELP = <<-HELP
18
+ #{NAME} NUM1 [NUM2 ...]
21
19
 
22
- Disables the breakpoints given as a space separated list of breakpoint
23
- numbers. See also "info break" to get a list.
24
- HELP
20
+ Disables the breakpoints given as a space-separated list of
21
+ numbers.
25
22
 
26
- CATEGORY = 'breakpoints'
27
- SHORT_HELP = 'Disable some breakpoints'
23
+ See also "enable" and "info break".
24
+ HELP
28
25
 
29
- $VERBOSE = old_verbose
26
+ CATEGORY = 'breakpoints'
27
+ SHORT_HELP = 'Disable some breakpoints'
28
+ }
30
29
 
31
30
  def initialize(proc)
32
31
  super
@@ -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
 
6
6
  class Trepan::Command::DisplayCommand < Trepan::Command
7
7
 
@@ -23,6 +23,8 @@ case or not.
23
23
  With no argument, evaluate and display all currently requested
24
24
  auto-display expressions. Use "undisplay" to cancel display
25
25
  requests previously made.
26
+
27
+ See also "undisplay", "enable", and "disable".
26
28
  HELP
27
29
 
28
30
  CATEGORY = 'data'
@@ -7,10 +7,10 @@ require_relative 'up'
7
7
  # direction (set by DIRECTION) reversed.
8
8
  class Trepan::Command::DownCommand < Trepan::Command::UpCommand
9
9
 
10
- # Silence already initialized constant .. warnings
11
- old_verbose = $VERBOSE
12
- $VERBOSE = nil
13
- HELP = <<-HELP
10
+ Trepan::Util.suppress_warnings {
11
+ old_verbose = $VERBOSE
12
+ $VERBOSE = nil
13
+ HELP = <<-HELP
14
14
  #{NAME} [count]
15
15
 
16
16
  Move the current frame down in the stack trace (to a newer frame). 0
@@ -19,10 +19,10 @@ is the most recent frame. If no count is given, move down 1.
19
19
  See also 'up' and 'frame'.
20
20
  HELP
21
21
 
22
- ALIASES = %w(d)
23
- NAME = File.basename(__FILE__, '.rb')
24
- SHORT_HELP = 'Move frame in the direction of the caller of the last-selected frame'
25
- $VERBOSE = old_verbose
22
+ ALIASES = %w(d)
23
+ NAME = File.basename(__FILE__, '.rb')
24
+ SHORT_HELP = 'Move frame in the direction of the caller of the last-selected frame'
25
+ }
26
26
 
27
27
  def initialize(proc)
28
28
  super
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative './base/cmd'
4
+ require_relative '../command'
5
5
 
6
6
  class Trepan::Command::EditCommand < Trepan::Command
7
7
 
@@ -8,29 +8,24 @@ require_relative 'disable'
8
8
  # ENABLE_PARM below).
9
9
  class Trepan::Command::EnableCommand < Trepan::Command::DisableCommand
10
10
 
11
- # Silence already initialized constant .. warnings
12
- old_verbose = $VERBOSE
13
- $VERBOSE = nil
14
- NAME = File.basename(__FILE__, '.rb')
15
- HELP = <<-HELP
16
- #{NAME} BPNUM1 [BPNUM2 ...]
11
+ Trepan::Util.suppress_warnings {
12
+ NAME = File.basename(__FILE__, '.rb')
13
+ HELP = <<-HELP
14
+ #{NAME} NUM1 [NUM2 ...]
17
15
 
18
- Enables breakpoints BPNUM1. Breakpoints numbers are given as a space-
19
- separated list numbers.
16
+ Enables breakpoints NUM1... Breakpoints numbers are given as
17
+ a space-separated list numbers.
20
18
 
21
- See also "info break" to get a list of breakpoints.
19
+ See also "disable" and "info break".
22
20
  HELP
21
+
22
+ ALIASES = %w(en)
23
+ SHORT_HELP = 'Enable some breakpoints'
24
+ }
23
25
 
24
- ALIASES = %w(en)
25
- SHORT_HELP = 'Enable some breakpoints'
26
- $VERBOSE = old_verbose
27
-
28
- def run(args)
29
- if args.size == 1
30
- errmsg('No breakpoint number given.')
31
- return
32
- end
33
- enable_disable_breakpoints("Disable", args[1..-1])
26
+ def initialize(proc)
27
+ super
28
+ @enable_parm = true # true if enable
34
29
  end
35
30
 
36
31
  end
@@ -40,9 +35,13 @@ if __FILE__ == $0
40
35
  dbgr, cmd = MockDebugger::setup
41
36
  cmd.run([cmd.name])
42
37
  cmd.run([cmd.name, '1'])
43
- cmds = cmd.proc.commands
38
+ cmdproc = cmd.proc
39
+ cmds = cmdproc.commands
44
40
  break_cmd = cmds['break']
45
41
  puts "To be continued..."
46
- # break_cmd.run(['break', cmdproc.frame.source_location[0].to_s])
47
- # cmd.run([cmd.name, '1'])
42
+ require 'ruby-debug-base';
43
+ cmdproc.frame_setup(Debugger.current_context, nil)
44
+ cmdproc.frame.instance_variable_set('@binding', TOPLEVEL_BINDING)
45
+ break_cmd.run(['break', __LINE__.to_s])
46
+ cmd.run([cmd.name, '1'])
48
47
  end
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative './base/cmd'
5
- require_relative '../../app/util'
4
+ require_relative '../command'
6
5
 
7
6
  class Trepan::Command::EvalCommand < Trepan::Command
8
7
 
@@ -1,13 +1,13 @@
1
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  class Trepan::Command::ExitCommand < Trepan::Command
5
5
 
6
6
  unless defined?(HELP)
7
7
  NAME = File.basename(__FILE__, '.rb')
8
8
  ALIASES = %w(quit q q! quit! exit!)
9
9
  HELP = <<-HELP
10
- #{NAME} [exitcode] - hard exit of the debugged program.
10
+ #{NAME} [exitcode] [unconditionally] - hard exit of the debugged program.
11
11
 
12
12
  The program being debugged is exited via exit!() which does not run
13
13
  the Kernel at_exit finalizers. If a return code is given, that is the
@@ -18,6 +18,13 @@ If you are in interactive mode, and confirm is not set off, you are
18
18
  prompted to confirm quitting. However if you do not want to be
19
19
  prompted, add ! the end. (vim/vi/ed users can use alias q!).
20
20
 
21
+ Examples:
22
+ #{NAME} # quit prompting if we are interactive
23
+ #{NAME} unconditionally # quit without prompting
24
+ #{NAME}! # same as above
25
+ #{NAME} 0 # same as "quit"
26
+ #{NAME}! 1 # unconditional quit setting exit code 1
27
+
21
28
  See also "kill" and "set confirm".'
22
29
  HELP
23
30
 
@@ -32,7 +39,7 @@ See also "kill" and "set confirm".'
32
39
  # This method runs the command
33
40
  def run(args) # :nodoc
34
41
  unconditional =
35
- if args.size > 1 && args[1] == 'unconditionally'
42
+ if args.size > 1 && args[-1] == 'unconditionally'
36
43
  args.shift
37
44
  true
38
45
  elsif args[0][-1..-1] == '!'
@@ -44,7 +51,17 @@ See also "kill" and "set confirm".'
44
51
  msg('Quit not confirmed.')
45
52
  return
46
53
  end
47
- exitrc = (args.size > 1) ? exitrc = Integer(args[1]) rescue 0 : 0
54
+
55
+ if (args.size > 1)
56
+ if args[1] =~ /\d+/
57
+ exitrc = args[1].to_i;
58
+ else
59
+ errmsg "Bad an Integer return type \"#{args[1]}\"";
60
+ return;
61
+ end
62
+ else
63
+ exitrc = 0
64
+ end
48
65
 
49
66
  # FIXME: Is this the best/most general way?
50
67
  ## @proc.finalize
@@ -59,8 +76,8 @@ end
59
76
  if __FILE__ == $0
60
77
  require_relative '../mock'
61
78
  dbgr, cmd = MockDebugger::setup
62
- puts "before #{cmd.name}"
63
- fork { cmd.run([cmd.name]) }
64
- puts "before #{cmd.name} 10"
79
+ Process.fork { cmd.run([cmd.name]) } if
80
+ Process.respond_to?(:fork)
81
+ cmd.run([cmd.name, 'foo'])
65
82
  cmd.run([cmd.name, '10'])
66
83
  end
@@ -1,6 +1,7 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
3
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
4
+ require_relative '../command'
4
5
 
5
6
  class Trepan::Command::FinishCommand < Trepan::Command
6
7
 
@@ -11,13 +12,17 @@ class Trepan::Command::FinishCommand < Trepan::Command
11
12
  HELP = <<-HELP
12
13
  #{NAME} [FRAME_NUM]
13
14
 
14
- Execute until selected stack frame returns.
15
+ Continue execution until leaving the current method. Sometimes this
16
+ is called 'step out'.
15
17
 
16
18
  If no frame number is given, we run until the currently selected frame
17
19
  returns. The currently selected frame starts out the most-recent
18
20
  frame or 0 if no frame positioning (e.g "up", "down" or "frame") has
19
21
  been performed. If a frame number is given we run until that frame
20
22
  returns.
23
+
24
+ See also commands:
25
+ 'continue', 'break', 'next', 'nexti', 'step' for other ways to continue.
21
26
  HELP
22
27
  NEED_RUNNING = true
23
28
  SHORT_HELP = 'Step into next method call or to next line'
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'; require 'require_relative'
2
- require_relative './base/cmd'
2
+ require_relative '../command'
3
3
 
4
4
  class Trepan::Command::FrameCommand < Trepan::Command
5
5
  CATEGORY = 'stack'
@@ -1,6 +1,6 @@
1
1
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  require_relative '../../app/complete'
5
5
  class Trepan::Command::HelpCommand < Trepan::Command
6
6
  unless defined?(HELP)
@@ -21,8 +21,6 @@ Some commands like 'info', 'set', and 'show' can accept an
21
21
  additional subcommand to give help just about that particular
22
22
  subcommand. For example 'help info line' give help about the
23
23
  info line command.
24
-
25
- See also 'examine' and 'whatis'.
26
24
  HELP
27
25
 
28
26
  ALIASES = %w(?)
@@ -155,7 +153,8 @@ Type "help" followed by command name for full documentation.
155
153
  category == @proc.commands[cmd_name].category
156
154
  end.sort
157
155
  width = settings[:maxwidth]
158
- return columnize_commands(cmds)
156
+ msg columnize_commands(cmds)
157
+ return
159
158
  end
160
159
 
161
160
  msg('')
@@ -24,5 +24,7 @@ end
24
24
 
25
25
  if __FILE__ == $0
26
26
  require_relative '../mock'
27
+ require 'ruby-debug'; Debugger.start; debugger
27
28
  dbgr, cmd = MockDebugger::setup
29
+ cmd.run(['info', 'iv'])
28
30
  end