trepanning 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/ChangeLog +214 -0
  2. data/NEWS +12 -0
  3. data/README.textile +1 -7
  4. data/Rakefile +13 -0
  5. data/app/default.rb +5 -4
  6. data/app/disassemble.rb +25 -3
  7. data/app/run.rb +0 -18
  8. data/bin/trepan +4 -6
  9. data/data/irbrc +3 -17
  10. data/io/base_io.rb +3 -1
  11. data/io/null_output.rb +41 -0
  12. data/lib/trepanning.rb +10 -13
  13. data/processor/command/backtrace.rb +7 -6
  14. data/processor/command/base/subcmd.rb +4 -0
  15. data/processor/command/base/submgr.rb +1 -1
  16. data/processor/command/base/subsubmgr.rb +1 -1
  17. data/processor/command/break.rb +12 -4
  18. data/processor/command/continue.rb +2 -2
  19. data/processor/command/delete.rb +1 -1
  20. data/processor/command/disable.rb +1 -1
  21. data/processor/command/disassemble.rb +1 -1
  22. data/processor/command/finish.rb +3 -3
  23. data/processor/command/info_subcmd/iseq.rb +9 -0
  24. data/processor/command/info_subcmd/registers_subcmd/dfp.rb +7 -16
  25. data/processor/command/info_subcmd/registers_subcmd/lfp.rb +5 -17
  26. data/processor/command/info_subcmd/registers_subcmd/pc.rb +6 -19
  27. data/processor/command/info_subcmd/registers_subcmd/sp.rb +14 -24
  28. data/processor/command/list.rb +34 -19
  29. data/processor/command/reload.rb +1 -1
  30. data/processor/command/restart.rb +8 -9
  31. data/processor/command/set_subcmd/auto.rb +1 -2
  32. data/processor/command/set_subcmd/auto_subcmd/eval.rb +6 -19
  33. data/processor/command/set_subcmd/auto_subcmd/irb.rb +7 -23
  34. data/processor/command/set_subcmd/auto_subcmd/list.rb +5 -22
  35. data/processor/command/set_subcmd/basename.rb +6 -20
  36. data/processor/command/set_subcmd/debug.rb +1 -1
  37. data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +9 -22
  38. data/processor/command/set_subcmd/debug_subcmd/except.rb +8 -20
  39. data/processor/command/set_subcmd/debug_subcmd/macro.rb +7 -19
  40. data/processor/command/set_subcmd/debug_subcmd/skip.rb +5 -18
  41. data/processor/command/set_subcmd/debug_subcmd/stack.rb +5 -18
  42. data/processor/command/set_subcmd/hidelevel.rb +60 -0
  43. data/processor/command/set_subcmd/max.rb +1 -1
  44. data/processor/command/set_subcmd/max_subcmd/list.rb +12 -23
  45. data/processor/command/set_subcmd/max_subcmd/stack.rb +8 -31
  46. data/processor/command/set_subcmd/substitute.rb +1 -1
  47. data/processor/command/set_subcmd/substitute_subcmd/eval.rb +1 -1
  48. data/processor/command/set_subcmd/substitute_subcmd/path.rb +1 -1
  49. data/processor/command/set_subcmd/substitute_subcmd/string.rb +6 -18
  50. data/processor/command/set_subcmd/timer.rb +1 -1
  51. data/processor/command/set_subcmd/trace.rb +1 -1
  52. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +1 -1
  53. data/processor/command/set_subcmd/trace_subcmd/print.rb +5 -21
  54. data/processor/command/set_subcmd/trace_subcmd/var.rb +1 -1
  55. data/processor/command/show_subcmd/args.rb +9 -27
  56. data/processor/command/show_subcmd/auto_subcmd/eval.rb +3 -15
  57. data/processor/command/show_subcmd/auto_subcmd/irb.rb +3 -15
  58. data/processor/command/show_subcmd/auto_subcmd/list.rb +3 -18
  59. data/processor/command/show_subcmd/basename.rb +3 -1
  60. data/processor/command/show_subcmd/hidelevel.rb +41 -0
  61. data/processor/command/show_subcmd/max.rb +1 -1
  62. data/processor/command/show_subcmd/trace_subcmd/buffer.rb +1 -1
  63. data/processor/command/show_subcmd/trace_subcmd/print.rb +1 -1
  64. data/processor/command/source.rb +6 -5
  65. data/processor/command/undisplay.rb +0 -1
  66. data/processor/default.rb +6 -2
  67. data/processor/frame.rb +2 -21
  68. data/processor/location.rb +44 -18
  69. data/processor/main.rb +0 -11
  70. data/processor/mock.rb +25 -0
  71. data/processor/validate.rb +34 -18
  72. data/test/functional/fn_helper.rb +14 -4
  73. data/test/functional/test-break.rb +35 -73
  74. data/test/functional/test-condition.rb +9 -10
  75. data/test/functional/test-delete.rb +5 -3
  76. data/test/unit/test-app-disassemble.rb +15 -3
  77. data/test/unit/test-app-run.rb +0 -4
  78. data/test/unit/test-cmd-break.rb +3 -0
  79. metadata +15 -11
@@ -5,7 +5,7 @@ require_relative 'base/cmd'
5
5
 
6
6
  class Trepan::Command::ListCommand < Trepan::Command
7
7
  unless defined?(HELP)
8
- NAME = File.basename(__FILE__, '.rb')
8
+ NAME = File.basename(__FILE__, '.rb')
9
9
  HELP = <<-HELP
10
10
  #{NAME}[>] [MODULE] [FIRST [NUM]]
11
11
  #{NAME}[>] LOCATION [NUM]
@@ -19,7 +19,7 @@ frame. If a subsequent #{NAME} command was issued with no intervening
19
19
  frame changing, then that is start the line after we last one
20
20
  previously shown.
21
21
 
22
- If the command has a '>' suffix, then lines centering is disabled and
22
+ If the command has a '>' suffix, then line centering is disabled and
23
23
  listing begins at the specificed location.
24
24
 
25
25
  The number of line to show is controled by the debugger listsize
@@ -59,6 +59,8 @@ Some examples:
59
59
  #{NAME} foo.rb:5 2 # Same as above
60
60
  #{NAME} FileUtils.cp # List lines around the FileUtils.cp function.
61
61
  #{NAME} . # List lines centered from where we currently are stopped
62
+ #{NAME} . 3 # List 3 lines starting from where we currently are stopped
63
+ # if . > 3. Otherwise we list from . to 3.
62
64
  #{NAME} - # List lines previous to those just shown
63
65
 
64
66
  The output of the #{NAME} command give a line number, and some status
@@ -84,6 +86,12 @@ disabled.
84
86
  SHORT_HELP = 'List source code'
85
87
  end
86
88
 
89
+ # If last is less than first, assume last is a count rather than an
90
+ # end line number.
91
+ def adjust_last(first, last)
92
+ last < first ? first + last - 1 : last
93
+ end
94
+
87
95
  # What a f*cking mess. Necessitated I suppose because we want to
88
96
  # allow somewhat flexible parsing with either module names, files or none
89
97
  # and optional line counts or end-line numbers.
@@ -122,7 +130,20 @@ disabled.
122
130
  first = [1, @proc.line_no - 2*listsize - 1].max
123
131
  elsif args[0] == '.'
124
132
  return no_frame_msg unless @proc.line_no
125
- first = [1, @proc.frame_line - center_correction].max
133
+ if args.size == 2
134
+ opts = {
135
+ :msg_on_error =>
136
+ "#{NAME} command last or count parameter expected, " +
137
+ 'got: %s.' % args[2]
138
+ }
139
+ second = @proc.get_an_int(args[1], opts)
140
+ return nil, nil, nil unless second
141
+ first = @proc.frame_line
142
+ last = adjust_last(first, second)
143
+ else
144
+ first = [1, @proc.frame_line - center_correction].max
145
+ end
146
+
126
147
  else
127
148
  modfunc, container, first = @proc.parse_position(args[0])
128
149
  if first == nil and modfunc == nil
@@ -135,29 +156,23 @@ disabled.
135
156
  elsif args.size == 2 or (args.size == 3 and modfunc)
136
157
  opts = {
137
158
  :msg_on_error =>
138
- 'Starting line expected, got %s.' % args[-1]
159
+ "#{NAME} command starting line expected, got %s." % args[-1]
139
160
  }
140
- num = @proc.get_an_int(args[1], opts)
141
-
142
- return nil, nil, nil unless num
161
+ last = @proc.get_an_int(args[1], opts)
162
+ return nil, nil, nil unless last
143
163
  if modfunc
144
164
  if first
145
- first = num
165
+ first = last
146
166
  if args.size == 3 and modfunc
147
- opts[:msg_on_error] = ('last or count parameter expected, ' +
148
- 'got: %s.' % args[2])
167
+ opts[:msg_on_error] =
168
+ ("#{NAME} command last or count parameter expected, " +
169
+ 'got: %s.' % args[2])
149
170
  last = @proc.get_an_int(args[2], opts)
171
+ return nil, nil, nil unless last
150
172
  end
151
- else
152
- last = num
153
173
  end
154
- else
155
- first = num - center_correction
156
- end
157
- if last and last < first
158
- # Assume last is a count rather than an end line number
159
- last = first + last - 1
160
174
  end
175
+ last = adjust_last(first, last)
161
176
  elsif not modfunc
162
177
  errmsg('At most 2 parameters allowed when no module' +
163
178
  ' name is found/given. Saw: %d parameters' % args.size)
@@ -168,7 +183,7 @@ disabled.
168
183
  return nil, nil, nil
169
184
  end
170
185
  end
171
- elsif !@proc.line_no and frame
186
+ elsif !@proc.line_no and @proc.frame
172
187
  first = [1, @proc.frame_line - center_correction].max
173
188
  else
174
189
  first = [1, @proc.line_no - center_correction].max
@@ -20,7 +20,7 @@ if __FILE__ == $0
20
20
  dbgr, cmd = MockDebugger::setup
21
21
 
22
22
  # require 'trepanning'
23
- # Trepan.debug(:set_restart => true)
23
+ # Trepan.debug
24
24
  xx = Trepan::Command::ReloadCommand.new(cmd)
25
25
  cmd.run([cmd.name])
26
26
  cmd.run([cmd.name, 'command'])
@@ -25,20 +25,19 @@ new copy of the debugger is used.
25
25
  dbgr = @proc.dbgr
26
26
  argv = dbgr.restart_argv
27
27
  if argv and argv.size > 0
28
- unless File.executable?(argv[0])
29
- msg(["File #{argv[0]} not executable.",
30
- "Adding Ruby interpreter."])
31
- argv.unshift Trepanning::ruby_path
32
- end
28
+ # unless File.executable?(argv[0])
29
+ # msg(["File #{argv[0]} not executable.",
30
+ # "Adding Ruby interpreter."])
31
+ # argv.unshift Trepanning::ruby_path
32
+ # end
33
33
  @proc.run_cmd(%w(show args))
34
34
  if not confirm('Restart (exec)?', false)
35
35
  msg "Restart not confirmed"
36
36
  else
37
37
  msg 'Restarting...'
38
38
  @proc.run_cmd(%w(save))
39
- argv.unshift
40
39
  # FIXME: Run atexit finalize routines?
41
- Dir.chdir(dbgr.initial_dir) if dbgr.initial_dir
40
+ Dir.chdir(RubyVM::OS_STARTUP_DIR)
42
41
  exec(*argv)
43
42
  end
44
43
  else
@@ -48,11 +47,11 @@ new copy of the debugger is used.
48
47
  end
49
48
 
50
49
  if __FILE__ == $0
51
- exit if ARGV[0] == 'exit'
50
+ exit if ARGV[-1] == 'exit'
52
51
  require_relative '../mock'
53
52
  dbgr, cmd = MockDebugger::setup
54
53
  dbgr.restart_argv = []
55
54
  cmd.run([cmd.name])
56
- dbgr.restart_argv = [File.expand_path($0), 'exit']
55
+ dbgr.restart_argv = RubyVM::OS_ARGV + ['exit']
57
56
  cmd.run([cmd.name])
58
57
  end
@@ -18,10 +18,9 @@ if __FILE__ == $0
18
18
  set_cmd = cmds['set']
19
19
  command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
20
20
  set_cmd)
21
- name = File.basename(__FILE__, '.rb')
22
21
  cmd_args = ['set', name]
23
22
  set_cmd.instance_variable_set('@last_args', cmd_args)
24
23
  # require_relative '../../../lib/trepanning'
25
- # Trepan.debug(:set_restart => true)
24
+ # Trepan.debug
26
25
  command.run(cmd_args)
27
26
  end
@@ -36,7 +36,7 @@ problem. Another possibility is to go into a real Ruby shell via the
36
36
  "
37
37
  MIN_ABBREV = 'ev'.size
38
38
  NAME = File.basename(__FILE__, '.rb')
39
- PREFIX = %w(set auto eval)
39
+ PREFIX = %W(set auto #{NAME})
40
40
  SHORT_HELP = "Set evaluation of unrecognized debugger commands"
41
41
  end
42
42
 
@@ -45,23 +45,10 @@ end
45
45
  if __FILE__ == $0
46
46
  # Demo it.
47
47
  require_relative '../../../mock'
48
- name = File.basename(__FILE__, '.rb')
49
-
50
- # FIXME: DRY the below code
51
- dbgr, set_cmd = MockTrepan::setup('set')
52
- auto_cmd = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
53
- set_cmd)
54
-
55
- # FIXME: remove the 'join' below
56
- cmd_name = Trepan::SubSubcommand::SetAutoEval::PREFIX.join('')
57
- subcmd = Trepan::SubSubcommand::SetAutoEval.new(set_cmd.proc,
58
- auto_cmd,
59
- cmd_name)
60
- # require_relative '../../../../lib/trepanning'
61
- # Trepan.debug(:set_restart => true)
62
-
63
- subcmd.run([cmd_name])
64
- %w(off on 0 1).each { |arg| subcmd.run([cmd_name, arg]) }
48
+ require_relative '../auto'
49
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
50
+ Trepan::SubSubcommand::SetAutoEval)
51
+ %w(off on 0 1).each { |arg| cmd.run([cmd.name, arg]) }
65
52
  puts '-' * 10
66
- puts subcmd.save_command.join("\n")
53
+ puts cmd.save_command.join("\n")
67
54
  end
@@ -7,7 +7,7 @@ class Trepan::Subcommand::SetAutoIrb < Trepan::SetBoolSubSubcommand
7
7
  HELP = "Set to automatically go into irb each time we enter the debugger"
8
8
  MIN_ABBREV = 'ir'.size
9
9
  NAME = File.basename(__FILE__, '.rb')
10
- PREFIX = %w(set auto irb)
10
+ PREFIX = %W(set auto #{NAME})
11
11
  end
12
12
 
13
13
  def run(args)
@@ -24,26 +24,10 @@ end
24
24
  if __FILE__ == $0
25
25
  # Demo it.
26
26
  require_relative '../../../mock'
27
- require_relative '../../../subcmd'
28
- require_relative '../../../hook'
29
- name = File.basename(__FILE__, '.rb')
30
-
31
- # FIXME: DRY the below code
32
- dbgr, set_cmd = MockTrepan::setup('set')
33
- auto_cmd = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
34
- set_cmd)
35
- # FIXME: remove the 'join' below
36
- cmd_name = Trepan::Subcommand::SetAutoIrb::PREFIX.join('')
37
- autox_cmd = Trepan::SubSubcommand::SetAutoIrb.new(set_cmd.proc,
38
- auto_cmd,
39
- cmd_name)
40
- # require_relative '../../../../lib/trepanning'
41
- # dbgr = Trepan.new(:set_restart => true)
42
- # dbgr.debugger
43
- set_cmd.proc.hook_initialize(set_cmd.proc.commands)
44
- subcmd_name = Trepan::Subcommand::SetAutoIrb::PREFIX[1..-1].join('')
45
- autox_cmd.run([subcmd_name])
46
- autox_cmd.run([subcmd_name, 'off'])
47
- puts autox_cmd.save_command.join("\n")
48
-
27
+ require_relative '../auto'
28
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
29
+ Trepan::SubSubcommand::SetAutoIrb)
30
+ %w(off on 0 1).each { |arg| cmd.run([cmd.name, arg]) }
31
+ puts '-' * 10
32
+ puts cmd.save_command.join("\n")
49
33
  end
@@ -25,27 +25,10 @@ end
25
25
  if __FILE__ == $0
26
26
  # Demo it.
27
27
  require_relative '../../../mock'
28
- require_relative '../../../subcmd'
29
- require_relative '../../../hook'
30
- name = File.basename(__FILE__, '.rb')
31
-
32
- # FIXME: DRY the below code
33
- dbgr, set_cmd = MockDebugger::setup('set')
34
- testcmdMgr = Trepan::Subcmd.new(set_cmd)
35
- auto_cmd = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
36
- set_cmd)
37
- # FIXME: remove the 'join' below
38
- cmd_name = Trepan::Subcommand::SetAutoList::PREFIX.join('')
39
- autox_cmd = Trepan::SubSubcommand::SetAutoList.new(set_cmd.proc,
40
- auto_cmd,
41
- cmd_name)
42
- # require_relative '../../../../lib/trepanning'
43
- # dbgr = Trepan.new(:set_restart => true)
44
- # dbgr.debugger
45
- set_cmd.proc.hook_initialize(set_cmd.proc.commands)
46
- subcmd_name = Trepan::Subcommand::SetAutoList::PREFIX[1..-1].join('')
47
- autox_cmd.run([subcmd_name])
48
- autox_cmd.run([subcmd_name, 'off'])
28
+ require_relative '../auto'
29
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
30
+ Trepan::SubSubcommand::SetAutoList)
31
+ %w(off on 0 1).each { |arg| cmd.run([cmd.name, arg]) }
49
32
  puts '-' * 10
50
- puts autox_cmd.save_command
33
+ puts cmd.save_command.join("\n")
51
34
  end
@@ -15,25 +15,11 @@ end
15
15
 
16
16
  if __FILE__ == $0
17
17
  # Demo it.
18
+ $0 = __FILE__ + 'notagain' # So we don't run this agin
18
19
  require_relative '../../mock'
19
- name = File.basename(__FILE__, '.rb')
20
-
21
- # FIXME: DRY the below code
22
- dbgr, cmd = MockDebugger::setup('set')
23
- subcommand = Trepan::Subcommand::SetBasename.new(cmd)
24
- testcmdMgr = Trepan::Subcmd.new(subcommand)
25
-
26
- subcommand.run_show_bool
27
- subcommand.summary_help(name)
28
-
29
- # require 'trepanning'
30
- # Trepan.debug(:set_restart => true)
31
- subcommand.run(['set', name])
32
- subcommand.run(['set', name, 'off'])
33
- subcommand.run(['set', name, 'on'])
34
- subcommand.summary_help(name)
35
- puts
36
- puts '-' * 20
37
- puts subcommand.save_command
38
-
20
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetBasename, false)
21
+ cmd.run(cmd.prefix + ['off'])
22
+ cmd.run(cmd.prefix + ['ofn'])
23
+ cmd.run(cmd.prefix)
24
+ puts cmd.save_command
39
25
  end
@@ -22,6 +22,6 @@ if __FILE__ == $0
22
22
  cmd_args = ['set', name]
23
23
  set_cmd.instance_variable_set('@last_args', cmd_args)
24
24
  # require_relative '../../../lib/trepanning'
25
- # Trepan.debug(:set_restart => true)
25
+ # Trepan.debug
26
26
  command.run(cmd_args)
27
27
  end
@@ -4,15 +4,15 @@ require_relative '../../base/subsubcmd'
4
4
 
5
5
  class Trepan::SubSubcommand::SetDebugDbgr < Trepan::SetBoolSubSubcommand
6
6
  unless defined?(HELP)
7
- HELP = 'set debug dbgr [on|off]
7
+ NAME = File.basename(__FILE__, '.rb')
8
+ PREFIX = %W(set debug #{NAME})
9
+ HELP = "#{PREFIX.join(" ")} [on|off]
8
10
 
9
11
  Facilitates debugging the debugger. Global variables $trepan_cmdproc
10
12
  and $trepan_frame are set to the current values of @frame and self
11
- when the command processor was entered. '
13
+ when the command processor was entered."
12
14
 
13
15
  MIN_ABBREV = 'db'.size
14
- NAME = File.basename(__FILE__, '.rb')
15
- PREFIX = %W(set debug #{NAME})
16
16
  SHORT_HELP = 'Set debugging debugger'
17
17
  end
18
18
 
@@ -27,23 +27,10 @@ end
27
27
  if __FILE__ == $0
28
28
  # Demo it.
29
29
  require_relative '../../../mock'
30
- name = File.basename(__FILE__, '.rb')
31
-
32
- # FIXME: DRY the below code
33
- dbgr, dbg_cmd = MockDebugger::setup('set')
34
- debug_cmd = Trepan::SubSubcommand::SetDebug.new(dbgr.core.processor,
35
- dbg_cmd)
36
- # FIXME: remove the 'join' below
37
- cmd_name = Trepan::SubSubcommand::SetDebugDbgr::PREFIX.join('')
38
- debugx_cmd = Trepan::SubSubcommand::SetDebugDbgr.new(dbg_cmd.proc,
39
- debug_cmd,
40
- cmd_name)
41
- # require_relative '../.././../lib/trepanning'
42
- # dbgr = Trepan.new(:set_restart => true)
43
- # dbgr.debugger
44
- debugx_cmd.run([name])
45
- debugx_cmd.run([name, 'on'])
46
- debugx_cmd.run([name, 'off'])
30
+ require_relative '../debug'
31
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
32
+ Trepan::SubSubcommand::SetDebugDbgr)
33
+ %w(off on 0 1).each { |arg| cmd.run([cmd.name, arg]) }
47
34
  puts '-' * 10
48
- puts debugx_cmd.save_command
35
+ puts cmd.save_command.join("\n")
49
36
  end
@@ -5,31 +5,19 @@ require_relative '../../base/subsubcmd'
5
5
  class Trepan::SubSubcommand::SetDebugExcept < Trepan::SetBoolSubSubcommand
6
6
  unless defined?(HELP)
7
7
  HELP = 'Set to show execution traceback on debugger command exception'
8
- MIN_ABBREV = 'sk'.size
8
+ MIN_ABBREV = 'ex'.size
9
9
  NAME = File.basename(__FILE__, '.rb')
10
- PREFIX = %w(set debug except)
10
+ PREFIX = %W(set debug #{NAME})
11
11
  end
12
12
  end
13
13
 
14
14
  if __FILE__ == $0
15
15
  # Demo it.
16
16
  require_relative '../../../mock'
17
- require_relative '../../../subcmd'
18
- name = File.basename(__FILE__, '.rb')
19
-
20
- # FIXME: DRY the below code
21
- dbgr, dbg_cmd = MockDebugger::setup('set')
22
- debug_cmd = Trepan::SubSubcommand::SetDebug.new(dbgr.core.processor,
23
- dbg_cmd)
24
- # FIXME: remove the 'join' below
25
- cmd_name = Trepan::SubSubcommand::SetDebugExcept::PREFIX.join('')
26
- debugx_cmd = Trepan::SubSubcommand::SetDebugExcept.new(dbg_cmd.proc,
27
- debug_cmd,
28
- cmd_name)
29
- # require_relative '../../../../lib/trepan'
30
- # dbgr = Trepan.new(:set_restart => true)
31
- # dbgr.debugger
32
- debugx_cmd.run([name, 'off'])
33
- debugx_cmd.run([name])
34
- debugx_cmd.run([name, 'on'])
17
+ require_relative '../debug'
18
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
19
+ Trepan::SubSubcommand::SetDebugExcept)
20
+ %w(off on 0 1).each { |arg| cmd.run([cmd.name, arg]) }
21
+ puts '-' * 10
22
+ puts cmd.save_command.join("\n")
35
23
  end
@@ -7,29 +7,17 @@ class Trepan::SubSubcommand::SetDebugMacro < Trepan::SetBoolSubSubcommand
7
7
  HELP = "Set macro debugging"
8
8
  MIN_ABBREV = 'macro'.size
9
9
  NAME = File.basename(__FILE__, '.rb')
10
- PREFIX = %w(set debug macro)
10
+ PREFIX = %W(set debug #{NAME})
11
11
  end
12
12
  end
13
13
 
14
14
  if __FILE__ == $0
15
15
  # Demo it.
16
16
  require_relative '../../../mock'
17
- require_relative '../../../subcmd'
18
- name = File.basename(__FILE__, '.rb')
19
-
20
- # FIXME: DRY the below code
21
- dbgr, set_cmd = MockTrepan::setup('set')
22
- debug_cmd = Trepan::SubSubcommand::SetDebug.new(dbgr.core.processor,
23
- set_cmd)
24
- # FIXME: remove the 'join' below
25
- cmd_name = Trepan::SubSubcommand::SetDebugMacro::PREFIX.join('')
26
- debugx_cmd = Trepan::SubSubcommand::SetDebugMacro.new(set_cmd.proc,
27
- debug_cmd,
28
- cmd_name)
29
- # require_relative '../../../../lib/trepanning'
30
- # dbgr = Trepan.new(:set_restart => true)
31
- # dbgr.debugger
32
- debugx_cmd.run([name])
33
- debugx_cmd.run([name, 'off'])
34
- debugx_cmd.run([name, 'on'])
17
+ require_relative '../debug'
18
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetDebug,
19
+ Trepan::SubSubcommand::SetDebugMacro)
20
+ %w(off on 0 1).each { |arg| cmd.run([cmd.name, arg]) }
21
+ puts '-' * 10
22
+ puts cmd.save_command.join("\n")
35
23
  end