From 64e6d85c8ec9d95f6b7cc98d2d4e239236c8afd5 Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Tue, 27 May 2025 21:46:43 +0000 Subject: [PATCH] gdb: suggest &main instead of main (address of symbol) in commands --- pwndbg/commands/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pwndbg/commands/__init__.py b/pwndbg/commands/__init__.py index cf9d7d4e7..9eb478d50 100644 --- a/pwndbg/commands/__init__.py +++ b/pwndbg/commands/__init__.py @@ -524,8 +524,15 @@ def fix_int_reraise_arg(arg) -> int: fixed = fix_reraise_arg(arg) return int(fixed) except pwndbg.dbg_mod.Error as e: + try: + address_value = int(fix_reraise_arg(f"&{arg}")) + colored_arg = message.notice(f"&{arg}") + suggestion = f"\nDid you mean to use {colored_arg} ? (&{arg} = {address_value:#x})" + except: + raise + suggestion = "" raise argparse.ArgumentTypeError( - f"couldn't convert '{arg}' ({fixed.type.name_to_human_readable}) to int: {e}" + f"couldn't convert '{arg}' ({fixed.type.name_to_human_readable}) to int: {e}{suggestion}" )