I have a core file caused by 'too many open file' in Linux. I want to know how many fds the program used at crash time and the mapping of fds. Can I get file descriptor list from that core file?
With gdb or some other tools?
On Linux, core dumps are normally in ELF format. However, the ELF specification doesn't tell us anything about the content format - only how to identify that it's a core file.
So we need to look at the source of binfmt_elf.c where core files are written. There's a promising-looking function called fill_files_note()
, but on closer reading, it appears to be recording memory-mapped files (including the program and library text), rather than file descriptors.
It appears that no information about open fds is recorded in a Linux core file. If you believe that useful data could be recorded, you'll need to write the code to do so yourself.