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
@@ -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 events from the trace buffer, or printing
13
14
  those events.
14
15
 
15
- See 'help #{PREFIX.join(' ')} *' for a list of subcommands or 'help set trace
16
- <name>' for help on a particular trace subcommand."
17
-
16
+ See "help #{PREFIX.join(' ')} *" for a list of subcommands or "#{PREFIX.join(' ')} <name>"
17
+ 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.'
@@ -7,13 +7,14 @@ class Trepan::SubSubcommand::SetTracePrint < Trepan::SetBoolSubSubcommand
7
7
  unless defined?(HELP)
8
8
  Trepanning::SubSubcommand.set_name_prefix(__FILE__, self)
9
9
  HELP = <<-EOH
10
- #{CMD} [on|off|1|0]
10
+ #{CMD} [on|off]
11
11
 
12
- Set printing trace events.
12
+ Set printing trace events. This is similar to "set -x" tracing in
13
+ POSIX shells.
13
14
  EOH
14
15
 
15
16
  MIN_ABBREV = 'p'.size
16
- SHORT_HELP = 'Set print trace events'
17
+ SHORT_HELP = 'Set print trace events, like "set -x" of POSIX shell'
17
18
  end
18
19
 
19
20
  def run(args)
@@ -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 '../../io/input' # For GNU_readline?
4
- Trepan.suppress_warnings { require 'irb' }
5
- require_relative 'base/cmd'
3
+ require_relative '../command'
6
4
  require_relative '../../app/irb'
7
5
 
8
6
  class Trepan::Command::IRBCommand < Trepan::Command
9
7
 
10
8
  unless defined?(HELP)
9
+ require_relative '../../io/input' # For GNU_readline? and supress_warnings
10
+ Trepan.suppress_warnings { require 'irb' }
11
11
  NAME = File.basename(__FILE__, '.rb')
12
12
  HELP = <<-HELP
13
13
  #{NAME} [-d]
@@ -62,8 +62,8 @@ Here then is a loop to query VM stack values:
62
62
  end
63
63
 
64
64
  $trepan = @proc.dbgr
65
+ $trepan_cmdproc = @proc
65
66
  if add_debugging
66
- $trepan_cmdproc = @proc
67
67
  $trepan_frame = @proc.frame
68
68
  end
69
69
  $trepan_in_irb = true
@@ -127,6 +127,7 @@ end
127
127
 
128
128
  if __FILE__ == $0
129
129
  require_relative '../mock'
130
+ require_relative '../../app/irb'
130
131
  # dbgr, cmd = MockDebugger::setup
131
132
  dbgr, cmd = MockDebugger::setup(nil, false)
132
133
  cmd.proc.frame.instance_variable_set('@binding', binding)
@@ -3,7 +3,7 @@
3
3
  require 'rubygems'; require 'require_relative'
4
4
  require_relative '../base/subcmd'
5
5
 
6
- class Trepan::Subcommand::ShowAlias < Trepan::Subcommand
6
+ class Trepan::Subcommand::ShowAliases < Trepan::Subcommand
7
7
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
8
  unless defined?(HELP)
9
9
  HELP = <<-EOH
@@ -32,7 +32,7 @@ all alias names
32
32
  elsif @proc.aliases.empty?
33
33
  msg "No aliases defined."
34
34
  else
35
- section "List of aliases names currently defined:"
35
+ section "List of alias names currently defined:"
36
36
  msg columnize_commands(@proc.aliases.keys.sort)
37
37
  end
38
38
  end
@@ -4,7 +4,7 @@ require 'optparse'
4
4
 
5
5
  # Our local modules
6
6
  require 'rubygems'; require 'require_relative'
7
- require_relative 'base/cmd'
7
+ require_relative '../command'
8
8
  require_relative '../../interface/script'
9
9
  require_relative '../../io/null_output'
10
10
  require_relative '../../app/default'
@@ -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::StepCommand < Trepan::Command
6
6
 
@@ -68,10 +68,7 @@ See also the commands:
68
68
  step_count = @proc.get_an_int(step_str, count_opts)
69
69
  return unless step_count
70
70
  end
71
- ## @proc.state.context.step(step_count, force)
72
- @proc.context.step(step_count, opts[:different_pos])
73
- @proc.state.proceed
74
- @proc.leave_cmd_loop = true
71
+ @proc.step(step_count, opts)
75
72
  end
76
73
  end
77
74
 
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'; require 'require_relative'
2
- require_relative './base/cmd'
2
+ require_relative '../command'
3
3
  require_relative 'break'
4
4
 
5
5
  class Trepan::Command::SetTempBreakpointCommand <
@@ -1,17 +1,18 @@
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
+ require_relative '../../app/complete'
4
5
 
5
6
  class Trepan::Command::UnaliasCommand < Trepan::Command
6
7
 
7
8
  unless defined?(HELP)
8
- HELP =
9
- "unalias COMMAND
9
+ HELP = <<-HELP
10
+ unalias ALIAS
10
11
 
11
- Remove alias for COMMAND
12
+ Remove alias ALIAS
12
13
 
13
14
  See also 'alias'.
14
- "
15
+ HELP
15
16
 
16
17
  CATEGORY = 'support'
17
18
  MIN_ARGS = 1
@@ -21,6 +22,10 @@ See also 'alias'.
21
22
  SHORT_HELP = 'Remove an alias'
22
23
  end
23
24
 
25
+ def complete(prefix)
26
+ Trepan::Complete.complete_token(@proc.aliases.keys, prefix)
27
+ end
28
+
24
29
  # Run command.
25
30
  def run(args)
26
31
  args[1..-1].each do |arg|
@@ -38,7 +43,7 @@ if __FILE__ == $0
38
43
  # Demo it.
39
44
  require_relative '../mock'
40
45
  dbgr, cmd = MockDebugger::setup
41
- cmd.run %w(cmd.name exit!)
42
- cmd.run %w(cmd.name exit!)
46
+ cmd.run %w(cmd.name n)
47
+ cmd.run %w(cmd.name n)
43
48
  cmd.run %w(cmd.name foo bar c)
44
49
  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 'base/cmd'
4
+ require_relative '../command'
5
5
 
6
6
  # undisplay display-number...
7
7
  class Trepan::Command::UndisplayCommand < Trepan::Command
@@ -9,37 +9,41 @@ class Trepan::Command::UndisplayCommand < Trepan::Command
9
9
  unless defined?(HELP)
10
10
  NAME = File.basename(__FILE__, '.rb')
11
11
  HELP = <<EOH
12
- undisplay DISPLAY_NUMBER ...
12
+ #{NAME} DISPLAY_NUMBER ...
13
13
  Cancel some expressions to be displayed when program stops.
14
14
  Arguments are the code numbers of the expressions to stop displaying.
15
15
  No argument means cancel all automatic-display expressions.
16
16
  "delete display" has the same effect as this command.
17
- Do "info display" to see current list of code numbers.
17
+ Use "info display" to see current list of display numbers.
18
18
  EOH
19
19
 
20
- ALIASES = %w(und)
21
20
  CATEGORY = 'data'
22
21
  NEED_STACK = false
23
22
  SHORT_HELP = 'Cancel some expressions to be displayed when program stops'
24
23
  end
25
24
 
25
+ def complete(prefix)
26
+ @proc.displays.nums.map{|disp| disp.to_s}
27
+ end
28
+
26
29
  def run(args)
27
30
 
28
31
  if args.size == 1
29
- @proc.displays.clear
30
- return
32
+ if confirm('Delete all displays?', false)
33
+ @proc.displays.clear
34
+ return
35
+ end
31
36
  end
32
37
  opts = {}
33
38
  args[1..-1].each do |arg|
34
- opts[:msg_on_error] = '%s must be a display number' % arg
39
+ opts = {:msg_on_error => '%s must be a display number' % arg}
35
40
  i = @proc.get_an_int(arg, opts)
36
41
  if i
37
42
  unless @proc.displays.delete_index(i)
38
- errmsg("no display number %d." % i)
43
+ errmsg("No display number %d." % i)
39
44
  return
40
45
  end
41
46
  end
42
- return false
43
47
  end
44
48
  end
45
49
  end
@@ -1,17 +1,15 @@
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
 
5
- # up command. Like 'down' butthe direction (set by DIRECTION) is different.
5
+ # up command. Like 'down' but the direction (set by DIRECTION) is different.
6
6
  #
7
7
  # NOTE: The down command subclasses this, so beware when changing!
8
8
  class Trepan::Command::UpCommand < Trepan::Command
9
9
 
10
- # Silence already initialized constant .. warnings
11
- old_verbose = $VERBOSE
12
- $VERBOSE = nil
13
- NAME = File.basename(__FILE__, '.rb')
14
- HELP = <<-HELP
10
+ Trepan::Util.suppress_warnings {
11
+ NAME = File.basename(__FILE__, '.rb')
12
+ HELP = <<-HELP
15
13
  #{NAME} [count]
16
14
 
17
15
  Move the current frame up in the stack trace (to an older frame). 0 is
@@ -20,12 +18,12 @@ the most recent frame. If no count is given, move up 1.
20
18
  See also 'down' and 'frame'.
21
19
  HELP
22
20
 
23
- ALIASES = %w(u)
24
- CATEGORY = 'stack'
25
- MAX_ARGS = 1 # Need at most this many
26
- NEED_STACK = true
27
- SHORT_HELP = 'Move frame in the direction of the caller of the last-selected frame'
28
- $VERBOSE = old_verbose
21
+ ALIASES = %w(u)
22
+ CATEGORY = 'stack'
23
+ MAX_ARGS = 1 # Need at most this many
24
+ NEED_STACK = true
25
+ SHORT_HELP = 'Move frame in the direction of the caller of the last-selected frame'
26
+ }
29
27
 
30
28
  def complete(prefix)
31
29
  @proc.frame_complete(prefix, @direction)