Skip to content

Commit

Permalink
add option to show retaddr register to config (pwndbg#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqi authored and zachriggle committed Oct 19, 2016
1 parent cb00aa7 commit 30f1498
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pwndbg/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ def regs(*regs):
print('\n'.join(get_regs(*regs)))

pwndbg.config.Parameter('show-flags', False, 'whether to show flags registers')
pwndbg.config.Parameter('show-retaddr-reg', False, 'whether to show return address register')

def get_regs(*regs):
result = []

if not regs:
if not regs and pwndbg.config.show_retaddr_reg:
regs = pwndbg.regs.gpr + (pwndbg.regs.frame, pwndbg.regs.current.stack) + pwndbg.regs.retaddr + (pwndbg.regs.current.pc,)
elif not regs:
regs = pwndbg.regs.gpr + (pwndbg.regs.frame, pwndbg.regs.current.stack, pwndbg.regs.current.pc)

if pwndbg.config.show_flags:
Expand Down
5 changes: 3 additions & 2 deletions pwndbg/regs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self,
if reg and reg not in self.common:
self.common.append(reg)

self.all = set(i for i in misc) | set(flags) | set(self.common)
self.all = set(i for i in misc) | set(flags) | set(self.retaddr) | set(self.common)
self.all -= {None}

def __iter__(self):
Expand Down Expand Up @@ -241,7 +241,6 @@ def __iter__(self):
'arm': arm,
'aarch64': aarch64,
'powerpc': powerpc,
'powerpc': powerpc,
}

@pwndbg.proc.OnlyWhenRunning
Expand Down Expand Up @@ -426,3 +425,5 @@ def __repr__(self):
def update_last():
M = sys.modules[__name__]
M.last = {k:M[k] for k in M.common}
if pwndbg.config.show_retaddr_reg:
M.last.update({k:M[k] for k in M.retaddr})

0 comments on commit 30f1498

Please sign in to comment.