mirror of https://github.com/pwndbg/pwndbg.git
Fix exception when pwndbg is sourced after attach
This commit fixes an exception when pwndbg is sources after gdb is attached to a process. Below log is with `set exception-verbose on` and `set exception-debugger on` hardcoded into the sources. We can see that: 1. We get an immediate exception 2. The `pwndbg.arch.current` is set incorrectly to `i386` 3. The real arch is `i386:x86-64` ``` $ gdb -q -p $(pidof a.out) ./a.out Reading symbols from ./a.out... (No debugging symbols found in ./a.out) Attaching to program: /home/dc/example/a.out, process 415704 Reading symbols from /lib/x86_64-linux-gnu/libc.so.6... Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.31.so... Reading symbols from /lib64/ld-linux-x86-64.so.2... (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) 0x00007f4bb94e7142 in __GI___libc_read (fd=0, buf=0x55ee576fb6b0, nbytes=1024) at ../sysdeps/unix/sysv/linux/read.c:26 26 ../sysdeps/unix/sysv/linux/read.c: No such file or directory. (gdb) source /home/dc/tools/pwndbg/gdbinit.py pwndbg: loaded 195 commands. Type pwndbg [filter] for a list. pwndbg: created $rebase, $ida gdb functions (can be used with print/break) Traceback (most recent call last): File "/home/dc/tools/pwndbg/pwndbg/commands/__init__.py", line 130, in __call__ return self.function(*args, **kwargs) File "/home/dc/tools/pwndbg/pwndbg/commands/__init__.py", line 221, in _OnlyWhenRunning return function(*a, **kw) File "/home/dc/tools/pwndbg/pwndbg/commands/context.py", line 269, in context result[target].extend(func(target=out, File "/home/dc/tools/pwndbg/pwndbg/commands/context.py", line 350, in context_regs regs = get_regs() File "/home/dc/tools/pwndbg/pwndbg/commands/context.py", line 399, in get_regs m = ' ' * len(change_marker) if reg not in changed else C.register_changed(change_marker) TypeError: argument of type 'NoneType' is not iterable If that is an issue, you can report it on https://github.com/pwndbg/pwndbg/issues (Please don't forget to search if it hasn't been reported before) To generate the report and open a browser, you may run `bugreport --run-browser` PS: Pull requests are welcome > /home/dc/tools/pwndbg/pwndbg/commands/context.py(399)get_regs() -> m = ' ' * len(change_marker) if reg not in changed else C.register_changed(change_marker) (Pdb) print(changed) None (Pdb) print(reg) eax (Pdb) print(pwndbg.arch.current) i386 (Pdb) print(gdb.execute('show arch', to_string=True)) The target architecture is set automatically (currently i386:x86-64) (Pdb) ```pull/942/head
parent
4f8db3a7d5
commit
b9e7bf1a75
Loading…
Reference in new issue