From b987b4141281c6e4922923c82ca972f71479ab46 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Thu, 9 Jun 2016 20:58:27 -0600 Subject: [PATCH] Work around loud exception for GDB 7.7 which may cause wrong arch to be used --- pwndbg/arch.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pwndbg/arch.py b/pwndbg/arch.py index 48c6bb794..8d2f92bbe 100644 --- a/pwndbg/arch.py +++ b/pwndbg/arch.py @@ -29,7 +29,16 @@ def fix_arch(arch): def update(): m = sys.modules[__name__] - m.current = fix_arch(gdb.selected_frame().architecture().name()) + # GDB 7.7 (Ubuntu Trusty) does not like selected_frame() when EBP/RBP + # is not mapped / pounts to an invalid address. + # + # As a work-around for Trusty users, handle the exception and bail. + # This may lead to inaccurate results, but there's not much to be done. + try: + m.current = fix_arch(gdb.newest_frame().architecture().name()) + except Exception: + return + m.ptrsize = pwndbg.typeinfo.ptrsize m.ptrmask = (1 << 8*pwndbg.typeinfo.ptrsize)-1