diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ac08c6ab..5bb808ded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,18 +73,19 @@ The table below shows which release corresponds to each branch, and what date th | [2.2.0](#220) | | Jan 5, 2015 ## 5.0.0 (`dev`) - - [#2507][2507] Add `+LINUX` and `+WINDOWS` doctest options and start proper testing on Windows - [#2522][2522] Support starting a kitty debugging window with the 'kitten' command - [#2524][2524] Raise EOFError during `process.recv` when stdout closes on Windows - [#2526][2526] Properly make use of extra arguments in `packing` utilities. `sign` parameter requires keyword syntax to specify it. - [#2517][2517] Allow to passthru kwargs on `ssh.__getattr__` convenience function to fix SSH motd problems +- [#2527][2527] Allow setting debugger path via `context.gdb_binary` [2507]: https://github.com/Gallopsled/pwntools/pull/2507 [2522]: https://github.com/Gallopsled/pwntools/pull/2522 [2524]: https://github.com/Gallopsled/pwntools/pull/2524 [2526]: https://github.com/Gallopsled/pwntools/pull/2526 [2517]: https://github.com/Gallopsled/pwntools/pull/2517 +[2527]: https://github.com/Gallopsled/pwntools/pull/2527 ## 4.15.0 (`beta`) - [#2508][2508] Ignore a warning when compiling with asm on nix diff --git a/pwnlib/context/__init__.py b/pwnlib/context/__init__.py index 82f71c315..655976a57 100644 --- a/pwnlib/context/__init__.py +++ b/pwnlib/context/__init__.py @@ -363,6 +363,7 @@ class ContextType(object): 'encoding': 'auto', 'endian': 'little', 'gdbinit': "", + 'gdb_binary': "", 'kernel': None, 'local_libcdb': "/var/lib/libc-database", 'log_level': logging.INFO, @@ -1546,6 +1547,20 @@ def gdbinit(self, value): """ return str(value) + @_validator + def gdb_binary(self, value): + """Path to the binary that is used when running GDB locally. + + This is useful when you have multiple versions of gdb installed or the gdb binary is + called something different. + + If set to an empty string, pwntools will try to search for a reasonable gdb binary from + the path. + + Default value is ``""``. + """ + return str(value) + @_validator def cyclic_alphabet(self, alphabet): """Cyclic alphabet. diff --git a/pwnlib/gdb.py b/pwnlib/gdb.py index 9dd509360..1c6c1bfc3 100644 --- a/pwnlib/gdb.py +++ b/pwnlib/gdb.py @@ -750,6 +750,12 @@ def binary(): >>> gdb.binary() # doctest: +SKIP '/usr/bin/gdb' """ + if context.gdb_binary: + gdb = misc.which(context.gdb_binary) + if not gdb: + log.warn_once('Path to gdb binary `{}` not found'.format(context.gdb_binary)) + return gdb + gdb = misc.which('pwntools-gdb') or misc.which('gdb') if not context.native: