class DEBUGGER__::UI_UnixDomainServer

Public Class Methods

new(sock_dir: nil, sock_path: nil) click to toggle source
Calls superclass method DEBUGGER__::UI_ServerBase::new
# File debug-1.4.0/lib/debug/server.rb, line 404
def initialize sock_dir: nil, sock_path: nil
  @sock_path = sock_path
  @sock_dir = sock_dir || DEBUGGER__.unix_domain_socket_dir
  @sock_for_fork = nil

  super()
end

Public Instance Methods

accept() { |sock| ... } click to toggle source
Calls superclass method DEBUGGER__::UI_ServerBase#accept
# File debug-1.4.0/lib/debug/server.rb, line 417
def accept
  super # for fork

  case
  when @sock_path
  when sp = CONFIG[:sock_path]
    @sock_path = sp
  else
    @sock_path = DEBUGGER__.create_unix_domain_socket_name(@sock_dir)
  end

  ::DEBUGGER__.warn "Debugger can attach via UNIX domain socket (#{@sock_path})"
  vscode_setup if CONFIG[:open_frontend] == 'vscode'

  begin
    Socket.unix_server_loop @sock_path do |sock, client|
      @sock_for_fork = sock
      @client_addr = client

      yield sock
    ensure
      sock.close
      @sock_for_fork = nil
    end
  rescue Errno::ECONNREFUSED => _e
    ::DEBUGGER__.warn "#{_e.message} (socket path: #{@sock_path})"

    if @sock_path.start_with? Config.unix_domain_socket_tmpdir
      # try on homedir
      @sock_path = Config.create_unix_domain_socket_name(unix_domain_socket_homedir)
      ::DEBUGGER__.warn "retry with #{@sock_path}"
      retry
    else
      raise
    end
  end
end
vscode_setup() click to toggle source
# File debug-1.4.0/lib/debug/server.rb, line 412
def vscode_setup
  require_relative 'server_dap'
  UI_DAP.setup @sock_path
end