News fom dwarves land


Now we can also move bitfields around to combine it with other fields, moving a list of members with the same offset (the definition of a bitfield) to after other members that have holes bigger than the size of the (possibly type demoted) list of members comprising a bitfield, also there is a new pahole command line option to show all the steps involved in reorganizing a struct, –show_reorg_steps, look here for how it looks like.

Also related to this pahole news is the fact that the class__reorganize() & supporting code was moved to, where its is made useful for the other dwarves, which leads us to the next dwarves news:


The class tracer now is past its stone age, getting fast to an exciting iron age: printk was replaced by a not so carefully (as in SMP?!?! I only have a dual pentium 100 machine here, damn!) stolen from blktrace (I hope that the UTT effort is merged sooner than later so that I can use it), namely using debugfs + relay to, ho hum, relay the internal state of the class (a funny name for structs) being traced to userspace, ah, since I’m talking about the internal state: the way that it is collected at the probe points now is much, much improved, looking like blktrace, except for the fact that the data being collected is the subset of the members that are “reducible” to a basic type (signed and unsigned int, long, char, long long), which, for now, its just the basic types, but will be shortly augmented by a set of “reducers” for things like spinlock_t, wait_queue_head_t, etc.

Ok, lets break the paragraph a bit to get away from my problem with writing: very long paragraphs…

Back to how ctracer packs the internal state: have you seen how pahole can reorganize structs to fill holes and reduce the structure size? Yeah, we just look at all the struct members, looking for DW_TAG_basic_type members and leave just those, then call class__reorganize() and the struct gets in the best possible layout to save space at each probe point.

Ctracer also uses the same opportunity to generate a tool called ctracer2ostra.c, that is used to convert the binary traces to a colon separated list of formatted values easily parsable by ostra-cg, the callgraph tool that produces nifty buzzword soups (CSS, javascript, ajax in the future, cross-referencing with LXR, python matplotlib graphs of values that each traced class member got in the course of tracing, and plottings for the times each of the “class” “methods” took).

The new improved process for this is detailed in the README.ctracer file, but to give you a quick glance of what it involves:

rpm -ivh
mkdir foo
cd foo
ln -s /usr/lib/ctracer/* .
make CLASS=sock
insmod ctracer.ko
# do some networking kung foo fighting activity or change CLASS to your preferred struct (but beware, as we use do_gettimeofday (how lame) you can get some crashes if tracing something more fishy than struct sock methods)
cat /sys/kernel/debug/ctracer.o > /tmp/ctracer.log
rmmod ctracer.ko
make callgraphs
# Enjoy things like this, where I was bold enough to try this thing on my main machine while doing all sorts of stuff, believe me, it was just one or two dozen harmless oopses, kprobes trying to justify its paycheck!

And to top it all I’ve been getting help from Davi Arnaut on the global variables and DW_AT_location front, were he contributed basic support for where variables are in the computer memory pyramid (Registers? Stack?), he even wrote the first non-acme dwarf, pglobal, that shows all the global variables in your dear project binary files, now its just a matter of extending this to use libebl and get the register names for each arch to go to the next ctracer level, where we’ll stop using costly Jay-probes and get the elusive parameters directly from their hiding place!

Post a comment or leave a trackback: Trackback URL.


  • Jeff Muizelaar  On February 25, 2007 at 12:54 am

    The cmake build system is a pain. I used to track pahole development very closely and even wrote a tool based on it for tracing shared libraries. Unfortunately, since the switch to cmake I haven’t been able to build it.

    The first problem was that I didn’t have a new enough version of cmake, so I had to compile cmake from source. Now that I have a working cmake, I haven’t been able to get cmake to find my libdwarf headers (they’re in $HOME/usr/include). I’ve tried editing FindDWARF.cmake but that doesn’t seem to work either.

  • admin  On February 25, 2007 at 10:57 am

    build systems, oh well, the whole story is that I never studied autoconf/automake enough to get over the feeling that it was overly complicated, so when I felt the need for using such a system in pahole I made this comment about having to finally learn the autotools and a friend, Helio Chissini, suggested using cmake, he was so enthusiastic about it that quickly provided the initial CMakeFile.txt (camel case, bah, my first annoyance on cmake 🙂 ) and the FindDWARF.cmake.

    But I continue a lazy boy on such build systems… I’m now trying to fix this tho, should have something for you to test later today. Or perhaps I should just get back to using the autotools. 🙂

  • admin  On February 25, 2007 at 5:24 pm

    Ok, today I’ve read a bit more about cmake to get its instruction files in a better shape, including solving the problem that is affecting you, that is, to have elfutils installed in a non-standard path, I’ve tested installing elfutils in ~/usr/local and with the just commited pahole csets it just works, in your case just edit cmake/modules/FindDWARF.cmake replacing ~/usr/local/ with ~/usr/ and you should be set.

    CMake is being adopted by more and more projects, notably KDE4, that will provide the impetus for it to be properly supported in all distros, providing competition for SCons and the venerable auto-tools, which is always good.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: