From 1bbc39d9bd6a7e25e00972074fbe03003e219c26 Mon Sep 17 00:00:00 2001 From: disconnect3d Date: Sat, 5 Sep 2020 03:41:41 -0700 Subject: [PATCH] format_args: display fd path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit E.g. for calls like this: ``` ► 0x555555554a57 call ioctl@plt fd: 0x3 request: 0xae01 vararg: 0x0 ``` We want to display the `fd` as: `fd: 0x3 (/some/path)` fetched from `readlink -f /proc/$PID/fd/$FD`. --- pwndbg/arguments.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pwndbg/arguments.py b/pwndbg/arguments.py index e92357279..e067fd3d3 100644 --- a/pwndbg/arguments.py +++ b/pwndbg/arguments.py @@ -201,5 +201,11 @@ def format_args(instruction): for arg, value in get(instruction): code = arg.type != 'char' pretty = pwndbg.chain.format(value, code=code) + + # Enhance args display + if arg.name == 'fd' and isinstance(value, int): + path = pwndbg.file.readlink('/proc/%d/fd/%d' % (pwndbg.proc.pid, value)) + pretty += ' (%s)' % path + result.append('%-10s %s' % (N.argument(arg.name) + ':', pretty)) return result