trepanning 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/ChangeLog +161 -0
  2. data/NEWS +10 -0
  3. data/Rakefile +13 -19
  4. data/app/frame.rb +1 -1
  5. data/app/irb.rb +1 -1
  6. data/app/util.rb +3 -10
  7. data/data/irbrc +1 -1
  8. data/lib/trepanning.rb +2 -2
  9. data/processor/command/alias.rb +10 -11
  10. data/processor/command/backtrace.rb +8 -9
  11. data/processor/command/base/cmd.rb +4 -0
  12. data/processor/command/base/subcmd.rb +0 -1
  13. data/processor/command/base/submgr.rb +12 -3
  14. data/processor/command/break.rb +14 -15
  15. data/processor/command/condition.rb +11 -12
  16. data/processor/command/continue.rb +10 -11
  17. data/processor/command/debug.rb +7 -8
  18. data/processor/command/delete.rb +10 -9
  19. data/processor/command/directory.rb +1 -1
  20. data/processor/command/disable.rb +8 -9
  21. data/processor/command/disassemble.rb +7 -8
  22. data/processor/command/display.rb +10 -11
  23. data/processor/command/down.rb +8 -9
  24. data/processor/command/enable.rb +9 -10
  25. data/processor/command/exit.rb +11 -10
  26. data/processor/command/finish.rb +12 -11
  27. data/processor/command/frame.rb +3 -4
  28. data/processor/command/help.rb +14 -16
  29. data/processor/command/info.rb +7 -8
  30. data/processor/command/irb.rb +13 -14
  31. data/processor/command/kill.rb +21 -10
  32. data/processor/command/list.rb +36 -36
  33. data/processor/command/macro.rb +4 -5
  34. data/processor/command/next.rb +19 -20
  35. data/processor/command/nocache.rb +3 -4
  36. data/processor/command/{print.rb → pr.rb} +11 -9
  37. data/processor/command/ps.rb +8 -8
  38. data/processor/command/quit.rb +17 -15
  39. data/processor/command/raise.rb +11 -10
  40. data/processor/command/reload.rb +4 -5
  41. data/processor/command/restart.rb +11 -10
  42. data/processor/command/save.rb +12 -9
  43. data/processor/command/set.rb +14 -15
  44. data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +1 -1
  45. data/processor/command/set_subcmd/debug_subcmd/skip.rb +1 -1
  46. data/processor/command/show.rb +7 -7
  47. data/processor/command/show_subcmd/alias.rb +3 -4
  48. data/processor/command/show_subcmd/args.rb +0 -2
  49. data/processor/command/show_subcmd/auto.rb +2 -3
  50. data/processor/command/show_subcmd/basename.rb +0 -3
  51. data/processor/command/show_subcmd/debug.rb +2 -1
  52. data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +1 -1
  53. data/processor/command/show_subcmd/different.rb +0 -3
  54. data/processor/command/show_subcmd/events.rb +0 -2
  55. data/processor/command/show_subcmd/macro.rb +2 -5
  56. data/processor/command/show_subcmd/max.rb +2 -1
  57. data/processor/command/show_subcmd/trace.rb +2 -2
  58. data/processor/command/source.rb +9 -8
  59. data/processor/command/step.rb +28 -29
  60. data/processor/command/stepi.rb +1 -1
  61. data/processor/command/unalias.rb +4 -5
  62. data/processor/command/undisplay.rb +4 -5
  63. data/processor/command/up.rb +9 -10
  64. data/processor/eval.rb +6 -2
  65. data/processor/frame.rb +32 -26
  66. data/processor/main.rb +1 -1
  67. data/processor/mock.rb +9 -3
  68. data/processor/running.rb +11 -7
  69. data/processor/validate.rb +1 -2
  70. data/test/functional/test-fn_helper.rb +42 -0
  71. data/test/functional/test-raise.rb +1 -1
  72. data/test/functional/test-return.rb +2 -2
  73. data/test/unit/test-app-util.rb +3 -4
  74. data/test/unit/test-base-subcmd.rb +2 -1
  75. data/test/unit/test-cmd-help.rb +4 -4
  76. data/test/unit/test-proc-frame.rb +1 -2
  77. data/test/unit/test-proc-main.rb +1 -1
  78. metadata +10 -7
@@ -50,12 +50,11 @@ end
50
50
 
51
51
  if __FILE__ == $0
52
52
  require_relative '../mock'
53
- name = File.basename(__FILE__, '.rb')
54
- dbgr, cmd = MockDebugger::setup(name)
53
+ dbgr, cmd = MockDebugger::setup
55
54
  cmdproc = dbgr.core.processor
56
- ['macro foo Proc.new{|x, y| x+y}',
57
- 'macro bad x+1',
58
- 'macro bad2 1+2'].each do |cmdline|
55
+ ["#{cmd.name} foo Proc.new{|x, y| x+y}",
56
+ "#{cmd.name} bad x+1",
57
+ "#{cmd.name} bad2 1+2"].each do |cmdline|
59
58
  args = cmdline.split
60
59
  cmd_argstr = cmdline[args[0].size..-1].lstrip
61
60
  cmdproc.instance_variable_set('@cmd_argstr', cmd_argstr)
@@ -5,13 +5,14 @@ require_relative 'base/cmd'
5
5
  class Trepan::Command::NextCommand < Trepan::Command
6
6
 
7
7
  unless defined?(HELP)
8
- HELP =
9
- "next[+|=|-|<|>|!|<>] [EVENT-NAME...] [count]
8
+ NAME = File.basename(__FILE__, '.rb')
9
+ HELP = <<-HELP
10
+ #{NAME}[+|=|-|<|>|!|<>] [EVENT-NAME...] [count]
10
11
 
11
12
  Step one statement ignoring steps into function calls at this level.
12
13
  Sometimes this is called 'step over'.
13
14
 
14
- With an integer argument, perform 'next' that many times. However if
15
+ With an integer argument, perform '#{NAME}' that many times. However if
15
16
  an exception occurs at this level, or we 'return' or 'yield' or the
16
17
  thread changes, we stop regardless of count.
17
18
 
@@ -24,29 +25,28 @@ If no suffix is given, the debugger setting 'different'
24
25
  determines this behavior.
25
26
 
26
27
  Examples:
27
- next # next 1 event, *any* event
28
- next 1 # same as above
29
- next+ # same but force stopping on a new line
30
- next= # same but force stopping on a new line a new frame added
31
- next- # same but force stopping on a new line a new frame added
32
- next 5/5+0 # same as above
33
- next line # next using only line events
34
- next call # next using only call call events
35
- next<> # next using call return events at this level or below
36
- "
28
+ #{NAME} # #{NAME} 1 event, *any* event
29
+ #{NAME} 1 # same as above
30
+ #{NAME}+ # same but force stopping on a new line
31
+ #{NAME}= # same but force stopping on a new line a new frame added
32
+ #{NAME}- # same but force stopping on a new line a new frame added
33
+ #{NAME} 5/5+0 # same as above
34
+ #{NAME} line # #{NAME} using only line events
35
+ #{NAME} call # #{NAME} using only call call events
36
+ #{NAME}<> # #{NAME} using call return events at this level or below
37
+ HELP
37
38
 
38
- ALIASES = %w(n next+ next- next< next> next<> next! n> n< n! n+ n-
39
+ ALIASES = %W(n #{NAME}+ #{NAME}- #{NAME}< #{NAME}> #{NAME}<> #{NAME}! n> n< n! n+ n-
39
40
  n<> n=)
40
41
  CATEGORY = 'running'
41
42
  # execution_set = ['Running']
42
43
  MAX_ARGS = 1 # Need at most this many. FIXME: will be eventually 2
43
- NAME = File.basename(__FILE__, '.rb')
44
44
  NEED_RUNNING = true
45
45
  SHORT_HELP = 'Step program without entering called functions'
46
46
  end
47
47
 
48
48
  # This method runs the command
49
- def run(args) # :nodoc
49
+ def run(args)
50
50
  opts = @proc.parse_next_step_suffix(args[0])
51
51
  if args.size == 1
52
52
  # Form is: "next" which means "next 1"
@@ -55,7 +55,7 @@ Examples:
55
55
  count_str = args[1]
56
56
  opts = {
57
57
  :msg_on_error =>
58
- "The 'next' command argument must eval to an integer. Got: %s" %
58
+ "The '#{NAME}' command argument must eval to an integer. Got: %s" %
59
59
  count_str,
60
60
  :min_value => 1
61
61
  }
@@ -70,9 +70,8 @@ end
70
70
 
71
71
  if __FILE__ == $0
72
72
  require_relative '../mock'
73
- name = File.basename(__FILE__, '.rb')
74
- dbgr, cmd = MockDebugger::setup(name)
75
- [%w(n 5), %w(next 1+2), %w(n foo)].each do |c|
73
+ dbgr, cmd = MockDebugger::setup
74
+ [%w(n 5), %W(#{cmd.name} 1+2), %w(n foo)].each do |c|
76
75
  dbgr.core.step_count = 0
77
76
  cmd.proc.leave_cmd_loop = false
78
77
  result = cmd.run(c)
@@ -15,7 +15,7 @@ class Trepan::Command::NoCacheCommand < Trepan::Command
15
15
  end
16
16
 
17
17
  # This method runs the command
18
- def run(args) # :nodoc
18
+ def run(args)
19
19
  if @proc.frame.iseq
20
20
  puts @proc.frame.iseq.disassemble
21
21
  count = @proc.frame.iseq.killcache
@@ -27,7 +27,6 @@ end
27
27
 
28
28
  if __FILE__ == $0
29
29
  require_relative '../mock'
30
- name = File.basename(__FILE__, '.rb')
31
- dbgr, cmd = MockDebugger::setup(name)
32
- cmd.run([name])
30
+ dbgr, cmd = MockDebugger::setup
31
+ cmd.run([cmd.name])
33
32
  end
@@ -2,22 +2,25 @@
2
2
  # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require_relative 'base/cmd'
4
4
  require_relative '../eval'
5
- class Trepan::Command::PrintCommand < Trepan::Command
5
+ class Trepan::Command::PrCommand < Trepan::Command
6
6
 
7
7
  unless defined?(HELP)
8
- HELP =
9
- "print EXPRESSION
8
+ NAME = File.basename(__FILE__, '.rb')
9
+ HELP = <<-HELP
10
+ "#{NAME} EXPRESSION
10
11
 
11
12
  Print the value of the EXPRESSION. Variables accessible are those of the
12
13
  environment of the selected stack frame, plus globals.
13
14
 
14
15
  If the length output string large, the first part of the value is
15
- shown and ... indicates it has been truncated."
16
+ shown and ... indicates it has been truncated.
17
+
18
+ See 'set max string' to change the string truncation limit.
19
+ HELP
16
20
 
17
21
  # ALIASES = %w(p)
18
22
  CATEGORY = 'data'
19
- NAME = File.basename(__FILE__, '.rb')
20
- SHORT_HELP = 'Print expression'
23
+ SHORT_HELP = 'print expression truncating long output'
21
24
  end
22
25
 
23
26
  def run(args)
@@ -27,11 +30,10 @@ end
27
30
 
28
31
  if __FILE__ == $0
29
32
  require_relative '../mock'
30
- name = File.basename(__FILE__, '.rb')
31
- dbgr, cmd = MockDebugger::setup(name)
33
+ dbgr, cmd = MockDebugger::setup
32
34
  arg_str = '1 + 2'
33
35
  cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
34
- cmd.run([name, arg_str])
36
+ cmd.run([cmd.name, arg_str])
35
37
  cmdproc = dbgr.core.processor
36
38
  cmds = dbgr.core.processor.commands
37
39
  end
@@ -5,14 +5,15 @@ require_relative '../eval'
5
5
  class Trepan::Command::PsCommand < Trepan::Command
6
6
 
7
7
  unless defined?(HELP)
8
- HELP =
9
- "ps ARRAY
8
+ NAME = File.basename(__FILE__, '.rb')
9
+ HELP = <<-HELP
10
+ #{NAME} ARRAY
10
11
 
11
- Print the value of the ARRAY in columns and sorted."
12
+ Print the value of the ARRAY in columns and sorted.
13
+ HELP
12
14
 
13
15
  CATEGORY = 'data'
14
16
  MIN_ARGS = 1 # Need least this many
15
- NAME = File.basename(__FILE__, '.rb')
16
17
  SHORT_HELP = 'Print array sorted and in columns'
17
18
  end
18
19
 
@@ -29,12 +30,11 @@ end
29
30
 
30
31
  if __FILE__ == $0
31
32
  require_relative '../mock'
32
- name = File.basename(__FILE__, '.rb')
33
- dbgr, cmd = MockDebugger::setup(name)
33
+ dbgr, cmd = MockDebugger::setup
34
34
  arg_str = '(1..30).to_a'
35
35
  cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
36
- cmd.run([name, arg_str])
36
+ cmd.run([cmd.name, arg_str])
37
37
  arg_str = '1'
38
38
  cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
39
- cmd.run([name, arg_str])
39
+ cmd.run([cmd.name, arg_str])
40
40
  end
@@ -3,8 +3,11 @@ require_relative 'base/cmd'
3
3
  class Trepan::Command::QuitCommand < Trepan::Command
4
4
 
5
5
  unless defined?(HELP)
6
- HELP =
7
- 'quit[!] [unconditionally] [exit code] - gentle termination
6
+ NAME = File.basename(__FILE__, '.rb')
7
+ HELP = <<-HELP
8
+ #{NAME}[!] [unconditionally] [exit code]
9
+
10
+ gentle termination
8
11
 
9
12
  The program being debugged is exited via exit() which runs the Kernel
10
13
  at_exit finalizers. If a return code is given, that is the return code
@@ -12,17 +15,17 @@ passed to exit() - presumably the return code that will be passed back
12
15
  to the OS. If no exit code is given, 0 is used.
13
16
 
14
17
  Examples:
15
- quit # quit prompting if we are interactive
16
- quit conditionally # quit without prompting
17
- quit! # same as above
18
- quit 0 # same as "quit"
19
- quit! 1 # unconditional quit setting exit code 1
18
+ #{NAME} # quit prompting if we are interactive
19
+ #{NAME} conditionally # quit without prompting
20
+ #{NAME}! # same as above
21
+ #{NAME} 0 # same as "quit"
22
+ #{NAME}! 1 # unconditional quit setting exit code 1
20
23
 
21
- See also the commands "exit" and "kill".'
24
+ See also the commands "exit" and "kill".
25
+ HELP
22
26
 
23
- ALIASES = %w(quit! q q!)
27
+ ALIASES = %W(#{NAME}! q q!)
24
28
  CATEGORY = 'support'
25
- NAME = File.basename(__FILE__, '.rb')
26
29
  MAX_ARGS = 2 # Need at most this many
27
30
  SHORT_HELP = 'Quit program - gently'
28
31
  end
@@ -31,7 +34,7 @@ See also the commands "exit" and "kill".'
31
34
  # whether exit! or exit is used.
32
35
 
33
36
  # This method runs the command
34
- def run(args) # :nodoc
37
+ def run(args)
35
38
  unconditional =
36
39
  if args.size > 1 && args[1] == 'unconditionally'
37
40
  args.shift
@@ -54,9 +57,8 @@ end
54
57
 
55
58
  if __FILE__ == $0
56
59
  require_relative '../mock'
60
+ dbgr, cmd = MockDebugger::setup
57
61
  name = File.basename(__FILE__, '.rb')
58
- dbgr, cmd = MockDebugger::setup(name)
59
- name = File.basename(__FILE__, '.rb')
60
- fork { cmd.run([name]) }
61
- cmd.run([name, '5'])
62
+ fork { cmd.run([cmd.name]) }
63
+ cmd.run([cmd.name, '5'])
62
64
  end
@@ -3,19 +3,21 @@ require_relative 'base/cmd'
3
3
  class Trepan::Command::RaiseCommand < Trepan::Command
4
4
 
5
5
  unless defined?(HELP)
6
- HELP =
7
- "raise EXCEPTION
6
+ NAME = File.basename(__FILE__, '.rb')
7
+ HELP = <<-HELP
8
+ #{NAME} [exception-name]
8
9
 
9
- Raise an exception in the debugged program."
10
+ Raise an EXCEPTION-NAME in the debugged program. If no exception name
11
+ is given, raise RuntimeError.
12
+ HELP
10
13
 
11
14
  CATEGORY = 'running'
12
15
  MAX_ARGS = 1 # Need at most this many
13
- NAME = File.basename(__FILE__, '.rb')
14
16
  SHORT_HELP = 'Raise an exception in the debugged program'
15
17
  end
16
18
 
17
19
  # This method runs the command
18
- def run(args) # :nodoc
20
+ def run(args)
19
21
  exception =
20
22
  if args.size > 1
21
23
  except_str = args[1..-1].join(' ')
@@ -39,9 +41,8 @@ end
39
41
 
40
42
  if __FILE__ == $0
41
43
  require_relative '../mock'
42
- name = File.basename(__FILE__, '.rb')
43
- dbgr, cmd = MockDebugger::setup(name)
44
- puts cmd.run([name, 'NotanException'])
45
- puts cmd.run([name, '[5]'])
46
- puts cmd.run([name, 'RuntimeError'])
44
+ dbgr, cmd = MockDebugger::setup
45
+ puts cmd.run([cmd.name, 'NotanException'])
46
+ puts cmd.run([cmd.name, '[5]'])
47
+ puts cmd.run([cmd.name, 'RuntimeError'])
47
48
  end
@@ -3,10 +3,10 @@
3
3
  require_relative 'base/submgr'
4
4
 
5
5
  class Trepan::Command::ReloadCommand < Trepan::SubcommandMgr
6
+ NAME = File.basename(__FILE__, '.rb')
6
7
  ALIASES = %w(rel)
7
8
  HELP = 'Reload information'
8
9
  CATEGORY = 'data'
9
- NAME = File.basename(__FILE__, '.rb')
10
10
  NEED_STACK = false
11
11
  SHORT_HELP = 'Reload information'
12
12
  def initialize(proc)
@@ -17,12 +17,11 @@ end
17
17
 
18
18
  if __FILE__ == $0
19
19
  require_relative '../mock'
20
- name = File.basename(__FILE__, '.rb')
21
- dbgr, cmd = MockDebugger::setup(name)
20
+ dbgr, cmd = MockDebugger::setup
22
21
 
23
22
  # require 'trepanning'
24
23
  # Trepan.debug(:set_restart => true)
25
24
  xx = Trepan::Command::ReloadCommand.new(cmd)
26
- cmd.run([name])
27
- cmd.run([name, 'command'])
25
+ cmd.run([cmd.name])
26
+ cmd.run([cmd.name, 'command'])
28
27
  end
@@ -5,19 +5,22 @@ require_relative '../../app/run'
5
5
  class Trepan::Command::RestartCommand < Trepan::Command
6
6
 
7
7
  unless defined?(HELP)
8
+ NAME = File.basename(__FILE__, '.rb')
8
9
  ALIASES = %w(R run)
9
- HELP =
10
- 'restart - Restart debugger and program via an exec
11
- call. All state is lost, and new copy of the debugger is used.'
10
+ HELP = <<-HELP
11
+ #{NAME}
12
+
13
+ Restart debugger and program via an exec call. All state is lost, and
14
+ new copy of the debugger is used.
15
+ HELP
12
16
 
13
17
  CATEGORY = 'running'
14
18
  MAX_ARGS = 0 # Need at most this many
15
- NAME = File.basename(__FILE__, '.rb')
16
19
  SHORT_HELP = '(Hard) restart of program via exec()'
17
20
  end
18
21
 
19
22
  # This method runs the command
20
- def run(args) # :nodoc
23
+ def run(args)
21
24
 
22
25
  dbgr = @proc.dbgr
23
26
  argv = dbgr.restart_argv
@@ -46,12 +49,10 @@ end
46
49
 
47
50
  if __FILE__ == $0
48
51
  exit if ARGV[0] == 'exit'
49
-
50
52
  require_relative '../mock'
51
- name = File.basename(__FILE__, '.rb')
52
- dbgr, cmd = MockDebugger::setup(name)
53
+ dbgr, cmd = MockDebugger::setup
53
54
  dbgr.restart_argv = []
54
- cmd.run([name])
55
+ cmd.run([cmd.name])
55
56
  dbgr.restart_argv = [File.expand_path($0), 'exit']
56
- cmd.run([name])
57
+ cmd.run([cmd.name])
57
58
  end
@@ -4,17 +4,21 @@ require_relative 'base/cmd'
4
4
  class Trepan::Command::SaveCommand < Trepan::Command
5
5
 
6
6
  unless defined?(HELP)
7
- HELP =
8
- "Save settings to a file"
7
+ NAME = File.basename(__FILE__, '.rb')
8
+ HELP = <<-HELP
9
+ #{NAME} [filename]
10
+
11
+ Save settings to file FILENAME. If FILENAME not given one will be made
12
+ selected.
13
+ HELP
9
14
 
10
15
  CATEGORY = 'running'
11
16
  MAX_ARGS = 1 # Need at most this many
12
- NAME = File.basename(__FILE__, '.rb')
13
17
  SHORT_HELP = 'Send debugger state to a file'
14
18
  end
15
19
 
16
20
  # This method runs the command
17
- def run(args) # :nodoc
21
+ def run(args)
18
22
  save_filename =
19
23
  if args.size > 1
20
24
  args[1]
@@ -51,10 +55,9 @@ end
51
55
 
52
56
  if __FILE__ == $0
53
57
  require_relative '../mock'
54
- name = File.basename(__FILE__, '.rb')
55
- dbgr, cmd = MockDebugger::setup(name)
58
+ dbgr, cmd = MockDebugger::setup
56
59
  require 'tmpdir'
57
- cmd.run([name, Dir.tmpdir])
58
- cmd.run([name])
59
- cmd.run([name, File.join(Dir.tmpdir, 'save_file.txt')])
60
+ cmd.run([cmd.name, Dir.tmpdir])
61
+ cmd.run([cmd.name])
62
+ cmd.run([cmd.name, File.join(Dir.tmpdir, 'save_file.txt')])
60
63
  end
@@ -4,22 +4,22 @@ require_relative 'base/submgr'
4
4
 
5
5
  class Trepan::Command::SetCommand < Trepan::SubcommandMgr
6
6
  unless defined?(HELP)
7
- HELP =
8
- 'Modifies parts of the debugger environment.
7
+ NAME = File.basename(__FILE__, '.rb')
8
+ HELP = <<-HELP
9
+ Modifies parts of the debugger environment.
9
10
 
10
11
  You can give unique prefix of the name of a subcommand to get
11
12
  information about just that subcommand.
12
13
 
13
- Type "set" for a list of "set" subcommands and what they do.
14
- Type "help set *" for just the list of "set" subcommands.
14
+ Type "#{NAME}" for a list of "#{NAME}" subcommands and what they do.
15
+ Type "help #{NAME} *" for just the list of "#{NAME}" subcommands.
15
16
 
16
- For compatability with older ruby-debug "set auto..." is the
17
- same as "set auto ...". For example "set autolist" is the same
18
- as "set auto list".
19
- '
17
+ For compatability with older ruby-debug "#{NAME} auto..." is the
18
+ same as "#{NAME} auto ...". For example "#{NAME} autolist" is the same
19
+ as "#{NAME} auto list".
20
+ HELP
20
21
 
21
22
  CATEGORY = 'support'
22
- NAME = File.basename(__FILE__, '.rb')
23
23
  NEED_STACK = false
24
24
  SHORT_HELP = 'Modify parts of the debugger environment'
25
25
  end
@@ -38,10 +38,9 @@ end
38
38
 
39
39
  if __FILE__ == $0
40
40
  require_relative '../mock'
41
- name = File.basename(__FILE__, '.rb')
42
- dbgr, cmd = MockDebugger::setup(name)
43
- cmd.run([name])
44
- cmd.run([name, 'autolist'])
45
- cmd.run([name, 'autoeval', 'off'])
46
- cmd.run([name, 'basename'])
41
+ dbgr, cmd = MockDebugger::setup
42
+ cmd.run([cmd.name])
43
+ cmd.run([cmd.name, 'autolist'])
44
+ cmd.run([cmd.name, 'autoeval', 'off'])
45
+ cmd.run([cmd.name, 'basename'])
47
46
  end