Exemplo n.º 1
0
jint 
inStream_readInt(PacketInputStream *stream)
{
    jint val = 0;
    (void)readBytes(stream, &val, sizeof(val));
    return JAVA_TO_HOST_INT(val);
}
Exemplo n.º 2
0
jint 
PacketInputStream::read_int( )
{
  int val = 0;
  read_bytes(&val, sizeof(val));
  return JAVA_TO_HOST_INT(val);
}
Exemplo n.º 3
0
bool
PacketInputStream::receive_packet()
{
  juint len, id;
  int bytes_avail;
  unsigned char uc;
  SETUP_ERROR_CHECKER_ARG;

  Transport::transport_op_def_t *ops = _transport_ops;

  bytes_avail = ops->peek_bytes(&_transport, &len, sizeof(len));
  if (bytes_avail < sizeof(len)) {
    // Try later, not enough bytes to get the packet length
    return false;
  }
  len = JAVA_TO_HOST_INT(len);
  if (len < JDWP_HEADER_SIZE) {
    return false;
  }
  if (len > JDWP_HEADER_SIZE) {
    SAVE_CURRENT_EXCEPTION;
    _input_data = PacketStream::get_buffer(len - JDWP_HEADER_SIZE JVM_NO_CHECK);
    RESTORE_CURRENT_EXCEPTION;
    if (_input_data.is_null()) {
      // not enough memory for this packet buffer
      flush_and_send_oom(ops);
      return false;
    }
  }
  ops->read_int(&_transport, &len);
  len = JAVA_TO_HOST_INT(len);
  if (len < JDWP_HEADER_SIZE) {
    flush(ops);
    return false;
  }
  set_data_len(len - JDWP_HEADER_SIZE);
  ops->read_int(&_transport, &id);
  id = JAVA_TO_HOST_INT(id);
  set_id(id);

  ops->read_bytes(&_transport, &uc, sizeof(uc), true);
  set_flags(uc);
  if (flags() & FLAGS_REPLY) {
    short error_code;
    ops->read_short(&_transport, &error_code);
    error_code = JAVA_TO_HOST_SHORT(error_code);
    set_error(error_code);
  } else {
    ops->read_bytes(&_transport, &uc, sizeof(uc), true);
    set_cmd_set(uc);
    ops->read_bytes(&_transport, &uc, sizeof(uc), true);
    set_cmd(uc);
  }
  if (len > JDWP_HEADER_SIZE) {
    // read in the whole packet
    ops->read_bytes(&_transport, _input_data.base_address(),
                    len - JDWP_HEADER_SIZE, true);
  }
 _output_index = 0;
  return true;
}