gdb-heap icon indicating copy to clipboard operation
gdb-heap copied to clipboard

Don't read /proc/$PID/maps for core files

Open doctau opened this issue 11 years ago • 5 comments

iter_mmap_heap_chunks() tries to read /proc/$PID/maps which only works if the process is currently running. If you are using a core file, it will fail with an exceptions.IOError.

Having iter_mmap_chunks() return immediately if we are processing a core file rather than having an attached process solves it.

doctau avatar Jul 25 '14 02:07 doctau

Do you have a PR?

rogerhu avatar Jul 25 '14 03:07 rogerhu

Not yet, I just added a "return" to the top temporarily to work on the core file I'm looking at. I can do one later after I've had a chance to look at the gdb API which I haven't used before (unless you fix it first)

doctau avatar Jul 25 '14 03:07 doctau

If we return immediately, it presumably won't find the mmapped chunks.

I'm told that

(gdb) info proc mappings

works for core files from NT_FILE; this could be a way to find them when running on a coredump.

davidmalcolm avatar Mar 14 '16 13:03 davidmalcolm

Same problem hiere:

(gdb) heap
Python Exception <class 'FileNotFoundError'> [Errno 2] No such file or directory: '/proc/4951/maps':
Error occurred in Python command: [Errno 2] No such file or directory: '/proc/4951/maps'

spaceone avatar Dec 02 '19 10:12 spaceone

There is another util for analyzing heap in core dumps: https://github.com/vmware/chap If you want, you can dump allocation list via comand "list allocations" in chap. After that you need to parse this list to get allocations for gdbheap instead of porcfs. I also tried parse allocations via gdbheap based on gdb command "info files", but this method failed.

XCemaXX avatar Dec 13 '23 18:12 XCemaXX