# Path: voidwalker/framework/interface/command.py
# class BreakpointCommand(Command):
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def execute(self, terminal, inferior, argument):
#         raise NotImplementedError
# 
# Path: voidwalker/framework/interface/command.py
# class PrefixCommand(Command):
#     def execute(self, terminal):
#         terminal.write('%(face-error)sAttempting to invoke an '
#                        'incomplete command!\n')
# 
# Path: voidwalker/framework/interface/command.py
# def register_command(cls):
#     _command_list.append(cls)
#     return cls
# 
# Path: voidwalker/backends/gdb/tools/interface.py
# class GdbCommand(PrefixCommand):
#     '''Commands for interacting with GDB'''
# 
#     @staticmethod
#     def name():
#         return '%s %s' % (VoidwalkerCommand.name(), 'gdb')
# 
#     def __init__(self):
#         super(GdbCommand, self).__init__()


import gdb
import re
from ....framework.interface.command import BreakpointCommand
from ....framework.interface.command import PrefixCommand
from ....framework.interface.command import register_command
from .interface import GdbCommand
    def name():
        return '%s %s' % (GdbCommand.name(), 'break')

    def __init__(self):
        super(BreakCommand, self).__init__()


@register_command
class BreakTextCommand(BreakpointCommand):
    '''Break on text section entry point

Sets a breakpoint at the text section entrypoint. This command is useful if
there are no symbols and no known address to set a breakpoint at.'''

    _text_exp = re.compile(r'(?P<start>0x[0-9a-z]+)\s*-\s*(?P<end>0x[0-9a-z]+)'
                           r'\s+is\s+(?P<section>[^\s]+)', re.IGNORECASE)

    @staticmethod
    def name():
        return '%s %s' % (BreakCommand.name(), 'text')

    def __init__(self):
        super(BreakTextCommand, self).__init__()
        self._terminal = None

    def invoke(self, thread, argument, from_tty=False):
        sections = gdb.execute('info target', to_string=True)
        address = None
        for match in self._text_exp.finditer(sections):
            if match.group('section') == '.text':

# Path: voidwalker/framework/interface/command.py
# class BreakpointCommand(Command):
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def execute(self, terminal, inferior, argument):
#         raise NotImplementedError
# 
# Path: voidwalker/framework/interface/command.py
# class PrefixCommand(Command):
#     def execute(self, terminal):
#         terminal.write('%(face-error)sAttempting to invoke an '
#                        'incomplete command!\n')
# 
# Path: voidwalker/framework/interface/command.py
# def register_command(cls):
#     _command_list.append(cls)
#     return cls
# 
# Path: voidwalker/backends/gdb/tools/interface.py
# class GdbCommand(PrefixCommand):
#     '''Commands for interacting with GDB'''
# 
#     @staticmethod
#     def name():
#         return '%s %s' % (VoidwalkerCommand.name(), 'gdb')
# 
#     def __init__(self):
#         super(GdbCommand, self).__init__()


# Path: voidwalker/backends/gdb/tools/breakpoints.py
import gdb
import re
from ....framework.interface.command import BreakpointCommand
from ....framework.interface.command import PrefixCommand
from ....framework.interface.command import register_command
from .interface import GdbCommand

    def name():
        return '%s %s' % (GdbCommand.name(), 'break')

    def __init__(self):
        super(BreakCommand, self).__init__()


@register_command
class BreakTextCommand(BreakpointCommand):
    '''Break on text section entry point

Sets a breakpoint at the text section entrypoint. This command is useful if
there are no symbols and no known address to set a breakpoint at.'''

    _text_exp = re.compile(r'(?P<start>0x[0-9a-z]+)\s*-\s*(?P<end>0x[0-9a-z]+)'
                           r'\s+is\s+(?P<section>[^\s]+)', re.IGNORECASE)

    @staticmethod
    def name():
        return '%s %s' % (BreakCommand.name(), 'text')

    def __init__(self):
        super(BreakTextCommand, self).__init__()
        self._terminal = None

    def invoke(self, thread, argument, from_tty=False):
        sections = gdb.execute('info target', to_string=True)
        address = None
        for match in self._text_exp.finditer(sections):
            if match.group('section') == '.text':

                address = abs(long(match.group('start'), 16))