rbx-trepanning 0.0.6-universal-rubinius-1.2 → 0.0.7-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/.gitignore +5 -0
  2. data/ChangeLog +161 -0
  3. data/Makefile +13 -0
  4. data/NEWS +11 -0
  5. data/Rakefile +6 -5
  6. data/app/.gitignore +2 -0
  7. data/app/breakpoint.rb +53 -36
  8. data/app/brkptmgr.rb +10 -0
  9. data/app/complete.rb +29 -2
  10. data/app/condition.rb +22 -0
  11. data/app/default.rb +1 -0
  12. data/app/eventbuffer.rb +147 -0
  13. data/app/frame.rb +3 -1
  14. data/app/options.rb +2 -2
  15. data/app/run.rb +5 -3
  16. data/bin/.gitignore +2 -0
  17. data/data/.gitignore +2 -0
  18. data/doc/.gitignore +1 -0
  19. data/doc/debugger.html +108 -0
  20. data/interface/.gitignore +2 -0
  21. data/interface/user.rb +8 -7
  22. data/io/.gitignore +3 -0
  23. data/io/input.rb +14 -8
  24. data/lib/.gitignore +2 -0
  25. data/lib/trepanning.rb +25 -33
  26. data/processor/.gitignore +3 -0
  27. data/processor/Makefile +7 -0
  28. data/processor/breakpoint.rb +4 -0
  29. data/processor/command/.gitignore +2 -0
  30. data/processor/command/backtrace.rb +5 -0
  31. data/processor/command/base/.gitignore +2 -0
  32. data/processor/command/base/subcmd.rb +2 -1
  33. data/processor/command/base/subsubcmd.rb +23 -1
  34. data/processor/command/base/subsubmgr.rb +2 -1
  35. data/processor/command/complete.rb +2 -1
  36. data/processor/command/condition.rb +62 -0
  37. data/processor/command/down.rb +4 -4
  38. data/processor/command/eval.rb +14 -6
  39. data/processor/command/exit.rb +8 -7
  40. data/processor/command/frame.rb +6 -2
  41. data/processor/command/info_subcmd/.gitignore +3 -0
  42. data/processor/command/info_subcmd/breakpoints.rb +8 -0
  43. data/processor/command/info_subcmd/files.rb +1 -1
  44. data/processor/command/info_subcmd/line.rb +1 -1
  45. data/processor/command/info_subcmd/ruby.rb +1 -1
  46. data/processor/command/kill.rb +21 -10
  47. data/processor/command/macro.rb +15 -23
  48. data/processor/command/set_subcmd/.gitignore +2 -0
  49. data/processor/command/set_subcmd/auto_subcmd/.gitignore +2 -0
  50. data/processor/command/set_subcmd/debug_subcmd/.gitignore +2 -0
  51. data/processor/command/set_subcmd/different.rb +2 -0
  52. data/processor/command/set_subcmd/max_subcmd/.gitignore +2 -0
  53. data/processor/command/set_subcmd/substitute_subcmd/.gitignore +3 -0
  54. data/processor/command/set_subcmd/trace_subcmd/.gitignore +2 -0
  55. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
  56. data/processor/command/set_subcmd/trace_subcmd/print.rb +13 -29
  57. data/processor/command/show_subcmd/.gitignore +3 -0
  58. data/processor/command/show_subcmd/alias.rb +7 -3
  59. data/processor/command/show_subcmd/auto_subcmd/.gitignore +3 -0
  60. data/processor/command/show_subcmd/auto_subcmd/irb.rb +1 -1
  61. data/processor/command/show_subcmd/debug_subcmd/.gitignore +3 -0
  62. data/processor/command/show_subcmd/macro.rb +62 -0
  63. data/processor/command/show_subcmd/max_subcmd/.gitignore +2 -0
  64. data/processor/command/show_subcmd/trace_subcmd/.gitignore +2 -0
  65. data/processor/command/show_subcmd/trace_subcmd/buffer.rb +64 -0
  66. data/processor/command/show_subcmd/trace_subcmd/print.rb +5 -20
  67. data/processor/command/source.rb +7 -0
  68. data/processor/command/up.rb +12 -8
  69. data/processor/eventbuf.rb +101 -0
  70. data/processor/frame.rb +19 -1
  71. data/processor/hook.rb +2 -2
  72. data/processor/load_cmds.rb +57 -49
  73. data/processor/location.rb +40 -0
  74. data/processor/main.rb +27 -26
  75. data/processor/msg.rb +17 -0
  76. data/processor/stepping.rb +21 -1
  77. data/processor/validate.rb +1 -0
  78. data/rbx-trepanning.gemspec +40 -0
  79. data/sample/.gitignore +2 -0
  80. data/test/data/.gitignore +1 -0
  81. data/test/example/.gitignore +2 -0
  82. data/test/functional/.gitignore +3 -0
  83. data/test/functional/test-finish.rb +2 -2
  84. data/test/integration/.gitignore +3 -0
  85. data/test/unit/.gitignore +3 -0
  86. data/test/unit/cmd-helper.rb +6 -2
  87. data/test/unit/test-app-brkpt.rb +14 -12
  88. data/test/unit/test-app-complete.rb +39 -0
  89. data/test/unit/test-app-condition.rb +18 -0
  90. data/test/unit/test-app-options.rb +8 -1
  91. data/test/unit/test-base-subsubcmd.rb +21 -0
  92. data/test/unit/test-cmd-finish.rb +4 -0
  93. data/test/unit/test-completion.rb +11 -6
  94. data/test/unit/test-proc-load_cmds.rb +2 -2
  95. metadata +295 -218
  96. data/app/breakpoint.rbc +0 -3551
  97. data/app/brkptmgr.rbc +0 -2903
  98. data/app/client.rbc +0 -1225
  99. data/app/complete.rbc +0 -1288
  100. data/app/default.rbc +0 -1132
  101. data/app/display.rbc +0 -2578
  102. data/app/frame.rbc +0 -1808
  103. data/app/irb.rbc +0 -2094
  104. data/app/iseq.rbc +0 -2192
  105. data/app/llvm.rbc +0 -2478
  106. data/app/method.rbc +0 -2492
  107. data/app/method_name.rbc +0 -2467
  108. data/app/mock.rbc +0 -398
  109. data/app/options.rbc +0 -2898
  110. data/app/rbx-llvm.rbc +0 -2478
  111. data/app/run.rbc +0 -1244
  112. data/app/util.rbc +0 -1146
  113. data/app/validate.rbc +0 -676
  114. data/bin/trepan.compiled.rbc +0 -1043
  115. data/bin/trepanx.compiled.rbc +0 -1049
  116. data/data/irbrc.compiled.rbc +0 -640
  117. data/interface/base_intf.rbc +0 -1899
  118. data/interface/client.rbc +0 -1072
  119. data/interface/comcodes.rbc +0 -385
  120. data/interface/script.rbc +0 -1642
  121. data/interface/server.rbc +0 -2213
  122. data/interface/user.rbc +0 -2867
  123. data/io/base_io.rbc +0 -2111
  124. data/io/input.rbc +0 -2528
  125. data/io/null_output.rbc +0 -730
  126. data/io/string_array.rbc +0 -2466
  127. data/io/tcpclient.rbc +0 -2419
  128. data/io/tcpfns.rbc +0 -694
  129. data/io/tcpserver.rbc +0 -2638
  130. data/lib/trepanning.rbc +0 -7705
  131. data/lib/trepanning2.rb +0 -441
  132. data/sample/list-terminal-colors.rbc +0 -2318
  133. data/sample/rocky-trepanx-colors.rbc +0 -530
  134. data/test/data/step-bug.cmd +0 -11
  135. data/test/data/step-bug.right +0 -3
  136. data/test/example/step-bug.rb +0 -14
  137. data/test/integration/skip-test-step-bug.rb +0 -17
@@ -4,24 +4,25 @@ require_relative 'base/cmd'
4
4
  class Trepan::Command::ExitCommand < Trepan::Command
5
5
 
6
6
  unless defined?(HELP)
7
+ NAME = File.basename(__FILE__, '.rb')
7
8
  ALIASES = %w(quit q q! quit! exit!)
8
- HELP =
9
- 'exit [exitcode] - hard exit of the debugged program.
9
+ HELP = <<-HELP
10
+ #{NAME} [exitcode] - hard exit of the debugged program.
10
11
 
11
12
  The program being debugged is exited via exit!() which does not run
12
13
  the Kernel at_exit finalizers. If a return code is given, that is the
13
14
  return code passed to exit() - presumably the return code that will be
14
15
  passed back to the OS. If no exit code is given, 0 is used.
15
16
 
16
- If you are in interactive mode, you are prompted to confirm
17
- quitting. However if you do not want to be prompted, add ! the end.
18
- (vim/vi/ed users can use alias q!).
17
+ If you are in interactive mode, and confirm is not set off, you are
18
+ prompted to confirm quitting. However if you do not want to be
19
+ prompted, add ! the end. (vim/vi/ed users can use alias q!).
19
20
 
20
- See also "kill".'
21
+ See also "kill" and "set confirm".'
22
+ HELP
21
23
 
22
24
  CATEGORY = 'support'
23
25
  MAX_ARGS = 2 # Need at most this many
24
- NAME = File.basename(__FILE__, '.rb')
25
26
  SHORT_HELP = 'Exit program via "exit!()"'
26
27
  end
27
28
 
@@ -28,6 +28,10 @@ See also 'up', 'down', and 'backtrace'.
28
28
  NAME = File.basename(__FILE__, '.rb')
29
29
  SHORT_HELP = 'Make a specific frame in the call stack the current frame'
30
30
 
31
+ def complete(prefix)
32
+ @proc.frame_complete(prefix, nil)
33
+ end
34
+
31
35
  def run(args)
32
36
 
33
37
  if args.size == 1
@@ -60,11 +64,11 @@ See also 'up', 'down', and 'backtrace'.
60
64
  errmsg('No frames recorded.')
61
65
  return false
62
66
  end
67
+ low, high = @proc.frame_low_high(nil)
63
68
  opts={
64
69
  :msg_on_error =>
65
70
  "The '#{NAME}' command requires a frame number. Got: #{position_str}",
66
- :min_value => -stack_size,
67
- :max_value => stack_size-1
71
+ :min_value => low, :max_value => high
68
72
  }
69
73
  frame_num = @proc.get_an_int(position_str, opts)
70
74
  return false unless frame_num
@@ -0,0 +1,3 @@
1
+ /*.rbc
2
+ /*~
3
+
@@ -46,6 +46,14 @@ EOH
46
46
  section "Num Breakpoint"
47
47
  bpmgr.list.each do |bp|
48
48
  msg "%3d: %s" % [bp.id, bp.describe]
49
+ if bp.condition && bp.condition != 'true'
50
+ msg("\tstop only if %s" % bp.condition)
51
+ end
52
+ if bp.hits > 0
53
+ ss = (bp.hits > 1) ? 's' : ''
54
+ msg("\tbreakpoint already hit %d time%s" %
55
+ [bp.hits, ss])
56
+ end
49
57
  end
50
58
  section 'Deferred breakpoints...'
51
59
  @proc.dbgr.deferred_breakpoints.each_with_index do |bp, i|
@@ -12,7 +12,7 @@ class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
12
12
  DEFAULT_FILE_ARGS = %w(size mtime sha1)
13
13
 
14
14
  HELP = <<-EOH
15
- #{CMD=PREFIX.join(' ')} [{FILENAME|.|*} [all|ctime|brkpts|mtime|sha1|size|stat]]
15
+ #{CMD} [{FILENAME|.|*} [all|ctime|brkpts|mtime|sha1|size|stat]]
16
16
 
17
17
  Show information about the current file. If no filename is given and
18
18
  the program is running, then the current file associated with the
@@ -7,7 +7,7 @@ class Trepan::Subcommand::InfoLine < Trepan::Subcommand
7
7
  unless defined?(HELP)
8
8
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
9
  HELP = <<-EOH
10
- #{CMD=PREFIX.join(' ')} [LINE-NUMBER]
10
+ #{CMD} [LINE-NUMBER]
11
11
 
12
12
  Show bytecode offset for LINE-NUMBER. If no LINE-NUMBER is given,
13
13
  then we use the current line that we are stopped in.
@@ -7,7 +7,7 @@ class Trepan::Subcommand::InfoRuby < Trepan::Subcommand
7
7
  unless defined?(HELP)
8
8
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
9
  HELP = <<-EOH
10
- #{CMD=PREFIX.join(' ')} [-v|--verbose|-no-verbose]
10
+ #{CMD} [-v|--verbose|-no-verbose]
11
11
 
12
12
  Show Ruby version information such as you'd get from
13
13
  "rbx -v" (which is really just the value of RUBY_RELEASE_DATE),
@@ -1,4 +1,4 @@
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
3
  require_relative 'base/cmd'
4
4
  class Trepan::Command::KillCommand < Trepan::Command
@@ -6,15 +6,16 @@ class Trepan::Command::KillCommand < Trepan::Command
6
6
  unless defined?(HELP)
7
7
  NAME = File.basename(__FILE__, '.rb')
8
8
  HELP = <<-HELP
9
- #{NAME} [signal-number|signal-name|unconditionally]
9
+ #{NAME} [signal-number|signal-name]
10
10
 
11
11
  Kill execution of program being debugged.
12
12
 
13
13
  Equivalent of Process.kill('KILL', Process.pid). This is an unmaskable
14
14
  signal. When all else fails, e.g. in thread code, use this.
15
15
 
16
- If 'unconditionally' is given, no questions are asked. Otherwise, if
17
- we are in interactive mode, we'll prompt to make sure.
16
+ If you are in interactive mode, you are prompted to confirm killing.
17
+ However when this command is aliased from a command ending in !, no
18
+ questions are asked.
18
19
 
19
20
  Examples:
20
21
 
@@ -23,28 +24,38 @@ Examples:
23
24
  #{NAME} KILL # same as above
24
25
  #{NAME} kill # same as above
25
26
  #{NAME} -9 # same as above
26
- #{NAME} 9 # same as above
27
+ #{NAME} 9 # same as above
28
+ #{NAME}! 9 # same as above, but no questions asked.
27
29
  HELP
28
30
 
31
+ ALIASES = %w(kill!)
29
32
  CATEGORY = 'running'
30
33
  MAX_ARGS = 1 # Need at most this many
31
34
  SHORT_HELP = 'Send this process a POSIX signal (default "9" is "kill -9")'
32
35
  end
36
+
37
+ def complete(prefix)
38
+ completions = Signal.list.keys +
39
+ Signal.list.values.map{|i| i.to_s} +
40
+ Signal.list.values.map{|i| (-i).to_s}
41
+ Trepan::Complete.complete_token(completions, prefix)
42
+ end
33
43
 
34
44
  # This method runs the command
35
45
  def run(args) # :nodoc
46
+ unconditional = ('!' == args[0][-1..-1])
36
47
  if args.size > 1
37
48
  sig = Integer(args[1]) rescue args[1]
38
49
  unless sig.is_a?(Integer) || Signal.list.member?(sig.upcase)
39
50
  errmsg("Signal name '#{sig}' is not a signal I know about.\n")
40
51
  return false
41
52
  end
42
- # FIXME: reinstate
43
- # if 'KILL' == sig || Signal['KILL'] == sig
44
- # @proc.intf.finalize
45
- # end
53
+ # FIXME: reinstate
54
+ if 'KILL' == sig || Signal['KILL'] == sig
55
+ @proc.intf.finalize
56
+ end
46
57
  else
47
- if not confirm('Really kill?', false)
58
+ if not (unconditional || confirm('Really quit?', false))
48
59
  msg('Kill not confirmed.')
49
60
  return
50
61
  else
@@ -11,33 +11,25 @@ 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 and should return either a String or an Array of Strings to
15
- use in its place. If the return is a String, that gets tokenized by a
16
- simple String#split . Note that macro processing is done right after
17
- splitting on ;; so if the macro returns a string containing ;; those
18
- won't be handled on the first string returned.
14
+ arguments.
15
+
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.
19
21
 
20
22
  If instead, Array of Strings is returned, then the first string is
21
23
  unshifted from the array and executed. The remaning strings are pushed
22
24
  onto the command queue. In contrast to the first string, subsequent
23
- strings which contain other macros or ;; splitting will be acted upon.
25
+ strings can contain other macros, and ;; in those strings will be
26
+ split into separate commands.
24
27
 
25
28
  Here is an example. The below creates a macro called finish+ which
26
29
  issues two commands 'finish' followed by 'step':
27
30
 
28
31
  macro fin+ Proc.new{|*args| %w(finish step)}
29
32
 
30
- Here is another example using arguments. I use the following to debug
31
- a debugger command:
32
-
33
- macro dbgcmd Proc.new{|*args| ["set debug dbgr", "debug $trepan_cmdproc.commands['\#{args[0]}'].run(\#{args.inspect})"]}
34
-
35
- With the above, 'dbgcmd list 5' will ultimately expand to:
36
- set debug dbgr
37
- debug $trepan_cmdproc.commands['list'].run(['5'])
38
-
39
- and will debug the debugger's 'list' command on the command 'list 5'.
40
-
41
33
  See also 'show macro'.
42
34
  HELP
43
35
 
@@ -47,15 +39,15 @@ See also 'show macro'.
47
39
  end
48
40
 
49
41
  def run(args)
50
- macro_name = args[1]
51
- proc_argstr = @proc.cmd_argstr[macro_name.size..-1].lstrip
52
- proc_obj = @proc.debug_eval(proc_argstr, @proc.settings[:maxstring])
42
+ cmd_name = args[1]
43
+ cmd_argstr = @proc.cmd_argstr[cmd_name.size..-1].lstrip
44
+ proc_obj = @proc.debug_eval(cmd_argstr, @proc.settings[:maxstring])
53
45
  if proc_obj
54
46
  if proc_obj.is_a?(Proc)
55
- @proc.macros[macro_name] = proc_obj
56
- msg "Macro \"#{macro_name}\" defined."
47
+ @proc.macros[cmd_name] = [proc_obj, cmd_argstr]
48
+ msg "Macro \"#{cmd_name}\" defined."
57
49
  else
58
- errmsg "Expecting a Proc object; got: #{proc_argstr}"
50
+ errmsg "Expecting a Proc object; got: #{cmd_argstr}"
59
51
  end
60
52
  end
61
53
  end
@@ -0,0 +1,2 @@
1
+ /*~
2
+ /*.rbc
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -38,6 +38,8 @@ override this setting.
38
38
  SHORT_HELP = "Set to make sure 'next/step' move to a new position."
39
39
  end
40
40
 
41
+ completion %w(on off nostack)
42
+
41
43
  def run(args)
42
44
  if args.size == 3 && 'nostack' == args[2]
43
45
  @proc.settings[:different] = 'nostack'
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,42 @@
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
+ require_relative '../trace'
6
+ class Trepan::SubSubcommand::SetTraceBuffer < Trepan::SetBoolSubSubcommand
7
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
+ unless defined?(HELP)
9
+ HELP = <<-EOH
10
+ #{CMD} [on|off|1|0]
11
+
12
+ Set saving trace events in a buffer
13
+ EOH
14
+ MIN_ABBREV = 'b'.size
15
+ SHORT_HELP = 'Set saving trace events in a buffer'
16
+ end
17
+
18
+ def run(args)
19
+ super
20
+ if settings[:tracebuffer]
21
+ # @proc.start_capture
22
+ @proc.unconditional_prehooks.insert_if_new(-1, *@proc.tracebuf_hook)
23
+ else
24
+ @proc.unconditional_prehooks.delete_by_name('tracebuffer')
25
+ # @proc.stop_capture
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ if __FILE__ == $0
32
+ # Demo it.
33
+ require_relative '../../../mock'
34
+ require_relative '../trace'
35
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetTrace,
36
+ Trepan::SubSubcommand::SetTraceBuffer)
37
+ %w(off on 1 0).each do |arg|
38
+ cmd.run([cmd.name, arg])
39
+ end
40
+ puts cmd.save_command()
41
+ end
42
+
@@ -1,18 +1,18 @@
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
  require_relative '../trace'
6
6
  class Trepan::SubSubcommand::SetTracePrint < Trepan::SetBoolSubSubcommand
7
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
7
8
  unless defined?(HELP)
8
- HELP =
9
- "set trace print [on|off|1|0]
9
+ HELP = <<-EOH
10
+ "#{CMD} [on|off|1|0]
10
11
 
11
- Set printing trace events."
12
+ Set printing trace events.
13
+ EOH
12
14
 
13
15
  MIN_ABBREV = 'p'.size
14
- NAME = File.basename(__FILE__, '.rb')
15
- PREFIX = %w(set trace print)
16
16
  SHORT_HELP = 'Set print trace events'
17
17
  end
18
18
 
@@ -30,28 +30,12 @@ end
30
30
  if __FILE__ == $0
31
31
  # Demo it.
32
32
  require_relative '../../../mock'
33
- require_relative '../../../subcmd'
34
- name = File.basename(__FILE__, '.rb')
35
-
36
- # FIXME: DRY the below code
37
- cmd_ary = Trepan::SubSubcommand::SetTracePrint::PREFIX
38
- dbgr, parent_cmd = MockDebugger::setup(cmd_ary[0], false)
39
- trace_cmd = Trepan::SubSubcommand::SetTrace.new(dbgr.processor,
40
- parent_cmd)
41
- cmd_name = cmd_ary.join('')
42
- subcmd = Trepan::SubSubcommand::SetTracePrint.new(parent_cmd.proc,
43
- trace_cmd,
44
- cmd_name)
45
- prefix_run = cmd_ary[2..-1]
46
- # require_relative '../../../../lib/trepanning'
47
- # dbgr = Trepan.new(:set_restart => true)
48
- # dbgr.debugger
49
-
50
- subcmd.run(prefix_run)
51
- %w(off on 1 0).each { |arg| subcmd.run(prefix_run + [arg]) }
52
- puts
53
- puts '-' * 20
54
- puts subcmd.save_command()
55
-
33
+ require_relative '../trace'
34
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetTrace,
35
+ Trepan::SubSubcommand::SetTracePrint)
36
+ %w(off on 1 0).each do |arg|
37
+ cmd.run([cmd.name, arg])
38
+ end
39
+ puts cmd.save_command()
56
40
  end
57
41
 
@@ -0,0 +1,3 @@
1
+ /*.rbc
2
+ /*~
3
+
@@ -4,10 +4,10 @@ require 'rubygems'; require 'require_relative'
4
4
  require_relative '../base/subcmd'
5
5
 
6
6
  class Trepan::Subcommand::ShowAlias < Trepan::Subcommand
7
- Trepanning::Subcommand.set_name_prefix(__FILE__, self)
7
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
8
  unless defined?(HELP)
9
9
  HELP = <<-EOH
10
- #{PREFIX.join(' ')} [NAME1 NAME2 ...]
10
+ #{CMD} [NAME1 NAME2 ...]
11
11
 
12
12
  If aliases names are given, show their definition. If left blank, show
13
13
  all alias names
@@ -16,6 +16,10 @@ all alias names
16
16
  SHORT_HELP = "Show defined aliases"
17
17
  end
18
18
 
19
+ def complete(prefix)
20
+ Trepan::Complete.complete_token(@proc.aliases.keys, prefix)
21
+ end
22
+
19
23
  def run(args)
20
24
  if args.size > 2
21
25
  args[2..-1].each do |alias_name|
@@ -28,7 +32,7 @@ all alias names
28
32
  elsif @proc.aliases.empty?
29
33
  msg "No aliases defined."
30
34
  else
31
- msg "List of aliases names currently defined:"
35
+ section "List of aliases names currently defined:"
32
36
  msg columnize_commands(@proc.aliases.keys.sort)
33
37
  end
34
38
  end
@@ -0,0 +1,3 @@
1
+ /*.rbc
2
+ /*~
3
+
@@ -18,6 +18,6 @@ if __FILE__ == $0
18
18
  # Demo it.
19
19
  require_relative '../../../mock'
20
20
  require_relative '../auto'
21
- cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::ShowIrb,
21
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::ShowAuto,
22
22
  Trepan::SubSubcommand::ShowAutoIrb)
23
23
  end
@@ -0,0 +1,3 @@
1
+ /*.rbc
2
+ /*~
3
+
@@ -0,0 +1,62 @@
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
+ require_relative '../../../app/complete'
6
+
7
+ class Trepan::Subcommand::ShowMacro < Trepan::Subcommand
8
+ unless defined?(HELP)
9
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
+ HELP = <<-HELP
11
+ #{CMD}
12
+ #{CMD} *
13
+ #{CMD} MACRO1 [MACRO2 ..]
14
+
15
+ In the first form a list of the existing macro names are shown
16
+ in column format.
17
+
18
+ In the second form, all macro names and their definitions are show.
19
+
20
+ In the last form the only definitions of the given macro names is shown.
21
+ HELP
22
+ SHORT_HELP = "Show defined macros"
23
+ MIN_ABBREV = 'ma'.size
24
+ end
25
+
26
+ def complete(prefix)
27
+ Trepan::Complete.complete_token(@proc.macros.keys + %w(*), prefix)
28
+ end
29
+
30
+ def run(args)
31
+ if args.size > 2
32
+ macro_names =
33
+ if args.size == 3 && '*' == args[2]
34
+ @proc.macros.keys
35
+ else
36
+ args[2..-1]
37
+ end
38
+ macro_names.each do |macro_name|
39
+ if @proc.macros.member?(macro_name)
40
+ section "#{macro_name}:"
41
+ string = @proc.macros[macro_name][1]
42
+ msg " #{@proc.ruby_format(string)}", {:unlimited => true}
43
+ else
44
+ errmsg "%s is not a defined macro" % macro_name
45
+ end
46
+ end
47
+ elsif @proc.macros.empty?
48
+ msg "No macros defined."
49
+ else
50
+ msg columnize_commands(@proc.macros.keys.sort)
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ if __FILE__ == $0
57
+ # Demo it.
58
+ $0 = __FILE__ + 'notagain' # So we don't run this agin
59
+ require_relative '../../mock'
60
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowMacro)
61
+ cmd.run(cmd.prefix + %w(u foo))
62
+ end
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -0,0 +1,64 @@
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::SubSubcommand::ShowTraceBuffer < Trepan::ShowBoolSubSubcommand
7
+ Trepanning::SubSubcommand.set_name_prefix(__FILE__, self)
8
+ unless defined?(HELP)
9
+ HELP = <<-EOH
10
+ #{CMD} [NUM]
11
+
12
+ Show the events recorded in the event buffer. If NUM is a negative
13
+ number, events run starting from that many debugger stops back. If NUM
14
+ is a positive number, we print starting from that (adjusted) position
15
+ in the event buffer with Since the event buffer may be a ring, its
16
+ zero being the first position. (Since the event buffer may be a ring
17
+ the earliest position recorded may move around.)
18
+ EOH
19
+ MIN_ABBREV = 'b'.size
20
+ SHORT_HELP = "Show tracing buffer"
21
+ end
22
+
23
+ def parse_show_buffer_args(args)
24
+ marksize = @proc.eventbuf.size
25
+ opts = {
26
+ :max_value => @proc.eventbuf.size,
27
+ :min_value => - marksize,
28
+ :msg_on_error =>
29
+ 'Positive or negative number expected, got %s.' % args[0]
30
+ }
31
+ num = @proc.get_an_int(args[0], opts)
32
+ return nil, nil unless num
33
+ num = marksize + num if num < 0
34
+ first = @proc.eventbuf.zero_pos + num
35
+ return first, nil
36
+ end
37
+
38
+ def run(args)
39
+ if args.size > 1
40
+ if @proc.eventbuf.size == 0
41
+ msg 'no events recorded.'
42
+ errmsg 'event buffer tracing is off. ' +
43
+ 'use "set trace buffer on" to turn on.' unless
44
+ settings[:tracebuffer]
45
+ return
46
+ end
47
+ first, last = parse_show_buffer_args(args[1..-1])
48
+
49
+ return unless first
50
+ @proc.eventbuf_print(first, last, settings[:maxwidth])
51
+ else
52
+ super
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ if __FILE__ == $0
59
+ # Demo it.
60
+ require_relative '../../../mock'
61
+ require_relative '../trace'
62
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::ShowTrace,
63
+ Trepan::SubSubcommand::ShowTraceBuffer)
64
+ end
@@ -1,5 +1,6 @@
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
+ require 'rubygems'; require 'require_relative'
3
4
  require_relative '../../base/subsubcmd'
4
5
 
5
6
  class Trepan::SubSubcommand::ShowTracePrint < Trepan::ShowBoolSubSubcommand
@@ -16,23 +17,7 @@ end
16
17
  if __FILE__ == $0
17
18
  # Demo it.
18
19
  require_relative '../../../mock'
19
- require_relative '../../../subcmd'
20
- name = File.basename(__FILE__, '.rb')
21
-
22
- # FIXME: DRY the below code
23
- dbgr, show_cmd = MockDebugger::setup('show')
24
- testcmdMgr = Trepan::Subcmd.new(show_cmd)
25
- trace_cmd = Trepan::SubSubcommand::ShowTrace.new(dbgr.core.processor,
26
- show_cmd)
27
-
28
- # FIXME: remove the 'join' below
29
- cmd_name = Trepan::SubSubcommand::ShowTracePrint::PREFIX.join('')
30
- tb_cmd = Trepan::SubSubcommand::ShowTracePrint.new(show_cmd.proc,
31
- trace_cmd,
32
- cmd_name)
33
- # require_relative '../../../../lib/trepanning'
34
- # dbgr = Trepan.new(:set_restart => true)
35
- # dbgr.debugger
36
- tb_cmd.run([])
37
-
20
+ require_relative '../trace'
21
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::ShowTrace,
22
+ Trepan::SubSubcommand::ShowTracePrint)
38
23
  end
@@ -49,6 +49,13 @@ unless option -c or --continue is given.
49
49
 
50
50
  end
51
51
 
52
+ def complete(prefix)
53
+ # opts = %w(-c --continue --no-continue -N --no -y --yes
54
+ # --verbose --no-verbose)
55
+ # return Trepan::Complete.complete_token(opts, prefix) if prefix.empty?
56
+ Readline::FILENAME_COMPLETION_PROC.call(prefix) || []
57
+ end
58
+
52
59
  def parse_options(options, args) # :nodoc
53
60
  seen_yes_no = false
54
61
  parser = OptionParser.new do |opts|