def cmp_regs(cpu, should_print=False): ''' Compare registers from a remote gdb session to current mcore. :param manticore.core.cpu Cpu: Current cpu :param bool should_print: Whether to print values to stdout :return: Whether or not any differences were detected :rtype: bool ''' differing = False gdb_regs = gdb.getCanonicalRegisters() for name in sorted(gdb_regs): vg = gdb_regs[name] if name.endswith('psr'): name = 'apsr' v = cpu.read_register(name.upper()) if should_print: logger.debug('{} gdb:{:x} mcore:{:x}'.format(name, vg, v)) if vg != v: if should_print: logger.warning('^^ unequal') differing = True if differing: logger.debug(qemu.correspond(None)) return differing
def cmp_regs(cpu, should_print=False): ''' Compare registers from a remote gdb session to current mcore. :param manticore.core.cpu Cpu: Current cpu :param bool should_print: Whether to print values to stdout :return: Whether or not any differences were detected :rtype: bool ''' differing = False gdb_regs = gdb.getCanonicalRegisters() for name in sorted(gdb_regs): vg = gdb_regs[name] if name.endswith('psr'): name = 'apsr' v = cpu.read_register(name.upper()) if should_print: logger.debug('{} gdb:{:x} mcore:{:x}'.format(name, vg, v)) if vg != v: if should_print: logger.warning('^^ unequal') differing = True if differing: logger.debug(qemu.correspond(None)) return differing
def initialize(state): ''' Synchronize the stack and register state (manticore->qemu) ''' logger.debug("Copying {} bytes in the stack..".format(stack_top - state.cpu.SP)) stack_bottom = min(state.cpu.SP, gdb.getR('SP')) for address in range(stack_bottom, stack_top): b = state.cpu.read_int(address, 8) gdb.setByte(address, chr(b)) logger.debug("Done") # Qemu fd's start at 5, ours at 3. Add two filler fds mcore_stdout = state.platform.files[1] state.platform.files.append(mcore_stdout) state.platform.files.append(mcore_stdout) # Sync gdb's regs for gdb_reg in gdb.getCanonicalRegisters(): if gdb_reg.endswith('psr'): mcore_reg = 'APSR' else: mcore_reg = gdb_reg.upper() value = state.cpu.read_register(mcore_reg) gdb.setR(gdb_reg, value)
def initialize(state): ''' Synchronize the stack and register state (manticore->qemu) ''' logger.debug("Copying {} bytes in the stack..".format(stack_top - state.cpu.SP)) stack_bottom = min(state.cpu.SP, gdb.getR('SP')) for address in range(stack_bottom, stack_top): b = state.cpu.read_int(address, 8) gdb.setByte(address, chr(b)) logger.debug("Done") # Qemu fd's start at 5, ours at 3. Add two filler fds mcore_stdout = state.platform.files[1] state.platform.files.append(mcore_stdout) state.platform.files.append(mcore_stdout) # Sync gdb's regs for gdb_reg in gdb.getCanonicalRegisters(): if gdb_reg.endswith('psr'): mcore_reg = 'APSR' else: mcore_reg = gdb_reg.upper() value = state.cpu.read_register(mcore_reg) gdb.setR(gdb_reg, value)