Skip to content

Commit

Permalink
hoist computation of zero fill amount out of the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
smiley committed Aug 3, 2023
1 parent aa7c121 commit 5f7190a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pwndbg/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,12 +798,13 @@ def context_backtrace(with_banner=True, target=sys.stdout, width=None):
frame = newest_frame
i = 0
bt_prefix = "%s" % pwndbg.gdblib.config.backtrace_prefix
zero_fill_amount = pwndbg.gdblib.arch.ptrsize * 2
while True:
prefix = bt_prefix if frame == this_frame else " " * len(bt_prefix)
prefix = f" {c.prefix(prefix)}"
frame_pc = frame.pc()
frame_pc_on_stack = pwndbg.gdblib.stack.find_addr_on_stack(frame_pc)
padded_text = "0x" + hex(frame_pc_on_stack)[2:].zfill(pwndbg.gdblib.arch.ptrsize * 2)
padded_text = "0x" + hex(frame_pc_on_stack)[2:].zfill(zero_fill_amount)
stackaddr = M.get(frame_pc_on_stack, padded_text)
addrsz = f"({stackaddr}) {M.get(frame_pc)}"
symbol = c.symbol(pwndbg.gdblib.symbol.get(int(frame_pc)))
Expand Down

0 comments on commit 5f7190a

Please sign in to comment.