format_args: display fd path

E.g. for calls like this:
```
 ► 0x555555554a57 <main+296>    call   ioctl@plt <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`.
pull/880/head
disconnect3d 5 years ago committed by Disconnect3d
parent 2a77b2d20b
commit 1bbc39d9bd

@ -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

Loading…
Cancel
Save