Exemplo n.º 1
0
    def _create_registers_section(self, previous_context, context):
        registers_section = Section('registers')
        for _, register_dict in context.registers():
            reg_size = 0
            for name in register_dict.keys():
                reg_size = max(reg_size, len(name))

            table = Table()
            for name, register in register_dict.items():
                contents = [('%(face-identifier)s' +
                             (('%%-%ds: ' % reg_size) % name))]

                value = register.value()
                face = '%(face-constant)s'
                if previous_context.register(register.name()).value() != value:
                    face = '%(face-special)s'

                if value is not None:
                    contents += [('%s%s' % (face, register.str()))]

                else:
                    contents += [('%(face-comment)s' +
                                  (' %(register)s ' %
                                   {'register': register.str()}))]

                cell = Cell(''.join(contents))
                table.add_cell(cell)

            registers_section.add_component(table)

        return registers_section
Exemplo n.º 2
0
    def _create_registers_section(self, previous_context, context):
        registers_section = Section('registers')
        for _, register_dict in context.registers():
            reg_size = 0
            for name in register_dict.keys():
                reg_size = max(reg_size, len(name))

            table = Table()
            for name, register in register_dict.items():
                contents = [
                    ('%(face-identifier)s' + (('%%-%ds: ' % reg_size) % name))
                ]

                value = register.value()
                face = '%(face-constant)s'
                if previous_context.register(register.name()).value() != value:
                    face = '%(face-special)s'

                if value is not None:
                    contents += [('%s%s' % (face, register.str()))]

                else:
                    contents += [
                        ('%(face-comment)s' + (' %(register)s ' % {
                            'register': register.str()
                        }))
                    ]

                cell = Cell(''.join(contents))
                table.add_cell(cell)

            registers_section.add_component(table)

        return registers_section
Exemplo n.º 3
0
    def execute(self, terminal, thread, arguments):
        if len(arguments) != 2:
            terminal.write(('%(face-error)sError:'
                            '%(face-normal)s invalid arguments!\n'))
            return

        address = abs(int(arguments[0]))
        size = abs(int(arguments[1]))

        inferior = thread.get_inferior()
        listing = inferior.disassemble(address, size)

        section = Section('0x%016lX' % address)
        section.add_component(InstructionListingWidget(listing))
        section.draw(terminal, terminal.width())
Exemplo n.º 4
0
    def draw(self, terminal, width):
        section = Section('context')
        regs = self._create_registers_section(self._previous_context,
                                              self._context)
        section.add_component(regs)

        if self._context.stack() is not None and len(self._context.stack()):
            stack = self._create_stack_section(self._context)
            section.add_component(stack)

        if len(self._context.instruction_listing()):
            instructions = self._create_code_section(self._context)
            section.add_component(instructions)

        section.draw(terminal, width)
        terminal.reset()
Exemplo n.º 5
0
    def execute(self, terminal, thread, arguments):
        if len(arguments) != 2:
            terminal.write(('%(face-error)sError:'
                            '%(face-normal)s invalid arguments!\n'))
            return

        address = abs(int(arguments[0]))
        size = abs(int(arguments[1]))

        inferior = thread.get_inferior()
        data_dump = inferior.read_memory(address, size)
        data_chunk = DataChunk(address, data_dump)

        section = Section('0x%016lX' % address)
        section.add_component(DataWidget(data_chunk))
        section.draw(terminal, terminal.width())
Exemplo n.º 6
0
    def draw(self, terminal, width):
        section = Section("context")
        regs = self._create_registers_section(self._previous_context, self._context)
        section.add_component(regs)

        if self._context.stack() is not None and len(self._context.stack()):
            stack = self._create_stack_section(self._context)
            section.add_component(stack)

        if len(self._context.instruction_listing()):
            instructions = self._create_code_section(self._context)
            section.add_component(instructions)

        section.draw(terminal, width)
        terminal.reset()
Exemplo n.º 7
0
            def execute(self, terminal, *_):
                table = Table()
                for name, snippet in snippet_repository.snippets():
                    row = Row()
                    row.add_cell(Cell('%s%s' % ('%(face-identifier)s', name)))
                    row.add_cell(Cell('%s%s' % ('%(face-comment)s',
                                                snippet.description())))
                    table.add_row(row)

                section = Section('snippets')
                section.add_component(table)
                section.draw(terminal, terminal.width())
Exemplo n.º 8
0
    def execute(self, terminal, thread, arguments):
        if len(arguments) != 2:
            terminal.write(('%(face-error)sError:'
                            '%(face-normal)s invalid arguments!\n'))
            return

        address = abs(long(arguments[0]))
        size = abs(long(arguments[1]))

        inferior = thread.get_inferior()
        listing = inferior.disassemble(address, size)

        section = Section('0x%016lX' % address)
        section.add_component(InstructionListingWidget(listing))
        section.draw(terminal, terminal.width())
Exemplo n.º 9
0
    def execute(self, terminal, thread, arguments):
        if len(arguments) != 2:
            terminal.write(('%(face-error)sError:'
                            '%(face-normal)s invalid arguments!\n'))
            return

        address = abs(long(arguments[0]))
        size = abs(long(arguments[1]))

        inferior = thread.get_inferior()
        data_dump = inferior.read_memory(address, size)
        data_chunk = DataChunk(address, data_dump)

        section = Section('0x%016lX' % address)
        section.add_component(DataWidget(data_chunk))
        section.draw(terminal, terminal.width())
Exemplo n.º 10
0
    def test_section(self):
        section = Section("test section")
        section.draw(self._terminal, self._terminal.width())

        self.assertRaises(AssertionError, section.draw, self._terminal, 1)
Exemplo n.º 11
0
 def _create_code_section(self, context):
     section = Section('code')
     listing = InstructionListingWidget(context.instruction_listing())
     section.add_component(listing)
     return section
Exemplo n.º 12
0
 def _create_stack_section(self, context):
     section = Section('stack')
     section.add_component(DataWidget(context.stack()))
     return section
Exemplo n.º 13
0
 def _create_code_section(self, context):
     section = Section('code')
     listing = InstructionListingWidget(context.instruction_listing())
     section.add_component(listing)
     return section
Exemplo n.º 14
0
 def _create_stack_section(self, context):
     section = Section('stack')
     section.add_component(DataWidget(context.stack()))
     return section
Exemplo n.º 15
0
    def test_section(self):
        section = Section('test section')
        section.draw(self._terminal, self._terminal.width())

        self.assertRaises(AssertionError, section.draw, self._terminal, 1)