Sha256: 8f617e5dae658d60f1490986da5087296795164649afc860b6d0c3e823c6eeec

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
require 'rubygems'; require 'require_relative'
require_relative 'default'                # default debugger settings
require_relative '../interface/comcodes'  # communication codes

module Trepanning
  include Trepanning::RemoteCommunication
  def start_client(options)
    puts "Client option given"
    dbgr = Trepan.new(:client      => true,
                      :cmdfiles    => [],
                      :initial_dir => options[:chdir],
                      :nx          => true,
                      :host        => options[:host],
                      :port        => options[:port]
                      )
    intf = dbgr.intf[-1]
    while true
      begin
        control_code, line = intf.read_remote
      rescue EOFError, Errno::EPIPE
        puts "Remote debugged process closed connection"
        break
      end
      # p [control_code, line]
      case control_code
      when PRINT
        print line
      when CONFIRM_TRUE
        response = intf.confirm(line, true)
        intf.write_remote(CONFIRM_REPLY, response ? 'Y' : 'N')
      when CONFIRM_FALSE
        response = intf.confirm(line, true)
        intf.write_remote(CONFIRM_REPLY, response ? 'Y' : 'N')
      when PROMPT
        # require 'trepanning'
        # debugger
        begin
          command = intf.read_command(line)
        rescue EOFError
          puts "user-side EOF. Quitting..."
          break
        end
        begin 
          intf.write_remote(COMMAND, command)
        rescue Errno::EPIPE
          puts "Remote debugged process died"
          break
        end
      when QUIT
        break
      when RESTART
        break
      else
        $stderr.puts "** Unknown control code: #{control_code}"
      end
    end
  end
  module_function :start_client
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rbx-trepanning-0.0.8-universal-rubinius-1.2 app/client.rb
rbx-trepanning-0.0.7-universal-rubinius-1.2 app/client.rb
rbx-trepanning-0.0.6-universal-rubinius-1.2 app/client.rb
rbx-trepanning-0.0.5-universal-rubinius-1.2.1 app/client.rb
rbx-trepanning-0.0.4-universal-rubinius-1.2 app/client.rb