title: Examining C/C++ Heap memory statistics in gdb
body: <p>I'm trying to investigate the state of the C/C++ heap from within gdb on Linux amd64, is there a nice way to do this?</p>
  
  <p>One approach I've tried is to "call mallinfo()" but unfortunately I can't then extract the values I want since gdb doesn't deal with the return value properly.</p>
  
  <p>I'm not easily able to write a function to be compiled into the binary for the process I am attached to, so I can simply implement my own function to extract the values by calling mallinfo() in my own code this way.  Is there perhaps a clever trick that will allow me to do this on-the-fly?</p>
  
  <p>Another option could be to locate the heap and traverse the malloc headers / free list; I'd appreciate any pointers to where I could start in finding the location and layout of these.</p>
  
  <p>I've been trying to Google and read around the problem for about 2 hours and I've learnt some fascinating stuff but still not found what I need.</p>