# Path: voltron/view.py
# ADDR_FORMAT_128 = '0x{0:0=32X}'
# ADDR_FORMAT_64 = '0x{0:0=16X}'
# ADDR_FORMAT_32 = '0x{0:0=8X}'
# ADDR_FORMAT_16 = '0x{0:0=4X}'
# SHORT_ADDR_FORMAT_128 = '{0:0=32X}'
# SHORT_ADDR_FORMAT_64 = '{0:0=16X}'
# SHORT_ADDR_FORMAT_32 = '{0:0=8X}'
# SHORT_ADDR_FORMAT_16 = '{0:0=4X}'
# class AliasedSubParsersAction(argparse._SubParsersAction):
#     class _AliasedPseudoAction(argparse.Action):
# class AnsiString(object):
# class VoltronView (object):
# class TerminalView (VoltronView):
#         def __init__(self, name, aliases, help):
#     def add_parser(self, name, **kwargs):
#     def __init__(self, string):
#     def __getitem__(self, key):
#     def __str__(self):
#     def __len__(self):
#     def clean(self):
# def requires_async(func):
#     def inner(self, *args, **kwargs):
#     def add_generic_arguments(cls, sp):
#     def configure_subparser(cls, subparsers):
#     def __init__(self, args={}, loaded_config={}):
#     def build_config(self):
#     def apply_cli_config(self):
#     def setup(self):
#     def cleanup(self):
#     def render(self, results):
#     def do_render(error=None):
#     def should_reconnect(self):
#     def sigwinch_handler(self, sig, stack):
#     def __init__(self, *a, **kw):
#     def init_window(self):
#     def cleanup(self):
#     def clear(self):
#     def render(self, results):
#     def do_render(self, error=None):
#     def sigwinch_handler(self, sig, stack):
#     def window_size(self):
#     def body_height(self):
#     def colour(self, text='', colour=None, background=None, attrs=[]):
#     def format_header_footer(self, c):
#     def pad_body(self):
#     def truncate_body(self):
#     def build_requests(self):
#     def run(self):
#         def render(results=[], error=None):
#     def handle_key(self, key):
#     def exit(self):
#     def page_up(self):
#     def page_down(self):
#     def line_up(self):
#     def line_down(self):
#     def reset(self):
# 
# Path: voltron/plugin.py
# def api_request(request, *args, **kwargs):
#     """
#     Create an API request.
# 
#     `request_type` is the request type (string). This is used to look up a
#     plugin, whose request class is instantiated and passed the remaining
#     arguments passed to this function.
#     """
#     plugin = pm.api_plugin_for_request(request)
#     if plugin and plugin.request_class:
#         req = plugin.request_class(*args, **kwargs)
#     else:
#         raise Exception("Invalid request type")
#     return req
# 
# class ViewPlugin(VoltronPlugin):
#     """
#     View plugin parent class.
# 
#     `plugin_type` is 'view'
#     `name` is the name of the view (e.g. 'register' or 'disassembly')
#     `view_class` is the main view class
# 
#     See the core view plugins in voltron/plugins/view/ for examples.
#     """
#     plugin_type = 'view'
#     name = None
#     view_class = None
# 
#     @classmethod
#     def initialise(cls):
#         if cls.view_class:
#             cls.view_class._plugin = cls
#             cls.view_class.view_type = cls.name
# 
# Path: voltron/lexers.py
# class DisassemblyLexer(RegexLexer):
# class LLDBIntelLexer(DisassemblyLexer):
# class LLDBATTLexer(DisassemblyLexer):
# class GDBATTLexer(DisassemblyLexer):
# class GDBIntelLexer(DisassemblyLexer):
# class VDBATTLexer(DisassemblyLexer):
# class CapstoneIntelLexer(DisassemblyLexer):
# class VDBIntelLexer(RegexLexer):
# class WinDbgIntelLexer(RegexLexer):
# class WinDbgATTLexer(WinDbgIntelLexer):


from voltron.view import TerminalView, VoltronView, log
from voltron.plugin import api_request, ViewPlugin
from voltron.lexers import get_lexer_by_name
import pygments
import pygments.formatters
    def render(self, results):
        [res] = results

        # Set up header & error message if applicable
        self.title = '[disassembly]'

        # don't render if it timed out, probably haven't stepped the debugger again
        if res.timed_out:
            return

        if res and res.is_success:
            # Get the disasm
            disasm = res.disassembly
            disasm = '\n'.join(disasm.split('\n')[:self.body_height()])

            # Highlight output
            try:
                host = 'capstone' if self.args.use_capstone else res.host
                lexer = get_lexer_by_name('{}_{}'.format(host, res.flavor))
                formatter = pygments.formatters.get_formatter_by_name(
                    self.config.format.pygments_formatter,
                    style=self.config.format.pygments_style)
                disasm = pygments.highlight(disasm, lexer, formatter)
            except Exception as e:
                log.warning('Failed to highlight disasm: ' + str(e))
                log.info(self.config.format)

            # Build output
            self.body = disasm.rstrip()
        else:

# Path: voltron/view.py
# ADDR_FORMAT_128 = '0x{0:0=32X}'
# ADDR_FORMAT_64 = '0x{0:0=16X}'
# ADDR_FORMAT_32 = '0x{0:0=8X}'
# ADDR_FORMAT_16 = '0x{0:0=4X}'
# SHORT_ADDR_FORMAT_128 = '{0:0=32X}'
# SHORT_ADDR_FORMAT_64 = '{0:0=16X}'
# SHORT_ADDR_FORMAT_32 = '{0:0=8X}'
# SHORT_ADDR_FORMAT_16 = '{0:0=4X}'
# class AliasedSubParsersAction(argparse._SubParsersAction):
#     class _AliasedPseudoAction(argparse.Action):
# class AnsiString(object):
# class VoltronView (object):
# class TerminalView (VoltronView):
#         def __init__(self, name, aliases, help):
#     def add_parser(self, name, **kwargs):
#     def __init__(self, string):
#     def __getitem__(self, key):
#     def __str__(self):
#     def __len__(self):
#     def clean(self):
# def requires_async(func):
#     def inner(self, *args, **kwargs):
#     def add_generic_arguments(cls, sp):
#     def configure_subparser(cls, subparsers):
#     def __init__(self, args={}, loaded_config={}):
#     def build_config(self):
#     def apply_cli_config(self):
#     def setup(self):
#     def cleanup(self):
#     def render(self, results):
#     def do_render(error=None):
#     def should_reconnect(self):
#     def sigwinch_handler(self, sig, stack):
#     def __init__(self, *a, **kw):
#     def init_window(self):
#     def cleanup(self):
#     def clear(self):
#     def render(self, results):
#     def do_render(self, error=None):
#     def sigwinch_handler(self, sig, stack):
#     def window_size(self):
#     def body_height(self):
#     def colour(self, text='', colour=None, background=None, attrs=[]):
#     def format_header_footer(self, c):
#     def pad_body(self):
#     def truncate_body(self):
#     def build_requests(self):
#     def run(self):
#         def render(results=[], error=None):
#     def handle_key(self, key):
#     def exit(self):
#     def page_up(self):
#     def page_down(self):
#     def line_up(self):
#     def line_down(self):
#     def reset(self):
# 
# Path: voltron/plugin.py
# def api_request(request, *args, **kwargs):
#     """
#     Create an API request.
# 
#     `request_type` is the request type (string). This is used to look up a
#     plugin, whose request class is instantiated and passed the remaining
#     arguments passed to this function.
#     """
#     plugin = pm.api_plugin_for_request(request)
#     if plugin and plugin.request_class:
#         req = plugin.request_class(*args, **kwargs)
#     else:
#         raise Exception("Invalid request type")
#     return req
# 
# class ViewPlugin(VoltronPlugin):
#     """
#     View plugin parent class.
# 
#     `plugin_type` is 'view'
#     `name` is the name of the view (e.g. 'register' or 'disassembly')
#     `view_class` is the main view class
# 
#     See the core view plugins in voltron/plugins/view/ for examples.
#     """
#     plugin_type = 'view'
#     name = None
#     view_class = None
# 
#     @classmethod
#     def initialise(cls):
#         if cls.view_class:
#             cls.view_class._plugin = cls
#             cls.view_class.view_type = cls.name
# 
# Path: voltron/lexers.py
# class DisassemblyLexer(RegexLexer):
# class LLDBIntelLexer(DisassemblyLexer):
# class LLDBATTLexer(DisassemblyLexer):
# class GDBATTLexer(DisassemblyLexer):
# class GDBIntelLexer(DisassemblyLexer):
# class VDBATTLexer(DisassemblyLexer):
# class CapstoneIntelLexer(DisassemblyLexer):
# class VDBIntelLexer(RegexLexer):
# class WinDbgIntelLexer(RegexLexer):
# class WinDbgATTLexer(WinDbgIntelLexer):


# Path: voltron/plugins/view/disasm.py
from voltron.view import TerminalView, VoltronView, log
from voltron.plugin import api_request, ViewPlugin
from voltron.lexers import get_lexer_by_name
import pygments
import pygments.formatters

    def render(self, results):
        [res] = results

        # Set up header & error message if applicable
        self.title = '[disassembly]'

        # don't render if it timed out, probably haven't stepped the debugger again
        if res.timed_out:
            return

        if res and res.is_success:
            # Get the disasm
            disasm = res.disassembly
            disasm = '\n'.join(disasm.split('\n')[:self.body_height()])

            # Highlight output
            try:
                host = 'capstone' if self.args.use_capstone else res.host
                lexer = get_lexer_by_name('{}_{}'.format(host, res.flavor))
                formatter = pygments.formatters.get_formatter_by_name(
                    self.config.format.pygments_formatter,
                    style=self.config.format.pygments_style)
                disasm = pygments.highlight(disasm, lexer, formatter)
            except Exception as e:
                log.warning('Failed to highlight disasm: ' + str(e))
                log.info(self.config.format)

            # Build output
            self.body = disasm.rstrip()
        else:

            log.error("Error disassembling: {}".format(res.message))