Sha256: 45e00e741e196c0765f634500bfc1620f381e62e6506c5845666906dc1b67a3b

Contents?: true

Size: 1.76 KB

Versions: 5

Compression:

Stored size: 1.76 KB

Contents

# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
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
trepanning-0.1.4 app/client.rb
trepanning-0.1.3 app/client.rb
trepanning-0.1.2 app/client.rb
trepanning-0.1.1 app/client.rb
trepanning-0.1.0 app/client.rb