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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/ChangeLog +682 -0
  2. data/NEWS +19 -0
  3. data/README.textile +8 -9
  4. data/Rakefile +8 -8
  5. data/app/complete.rb +52 -0
  6. data/app/complete.rbc +1288 -0
  7. data/app/irb.rb +1 -2
  8. data/app/irb.rbc +55 -72
  9. data/app/llvm.rbc +780 -878
  10. data/app/method.rb +1 -1
  11. data/app/method.rbc +31 -35
  12. data/app/method_name.rbc +2467 -0
  13. data/app/options.rb +7 -24
  14. data/app/options.rbc +238 -132
  15. data/app/rbx-llvm.rbc +2478 -0
  16. data/app/util.rb +3 -3
  17. data/app/util.rbc +23 -27
  18. data/bin/trepanx +4 -3
  19. data/bin/trepanx.compiled.rbc +42 -32
  20. data/data/irbrc +41 -0
  21. data/data/irbrc.compiled.rbc +640 -0
  22. data/interface/base_intf.rb +9 -5
  23. data/interface/base_intf.rbc +200 -146
  24. data/interface/comcodes.rb +10 -8
  25. data/interface/comcodes.rbc +68 -26
  26. data/interface/script.rbc +21 -9
  27. data/interface/user.rb +74 -8
  28. data/interface/user.rbc +1702 -156
  29. data/io/input.rb +37 -14
  30. data/io/input.rbc +869 -320
  31. data/io/tcpclient.rb +7 -1
  32. data/io/tcpclient.rbc +205 -113
  33. data/io/tcpfns.rb +5 -3
  34. data/io/tcpfns.rbc +82 -40
  35. data/io/tcpserver.rb +13 -10
  36. data/io/tcpserver.rbc +236 -183
  37. data/lib/trepanning.rb +62 -21
  38. data/lib/trepanning.rbc +1304 -874
  39. data/lib/{trepanning.rb.orig → trepanning2.rb} +12 -4
  40. data/processor/breakpoint.rb +4 -1
  41. data/processor/command/base/cmd.rb +48 -3
  42. data/processor/command/base/subcmd.rb +2 -1
  43. data/processor/command/base/submgr.rb +23 -20
  44. data/processor/command/base/subsubmgr.rb +13 -2
  45. data/processor/command/complete.rb +7 -17
  46. data/processor/command/continue.rb +19 -11
  47. data/processor/command/disassemble.rb +39 -12
  48. data/processor/command/eval.rb +23 -5
  49. data/processor/command/help.rb +60 -6
  50. data/processor/command/info_subcmd/{file.rb → files.rb} +76 -18
  51. data/processor/command/info_subcmd/line.rb +86 -0
  52. data/processor/command/info_subcmd/program.rb +2 -11
  53. data/processor/command/info_subcmd/ruby.rb +62 -0
  54. data/processor/command/info_subcmd/variables.rb +7 -0
  55. data/processor/command/irb.rb +39 -7
  56. data/processor/command/macro.rb +76 -0
  57. data/processor/command/set_subcmd/confirm.rb +24 -0
  58. data/processor/command/set_subcmd/max.rb +4 -5
  59. data/processor/command/show.rb +11 -0
  60. data/processor/command/show_subcmd/auto.rb +1 -0
  61. data/processor/command/show_subcmd/basename.rb +1 -2
  62. data/processor/command/show_subcmd/confirm.rb +18 -0
  63. data/processor/command/show_subcmd/max.rb +0 -2
  64. data/processor/command/source.rb +0 -1
  65. data/processor/default.rb +2 -0
  66. data/processor/disassemble.rb +1 -0
  67. data/processor/load_cmds.rb +104 -20
  68. data/processor/location.rb +11 -12
  69. data/processor/main.rb +10 -6
  70. data/processor/mock.rb +6 -2
  71. data/processor/stepping.rb +1 -4
  72. data/processor/subcmd.rb +3 -2
  73. data/processor/validate.rb +3 -3
  74. data/sample/list-terminal-colors.rbc +158 -4
  75. data/sample/rocky-trepanx-colors.rb +15 -7
  76. data/sample/rocky-trepanx-colors.rbc +530 -0
  77. data/test/data/quit2.cmd +6 -0
  78. data/test/data/quit2.right +3 -0
  79. data/test/data/step-bug.cmd +11 -0
  80. data/test/data/step-bug.right +3 -0
  81. data/test/example/step-bug.rb +14 -0
  82. data/test/integration/helper.rb +1 -1
  83. data/test/integration/skip-test-step-bug.rb +17 -0
  84. data/test/integration/test-quit.rb +11 -0
  85. data/test/unit/test-app-util.rb +0 -1
  86. data/test/unit/test-base-cmd.rb +47 -0
  87. data/test/unit/test-base-subcmd.rb +2 -2
  88. data/test/unit/test-base-submgr.rb +24 -0
  89. data/test/unit/test-cmd-help.rb +4 -0
  90. data/test/unit/test-completion.rb +38 -0
  91. data/test/unit/test-intf-user.rb +2 -2
  92. data/test/unit/test-io-tcpclient.rb +3 -2
  93. data/test/unit/test-proc-eval.rb +1 -1
  94. data/test/unit/test-proc-load_cmds.rb +9 -0
  95. data/test/unit/test-subcmd-help.rb +1 -5
  96. metadata +182 -167
  97. data/app/options.rb.orig +0 -154
  98. data/bin/trepan.orig +0 -0
  99. data/bin/trepan.rej +0 -11
  100. data/lib/trepanning.rb.rej +0 -11
  101. data/sample/rocky-dot-trepanrc.orig +0 -0
  102. data/sample/rocky-dot-trepanrc.rej +0 -11
@@ -2,22 +2,30 @@
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
4
  require 'linecache'
5
+ require 'columnize'
5
6
  require_relative '../base/subcmd'
7
+ require_relative '../../../app/complete'
6
8
 
7
- class Trepan::Subcommand::InfoFile < Trepan::Subcommand
9
+ class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
8
10
  unless defined?(HELP)
9
11
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
- DEFAULT_FILE_ARGS = %w(size sha1)
12
+ DEFAULT_FILE_ARGS = %w(size mtime sha1)
11
13
 
12
14
  HELP = <<-EOH
13
- #{PREFIX.join(' ')} [{FILENAME|.} [all | brkpts | sha1 | size | stat]]
15
+ #{CMD=PREFIX.join(' ')} [{FILENAME|.|*} [all|ctime|brkpts|mtime|sha1|size|stat]]
14
16
 
15
17
  Show information about the current file. If no filename is given and
16
- the program is running then the current file associated with the
17
- current stack entry is used. Sub options which can be shown about a file are:
18
+ the program is running, then the current file associated with the
19
+ current stack entry is used. Giving . has the same effect.
20
+
21
+ Given * gives a list of all files we know about.
22
+
23
+ Sub options which can be shown about a file are:
18
24
 
19
25
  brkpts -- Line numbers where there are statement boundaries.
20
26
  These lines can be used in breakpoint commands.
27
+ ctime -- File creation time
28
+ mtime -- File modification time
21
29
  sha1 -- A SHA1 hash of the source text. This may be useful in comparing
22
30
  source code.
23
31
  size -- The number of lines in the file.
@@ -25,16 +33,42 @@ stat -- File.stat information
25
33
 
26
34
  all -- All of the above information.
27
35
 
28
- If no sub-options are given #{DEFAULT_FILE_ARGS.join(' ')} are assumed.
36
+ If no sub-options are given, "#{DEFAULT_FILE_ARGS.join(' ')}" are assumed.
37
+
38
+ Examples:
39
+
40
+ #{CMD} # Show #{DEFAULT_FILE_ARGS.join(' ')} information about current file
41
+ #{CMD} . # same as above
42
+ #{CMD} brkpts # show the number of lines in the current file
43
+ #{CMD} brkpts size # same as above but also list breakpoint line numbers
44
+ #{CMD} * # Give a list of files we know about
29
45
  EOH
30
46
  MIN_ABBREV = 'fi'.size # Note we have "info frame"
31
47
  NEED_STACK = false
32
48
  end
49
+
50
+ # completion %w(all brkpts iseq sha1 size stat)
51
+
52
+ include Trepanning
53
+
54
+ def file_list
55
+ (LineCache.class_variable_get('@@file_cache').keys +
56
+ LineCache.class_variable_get('@@file2file_remap').keys).uniq
57
+ end
58
+ def complete(prefix)
59
+ completions = ['.'] + file_list
60
+ Trepan::Complete.complete_token(completions, prefix)
61
+ end
33
62
 
34
63
  # Get file information
35
64
  def run(args)
36
65
  return if args.size < 2
37
66
  args << '.' if 2 == args.size
67
+ if '*' == args[2]
68
+ section 'Files names cached:'
69
+ msg columnize_commands(file_list.sort)
70
+ return
71
+ end
38
72
  filename =
39
73
  if '.' == args[2]
40
74
  if not @proc.frame
@@ -50,7 +84,7 @@ EOH
50
84
  args += DEFAULT_FILE_ARGS if args.size == 3
51
85
 
52
86
  m = filename + ' is'
53
- canonic_name = LineCache::map_file(filename)
87
+ canonic_name = LineCache::map_file(filename) || filename
54
88
  if LineCache::cached?(canonic_name)
55
89
  m += " cached in debugger"
56
90
  if canonic_name != filename
@@ -70,8 +104,17 @@ EOH
70
104
  # canonic_name = matches[0]
71
105
  # end
72
106
  else
73
- msg(m + ' not cached in debugger.')
74
- return
107
+ matches = file_list.select{|try| try.end_with?(filename)}
108
+ if (matches.size > 1)
109
+ msg("Multiple files found ending filename string:")
110
+ matches.sort.each { |match_file| msg "\t%s" % match_file }
111
+ return
112
+ elsif 1 == matches.size
113
+ canonic_name = LineCache::map_file(matches[1])
114
+ else
115
+ msg(m + ' not cached in debugger.')
116
+ return
117
+ end
75
118
  end
76
119
  seen = {}
77
120
  args[3..-1].each do |arg|
@@ -102,6 +145,14 @@ EOH
102
145
  processed_arg = seen[:brkpts] = true
103
146
  end
104
147
 
148
+ if %w(all ctime).member?(arg)
149
+ unless seen[:ctime]
150
+ msg("create time:\t%s." %
151
+ LineCache::stat(canonic_name).ctime.to_s)
152
+ end
153
+ processed_arg = seen[:ctime] = true
154
+ end
155
+
105
156
  # if %w(all iseq).member?(arg)
106
157
  # unless seen[:iseq]
107
158
  # if SCRIPT_ISEQS__.member?(canonic_name)
@@ -116,6 +167,14 @@ EOH
116
167
  # processed_arg = seen[:iseq] = true
117
168
  # end
118
169
 
170
+ if %w(all mtime).member?(arg)
171
+ unless seen[:mtime]
172
+ msg("modify time:\t%s." %
173
+ LineCache::stat(canonic_name).mtime.to_s)
174
+ end
175
+ processed_arg = seen[:mtime] = true
176
+ end
177
+
119
178
  if %w(all stat).member?(arg)
120
179
  unless seen[:stat]
121
180
  msg("Stat info:\n\t%s." % LineCache::stat(canonic_name).inspect)
@@ -132,20 +191,19 @@ end
132
191
 
133
192
  if __FILE__ == $0
134
193
  require_relative '../../mock'
135
- name = File.basename(__FILE__, '.rb')
136
- # FIXME: DRY the below code
137
- dbgr, cmd = MockDebugger::setup('info')
138
- subcommand = Trepan::Subcommand::InfoFile.new(cmd)
139
- testcmdMgr = Trepan::Subcmd.new(subcommand)
194
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFiles, false)
140
195
  LineCache::cache(__FILE__)
196
+ LineCache::cache('../../mock.rb')
141
197
 
142
198
  [%w(info file nothere),
143
199
  %w(info file .),
200
+ %w(info file *),
144
201
  %w(info file),
145
- %w(info file file.rb),
146
- %w(info file . all),
147
- %w(info file . lines size sha1 sha1)].each do |args|
148
- subcommand.run(args)
202
+ %W(info file #{__FILE__}),
203
+ %W(info file #{__FILE__} all),
204
+ %W(info file #{__FILE__} brkpts bad size sha1 sha1)].each do |args|
205
+ cmd.run(args)
149
206
  puts '-' * 40
150
207
  end
208
+ p cmd.complete('')
151
209
  end
@@ -0,0 +1,86 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::InfoLine < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{CMD=PREFIX.join(' ')} [LINE-NUMBER]
11
+
12
+ Show bytecode offset for LINE-NUMBER. If no LINE-NUMBER is given,
13
+ then we use the current line that we are stopped in.
14
+
15
+ Examples:
16
+ #{CMD}
17
+ #{CMD} 10
18
+ EOH
19
+ MIN_ABBREV = 'li'.size
20
+ NEED_STACK = true
21
+ SHORT_HELP = 'Byte code offsets for source code line'
22
+ end
23
+
24
+ def ip_ranges_for_line(lines, line)
25
+ result = []
26
+ in_range = false
27
+ start_ip = nil
28
+ total = lines.size
29
+ i = 1
30
+ while i < total
31
+ cur_line = lines.at(i)
32
+ if cur_line == line
33
+ start_ip = lines.at(i-1)
34
+ in_range = true
35
+ elsif cur_line > line && in_range
36
+ result << [start_ip, lines.at(i-1)]
37
+ start_ip = nil
38
+ in_range = false
39
+ end
40
+ i += 2
41
+ end
42
+ if in_range && start_ip
43
+ result << [start_ip, lines.at(total-1)]
44
+ end
45
+ result
46
+ end
47
+
48
+ def run(args)
49
+ frame = @proc.frame
50
+ vm_location = frame.vm_location
51
+ cm = frame.method
52
+ filename = cm.file
53
+ lines = cm.lines
54
+ if args.size == 2
55
+ line_no = vm_location.line
56
+ else
57
+ lineno_str = args[2]
58
+ opts = {
59
+ :msg_on_error =>
60
+ "The 'info line' line number must be an integer. Got: %s" % lineno_str,
61
+ :min_value => lines.at(1),
62
+ :max_value => lines.at(lines.size-2)
63
+ }
64
+ line_no = @proc.get_an_int(lineno_str, opts)
65
+ return false unless line_no
66
+ end
67
+
68
+ ranges = ip_ranges_for_line(lines, line_no)
69
+ if ranges.empty?
70
+ msg "Line %s of %s:\n\tno bytecode offsets" % [line_no, filename]
71
+ else
72
+ msg "Line %s of %s:" % [line_no, filename]
73
+ ranges.each do |tuple|
74
+ msg "\t starts at offset %d and ends before offset %d" % tuple
75
+ end
76
+ end
77
+ end
78
+
79
+ end
80
+
81
+ if __FILE__ == $0
82
+ # Demo it.
83
+ require_relative '../../mock'
84
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoLine, false)
85
+ cmd.run(cmd.prefix)
86
+ end
@@ -44,15 +44,6 @@ end
44
44
  if __FILE__ == $0
45
45
  # Demo it.
46
46
  require_relative '../../mock'
47
- name = File.basename(__FILE__, '.rb')
48
-
49
- # FIXME: DRY the below code
50
- dbgr, cmd = MockDebugger::setup('info')
51
- subcommand = Trepan::Subcommand::InfoProgram.new(cmd)
52
- testcmdMgr = Trepan::Subcmd.new(subcommand)
53
-
54
- subcommand.run_show_bool
55
- name = File.basename(__FILE__, '.rb')
56
- subcommand.summary_help(name)
57
- puts
47
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoProgram, false)
48
+ cmd.run(cmd.prefix)
58
49
  end
@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::InfoRuby < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{CMD=PREFIX.join(' ')} [-v|--verbose|-no-verbose]
11
+
12
+ Show Ruby version information such as you'd get from
13
+ "rbx -v" (which is really just the value of RUBY_RELEASE_DATE),
14
+ or from "rbx -vv".
15
+
16
+ See also constants: RUBY_DESCRIPITON, RUBY_VERSION, and RUBY_RELEASE_DATE."
17
+ EOH
18
+ MIN_ABBREV = 'ru'.size
19
+ NEED_STACK = false
20
+ SHORT_HELP = 'Ruby version information'
21
+ end
22
+
23
+ def parse_options(args) # :nodoc
24
+ options = {}
25
+ parser = OptionParser.new do |opts|
26
+ opts.on("-v",
27
+ "--[no-]verbose", "show additional version information") do
28
+ |v|
29
+ options[:verbose] = v
30
+ end
31
+ end
32
+ parser.parse(args)
33
+ return options
34
+ end
35
+
36
+ def run(args)
37
+ options = parse_options(args[2..-1])
38
+ msg RUBY_DESCRIPTION
39
+ if options[:verbose]
40
+ msg "Options:"
41
+ msg " Interpreter type: #{Rubinius::INTERPRETER}"
42
+ if jit = Rubinius::JIT
43
+ msg " JIT enabled: #{jit.join(', ')}"
44
+ else
45
+ msg " JIT disabled"
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ if __FILE__ == $0
53
+ # Demo it.
54
+ $0 = __FILE__ + 'notagain' # So we don't run this again
55
+ require_relative '../../mock'
56
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoRuby, false)
57
+ cmd.run(cmd.prefix)
58
+ %w(-v --verbose --no-verbose).each do |opt|
59
+ puts '-' * 10 + " #{opt}"
60
+ cmd.run(cmd.prefix + [opt])
61
+ end
62
+ end
@@ -39,3 +39,10 @@ The optional argument is which variable specifically to show the value of.
39
39
  end
40
40
  end
41
41
  end
42
+
43
+ if __FILE__ == $0
44
+ # Demo it.
45
+ require_relative '../../mock'
46
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoVariables, false)
47
+ # cmd.run(cmd.prefix)
48
+ end
@@ -31,7 +31,7 @@ But arguments have to be quoted because #{NAME} will evaluate them:
31
31
 
32
32
  Here then is a loop to query VM stack values:
33
33
  (-1..1).each {|i| dbgr(\"info reg sp \#{i}\")}
34
- HELP
34
+ HELP
35
35
 
36
36
  CATEGORY = 'support'
37
37
  MAX_ARGS = 1 # Need at most this many
@@ -39,7 +39,7 @@ Here then is a loop to query VM stack values:
39
39
  end
40
40
 
41
41
  # This method runs the command
42
- def run(args) # :nodoc
42
+ def run(args)
43
43
  add_debugging =
44
44
  if args.size > 1
45
45
  '-d' == args[1]
@@ -65,10 +65,33 @@ Here then is a loop to query VM stack values:
65
65
  $trepanx_irb_statements = nil
66
66
  $trepanx_command = nil
67
67
 
68
- conf = {:BACK_TRACE_LIMIT => settings[:maxstack]}
69
- cont = IRB.start_session(@proc.frame.binding, @proc, conf).to_s
70
- trap('SIGINT', save_trap) # Restore old trap
68
+ conf = {:BACK_TRACE_LIMIT => settings[:maxstack],
69
+ :RC => true}
71
70
 
71
+ # ?? Should we set GNU readline to what we have,
72
+ # or let IRB make its own determination?
73
+
74
+ # Save the Readline history and set the Readline completion function
75
+ # to be IRB's function
76
+ if Trepan::GNU_readline?
77
+ @proc.intf.save_history if @proc.intf.respond_to?(:save_history)
78
+ require 'irb/completion'
79
+ Readline.completion_proc = IRB::InputCompletor::CompletionProc
80
+ end
81
+
82
+ # And just when you thought, we'd never get around to
83
+ # actually running irb...
84
+ cont = IRB.start_session(@proc.frame.binding, @proc, conf)
85
+ trap('SIGINT', save_trap) # Restore our old interrupt function.
86
+
87
+ # Restore the debuggers' Readline history and the Readline completion
88
+ # function
89
+ if Trepan::GNU_readline? && @proc.dbgr.completion_proc
90
+ @proc.intf.read_history if @proc.intf.respond_to?(:read_history)
91
+ Readline.completion_proc = @proc.dbgr.completion_proc
92
+ end
93
+
94
+ # Respect any backtrace limit set in irb.
72
95
  back_trace_limit = IRB.CurrentContext.back_trace_limit
73
96
  if settings[:maxstack] != back_trace_limit
74
97
  msg("\nSetting debugger's BACK_TRACE_LIMIT (%d) to match irb's last setting (%d)" %
@@ -76,8 +99,17 @@ Here then is a loop to query VM stack values:
76
99
  settings[:maxstack]= IRB.CurrentContext.back_trace_limit
77
100
  end
78
101
 
79
- if %w(continue finish next ext step).member?(cont)
80
- @proc.commands[cont].run([cont]) # (1, {})
102
+ case cont
103
+ when :continue
104
+ @proc.continue
105
+ when :finish
106
+ @proc.finish
107
+ when :next
108
+ @proc.next # (1, {})
109
+ when :quit
110
+ @proc.quit
111
+ when :step
112
+ @proc.step # (1, {})
81
113
  else
82
114
  @proc.print_location
83
115
  end
@@ -0,0 +1,76 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'base/cmd'
5
+ require_relative '../eval'
6
+ class Trepan::Command::MacroCommand < Trepan::Command
7
+
8
+ unless defined?(HELP)
9
+ NAME = File.basename(__FILE__, '.rb')
10
+ HELP = <<-HELP
11
+ #{NAME} MACRO-NAME PROC-OBJECT
12
+
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.
19
+
20
+ If instead, Array of Strings is returned, then the first string is
21
+ unshifted from the array and executed. The remaning strings are pushed
22
+ onto the command queue. In contrast to the first string, subsequent
23
+ strings which contain other macros or ;; splitting will be acted upon.
24
+
25
+ Here is an example. The below creates a macro called finish+ which
26
+ issues two commands 'finish' followed by 'step':
27
+
28
+ macro fin+ Proc.new{|*args| %w(finish step)}
29
+
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
+ See also 'show macro'.
42
+ HELP
43
+
44
+ CATEGORY = 'support'
45
+ MIN_ARGS = 2 # Need at least this many
46
+ SHORT_HELP = 'Define a macro'
47
+ end
48
+
49
+ 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])
53
+ if proc_obj
54
+ if proc_obj.is_a?(Proc)
55
+ @proc.macros[macro_name] = proc_obj
56
+ msg "Macro \"#{macro_name}\" defined."
57
+ else
58
+ errmsg "Expecting a Proc object; got: #{proc_argstr}"
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ if __FILE__ == $0
65
+ require_relative '../mock'
66
+ dbgr, cmd = MockDebugger::setup
67
+ cmdproc = cmd.proc
68
+ ["#{cmd.name} foo Proc.new{|x, y| 'x+y'}",
69
+ "#{cmd.name} bad2 1+2"].each do |cmdline|
70
+ args = cmdline.split
71
+ cmd_argstr = cmdline[args[0].size..-1].lstrip
72
+ cmdproc.instance_variable_set('@cmd_argstr', cmd_argstr)
73
+ cmd.run(args)
74
+ end
75
+ p cmdproc.macros
76
+ end
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::SetConfirm < Trepan::SetBoolSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Set whether to confirm potentially dangerous operations."
10
+ IN_LIST = true
11
+ MIN_ABBREV = 'co'.size
12
+ end
13
+ end
14
+
15
+ if __FILE__ == $0
16
+ # Demo it.
17
+ $0 = __FILE__ + 'notagain' # So we don't run this agin
18
+ require_relative '../../mock'
19
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::SetConfirm, false)
20
+ cmd.run(cmd.prefix + ['off'])
21
+ cmd.run(cmd.prefix + ['ofn'])
22
+ cmd.run(cmd.prefix)
23
+ puts cmd.save_command
24
+ end
@@ -19,9 +19,8 @@ if __FILE__ == $0
19
19
  cmd_name = cmd_ary.join('')
20
20
  prefix_run = cmd_ary[1..-1]
21
21
  cmd.run(prefix_run)
22
- # require_relative '../../../lib/trepanning'
23
- # # Trepan.debug(:set_restart => true)
24
- ## puts cmd.summary_help(cmd.name)
25
- ## puts
26
- ## puts '-' * 20
22
+ # require 'trepanning'; debugger
23
+ %w(s lis foo).each do |prefix|
24
+ p [prefix, cmd.complete(prefix)]
25
+ end
27
26
  end
@@ -18,6 +18,17 @@ Type "help show *" for just a list of "show" subcommands.'
18
18
  NEED_STACK = false
19
19
  SHORT_HELP = 'Show parts of the debugger environment'
20
20
  end
21
+
22
+ def run(args)
23
+ if args.size > 1
24
+ first = args[1].downcase
25
+ alen = 'auto'.size
26
+ args[1..1] = ['auto', first[alen..-1]] if
27
+ first.start_with?('auto') && first.size > alen
28
+ end
29
+ super
30
+ end
31
+
21
32
  end
22
33
 
23
34
  if __FILE__ == $0
@@ -8,6 +8,7 @@ class Trepan::SubSubcommand::ShowAuto < Trepan::SubSubcommandMgr
8
8
  unless defined?(HELP)
9
9
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
10
  HELP = 'Show settings which some sort of "automatic" default behavior'
11
+ MIN_ABBREV = 'au'.size
11
12
  end
12
13
  end
13
14
 
@@ -16,6 +16,5 @@ if __FILE__ == $0
16
16
  # Demo it.
17
17
  $0 = __FILE__ + 'notagain' # So we don't run this agin
18
18
  require_relative '../../mock'
19
- cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowBasename, false)
20
- cmd.run(cmd.prefix)
19
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowBasename)
21
20
  end
@@ -0,0 +1,18 @@
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
+
6
+ class Trepan::Subcommand::ShowConfirm < Trepan::ShowBoolSubcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = "Show confirm potentially dangerous operations setting"
10
+ MIN_ABBREV = 'co'.size
11
+ end
12
+ end
13
+
14
+ if __FILE__ == $0
15
+ # Demo it.
16
+ require_relative '../../mock'
17
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowConfirm, false)
18
+ end
@@ -24,6 +24,4 @@ if __FILE__ == $0
24
24
  cmd_name = cmd_ary.join('')
25
25
  prefix_run = cmd_ary[1..-1]
26
26
  cmd.run(prefix_run)
27
- # require_relative '../../../lib/trepanning'
28
- # Trepan.debug(:set_restart => true)
29
27
  end
@@ -10,7 +10,6 @@ require_relative '../../io/null_output'
10
10
  require_relative '../../app/default'
11
11
 
12
12
  class Trepan::Command::SourceCommand < Trepan::Command
13
- include Trepanning
14
13
  unless defined?(HELP)
15
14
  NAME = File.basename(__FILE__, '.rb')
16
15
  HELP = <<-HELP
data/processor/default.rb CHANGED
@@ -10,6 +10,7 @@ class Trepan
10
10
  :autolist => false, # Run 'list'
11
11
 
12
12
  :basename => false, # Show basename of filenames only
13
+ :confirm => true, # Confirm potentially dangerous operations?
13
14
  :different => 'nostack', # stop *only* when different position?
14
15
 
15
16
  :debugdbgr => false, # Debugging the debugger
@@ -25,6 +26,7 @@ class Trepan
25
26
  # means hide none. Less than 0 means show
26
27
  # all stack entries.
27
28
  :hightlight => false, # Use terminal highlight?
29
+
28
30
  :maxlist => 10, # Number of source lines to list
29
31
  :maxstack => 10, # backtrace limit
30
32
  :maxstring => 150, # Strings which are larger than this
@@ -14,6 +14,7 @@ class Trepan
14
14
  fin = meth.iseq.size
15
15
  end
16
16
 
17
+ start += 1 if start == -1
17
18
  section "Bytecode between #{start} and #{fin-1} for line #{line}"
18
19
 
19
20
  iseq_decoder = Rubinius::InstructionDecoder.new(meth.iseq)