Stuffing my pahole
There was an interesting utility mentioned on IRC the other day Pahole. What’s Pahole? Well, it’s an application that can tell you about holes in your structures. (And yes, if you’re not a programmer you probably really don’t care and can stop reading, heh.)
There’s an LWN Article about the initial release of Pahole and Nathan point to another excellent article. So, between the two of these I managed to get it working.
I’m using Ubuntu here and had to install a few utilities/libraries for everything to run successfully. I installed:
- cmake
- libdw-dev
- libebl-dev
After that following the instructions everything compiled fine. I ended up with the libdwarf stuff in /usr/local which I didn’t like, and pahole didn’t like either, so I moved it to /usr/local/lib and re-ran /sbin/ldconfig. Everything seems to be working as expected.
With everything installed I ran it on ewl: pahole -V ewl_widget.o
and
got…..nothing. After a bit of fiddling I realized I had removed the -g last
time I compiled Ewl. Once I’d re-compiled Ewl with -g and re-ran the above
command I got the expected output:
struct Ewl_Widget {
Ewl_Object object; /* 0 76 */
/* --- cacheline 1 boundary (64 bytes) was 12 bytes ago --- */
Ewl_Widget * parent; /* 76 4 */
Ewl_Callback_Chain callbacks[25]; /* 80 200 */
/* --- cacheline 4 boundary (256 bytes) was 24 bytes ago --- */
Ewl_Attach_List * attach; /* 280 4 */
void * smart_object; /* 284 4 */
void * fx_clip_box; /* 288 4 */
void * theme_object; /* 292 4 */
const char * theme_path; /* 296 4 */
const char * theme_group; /* 300 4 */
const char * theme_state; /* 304 4 */
const char * appearance; /* 308 4 */
const char * inheritance; /* 312 4 */
int layer; /* 316 4 */
/* --- cacheline 5 boundary (320 bytes) --- */
int toplayered; /* 320 4 */
Ecore_Hash * theme; /* 324 4 */
Ewl_Pair_List theme_text; /* 328 8 */
/* size: 336, cachelines: 6 */
/* last cacheline: 16 bytes */
};
Which, surprisingly , had no holes in it.
After that I ran it on /usr/local/lib/libewl.so.1.0.0 to see what everything looked like and came out with this. There are a few structs with holes in them, but nothing that we can actually fill.
If you want pahole to give you information on filling holes you can run:
``pahole -RC Ewl_Widget /usr/local/lib/libewl.so.1.0.0` and it would try to fill any holes in the Ewl_Widget structure.
All in all, a pretty cool little utility. I’ll have to keep it around and check Ewl every now and then to make sure we aren’t wasting any memory.