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
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
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())
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()
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())
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()
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())
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())
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())
def test_section(self): section = Section("test section") section.draw(self._terminal, self._terminal.width()) self.assertRaises(AssertionError, section.draw, self._terminal, 1)
def _create_code_section(self, context): section = Section('code') listing = InstructionListingWidget(context.instruction_listing()) section.add_component(listing) return section
def _create_stack_section(self, context): section = Section('stack') section.add_component(DataWidget(context.stack())) return section
def test_section(self): section = Section('test section') section.draw(self._terminal, self._terminal.width()) self.assertRaises(AssertionError, section.draw, self._terminal, 1)