def METHOD_NAME(self, fd):
    assert self.agent
    fd -= FD_OFFSET
    ptr = self.agent.context.read_core_register('sp') - 64
    assert isinstance(ptr, int)
    result, self._errno = self._server.syscall('fstat,%x,%x' % (fd, ptr))
    if result != -1:
        # Fields in stat struct are big endian as written by gdb.
        size = self.agent.context.read_memory_block8(ptr, 8)
        result = (size[0] << 56) \
                | (size[1] << 48) \
                | (size[2] << 40) \
                | (size[3] << 32) \
                | (size[4] << 24) \
                | (size[5] << 16) \
                | (size[6] << 8) \
                | (size[7])
    return result