[PATCH 0/5] Add a new 'info proc files' command

John Baldwin
2018-09-08T00:38:16Z

This series adds a new 'info proc files' subcommand of 'info proc'.
This subcommand lists information about the open file descriptors of a
process similar to how 'info proc mappings' lists information about
the active virtual memory mappings of a process. The series includes
support for reading the list of file descriptors from both process
core dumps and live processes under FreeBSD.

I've included some sample output below from a live ssh process. One
possibly odd thing to note is that FreeBSD includes some "special"
files in the list of open files that are not actual file descriptors,
but other files that each process references such as the current
working directory, the root directory (affected by chroot), the
controlling tty, etc.

(gdb) info proc files 22136
process 22136
Open files:

FD Type Offset Flags Name
text file - r-------- /usr/bin/slogin
ctty chr - rw------- /dev/pts/20
cwd dir - r-------- /usr/home/john
root dir - r-------- /
0 chr 0x32933a4 rw------- /dev/pts/20
1 chr 0x32933a4 rw------- /dev/pts/20
2 chr 0x32933a4 rw------- /dev/pts/20
3 socket 0x0 rw----n-- tcp4 10.0.1.2:53014 -> 10.0.1.10:22
4 socket 0x0 rw------- unix stream:/tmp/ssh-FIt89oAzOn5f/agent.2456
5 chr 0x32933a4 rw------- /dev/pts/20
6 chr 0x32933a4 rw------- /dev/pts/20
7 chr 0x32933a4 rw------- /dev/pts/20

John Baldwin (5):
Use KF_PATH to verify the size of a struct kinfo_file.
Add a new 'info proc files' subcommand of 'info proc'.
Add support for 'info proc files' on FreeBSD core dumps.
Support 'info proc files' on live FreeBSD processes.
Document the 'info proc files' command.

gdb/ChangeLog | 51 +++++
gdb/NEWS | 3 +
gdb/defs.h | 3 +
gdb/doc/ChangeLog | 5 +
gdb/doc/gdb.texinfo | 8 +
gdb/fbsd-nat.c | 44 ++++-
gdb/fbsd-tdep.c | 443 +++++++++++++++++++++++++++++++++++++++++++-
gdb/fbsd-tdep.h | 31 ++++
gdb/infcmd.c | 12 ++
9 files changed, 597 insertions(+), 3 deletions(-)

--
2.18.0