'Perform real NX test to see if it is enabled/supported by OS
Usage:
MYNAME [address]'

def nxtest(self, *arg):

    (address,) = normalize_argv(arg, 1)
    exec_wrapper = peda.execute_redirect('show    exec-wrapper').split('"')[1]
    if (exec_wrapper != ''):
        peda.execute('unset    exec-wrapper')
    if (not peda.getpid()):
        peda.execute('start')
    pc = peda.getreg('pc')
    sp = peda.getreg('sp')
    if (not address):
        address = sp
    peda.execute(('set    $pc    =    0x%x' % address))
    peda.execute(('set    *0x%x    =    0x%x' % (address, 3435973836)))
    peda.execute(('set    *0x%x    =    0x%x' % ((address + 4), 3435973836)))
    out = peda.execute_redirect('continue')
    text = ('NX    test    at    %s:    ' % (to_address(address) if (address != sp) else 'stack'))
    if out:
        if ('SIGSEGV' in out):
            text += red('Non-Executable')
        elif ('SIGTRAP' in out):
            text += green('Executable')
    else:
        text += 'Failed    to    test'
    msg(text)
    if (exec_wrapper != ''):
        peda.execute(('set    exec-wrapper    %s' % exec_wrapper))
    return
