Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix missing prompt/confirm output in client mode. Noticed during Band…

…ung 2012 tak.
  • Loading branch information...
commit 9f98035be75d852d52e806eda079fbd514fb05d0 1 parent 2326442
@rocky authored
View
2  Rakefile
@@ -86,7 +86,7 @@ Rake::TestTask.new(:'test:integration') do |t|
t.options = '--verbose' if $VERBOSE
end
-desc 'Test everything - unit tests for now.'
+desc 'Test everything - unit, functional, and integration tests.'
task :test do
exceptions = %w(test:unit test:functional test:integration).collect do |task|
begin
View
21 app/client.rb
@@ -1,20 +1,26 @@
# -*- coding: utf-8 -*-
-# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
+# Copyright (C) 2011, 2012 Rocky Bernstein <rockyb@rubyforge.net>
require_relative 'default' # default debugger settings
+require_relative '../lib/trepanning' # main Trepan object & initialization
require_relative '../interface/comcodes' # communication codes
module Trepanning
include Trepanning::RemoteCommunication
def start_client(options)
puts "Client option given"
+ user_opts = {}
+ %w(readline).each do |opt|
+ user_opts[opt.to_sym] = options[opt.to_sym]
+ end
+ puts user_opts.inspect
dbgr = Trepan.new(:client => true,
:cmdfiles => [],
:initial_dir => options[:chdir],
:nx => true,
:host => options[:host],
- :port => options[:port]
+ :port => options[:port],
+ :user_opts => user_opts
)
- intf = dbgr.intf[-1]
while true
begin
control_code, line = intf.read_remote
@@ -22,9 +28,13 @@ def start_client(options)
puts "Remote debugged process closed connection"
break
end
- # p [control_code, line]
case control_code
when PRINT
+
+ # FIXME: don't know why server sometimes adds a gratuituous space.
+ # the space is added somewhere inside TCPSocket.print
+ line = line[0..-2] if line.end_with?("\n ")
+
print line
when CONFIRM_TRUE
response = intf.confirm(line, true)
@@ -33,8 +43,7 @@ def start_client(options)
response = intf.confirm(line, true)
intf.write_remote(CONFIRM_REPLY, response ? 'Y' : 'N')
when PROMPT
- # require 'trepanning'
- # debugger
+ # Printing of prompt has been handled already by PRINT.
begin
command = intf.read_command(line)
rescue EOFError
View
2  interface/client.rb
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
+# Copyright (C) 2011, 2012 Rocky Bernstein <rockyb@rubyforge.net>
# Interface for client (i.e. user to communication-device) interaction.
# The debugged program is at the other end of the communcation.
View
4 interface/user.rb
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
+# Copyright (C) 2010-2012 Rocky Bernstein <rockyb@rubyforge.net>
# Interface when communicating with the user.
@@ -118,7 +118,7 @@ def read_command(prompt='')
def readline(prompt='')
@output.flush
- if @input.line_edit && @opts[:readline]
+ if @input.line_edit && @input.use_readline
@input.readline(prompt)
else
@output.write(prompt) if prompt and prompt.size > 0
View
11 io/input.rb
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
+# Copyright (C) 2010-2012 Rocky Bernstein <rockyb@rubyforge.net>
# Debugger user/command-oriented input possibly attached to IO-style
# input or GNU Readline.
@@ -13,6 +13,8 @@ class Trepan
# input or GNU Readline.
class UserInput < Trepan::InputBase
+ attr_reader :use_readline
+
@@readline_finalized = false
def initialize(inp, opts={})
@@ -36,6 +38,13 @@ def readline(prompt='')
if @line_edit && @use_readline
line = Readline.readline(prompt, true)
else
+ # Prompt should be empty and should have been
+ # handled by caller.
+ unless prompt.empty?
+ require 'trepanning'; debugger
+ raise RuntimeError,
+ "Internal error: prompt '#{prompt}' should have been handled by caller" unless prompt.empty?
+ end
line = @input.gets
end
rescue Interrupt
View
5 io/tcpserver.rb
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
+# Copyright (C) 2011, 2012 Rocky Bernstein <rockyb@rubyforge.net>
# Debugger Server Input/Output interface.
require 'socket'
@@ -84,7 +84,8 @@ def wait_for_connect
def write(msg)
wait_for_connect() unless connected?
# FIXME: do we have to check the size of msg and split output?
- @session.print(pack_msg(msg))
+ pack_msg = pack_msg(msg)
+ @session.print(pack_msg)
end
def writeline(msg)
View
6 lib/trepanning.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
-# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
+# Copyright (C) 2010-2012 Rocky Bernstein <rockyb@rubyforge.net>
require 'trace' # Trace filtering
require 'thread_frame' # Stack frame introspection and more.
require_relative '../app/complete' # command completion
@@ -65,8 +65,8 @@ def initialize(settings={})
opts[:port] = @settings[:port] if @settings[:port]
opts[:host] = @settings[:host] if @settings[:host]
opts[:complete] = @completion_proc
- opts[:readline] ||= @settings[:readline]
- [Trepan::ClientInterface.new(nil, nil, nil, {}, opts)]
+ user_opts = @settings[:user_opts] || {}
+ [Trepan::ClientInterface.new(nil, nil, nil, user_opts, opts)]
else
opts = {:complete => @completion_proc,
:readline => @settings[:readline]}
View
23 test/integration/test-remote.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+require 'test/unit'
+require_relative 'helper'
+
+class TestQuit < Test::Unit::TestCase
+ @@NAME = File.basename(__FILE__, '.rb')[5..-1]
+
+ def test_trepan_call
+ skip('need a usable fork to run this') unless Process.respond_to?(:fork)
+ skip('Not ready for prime time yet')
+ cmdfile = File.join(File.dirname(__FILE__), '../data/quit.cmd')
+ child = fork
+ if child
+ ## FIXME: client doesn't work with cmdfile yet.
+ serveropts = {:dbgr => '--client', :cmdfile => cmdfile}
+ run_debugger(@@NAME, 'gcd.rb', serveropts)
+ Process.wait
+ else
+ clientopts = {:dbgr => '--server', :nocommand => true}
+ run_debugger(@@NAME, 'gcd.rb', clientopts)
+ end
+ end
+end
View
2  test/unit/test-app-options.rb
@@ -52,7 +52,7 @@ def test_binary_opts
end
def test_help_and_version_opts
- omit unless Process.respond_to?(:fork)
+ skip('need a working fork') unless Process.respond_to?(:fork)
Process.fork {
%w(help version).each do |name|
setup
View
1  test/unit/test-cmd-quit.rb
@@ -10,6 +10,7 @@ def setup
end
def test_basic
+ skip('need a working fork') unless Process.respond_to?(:fork)
pid = fork { @cmd.run([@name, '10']) }
Process.wait
assert_equal(10, $?.exitstatus)
Please sign in to comment.
Something went wrong with that request. Please try again.