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
data/app/options.rb CHANGED
@@ -9,7 +9,7 @@ class Trepan
9
9
  require 'rubygems'; require 'require_relative'
10
10
  require_relative 'default'
11
11
 
12
- Trepan::VERSION = '0.0.6'
12
+ Trepan::VERSION = '0.0.7'
13
13
  Trepan::PROGRAM = 'trepanx'
14
14
 
15
15
  def self.show_version
@@ -32,7 +32,7 @@ class Trepan
32
32
  OptionParser.new do |opts|
33
33
  opts.banner = <<EOB
34
34
  #{show_version}
35
- Usage: #{PROGRAM} [options] <script.rb> [-- <script.rb parameters>]
35
+ Usage: #{PROGRAM} [options] [[--] <script.rb> <script.rb parameters>]
36
36
  EOB
37
37
  opts.on('--client',
38
38
  "Connect to out-of-process program") do
data/app/run.rb CHANGED
@@ -4,7 +4,7 @@ require 'rbconfig'
4
4
  require 'rubygems'; require 'require_relative'
5
5
  module Trepanning
6
6
 
7
- :module_function # All functions below are easily publically accessible
7
+ module_function # All functions below are easily publically accessible
8
8
 
9
9
  # Given a Ruby interpreter and program we are to debug, debug it.
10
10
  # The caller must ensure that ARGV is set up to remove any debugger
@@ -47,7 +47,10 @@ module Trepanning
47
47
  :skip_loader => true
48
48
  }.merge(start_opts)
49
49
  dbgr.start(start_opts)
50
- Kernel::load program_to_debug
50
+ begin
51
+ Kernel::load program_to_debug
52
+ rescue Interrupt
53
+ end
51
54
 
52
55
  # The dance we have to undo to restore $0 and undo the mess created
53
56
  # above.
@@ -59,7 +62,6 @@ module Trepanning
59
62
  def ruby_path
60
63
  File.join(%w(bindir RUBY_INSTALL_NAME).map{|k| RbConfig::CONFIG[k]})
61
64
  end
62
- module_function :ruby_path
63
65
 
64
66
  # Do a shell-like path lookup for prog_script and return the results.
65
67
  # If we can't find anything return prog_script.
data/bin/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /*~
2
+ /*.rbc
data/data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /*~
2
+ /*.rbc
data/doc/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /*~
data/doc/debugger.html ADDED
@@ -0,0 +1,108 @@
1
+ ---
2
+ title: Debugger
3
+ ---
4
+
5
+ Debugger
6
+ ========
7
+
8
+ Trepanning source-level debugger
9
+
10
+ Invoking in Code
11
+ ----------------
12
+
13
+ The Rubinius debugger can be invoked from code by embedding a call to start
14
+ the debugger
15
+
16
+ Consider the following code in app.rb
17
+
18
+ class Toast
19
+ attr_accessor :setting
20
+ def initialize
21
+ require 'rubygems'
22
+ require 'trepanning'
23
+ Trepan.start ## See Note 1 below.
24
+ @setting = :brown
25
+ @kind = :rye
26
+ end
27
+ end
28
+
29
+ p Toast.new.setting
30
+
31
+ Running the code in Rubinius would produce the following:
32
+
33
+ $ rbx app.rb
34
+
35
+ | Breakpoint: Toast#initialize at tmp/toast.rb:5
36
+ | 5: Trepan.start ## See Note 1 below.
37
+ (trepanx): help
38
+
39
+ Classes of commands:
40
+ breakpoints -- Making the program stop at certain points
41
+ data -- Examining data
42
+ files -- Specifying and examining files
43
+ running -- Running the program
44
+ stack -- Examining the call stack
45
+ status -- Status inquiries
46
+ support -- Support facilities
47
+
48
+ Type "help" followed by a class name for a list of commands in that class.
49
+ Type "help *" for the list of all commands.
50
+ Type "help REGEXP" for the list of commands matching /^#{REGEXP}/
51
+ Type "help CLASS *" for the list of all commands in class CLASS.
52
+ Type "help" followed by command name for full documentation.
53
+
54
+ (trepanx): help *
55
+ All command names:
56
+ alias delete exit kill restart step
57
+ backtrace disassemble frame next set tbreak
58
+ break down help nexti show unalias
59
+ continue eval info ps source up
60
+ (trepanx): bt
61
+ Backtrace:
62
+ 0 Toast#initialize at tmp/toast.rb:5
63
+ 1 main.__script__ at tmp/toast.rb:11
64
+ 2 Rubinius::CodeLoader#load_script(debug) at kernel/delta/codeloader.rb:67
65
+ 3 Rubinius::CodeLoader.load_script(name) at kernel/delta/codeloader.rb:91
66
+ 4 Rubinius::Loader#script at kernel/loader.rb:460
67
+ 5 Rubinius::Loader#main at kernel/loader.rb:552
68
+ 6 Rubinius::Loader.main at kernel/loader.rb:589
69
+ 7 Object#__script__ at kernel/loader.rb:601
70
+ (trepanx): n
71
+
72
+ | Breakpoint: Toast#initialize at app.rb:6 (16)
73
+ | 6: @setting = :brown
74
+ (trepanx): n
75
+
76
+ | Breakpoint: Toast#initialize at app.rb:7 (21)
77
+ | 7: @kind = :rye
78
+ (trepanx): eval @setting = :light_brown ## See Note 2 below.
79
+ $d0 = :light_brown
80
+ (trepanx): c # See Note 3.
81
+ :light_brown # output from running program
82
+
83
+ Help for the debugger commands is available by typing `help` when in the
84
+ debugger.
85
+
86
+ ** Note 1.
87
+ Or if you haven't mucked with ARGV, Dir.pwd, and $0 use:
88
+ Trepan.start(:set_restart => true). This tells the debugger to
89
+ capture this information so you can easily restart your program if you
90
+ need to.
91
+
92
+ ** Note 2.
93
+ If you run "set autoeval on" (actually this is on by default), then
94
+ unrecognized commands are automatically evaluated. So the "eval" is
95
+ not needed. However if this confuses you "set autoeval off". Another
96
+ way to explicitly evaluate commands is to start the line with !.
97
+
98
+ ** Note 3.
99
+
100
+ To quit execution, you can use exit which prompts for confimation or
101
+ q! which won't prompt. You can supply an exit code to return to the
102
+ OS. A related command is "kill" which sends a signal to the process,
103
+ the default when none is supplied being "TERM". Finally there's
104
+ "restart" which you would use if you had started with :set_restart =>
105
+ true.
106
+
107
+
108
+ More later....
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
data/interface/user.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
 
4
- # Interface when communicating with the user in the same process as
5
- # the debugged program.
4
+ # Interface when communicating with the user.
6
5
 
7
6
  # Our local modules
8
7
 
@@ -33,8 +32,8 @@ class Trepan::UserInterface < Trepan::Interface
33
32
  else
34
33
  Trepan::UserInput.open(inp, {:readline => opts[:readline]})
35
34
  end
36
- if Trepan::GNU_readline? && opts[:complete]
37
- Readline.completion_proc = opts[:complete]
35
+ if Trepan::GNU_readline? && @opts[:complete]
36
+ Readline.completion_proc = @opts[:complete]
38
37
  read_history
39
38
  end
40
39
  at_exit { finalize }
@@ -102,7 +101,7 @@ class Trepan::UserInterface < Trepan::Interface
102
101
  end
103
102
 
104
103
  def finalize(last_wishes=nil)
105
- # print exit annotation
104
+ # ?? print gdb-style exit annotation if annotate = 2?
106
105
  if Trepan::GNU_readline? && @history_save
107
106
  save_history
108
107
  end
@@ -111,11 +110,13 @@ class Trepan::UserInterface < Trepan::Interface
111
110
 
112
111
  def interactive? ; @input.interactive? end
113
112
 
114
- def read_command(prompt=''); readline(prompt) end
113
+ def read_command(prompt='')
114
+ readline(prompt)
115
+ end
115
116
 
116
117
  def readline(prompt='')
117
118
  @output.flush
118
- if @input.line_edit && @opts[:use_readline]
119
+ if @input.line_edit && @opts[:readline]
119
120
  @input.readline(prompt)
120
121
  else
121
122
  @output.write(prompt) if prompt and prompt.size > 0
data/io/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /*.rbc
2
+ /*~
3
+
data/io/input.rb CHANGED
@@ -21,7 +21,7 @@ class Trepan
21
21
  @input = inp || STDIN
22
22
  @eof = false
23
23
  @line_edit = @opts[:line_edit]
24
- @use_readline = opts[:readline]
24
+ @use_readline = @opts[:readline]
25
25
  end
26
26
 
27
27
  def closed?; @input.closed? end
@@ -30,7 +30,6 @@ class Trepan
30
30
  def interactive?
31
31
  @input.respond_to?(:isatty) && @input.isatty
32
32
  end
33
-
34
33
  # Read a line of input. EOFError will be raised on EOF.
35
34
  def readline(prompt='')
36
35
  raise EOFError if eof?
@@ -66,9 +65,15 @@ class Trepan
66
65
  end
67
66
 
68
67
  def finalize
69
- if defined?(RbReadline) && !@@readline_finalized
70
- RbReadline.rl_cleanup_after_signal()
71
- RbReadline.rl_deprep_terminal()
68
+ if defined?(RbReadline) && !@@readline_finalized
69
+ begin
70
+ RbReadline.rl_cleanup_after_signal()
71
+ rescue
72
+ end
73
+ begin
74
+ RbReadline.rl_deprep_terminal()
75
+ rescue
76
+ end
72
77
  @@readline_finalized = true
73
78
  end
74
79
  end
@@ -79,7 +84,10 @@ end
79
84
  def Trepan::GNU_readline?
80
85
  begin
81
86
  return @use_readline unless @use_readline.nil?
82
- @use_readline ||= require 'rb-readline.rb'
87
+ %w(rb-readline rb-readline.rb/readline).each do |gem_name|
88
+ @use_readline ||= require gem_name
89
+ break if @use_readline
90
+ end
83
91
  if @use_readline
84
92
  # Returns current line buffer
85
93
  def Readline.line_buffer
@@ -131,5 +139,3 @@ if __FILE__ == $0
131
139
  end
132
140
  end
133
141
  end
134
-
135
-
data/lib/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
data/lib/trepanning.rb CHANGED
@@ -1,10 +1,11 @@
1
+ #!/usr/bin/env ruby
1
2
  # -*- coding: utf-8 -*-
2
- # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
4
  require 'readline'
4
5
  require 'compiler/iseq'
5
6
 
6
7
  require 'rubygems'; require 'require_relative'
7
- require_relative '../app/complete'
8
+ require_relative '../app/complete' # command completion
8
9
  require_relative '../app/frame'
9
10
  require_relative '../app/util' # get_dollar_0
10
11
  require_relative '../processor/main'
@@ -12,6 +13,7 @@ require_relative '../app/breakpoint'
12
13
  require_relative '../app/default' # default debugger settings
13
14
  require_relative '../app/breakpoint'
14
15
  require_relative '../interface/user' # user interface (includes I/O)
16
+ require_relative '../interface/script' # --command interface (includes I/O)
15
17
  require_relative '../interface/client' # client interface (remote debugging)
16
18
  require_relative '../interface/server' # server interface (remote debugging)
17
19
  require_relative '../io/null_output'
@@ -26,7 +28,6 @@ class Trepan
26
28
  attr_accessor :breakpoint # Breakpoint. The current breakpoint we are
27
29
  # stopped at or nil if none.
28
30
  attr_accessor :intf # Array. The way the outside world
29
- # interfaces with us. An array, so that
30
31
  # interfaces with us. An array, so that
31
32
  # interfaces can be stacked.
32
33
  attr_accessor :restart_argv # How to restart us, empty or nil.
@@ -129,40 +130,24 @@ class Trepan
129
130
 
130
131
  # The method is called when we want to do debugger command completion
131
132
  # such as called from GNU Readline with <TAB>.
132
- def completion_method(str, leading=Readline.line_buffer)
133
- args =
134
- if str.empty? && leading.end_with?(' ')
135
- # A line ending with a blank means we want to get all completions
136
- # of the *next* token, not the current token.
137
- leading.split(' ').compact + ['']
138
- else
139
- # We split on a single blank rather than sequences of spaces
140
- # because we need to keep the line exactly as it is except for the
141
- # last token
142
- leading.split(' ').compact
143
- end
144
- completion = @processor.complete(args)
133
+ def completion_method(last_token, leading=Readline.line_buffer)
134
+ completion = @processor.complete(leading, last_token)
145
135
  if 1 == completion.size
146
- last_token = completion[0].split[-1]
147
- if last_token == str
148
- # If we were at the end of a complete token add a space so that
149
- # the next time, we'll complete any context after that.
150
- [str + ' ']
151
- elsif str.end_with?(' ') && str.strip == last_token
152
- # There is nothing more to complete
153
- []
154
- elsif str.empty? && completion[0] == leading
155
- # There is also nothing more to complete
156
- []
136
+ completion_token = completion[0]
137
+ if last_token.end_with?(' ')
138
+ if last_token.rstrip == completion_token
139
+ # There is nothing more to complete
140
+ []
141
+ else
142
+ []
143
+ end
157
144
  else
158
- [last_token]
145
+ [completion_token]
159
146
  end
160
147
  else
161
148
  # We have multiple completions. Get the last token so that will
162
149
  # be presented as a list of completions.
163
- completion.map do |cmd|
164
- cmd.split[-1]
165
- end
150
+ completion
166
151
  end
167
152
  end
168
153
 
@@ -244,6 +229,7 @@ class Trepan
244
229
  alias debugger start
245
230
 
246
231
  def stop(settings = {})
232
+ @processor.finalize
247
233
  Rubinius::VM.debug_channel = nil
248
234
  end
249
235
 
@@ -309,9 +295,15 @@ class Trepan
309
295
  if @breakpoint
310
296
  # Some breakpoints are frame specific. Check for this. hit!
311
297
  # also removes the breakpoint if it was temporary and hit.
312
- break if @breakpoint.hit!(@vm_locations.first.variables)
298
+ status = @breakpoint.hit!(@vm_locations.first.variables)
299
+ if status
300
+ break
301
+ elsif status.nil?
302
+ # A permanent breakpoint. Check the condition.
303
+ break if @breakpoint.condition?(@current_frame.binding)
304
+ end
313
305
  else
314
- @processor.step_bp.remove! if @processor.step_bp
306
+ @processor.remove_step_brkpt
315
307
  break
316
308
  end
317
309
  end
@@ -0,0 +1,3 @@
1
+ /*.rbc
2
+ /*~
3
+
@@ -0,0 +1,7 @@
1
+ # Whatever it is you want to do, it should be forwarded to the
2
+ # to top-level irectories
3
+ PHONY=check
4
+ check:
5
+
6
+ %:
7
+ $(MAKE) -C .. $@
@@ -19,6 +19,10 @@ class Trepan
19
19
  @brkpt = nil
20
20
  end
21
21
 
22
+ def breakpoint_finalize
23
+ @brkpts.finalize
24
+ end
25
+
22
26
  def breakpoint?
23
27
  @brkpt = @dbgr.breakpoint
24
28
  return !!@brkpt && %w(tbrkpt brkpt).member?(@brkpt.event)
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -33,6 +33,11 @@ See also 'set hidelevel'.
33
33
  NEED_STACK = true
34
34
  SHORT_HELP = 'Show the current call stack'
35
35
 
36
+ def complete(prefix)
37
+ @proc.frame_complete(prefix, nil)
38
+ end
39
+
40
+ # This method runs the command
36
41
  def run(args)
37
42
  verbose_ary, count_ary = args[1..-1].partition {|item| item =~ /full/i}
38
43
  verbose = !verbose_ary.empty?
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
@@ -202,7 +202,8 @@ module Trepanning
202
202
  dirname = File.basename(File.dirname(File.expand_path(__file__)))
203
203
  name = File.basename(__file__, '.rb')
204
204
  klass.const_set('NAME', name)
205
- klass.const_set('PREFIX', %W(#{dirname[0...-'_subcmd'.size]} #{name}))
205
+ prefix = klass.const_set('PREFIX', %W(#{dirname[0...-'_subcmd'.size]} #{name}))
206
+ klass.const_set('CMD', prefix.join(' '))
206
207
  end
207
208
  end
208
209
  end
@@ -1,5 +1,5 @@
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
  # A base class for debugger subcommands of subcommands.
4
4
  #
5
5
  # Note: don't end classname with Command (capital C as in SubCommand),
@@ -63,6 +63,7 @@ class Trepan
63
63
  end
64
64
 
65
65
  class SetBoolSubSubcommand < SubSubcommand
66
+ completion %w(on off)
66
67
  def run(args)
67
68
  run_set_bool(args)
68
69
  end
@@ -86,6 +87,27 @@ class Trepan
86
87
  end
87
88
  end
88
89
 
90
+ module Trepanning
91
+ module SubSubcommand
92
+ module_function
93
+ def set_name_prefix(__file__, klass)
94
+ full_dirname = File.dirname(File.expand_path(__file__))
95
+ full_parent_dirname = File.expand_path(File.join(full_dirname, '..'))
96
+ dirname = File.basename(full_dirname)
97
+ parent_dirname = File.basename(full_parent_dirname)
98
+ name = File.basename(__file__, '.rb')
99
+ klass.const_set('NAME', name)
100
+
101
+ short_dirname = dirname[0...-'_subcmd'.size]
102
+ short_parent_dirname = parent_dirname[0...-'_subcmd'.size]
103
+ prefix = klass.const_set('PREFIX', %W(#{short_parent_dirname}
104
+ #{short_dirname} #{name}))
105
+ klass.const_set('CMD', prefix.join(' '))
106
+ end
107
+ end
108
+ end
109
+
110
+
89
111
  if __FILE__ == $0
90
112
  # Demo it.
91
113
  require_relative '../../mock'
@@ -154,7 +154,8 @@ class Trepan::SubSubcommandMgr < Trepan::Subcommand
154
154
  end
155
155
 
156
156
  def complete_token_with_next(prefix)
157
- Trepan::Complete.complete_token_with_next(@subcmds.subcmds, prefix)
157
+ Trepan::Complete.complete_token_with_next(@subcmds.subcmds, prefix,
158
+ self.prefix.join(''))
158
159
  end
159
160
 
160
161
  def run(args)
@@ -18,7 +18,8 @@ List the completions for the rest of the line as a command.
18
18
 
19
19
  # This method runs the command
20
20
  def run(args) # :nodoc
21
- @proc.complete(args[1..-1]).each do |match|
21
+ last_arg = @proc.cmd_argstr.end_with?(' ') ? '' : args[-1]
22
+ @proc.complete(@proc.cmd_argstr, last_arg).each do |match|
22
23
  msg match
23
24
  end
24
25
  end
@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'base/cmd'
5
+ require_relative '../breakpoint'
6
+ require_relative '../../app/breakpoint'
7
+ require_relative '../../app/condition'
8
+
9
+ class Trepan::Command::ConditionCommand < Trepan::Command
10
+
11
+ unless defined?(HELP)
12
+ NAME = File.basename(__FILE__, '.rb')
13
+ HELP = <<-HELP
14
+ #{NAME} BP_NUMBER CONDITION
15
+
16
+ BP_NUMBER is a breakpoint number. CONDITION is an expression which
17
+ must evaluate to True before the breakpoint is honored. If CONDITION
18
+ is absent, any existing condition is removed; i.e., the breakpoint is
19
+ made unconditional.
20
+
21
+ Examples:
22
+ #{NAME} 5 x > 10 # Breakpoint 5 now has condition x > 10
23
+ #{NAME} 5 # Remove above condition
24
+ HELP
25
+
26
+ ALIASES = %w(cond)
27
+ CATEGORY = 'breakpoints'
28
+ MIN_ARGS = 1
29
+ NEED_STACK = false
30
+ SHORT_HELP = 'Specify breakpoint number N to break only if COND is true'
31
+ end
32
+
33
+ include Trepan::Condition
34
+
35
+ def run(args)
36
+ bpnum = @proc.get_an_int(args[1])
37
+ bp = @proc.breakpoint_find(bpnum)
38
+ return unless bp
39
+
40
+ if args.size > 2
41
+ condition = args[2..-1].join(' ')
42
+ return unless valid_condition?(condition)
43
+ else
44
+ condition = 'true'
45
+ msg('Breakpoint %d is now unconditional.' % bp.id)
46
+ end
47
+ bp.condition = condition
48
+ end
49
+ end
50
+
51
+ if __FILE__ == $0
52
+ require_relative '../mock'
53
+ dbgr, cmd = MockDebugger::setup
54
+
55
+ cmd.run([cmd.name, '1'])
56
+ cmdproc = dbgr.processor
57
+ cmds = cmdproc.commands
58
+ break_cmd = cmds['break']
59
+ break_cmd.run([break_cmd.name, __LINE__.to_s])
60
+ cmd.run([cmd.name, '1', 'x' '>' '10'])
61
+ cmd.run([cmd.name, '1'])
62
+ end
@@ -1,5 +1,5 @@
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 'up'
5
5
 
@@ -10,14 +10,14 @@ class Trepan::Command::DownCommand < Trepan::Command::UpCommand
10
10
  # Silence already initialized constant .. warnings
11
11
  old_verbose = $VERBOSE
12
12
  $VERBOSE = nil
13
- HELP =
14
- "d(own) [count]
13
+ HELP = <<-HELP
14
+ #{NAME} [count]
15
15
 
16
16
  Move the current frame down in the stack trace (to a newer frame). 0
17
17
  is the most recent frame. If no count is given, move down 1.
18
18
 
19
19
  See also 'up' and 'frame'.
20
- "
20
+ HELP
21
21
 
22
22
  ALIASES = %w(d)
23
23
  NAME = File.basename(__FILE__, '.rb')
@@ -5,8 +5,9 @@ require_relative './base/cmd'
5
5
 
6
6
  class Trepan::Command::EvalCommand < Trepan::Command
7
7
 
8
+ old_verbose = $VERBOSE
9
+ $VERBOSE = nil
8
10
  NAME = File.basename(__FILE__, '.rb')
9
- CATEGORY = 'data'
10
11
  HELP = <<-HELP
11
12
  #{NAME} [STRING]
12
13
 
@@ -17,23 +18,30 @@ may be used again easily. The name of the global variable is printed
17
18
  next to the inspect output of the value.
18
19
 
19
20
  If no string is given we run the string from the current source code
20
- about to be run
21
+ about to be run. If the command ends ? (via an alias) and no string
22
+ is given we will also strip off any leading 'if', 'while', 'elseif' or
23
+ 'until' in the string.
21
24
 
22
25
  #{NAME} 1+2 # 3
23
26
  #{NAME} @v
24
27
  #{NAME} # Run current source-code line
28
+ #{NAME}? # but strips off leading 'if', 'while', 'elsif' or 'until'
29
+ # from command
25
30
 
26
31
  See also 'set autoeval'
27
32
  HELP
28
33
 
29
- NAME = File.basename(__FILE__, '.rb')
34
+ ALIASES = %w(eval? ev? ev)
35
+ CATEGORY = 'data'
30
36
  NEED_STACK = true
31
37
  SHORT_HELP = 'Run code in the current context'
38
+ $VERBOSE = old_verbose
39
+
32
40
  def run(args)
33
41
  if args.size == 1
34
- loc = @proc.source_location_info
35
- opts = {:reload_on_change => @proc.reload_on_change}
36
- loc, junk, text = @proc.loc_and_text(loc, opts)
42
+ text = @proc.current_source_text
43
+ text.gsub!(/^\s*(?:if|elsif|until|while)\s*/,'') if
44
+ '?' == args[0][-1..-1]
37
45
  msg "eval: #{text}"
38
46
  else
39
47
  text = @proc.cmd_argstr