rbx-trepanning 0.0.8-universal-rubinius-1.2 → 0.1.0-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/ChangeLog +762 -238
  2. data/NEWS +44 -0
  3. data/Rakefile +61 -32
  4. data/app/breakpoint.rb +2 -0
  5. data/app/brkptmgr.rb +9 -11
  6. data/app/client.rb +0 -1
  7. data/app/cmd_parse.kpeg +21 -4
  8. data/app/cmd_parse.rb +10 -10
  9. data/app/cmd_parser.rb +1029 -840
  10. data/app/complete.rb +1 -1
  11. data/app/display.rb +38 -0
  12. data/app/file.rb +24 -0
  13. data/app/frame.rb +11 -4
  14. data/app/irb.rb +41 -39
  15. data/app/iseq.rb +71 -0
  16. data/app/options.rb +55 -30
  17. data/app/rbx-llvm.rb +0 -2
  18. data/app/run.rb +13 -9
  19. data/app/util.rb +55 -5
  20. data/bin/trepanx +3 -3
  21. data/data/irbrc +13 -13
  22. data/{interface/base_intf.rb → interface.rb} +5 -1
  23. data/interface/client.rb +4 -0
  24. data/interface/script.rb +13 -5
  25. data/interface/server.rb +5 -1
  26. data/interface/user.rb +8 -1
  27. data/{io/base_io.rb → io.rb} +0 -0
  28. data/io/input.rb +1 -1
  29. data/io/null_output.rb +28 -24
  30. data/io/string_array.rb +2 -3
  31. data/io/tcpclient.rb +1 -1
  32. data/io/tcpserver.rb +1 -1
  33. data/lib/trepanning.rb +11 -13
  34. data/{processor/main.rb → processor.rb} +50 -54
  35. data/processor/breakpoint.rb +150 -137
  36. data/processor/{command/base/cmd.rb → command.rb} +1 -1
  37. data/processor/command/alias.rb +14 -3
  38. data/processor/command/backtrace.rb +2 -1
  39. data/processor/command/base/subcmd.rb +1 -5
  40. data/processor/command/base/submgr.rb +5 -2
  41. data/processor/command/base/subsubcmd.rb +1 -1
  42. data/processor/command/base/subsubmgr.rb +4 -4
  43. data/processor/command/break.rb +1 -1
  44. data/processor/command/complete.rb +2 -1
  45. data/processor/command/condition.rb +2 -2
  46. data/processor/command/continue.rb +4 -4
  47. data/processor/command/delete.rb +34 -20
  48. data/processor/command/directory.rb +4 -4
  49. data/processor/command/disable.rb +71 -0
  50. data/processor/command/disassemble.rb +55 -22
  51. data/processor/command/display.rb +3 -1
  52. data/processor/command/down.rb +8 -8
  53. data/processor/command/edit.rb +74 -0
  54. data/processor/command/enable.rb +43 -0
  55. data/processor/command/eval.rb +37 -15
  56. data/processor/command/exit.rb +25 -6
  57. data/processor/command/finish.rb +5 -5
  58. data/processor/command/frame.rb +2 -2
  59. data/processor/command/help.rb +7 -9
  60. data/processor/command/help/README +10 -0
  61. data/processor/command/help/command.txt +37 -27
  62. data/processor/command/help/examples.txt +16 -0
  63. data/processor/command/help/filename.txt +1 -1
  64. data/processor/command/help/suffixes.txt +17 -0
  65. data/processor/command/info.rb +3 -1
  66. data/processor/command/info_subcmd/files.rb +3 -2
  67. data/processor/command/info_subcmd/frame.rb +2 -1
  68. data/processor/command/info_subcmd/line.rb +17 -28
  69. data/processor/command/info_subcmd/locals.rb +22 -0
  70. data/processor/command/{show_subcmd → info_subcmd}/macro.rb +4 -4
  71. data/processor/command/info_subcmd/program.rb +2 -0
  72. data/processor/command/info_subcmd/ruby.rb +2 -0
  73. data/processor/command/info_subcmd/source.rb +75 -0
  74. data/processor/command/info_subcmd/stack.rb +25 -0
  75. data/processor/command/info_subcmd/variables.rb +23 -36
  76. data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
  77. data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
  78. data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
  79. data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
  80. data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
  81. data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
  82. data/processor/command/kill.rb +8 -9
  83. data/processor/command/list.rb +101 -167
  84. data/processor/command/macro.rb +28 -10
  85. data/processor/command/next.rb +2 -1
  86. data/processor/command/nexti.rb +1 -1
  87. data/processor/command/parsetree.rb +51 -0
  88. data/processor/command/pr.rb +1 -2
  89. data/processor/command/ps.rb +1 -1
  90. data/processor/command/restart.rb +2 -2
  91. data/processor/command/save.rb +1 -1
  92. data/processor/command/server.rb +1 -1
  93. data/processor/command/set_subcmd/abbrev.rb +25 -0
  94. data/processor/command/set_subcmd/auto.rb +7 -1
  95. data/processor/command/set_subcmd/auto_subcmd/eval.rb +1 -2
  96. data/processor/command/set_subcmd/auto_subcmd/irb.rb +2 -3
  97. data/processor/command/set_subcmd/auto_subcmd/list.rb +2 -3
  98. data/processor/command/set_subcmd/different.rb +1 -1
  99. data/processor/command/set_subcmd/highlight.rb +7 -1
  100. data/processor/command/set_subcmd/reload.rb +42 -0
  101. data/processor/command/set_subcmd/timer.rb +58 -0
  102. data/processor/command/set_subcmd/trace.rb +4 -3
  103. data/processor/command/{irb.rb → shell.rb} +22 -19
  104. data/processor/command/show_subcmd/abbrev.rb +20 -0
  105. data/processor/command/show_subcmd/{alias.rb → aliases.rb} +2 -2
  106. data/processor/command/show_subcmd/auto_subcmd/eval.rb +2 -6
  107. data/processor/command/show_subcmd/directories.rb +22 -0
  108. data/processor/command/show_subcmd/hidelevel.rb +1 -1
  109. data/processor/command/show_subcmd/highlight.rb +2 -1
  110. data/processor/command/show_subcmd/reload.rb +18 -0
  111. data/processor/command/show_subcmd/timer.rb +18 -0
  112. data/processor/command/source.rb +9 -9
  113. data/processor/command/step.rb +1 -1
  114. data/processor/command/tbreak.rb +3 -2
  115. data/processor/command/unalias.rb +11 -6
  116. data/processor/command/undisplay.rb +13 -9
  117. data/processor/command/up.rb +13 -14
  118. data/processor/default.rb +47 -44
  119. data/processor/disassemble.rb +48 -35
  120. data/processor/display.rb +38 -3
  121. data/processor/eval.rb +54 -53
  122. data/processor/eventbuf.rb +69 -69
  123. data/processor/frame.rb +186 -187
  124. data/processor/help.rb +6 -4
  125. data/processor/hook.rb +103 -102
  126. data/processor/list.rb +123 -0
  127. data/processor/load_cmds.rb +9 -1
  128. data/processor/location.rb +193 -188
  129. data/processor/mock.rb +1 -7
  130. data/processor/msg.rb +56 -42
  131. data/processor/running.rb +26 -15
  132. data/processor/stepping.rb +2 -1
  133. data/processor/subcmd.rb +18 -43
  134. data/processor/validate.rb +41 -30
  135. data/processor/virtual.rb +33 -0
  136. data/rbx-trepanning.gemspec +7 -8
  137. data/sample/rocky-trepanx-colors.rb +0 -1
  138. data/test/data/fname-with-blank.right +2 -0
  139. data/test/data/inline-call.right +11 -10
  140. data/test/data/quit.right +1 -0
  141. data/test/example/debugger-stop.rb +1 -1
  142. data/test/example/goto2goto.rb +11 -0
  143. data/test/functional/fn_helper.rb +2 -2
  144. data/test/functional/test-list.rb +7 -6
  145. data/test/integration/helper.rb +5 -5
  146. data/test/unit/cmd-helper.rb +2 -6
  147. data/test/unit/test-app-cmd_parser.rb +3 -2
  148. data/test/unit/test-app-display.rb +22 -0
  149. data/test/unit/test-app-options.rb +14 -10
  150. data/test/unit/test-app-run.rb +0 -2
  151. data/test/unit/test-app-util.rb +21 -4
  152. data/test/unit/test-base-cmd.rb +5 -7
  153. data/test/unit/test-base-subcmd.rb +1 -5
  154. data/test/unit/test-base-submgr.rb +1 -1
  155. data/test/unit/test-base-subsubcmd.rb +0 -4
  156. data/test/unit/test-bin-trepanx.rb +2 -2
  157. data/test/unit/test-cmd-break.rb +2 -0
  158. data/test/unit/test-cmd-edit.rb +34 -0
  159. data/test/unit/test-cmd-kill.rb +11 -4
  160. data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
  161. data/test/unit/test-command.rb +45 -0
  162. data/test/unit/test-completion.rb +1 -1
  163. data/test/unit/test-proc-eval.rb +1 -2
  164. data/test/unit/test-proc-frame.rb +5 -3
  165. data/test/unit/test-proc-list.rb +55 -0
  166. data/test/unit/test-proc-load_cmds.rb +4 -3
  167. data/test/unit/test-proc-location.rb +32 -29
  168. data/test/unit/test-proc-main.rb +1 -5
  169. data/test/unit/test-proc-validate.rb +14 -4
  170. data/test/unit/test-subcmd-help.rb +1 -5
  171. metadata +73 -107
data/app/complete.rb CHANGED
@@ -10,7 +10,7 @@ class Trepan
10
10
  # Return an Array of String found from Array of String
11
11
  # +complete_ary+ which start out with String +prefix+.
12
12
  def complete_token(complete_ary, prefix)
13
- complete_ary.select { |cmd| cmd.to_s.start_with?(prefix) }.sort
13
+ complete_ary.select { |cmd| cmd.to_s.start_with?(prefix) }.map{|cmd| cmd.to_s}.sort
14
14
  end
15
15
 
16
16
  def complete_token_with_next(complete_hash, prefix, cmd_prefix='')
data/app/display.rb CHANGED
@@ -19,6 +19,13 @@ class DisplayMgr
19
19
  @list = []
20
20
  end
21
21
 
22
+ def [](index)
23
+ raise TypeError,
24
+ "index #{index} should be a Fixnum, is #{index.class}" unless
25
+ index.is_a?(Fixnum)
26
+ @list.detect {|disp| disp.number == index }
27
+ end
28
+
22
29
  def add(frame, arg, fmt=nil)
23
30
  return nil unless frame
24
31
  begin
@@ -83,6 +90,18 @@ Num Enb Expression"
83
90
  end
84
91
  false
85
92
  end
93
+
94
+ def max
95
+ @list.map{|disp| disp.number}.max
96
+ end
97
+
98
+ def nums
99
+ @list.map{|disp| disp.number}
100
+ end
101
+
102
+ def size
103
+ @list.size
104
+ end
86
105
  end
87
106
 
88
107
  class Display
@@ -98,6 +117,22 @@ class Display
98
117
  @number = number
99
118
  end
100
119
 
120
+ def disable
121
+ @enabled = false
122
+ end
123
+
124
+ def disabled?
125
+ !@enabled
126
+ end
127
+
128
+ def enable
129
+ @enabled = true
130
+ end
131
+
132
+ def enabled?
133
+ @enabled
134
+ end
135
+
101
136
  def to_s(frame)
102
137
  return 'No symbol "' + @arg + '" in current context.' unless frame
103
138
 
@@ -119,6 +154,7 @@ class Display
119
154
  what += @arg if @arg
120
155
  '%3d: %s' % [@number, what]
121
156
  end
157
+
122
158
  end
123
159
 
124
160
  if __FILE__ == $0
@@ -134,6 +170,8 @@ if __FILE__ == $0
134
170
 
135
171
  x = 1
136
172
  mgr.add(frame, 'x > 1')
173
+ puts "Number of displays %s" % mgr.size
174
+ puts "Max Number %d" % mgr.max
137
175
  print_display(mgr)
138
176
 
139
177
  mgr.enable_disable(1, false)
data/app/file.rb ADDED
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ # Things related to file/module status
4
+
5
+ module Trepanning
6
+ module FileName
7
+ def find_load_path(filename)
8
+ cl = Rubinius::CodeLoader.new(filename)
9
+ if cl.verify_load_path(filename)
10
+ path = cl.instance_variable_get('@load_path')
11
+ path.end_with?(filename) ? filename : nil
12
+ else
13
+ nil
14
+ end
15
+ end
16
+ end
17
+ end
18
+ if __FILE__ == $0
19
+ include Trepanning::FileName
20
+ require 'tmpdir.rb'
21
+ [__FILE__, 'tmpdir.rb'].each do |name|
22
+ p find_load_path(name)
23
+ end
24
+ end
data/app/frame.rb CHANGED
@@ -3,8 +3,8 @@ class Trepan
3
3
 
4
4
  # Call-Stack frame methods
5
5
  class Frame
6
- def initialize(debugger, number, vm_location)
7
- @debugger = debugger
6
+ def initialize(dbgr, number, vm_location)
7
+ @debugger = dbgr
8
8
  @number = number
9
9
  @vm_location = vm_location
10
10
  end
@@ -49,7 +49,9 @@ class Trepan
49
49
  end
50
50
  end
51
51
 
52
- str = "#{recv} at #{loc.method.active_path}:#{loc.line}"
52
+ filename = loc.method.active_path
53
+ filename = File.basename(filename) if opts[:basename]
54
+ str = "#{recv} at #{filename}:#{loc.line}"
53
55
  if opts[:show_ip]
54
56
  str << " (@#{loc.ip})"
55
57
  end
@@ -70,7 +72,8 @@ class Trepan
70
72
  end
71
73
 
72
74
  def line
73
- @vm_location.line
75
+ line_no = @vm_location.line
76
+ line_no == 0 ? ISeq::tail_code_line(method, next_ip) : line_no
74
77
  end
75
78
 
76
79
  def local_variables
@@ -85,6 +88,10 @@ class Trepan
85
88
  @vm_location.variables
86
89
  end
87
90
 
91
+ def stack_size
92
+ @debugger.vm_locations.size
93
+ end
94
+
88
95
  def eval?
89
96
  static = @vm_location.static_scope
90
97
  static && static.script && static.script.eval_source
data/app/irb.rb CHANGED
@@ -6,49 +6,51 @@ module IRB # :nodoc:
6
6
  # FIXME: should we read these out of a directory to
7
7
  # make this more user-customizable?
8
8
 
9
- # A base command class that resume execution
10
- class DebuggerResumeCommand
11
- def self.execute(conf, *opts)
12
- name =
13
- if self.name =~ /IRB::ExtendCommand::(\S+)/
14
- $1.downcase
15
- else
16
- 'unknown'
17
- end
18
- $trepan_args = opts
19
- $trepan_command =
20
- if $trepan_irb_statements
21
- $trepan_irb_statements
22
- else
23
- ([name] + opts).join(' ')
24
- end
25
-
26
- throw :IRB_EXIT, name.to_sym
9
+ unless defined? Continue
10
+ # A base command class that resume execution
11
+ class DebuggerResumeCommand
12
+ def self.execute(conf, *opts)
13
+ name =
14
+ if self.name =~ /IRB::ExtendCommand::(\S+)/
15
+ $1.downcase
16
+ else
17
+ 'unknown'
18
+ end
19
+ $trepan_args = opts
20
+ $trepan_command =
21
+ if $trepan_irb_statements
22
+ $trepan_irb_statements
23
+ else
24
+ ([name] + opts).join(' ')
25
+ end
26
+
27
+ throw :IRB_EXIT, name.to_sym
28
+ end
27
29
  end
28
- end
29
-
30
- class Continue < DebuggerResumeCommand ; end
31
- class Finish < DebuggerResumeCommand ; end
32
- class Next < DebuggerResumeCommand ; end
33
- class Quit < DebuggerResumeCommand ; end
34
- class Step < DebuggerResumeCommand ; end
35
-
36
- # Issues a comamnd to the debugger without continuing
37
- # execution.
38
- class Dbgr
39
- def self.execute(conf, *opts)
40
- $trepan_command =
41
- if opts.size == 1 && opts[0].is_a?(String)
42
- $trepan_args = opts[0]
43
- else
44
- opts.join(' ')
45
- end
46
- dbg_cmdproc = conf.workspace.instance_variable_get('@dbg_cmdproc')
47
- dbg_cmdproc.run_command($trepan_command)
30
+
31
+ class Continue < DebuggerResumeCommand ; end
32
+ class Finish < DebuggerResumeCommand ; end
33
+ class Next < DebuggerResumeCommand ; end
34
+ class Quit < DebuggerResumeCommand ; end
35
+ class Step < DebuggerResumeCommand ; end
36
+
37
+ # Issues a comamnd to the debugger without continuing
38
+ # execution.
39
+ class Dbgr
40
+ def self.execute(conf, *opts)
41
+ $trepan_command =
42
+ if opts.size == 1 && opts[0].is_a?(String)
43
+ $trepan_args = opts[0]
44
+ else
45
+ opts.join(' ')
46
+ end
47
+ dbg_cmdproc = conf.workspace.instance_variable_get('@dbg_cmdproc')
48
+ dbg_cmdproc.run_command($trepan_command)
49
+ end
48
50
  end
49
51
  end
50
-
51
52
  end
53
+
52
54
  if defined?(ExtendCommandBundle)
53
55
  # New irb Commands which are the same name as their debugger
54
56
  # counterpart
data/app/iseq.rb CHANGED
@@ -61,6 +61,42 @@ class Trepan
61
61
  end
62
62
  end
63
63
 
64
+ def ip_ranges_for_line(lines, line)
65
+ result = []
66
+ in_range = false
67
+ start_ip = nil
68
+ total = lines.size
69
+ i = 1
70
+ while i < total
71
+ cur_line = lines.at(i)
72
+ if cur_line == line
73
+ start_ip = lines.at(i-1)
74
+ in_range = true
75
+ elsif cur_line > line && in_range
76
+ result << [start_ip, lines.at(i-1)]
77
+ start_ip = nil
78
+ in_range = false
79
+ end
80
+ i += 2
81
+ end
82
+ if in_range && start_ip
83
+ result << [start_ip, lines.at(total-1)]
84
+ end
85
+ result
86
+ end
87
+
88
+ # Return range of ips covering ip. There will be only one of these.
89
+ # We surround this in another list to match the format of
90
+ # ip_ranges_for_line.
91
+ def ip_ranges_for_ip(lines, ip)
92
+ total = lines.size
93
+ i = 0
94
+ while i < total and lines.at(i) <= ip
95
+ i += 2
96
+ end
97
+ [[lines.at(i-2), lines.at(i)]]
98
+ end
99
+
64
100
  def next_interesting(cm, ip)
65
101
  pop = Rubinius::InstructionSet.opcodes_map[:pop]
66
102
 
@@ -70,6 +106,41 @@ class Trepan
70
106
 
71
107
  return ip
72
108
  end
109
+
110
+ # start is assumed to be on a tail code "synthesized" line, which
111
+ # has line number 0. Follow opcodes until we get to a line that is
112
+ # not 0.
113
+ def tail_code_line(cm, start)
114
+
115
+ iseq = cm.iseq
116
+
117
+ i = start
118
+ fin = cm.lines.last
119
+ while i < fin
120
+ line_no = cm.line_from_ip(i)
121
+ return line_no if line_no > 0
122
+ op = iseq[i]
123
+ case op
124
+ when OP_GOTO_IF_TRUE, OP_GOTO_IF_FALSE, OP_GOTO
125
+ when OP_GOTO
126
+ i = iseq[i+1]
127
+ when OP_RET
128
+ return -2
129
+ when nil
130
+ return -1
131
+ else
132
+ # Rubinius is getting an error here sometimes. Need to figure
133
+ # out what's wrong.
134
+ begin
135
+ op = Rubinius::InstructionSet[op]
136
+ rescue TypeError
137
+ return -1
138
+ end
139
+ i += (op.arg_count + 1)
140
+ end
141
+ end
142
+ return 0
143
+ end
73
144
 
74
145
  def yield_or_return_between(cm, start, fin)
75
146
  iseq = cm.iseq
data/app/options.rb CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  #!/usr/bin/env ruby
2
3
  # -*- coding: utf-8 -*-
3
4
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
@@ -9,8 +10,8 @@ class Trepan
9
10
  require 'rubygems'; require 'require_relative'
10
11
  require_relative 'default'
11
12
 
12
- Trepan::VERSION = '0.0.8'
13
- Trepan::PROGRAM = 'trepanx'
13
+ VERSION = '0.1.0'
14
+ PROGRAM = 'trepanx' unless defined? Trepan::PROGRAM
14
15
 
15
16
  def self.show_version
16
17
  "#{PROGRAM}, version #{VERSION}"
@@ -34,16 +35,18 @@ class Trepan
34
35
  #{show_version}
35
36
  Usage: #{PROGRAM} [options] [[--] <script.rb> <script.rb parameters>]
36
37
  EOB
38
+ opts.separator ''
39
+ opts.separator 'Options:'
37
40
  opts.on('--client',
38
- "Connect to out-of-process program") do
41
+ 'Connect to out-of-process program') do
39
42
  if options[:server]
40
- stderr.puts "--server option previously given. --client option ignored."
43
+ stderr.puts '--server option previously given. --client option ignored.'
41
44
  else
42
45
  options[:client] = true
43
46
  end
44
47
  end
45
48
  opts.on('-c', '--command FILE', String,
46
- "Execute debugger commands from FILE") do |cmdfile|
49
+ 'Execute debugger commands from FILE') do |cmdfile|
47
50
  if File.readable?(cmdfile)
48
51
  options[:cmdfiles] << cmdfile
49
52
  elsif File.exists?(cmdfile)
@@ -52,14 +55,7 @@ EOB
52
55
  stderr.puts "Command file '#{cmdfile}' does not exist."
53
56
  end
54
57
  end
55
- opts.on('--nx',
56
- "Do not run debugger initialization file #{CMD_INITFILE}") do
57
- options[:nx] = true
58
- end
59
- # opts.on('--output FILE', String, "Name of file to record output") do |outfile|
60
- # options[:outfile] = outfile
61
- # end
62
- opts.on("--cd DIR", String, "Change current directory to DIR") do |dir|
58
+ opts.on('--cd DIR', String, 'Change current directory to DIR') do |dir|
63
59
  if File.directory?(dir)
64
60
  if File.executable?(dir)
65
61
  options[:chdir] = dir
@@ -70,40 +66,69 @@ EOB
70
66
  stderr.puts "\"#{dir}\" is not a directory. Option --cd ignored."
71
67
  end
72
68
  end
73
- opts.on("-h", "--host NAME", String,
74
- "Host or IP used in TCP connections for --server or --client. " +
69
+ opts.on('--basename',
70
+ 'Show only file basename in file locations') do
71
+ options[:basename] = true
72
+ end
73
+ opts.on('-d', '--debug', 'Set $DEBUG=true') do
74
+ $DEBUG = true
75
+ end
76
+ opts.on('--[no-]highlight',
77
+ 'Use [no] syntax highlight output') do |v|
78
+ options[:highlight] = ((v) ? :term : nil)
79
+ end
80
+ opts.on('-h', '--host NAME', String,
81
+ 'Host or IP used in TCP connections for --server or --client. ' +
75
82
  "Default is #{DEFAULT_SETTINGS[:host].inspect}.") do
76
83
  |name_or_ip|
77
84
  options[:host] = name_or_ip
78
85
  end
79
- opts.on("-p", "--port NUMBER", Integer,
80
- "Port number used in TCP connections for --server or --client. " +
86
+ opts.on('-I', '--include PATH', String, 'Add PATH to $LOAD_PATH') do
87
+ |path|
88
+ $LOAD_PATH.unshift(path)
89
+ end
90
+ opts.on('--nx',
91
+ "Do not run debugger initialization file #{CMD_INITFILE}") do
92
+ options[:nx] = true
93
+ end
94
+ opts.on('-p', '--port NUMBER', Integer,
95
+ 'Port number used in TCP connections for --server or --client. ' +
81
96
  "Default is #{DEFAULT_SETTINGS[:port]}.") do
82
97
  |num|
83
98
  options[:port] = num
84
99
  end
85
- opts.on('--server',
86
- "Set up for out-of-process debugging") do
100
+ opts.on('--[no-]readline',
101
+ 'Try [not] GNU Readline') do |v|
102
+ options[:readline] = v
103
+ end
104
+ opts.on('-r', '--require SCRIPT', String,
105
+ 'Require the library, before executing your script') do |name|
106
+ if name == 'debug'
107
+ stderr.puts "ruby-debug is not compatible with Ruby's 'debug' library. This option is ignored."
108
+ else
109
+ require name
110
+ end
111
+ end
112
+ opts.on('-s', '--server',
113
+ 'Set up for out-of-process debugging') do
87
114
  if options[:client]
88
- stderr.puts "--client option previously given. --server option ignored."
115
+ stderr.puts '--client option previously given. --server option ignored.'
89
116
  else
90
117
  options[:server] = true
91
118
  end
92
119
  end
93
- opts.on('--[no-]highlight',
94
- "Use [no] syntax highlight output") do |v|
95
- options[:highlight] = ((v) ? :term : nil)
96
- end
97
- opts.on('--[no-]readline',
98
- "Try [not] GNU Readline") do |v|
99
- options[:readline] = v
120
+ opts.on('-x', '--trace', 'Turn on line tracing') do
121
+ options[:traceprint] = true
122
+ options[:nx] = true
100
123
  end
101
- opts.on_tail("-?", "--help", "Show this message") do
124
+ opts.separator ''
125
+ opts.on_tail('-?', '--help', 'Show this message') do
102
126
  options[:help] = true
103
127
  stdout.puts opts
128
+ exit
104
129
  end
105
- opts.on_tail("-v", "--version",
106
- "print the version") do
130
+ opts.on_tail('-v', '--version',
131
+ 'print the version') do
107
132
  options[:version] = true
108
133
  stdout.puts show_version
109
134
  end