Skip to content

Commit aa60bf6

Browse files
committed
Allow setting debugger path via context
1 parent 29fb02f commit aa60bf6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pwnlib/context/__init__.py

+15
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ class ContextType(object):
359359
'encoding': 'auto',
360360
'endian': 'little',
361361
'gdbinit': "",
362+
'gdb_binary': "",
362363
'kernel': None,
363364
'local_libcdb': "/var/lib/libc-database",
364365
'log_level': logging.INFO,
@@ -1539,6 +1540,20 @@ def gdbinit(self, value):
15391540
"""
15401541
return str(value)
15411542

1543+
@_validator
1544+
def gdb_binary(self, value):
1545+
"""Path to the binary that is used when running GDB locally.
1546+
1547+
This is useful when you have multiple versions of gdb installed or the gdb binary is
1548+
called something different.
1549+
1550+
If set to an empty string, pwntools will try to search for a reasonable gdb binary from
1551+
the path.
1552+
1553+
Default value is ``""``.
1554+
"""
1555+
return str(value)
1556+
15421557
@_validator
15431558
def cyclic_alphabet(self, alphabet):
15441559
"""Cyclic alphabet.

pwnlib/gdb.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,10 @@ def binary():
750750
>>> gdb.binary() # doctest: +SKIP
751751
'/usr/bin/gdb'
752752
"""
753-
gdb = misc.which('pwntools-gdb') or misc.which('gdb')
753+
if context.gdb_binary:
754+
gdb = misc.which(context.gdb_binary)
755+
else:
756+
gdb = misc.which('pwntools-gdb') or misc.which('gdb')
754757

755758
if not context.native:
756759
multiarch = misc.which('gdb-multiarch')

0 commit comments

Comments
 (0)