Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a sync op. Not sure if it will be useful though

  • Loading branch information...
commit f996d427d060b0b8aa057ea2364de6075a0a8be7 1 parent 1a6a251
@rocky authored
Showing with 49 additions and 10 deletions.
  1. +2 −0  app/client.rb
  2. +9 −8 interface/comcodes.rb
  3. +38 −2 interface/server.rb
View
2  app/client.rb
@@ -20,6 +20,8 @@ def start_client(options)
:port => options[:port],
:user_opts => user_opts
)
+ intf = dbgr.intf[-1]
+ intf.write_remote(SYNC, 'FIXME: add useful info')
while true
begin
control_code, line = intf.read_remote
View
17 interface/comcodes.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>
# Communication status codes
module Trepanning
@@ -7,14 +7,15 @@ module Trepanning
# client interface. COMMAND goes the other way.
module RemoteCommunication
unless defined?(PRINT)
- PRINT = '.'
- COMMAND = 'C'
- CONFIRM_TRUE = 'Y'
- CONFIRM_FALSE = 'N'
+ PRINT = '.' # Server wants to print
+ COMMAND = 'C' # read a command
+ CONFIRM_TRUE = 'Y' # Confirm read, default true
+ CONFIRM_FALSE = 'N' # Confirm read, default false
CONFIRM_REPLY = '?'
- QUIT = 'q'
- PROMPT = 'p'
- RESTART = 'r'
+ QUIT = 'q' # End debug session
+ PROMPT = 'p' # Write prompt
+ SYNC = 's' # Resynchronize communication
+ RESTART = 'r' # Restart
end
end
end
View
40 interface/server.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>
# Our local modules
require_relative '../interface'
@@ -37,6 +37,11 @@ def initialize(inout=nil, out=nil, connection_opts={})
Trepan::TCPDbgServer.new(@connection_opts)
# end
end
+
+ # In case we need to resync
+ @last_action = :nop
+ @last_args = []
+
# For Compatability
@output = @inout
@input = @inout
@@ -74,6 +79,8 @@ def confirm(prompt, default)
msg "Please answer 'yes' or 'no'. Try again."
end
end
+ @last_action = :confirm
+ @last_args = [prompt, default]
return default
end
@@ -95,16 +102,22 @@ def input_eof?
# used to write to a debugger that is connected to this
# server; `str' written will have a newline added to it
def msg(msg)
+ @last_args = [msg]
+ @last_action = :msg
@inout.writeline(PRINT + msg)
end
# used to write to a debugger that is connected to this
# server; `str' written will not have a newline added to it
def msg_nocr(msg)
+ @last_args = [msg]
+ @last_action = :msg_nocr
@inout.write(PRINT + msg)
end
def read_command(prompt)
+ @last_args = [prompt]
+ @last_action = :read_command
readline(prompt)
end
@@ -112,12 +125,23 @@ def read_data
@inout.read_dat
end
+ def nop; end
+
+ def resync
+ # puts "resync", @last_action, @last_args
+ method(@last_action).call(*@last_args)
+ end
+
def readline(prompt, add_to_history=true)
if prompt
write_prompt(prompt)
end
+
coded_line = @inout.read_msg()
- @read_ctrl = coded_line[0..0]
+ while (SYNC == @read_ctrl = coded_line[0..0])
+ resync
+ coded_line = @inout.read_msg()
+ end
coded_line[1..-1]
end
@@ -128,6 +152,8 @@ def state
def write_prompt(prompt)
@inout.write(PROMPT + prompt)
+ @last_args = [prompt]
+ @last_action = :write_prompt
end
def write_confirm(prompt, default)
@@ -137,10 +163,20 @@ def write_confirm(prompt, default)
code = CONFIRM_FALSE
end
@inout.write(code + prompt)
+ @last_args = [prompt, default]
+ @last_action = :write_confirm
end
end
# Demo
if __FILE__ == $0
intf = Trepan::ServerInterface.new(nil, nil, :open => false)
+ intf.resync
+ def intf.msg(msg)
+ @last_args = [msg]
+ @last_action = :msg
+ puts msg
+ end
+ intf.msg('Hi!')
+ intf.resync
end
Please sign in to comment.
Something went wrong with that request. Please try again.