def dump_regs(panda, cpu): ''' Print (telescoping) each register and its values ''' for (regname, reg) in registers.items(): val = cpu.env_ptr.regs[reg] print("{}: 0x{:x}".format(regname, val), end="\t") telescope(panda, cpu, val)
def dump_regs(self, cpu): ''' Print (telescoping) each register and its values ''' for (regname, reg) in self.registers.items(): val = self.get_reg(cpu, reg) print("{}: 0x{:x}".format(regname, val), end="\t") telescope(self.panda, cpu, val)
def dump_stack(self, cpu, words=8): ''' Print (telescoping) most recent `words` words on the stack (from stack pointer to stack pointer + `words`*word_size) ''' base_reg_s = "SP" base_reg_val = self.get_reg(cpu, self.reg_sp) word_size = int(self.panda.bits/4) for word_idx in range(words): val_b = self.panda.virtual_memory_read(cpu, base_reg_val+word_idx*word_size, word_size) val = int.from_bytes(val_b, byteorder='little') print("[{}+0x{:0>2x} == 0x{:0<8x}]: 0x{:0<8x}".format(base_reg_s, word_idx*word_size, base_reg_val+word_idx*word_size, val), end="\t") telescope(self.panda, cpu, val)
def dump_stack(panda, cpu): ''' Print (telescoping) most recent 8 words on the stack (from ESP ESP+8*word_size) ''' base_reg = R_SP base_reg_s = "SP" word_size = 4 N_WORDS = 8 base_reg_val = cpu.env_ptr.regs[base_reg] for word_idx in range(N_WORDS): val_b = panda.virtual_memory_read(cpu, base_reg_val+word_idx*word_size, word_size) val = int.from_bytes(val_b, byteorder='little') print("[{}+0x{:0>2x} == 0x{:0<8x}]: 0x{:0<8x}".format(base_reg_s, word_idx*word_size, base_reg_val+word_idx*word_size, val), end="\t") telescope(panda, cpu, val)