rogerhu / gdb-heap

Heap Analyzer for Python
Other
233 stars 39 forks source link

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

Open doctau opened 10 years ago

doctau commented 10 years ago

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.

rogerhu commented 10 years ago

Do you have a PR?

doctau commented 10 years ago

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)

davidmalcolm commented 8 years ago

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.

spaceone commented 4 years ago

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'
XCemaXX commented 10 months ago

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.