Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting debugger path via context.gdb_binary #2527

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions pwnlib/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions pwnlib/gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading