# Path: pwndbg/color/context.py
# def prefix(x):
# def highlight(x):
# def register(x):
# def register_changed(x):
# def flag_bracket(x):
# def flag_value(x):
# def flag_set(x):
# def flag_unset(x):
# def flag_changed(x):
# def banner(x):
# def banner_title(x):
# def format_flags(value, flags, last=None):


import pwndbg.arch
import pwndbg.commands
import pwndbg.regs
from pwndbg.color import context
from pwndbg.color import message
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals



@pwndbg.commands.ArgparsedCommand('Print out ARM CPSR or xPSR register')
@pwndbg.commands.OnlyWhenRunning
def cpsr():
    arm_print_psr()

@pwndbg.commands.ArgparsedCommand('Print out ARM xPSR or CPSR register')
@pwndbg.commands.OnlyWhenRunning
def xpsr():
    arm_print_psr()

def arm_print_psr():
    if pwndbg.arch.current not in ('arm', 'armcm'):
        print(message.warn("This is only available on ARM"))
        return

    reg = 'cpsr' if pwndbg.arch.current == 'arm' else 'xpsr'

# Path: pwndbg/color/context.py
# def prefix(x):
# def highlight(x):
# def register(x):
# def register_changed(x):
# def flag_bracket(x):
# def flag_value(x):
# def flag_set(x):
# def flag_unset(x):
# def flag_changed(x):
# def banner(x):
# def banner_title(x):
# def format_flags(value, flags, last=None):


# Path: pwndbg/commands/cpsr.py
import pwndbg.arch
import pwndbg.commands
import pwndbg.regs
from pwndbg.color import context
from pwndbg.color import message

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals



@pwndbg.commands.ArgparsedCommand('Print out ARM CPSR or xPSR register')
@pwndbg.commands.OnlyWhenRunning
def cpsr():
    arm_print_psr()

@pwndbg.commands.ArgparsedCommand('Print out ARM xPSR or CPSR register')
@pwndbg.commands.OnlyWhenRunning
def xpsr():
    arm_print_psr()

def arm_print_psr():
    if pwndbg.arch.current not in ('arm', 'armcm'):
        print(message.warn("This is only available on ARM"))
        return

    reg = 'cpsr' if pwndbg.arch.current == 'arm' else 'xpsr'

    print('%s %s' % (reg, context.format_flags(getattr(pwndbg.regs, reg), pwndbg.regs.flags[reg])))