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/rbx-llvm.rb CHANGED
@@ -8,8 +8,6 @@ module CodeRay
8
8
 
9
9
  class LLVM < Scanner
10
10
 
11
- include Streamable
12
-
13
11
  register_for :llvm
14
12
  file_extension 'llvm'
15
13
 
data/app/run.rb CHANGED
@@ -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 'rbconfig'
4
4
  require 'rubygems'; require 'require_relative'
5
5
  module Trepanning
@@ -58,16 +58,12 @@ module Trepanning
58
58
  ## untrace_var(:$0, dollar_0_tracker)
59
59
  end
60
60
 
61
- # Path name of Ruby interpreter we were invoked with.
62
- def ruby_path
63
- File.join(%w(bindir RUBY_INSTALL_NAME).map{|k| RbConfig::CONFIG[k]})
64
- end
65
-
66
61
  # Do a shell-like path lookup for prog_script and return the results.
67
62
  # If we can't find anything return prog_script.
68
63
  def whence_file(prog_script)
69
- if prog_script.index(File::SEPARATOR)
70
- # Don't search since this name has path separator components
64
+ if prog_script.start_with?(File::SEPARATOR) || prog_script.start_with?('.')
65
+ # Don't search since this name has path is explicitly absolute or
66
+ # relative.
71
67
  return prog_script
72
68
  end
73
69
  for dirname in ENV['PATH'].split(File::PATH_SEPARATOR) do
@@ -79,10 +75,18 @@ module Trepanning
79
75
  end
80
76
  end
81
77
 
78
+ # Path name of Ruby interpreter we were invoked with. Is part of
79
+ # 1.9 but not necessarily 1.8.
80
+ def RbConfig.ruby
81
+ File.join(RbConfig::CONFIG['bindir'],
82
+ RbConfig::CONFIG['RUBY_INSTALL_NAME'] +
83
+ RbConfig::CONFIG['EXEEXT'])
84
+ end unless defined? RbConfig.ruby
85
+
82
86
  if __FILE__ == $0
83
87
  # Demo it.
84
88
  include Trepanning
85
89
  puts whence_file('irb')
86
90
  puts whence_file('probably-does-not-exist')
87
- puts ruby_path
91
+ puts RbConfig.ruby
88
92
  end
data/app/util.rb CHANGED
@@ -12,25 +12,69 @@ class Trepan
12
12
  end
13
13
  end
14
14
 
15
+ # name is String and list is an Array of String.
16
+ # If name is a unique leading prefix of one of the entries of list,
17
+ # then return that. Otherwise return name.
18
+ def uniq_abbrev(list, name)
19
+ candidates = list.select do |try_name|
20
+ try_name.start_with?(name)
21
+ end
22
+ candidates.size == 1 ? candidates.first : name
23
+ end
24
+
25
+ # extract the "expression" part of a line of source code.
26
+ #
27
+ def extract_expression(text)
28
+ if text =~ /^\s*(?:if|elsif|unless)\s+/
29
+ text.gsub!(/^\s*(?:if|elsif|unless)\s+/,'')
30
+ text.gsub!(/\s+then\s*$/, '')
31
+ elsif text =~ /^\s*(?:until|while)\s+/
32
+ text.gsub!(/^\s*(?:until|while)\s+/,'')
33
+ text.gsub!(/\s+do\s*$/, '')
34
+ elsif text =~ /^\s*return\s+/
35
+ # EXPRESION in: return EXPRESSION
36
+ text.gsub!(/^\s*return\s+/,'')
37
+ elsif text =~ /^\s*case\s+/
38
+ # EXPRESSION in: case EXPESSION
39
+ text.gsub!(/^\s*case\s*/,'')
40
+ elsif text =~ /^\s*def\s*.*\(.+\)/
41
+ text.gsub!(/^\s*def\s*.*\((.*)\)/,'[\1]')
42
+ elsif text =~ /^\s*[A-Za-z_][A-Za-z0-9_\[\]]*\s*=[^=>]/
43
+ # RHS of an assignment statement.
44
+ text.gsub!(/^\s*[A-Za-z_][A-Za-z0-9_\[\]]*\s*=/,'')
45
+ end
46
+ return text
47
+ end
48
+
15
49
  # Find user portion of script skipping over Rubinius code loading.
16
50
  # Unless hidestack is off, we don't show parts of the frame below this.
17
51
  def find_main_script(locs)
18
52
  candidate = nil
19
53
  (locs.size-1).downto(0) do |i|
20
54
  loc = locs[i]
21
- if 'main.' == loc.describe_receiver &&
55
+ if 'Object#' == loc.describe_receiver &&
22
56
  :__script__ == loc.name
23
- if loc.method.active_path =~ /\/trepanx$/
57
+ if loc.method.active_path =~ /\/trepanx$/ ||
58
+ loc.method.active_path == 'kernel/loader.rb'
24
59
  # Might have been run from standalone trepanx.
25
60
  candidate = i
26
61
  else
27
- return locs.size - i - 1
62
+ return locs.size - i
28
63
  end
29
64
  end
30
65
  end
31
66
  candidate ? locs.size - candidate - 1 : nil
32
67
  end
33
- module_function :find_main_script
68
+
69
+ # Suppress warnings. The main one we encounter is "already initialized
70
+ # constant" because perhaps another version readline has done that already.
71
+ def suppress_warnings
72
+ original_verbosity = $VERBOSE
73
+ $VERBOSE = nil
74
+ result = yield
75
+ $VERBOSE = original_verbosity
76
+ return result
77
+ end
34
78
  end
35
79
  end
36
80
 
@@ -45,5 +89,11 @@ if __FILE__ == $0
45
89
  locs.each_with_index do |l, i|
46
90
  puts "#{i}: #{l.describe}"
47
91
  end
48
- puts "main script in above is #{locs.size() - 1 - find_main_script(locs)}"
92
+ ## puts "main script in above is #{locs.size() - 1 - find_main_script(locs)}"
93
+
94
+ list = %w(disassemble disable distance up)
95
+ p list
96
+ %w(dis disa u upper foo).each do |name|
97
+ puts "uniq_abbrev of #{name} is #{uniq_abbrev(list, name)}"
98
+ end
49
99
  end
data/bin/trepanx CHANGED
@@ -2,6 +2,7 @@
2
2
  # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  # Invoke debugger from the command line.
4
4
  require 'rubygems'; require 'require_relative'
5
+ require 'rbconfig' # For RbConfig.ruby
5
6
  require_relative '../app/run'
6
7
  require_relative '../app/options'
7
8
  require_relative '../app/client'
@@ -35,7 +36,6 @@ if File.basename(__FILE__) == File.basename($0)
35
36
 
36
37
  # FIXME: do we need to test defined?
37
38
  # FIXME: Should (some of) these be instance variables?
38
- Trepan::RUBY_PATH = ruby_path
39
39
  Trepan::TREPAN_PATH = trepan_path
40
40
 
41
41
  if ARGV.empty?
@@ -56,14 +56,14 @@ if File.basename(__FILE__) == File.basename($0)
56
56
  Trepan::PROG_SCRIPT = program_to_debug
57
57
 
58
58
  opts = {}
59
- %w(cmdfiles highlight initial_dir host nx port readline server
59
+ %w(cmdfiles highlight initial_dir host nx port readline server traceprint
60
60
  ).each do |opt|
61
61
  opts[opt.to_sym] = options[opt.to_sym]
62
62
  end
63
63
 
64
64
  # Set global so others may use this debugger.
65
65
  $trepan = Trepan.new(opts)
66
- debug_program($trepan, Trepan::RUBY_PATH,
66
+ debug_program($trepan, RbConfig.ruby,
67
67
  File.expand_path(program_to_debug))
68
68
  end
69
69
  end
data/data/irbrc CHANGED
@@ -1,13 +1,13 @@
1
1
  # -*- Ruby -*-
2
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  # We use this as the default startup file for irb inside trepan
4
4
  # Down the line we will have a way for folks to add/override this
5
5
  # with their own file.
6
6
  IRB.conf[:PROMPT_MODE] = :SIMPLE
7
7
  IRB.conf[:PROMPT][:SIMPLE] =
8
- {:PROMPT_C=>"trepanx ?> ",
9
- :PROMPT_I=>"trepanx >> ",
10
- :PROMPT_N=>"trepanx >> ",
8
+ {:PROMPT_C=>"trepan ?> ",
9
+ :PROMPT_I=>"trepan >> ",
10
+ :PROMPT_N=>"trepan >> ",
11
11
  :PROMPT_S=>nil,
12
12
  :RETURN=>"=> %s\n"}
13
13
 
@@ -20,22 +20,22 @@ IRB.conf[:PROMPT][:SIMPLE] =
20
20
  puts "You are in a trepan session. You should have access to program scope."
21
21
  puts "'dbgr', 'step', 'ne', 'q', 'cont' commands have been added."
22
22
 
23
- if defined?($trepanx) && $trepanx
24
- puts 'You should have access to debugger state via global variable $trepanx'
23
+ if defined?($trepan) && $trepan
24
+ puts 'You should have access to debugger state via global variable $trepan'
25
25
  end
26
- if defined?($trepanx_frame) && $trepanx_frame
27
- puts 'You should have access to the program frame via global variable $trepanx_frame'
26
+ if defined?($trepan_frame) && $trepan_frame
27
+ puts 'You should have access to the program frame via global variable $trepan_frame'
28
28
  end
29
- if defined?($trepanx_cmdproc) && $trepanx_cmdproc
30
- puts 'You should have access to the command processor via global variable $trepanx_cmdproc'
29
+ if defined?($trepan_cmdproc) && $trepan_cmdproc
30
+ puts 'You should have access to the command processor via global variable $trepan_cmdproc'
31
31
  end
32
32
 
33
33
  # Monkeypatch to save the current IRB statement to be run.
34
34
  class IRB::Context
35
- alias_method :_trepanx_original_evaluate, :evaluate
35
+ alias_method :_trepan_original_evaluate, :evaluate
36
36
  def evaluate(line, line_no)
37
- $trepanx_irb_statements = line
38
- _trepanx_original_evaluate(line, line_no)
37
+ $trepan_irb_statements = line
38
+ _trepan_original_evaluate(line, line_no)
39
39
  end
40
40
  end
41
41
 
@@ -16,7 +16,7 @@ class Trepan
16
16
  # - another interface in another process or computer
17
17
  class Interface
18
18
 
19
- attr_accessor :interactive, :history_io, :history_save, :input, :output
19
+ attr_accessor :history_io, :history_save, :interactive, :input, :output
20
20
 
21
21
  unless defined?(YES)
22
22
  YES = %w(y yes oui si yep ja)
@@ -59,6 +59,10 @@ class Trepan
59
59
  end
60
60
 
61
61
  def finalize(last_wishes=nil)
62
+ if @output && !@output.closed?
63
+ msg "%sThat's all, folks..." %
64
+ (defined?(Trepan::PROGRAM) ? "#{Trepan::PROGRAM}: " : '')
65
+ end
62
66
  close
63
67
  end
64
68
 
data/interface/client.rb CHANGED
@@ -46,6 +46,10 @@ class Trepan::ClientInterface < Trepan::Interface
46
46
  end
47
47
  end
48
48
 
49
+ def closed?
50
+ @inout.closed?
51
+ end
52
+
49
53
  def confirm(prompt, default)
50
54
  @user.confirm(prompt, default)
51
55
  end
data/interface/script.rb CHANGED
@@ -5,17 +5,19 @@
5
5
 
6
6
  # Our local modules
7
7
  require 'rubygems'; require 'require_relative'
8
- require_relative 'base_intf'
8
+ require_relative '../interface'
9
9
  require_relative '../io/input'
10
10
  require_relative '../io/string_array'
11
11
 
12
12
  # Interface when reading debugger scripts
13
13
  class Trepan::ScriptInterface < Trepan::Interface
14
+ attr_accessor :opts, :output
14
15
 
15
16
  DEFAULT_OPTS = {
16
17
  :abort_on_error => true,
17
18
  :confirm_val => false,
18
- :verbose => false
19
+ :verbose => false,
20
+ :basename => false
19
21
  } unless defined?(DEFAULT_OPTS)
20
22
 
21
23
  def initialize(script_name, out=nil, opts={})
@@ -28,7 +30,7 @@ class Trepan::ScriptInterface < Trepan::Interface
28
30
  @input = opts[:input] ||
29
31
  Trepan::UserInput.open(script_name, :line_edit => false)
30
32
  @buffer_output = []
31
- unless opts[:verbose] or out
33
+ unless @opts[:verbose] or out
32
34
  out = Trepan::StringArrayOutput.open(@buffer_output)
33
35
  end
34
36
  super(@input, out, @opts)
@@ -64,7 +66,7 @@ class Trepan::ScriptInterface < Trepan::Interface
64
66
  msg(mess)
65
67
  # FIXME: should we just set a flag and report eof? to be more
66
68
  # consistent with File and IO?
67
- raise IOError if @opts[:abort_on_error]
69
+ raise ScriptError if @opts[:abort_on_error]
68
70
  end
69
71
 
70
72
  def interactive? ; false end
@@ -75,7 +77,13 @@ class Trepan::ScriptInterface < Trepan::Interface
75
77
  @input_lineno += 1
76
78
  line = readline
77
79
  if @opts[:verbose]
78
- location = "%s line %s" % [@script_name, @input_lineno]
80
+ script_name =
81
+ if @opts[:basename]
82
+ File.basename(@script_name)
83
+ else
84
+ @script_name
85
+ end
86
+ location = "%s line %s" % [script_name, @input_lineno]
79
87
  msg('+ %s: %s' % [location, line])
80
88
  end
81
89
  # Do something with history?
data/interface/server.rb CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Our local modules
5
5
  require 'rubygems'; require 'require_relative'
6
- require_relative 'base_intf'
6
+ require_relative '../interface'
7
7
  require_relative 'comcodes'
8
8
  require_relative '../io/input'
9
9
  require_relative '../io/tcpserver'
@@ -52,6 +52,10 @@ class Trepan::ServerInterface < Trepan::Interface
52
52
  end
53
53
  end
54
54
 
55
+ def closed?
56
+ @inout.closed?
57
+ end
58
+
55
59
  # Called when a dangerous action is about to be done to make sure
56
60
  # it's okay. `prompt' is printed; user response is returned.
57
61
  # FIXME: make common routine for this and user.rb
data/interface/user.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # Our local modules
7
7
 
8
8
  require 'rubygems'; require 'require_relative'
9
- require_relative 'base_intf'
9
+ require_relative '../interface'
10
10
  require_relative '../io/input'
11
11
 
12
12
  # Interface when communicating with the user.
@@ -39,6 +39,10 @@ class Trepan::UserInterface < Trepan::Interface
39
39
  at_exit { finalize }
40
40
  end
41
41
 
42
+ def closed?
43
+ @input.closed? && @output.closed?
44
+ end
45
+
42
46
  # Called when a dangerous action is about to be done, to make
43
47
  # sure it's okay. Expect a yes/no answer to `prompt' which is printed,
44
48
  # suffixed with a question mark and the default value. The user
@@ -148,4 +152,7 @@ if __FILE__ == $0
148
152
  puts "EOF is now: %s" % intf.input.eof?.inspect
149
153
  end
150
154
  end
155
+ puts "User interface closed?: #{intf.closed?}"
156
+ intf.close
157
+ STDERR.puts "User interface closed?: #{intf.closed?}"
151
158
  end
File without changes
data/io/input.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  #
7
7
 
8
8
  require 'rubygems'; require 'require_relative'
9
- require_relative 'base_io'
9
+ require_relative '../io'
10
10
 
11
11
  class Trepan
12
12
 
data/io/null_output.rb CHANGED
@@ -1,35 +1,39 @@
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
 
4
4
  # Nukes output. Used for example in sourcing where you don't want
5
5
  # to see output.
6
6
  #
7
7
 
8
8
  require 'rubygems'; require 'require_relative'
9
- require_relative 'base_io'
9
+ require_relative '../io'
10
10
 
11
- class Trepan
12
- class OutputNull < Trepan::OutputBase
13
- def initialize(out, opts={})
14
- super
15
- end
16
-
17
- def close
18
- end
19
-
20
- def flush
21
- end
22
-
23
- # Use this to set where to write to. output can be a
24
- # file object or a string. This code raises IOError on error.
25
- def write(*args)
26
- end
27
-
28
- # used to write to a debugger that is connected to this
29
- # `str' written will have a newline added to it
30
- #
31
- def writeline( msg)
32
- end
11
+ class Trepan::OutputNull < Trepan::OutputBase
12
+ def initialize(out, opts={})
13
+ @closed = false
14
+ super
15
+ end
16
+
17
+ def close
18
+ @closed = true
19
+ end
20
+
21
+ def closed?
22
+ !!@closed
23
+ end
24
+
25
+ def flush
26
+ end
27
+
28
+ # Use this to set where to write to. output can be a
29
+ # file object or a string. This code raises IOError on error.
30
+ def write(*args)
31
+ end
32
+
33
+ # used to write to a debugger that is connected to this
34
+ # `str' written will have a newline added to it
35
+ #
36
+ def writeline( msg)
33
37
  end
34
38
  end
35
39
 
data/io/string_array.rb CHANGED
@@ -1,10 +1,10 @@
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
 
4
4
  # Simulate I/O using lists of strings.
5
5
 
6
6
  require 'rubygems'; require 'require_relative'
7
- require_relative 'base_io'
7
+ require_relative '../io'
8
8
 
9
9
  # Simulate I/O using an array of strings. Sort of like StringIO, but
10
10
  # even simplier.
@@ -153,4 +153,3 @@ if __FILE__ == $0
153
153
  inp.close
154
154
  puts "Input is closed? #{inp.closed?}"
155
155
  end
156
-