From 73d1cfd51fe42f32d88919e19d16663c246a1981 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Wed, 5 Apr 2017 16:48:43 -0500 Subject: [PATCH] Hide repeated instructions at the end of disassembly (#205) --- pwndbg/disasm/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pwndbg/disasm/__init__.py b/pwndbg/disasm/__init__.py index 71f399f72..64686b461 100644 --- a/pwndbg/disasm/__init__.py +++ b/pwndbg/disasm/__init__.py @@ -226,4 +226,12 @@ def near(address, instructions=1, emulate=False): if insn: insns.append(insn) + # Remove repeated instructions at the end of disassembly. + # Always ensure we display the current and *next* instruction, + # but any repeats after that are removed. + # + # This helps with infinite loops and RET sleds. + while insns and len(insns) > 2 and len(set(insns[-3:])) == 1: + del insns[-1] + return insns