'Returns the permissions for a page at address `addr`.
If optional arugment permissions is given, set page permissions to that prior to returning permissions.'

def permissions(self, addr, permissions=None):

    if self.state.se.symbolic(addr):
        raise SimMemoryError('page    permissions    cannot    currently    be    looked    up    for    symbolic    addresses')
    if isinstance(addr, claripy.ast.bv.BV):
        addr = self.state.se.any_int(addr)
    page_num = (addr / self._page_size)
    try:
        page = self._get_page(page_num)
    except KeyError:
        raise SimMemoryError('page    does    not    exist    at    given    address')
    if (permissions is not None):
        if isinstance(permissions, (int, long)):
            permissions = claripy.BVV(permissions, 3)
        if (not isinstance(permissions, claripy.ast.bv.BV)):
            raise SimMemoryError('Unknown    permissions    argument    type    of    {0}.'.format(type(permissions)))
        page.permissions = permissions
    return page.permissions
