Darryl Gove's blog

Wednesday May 20, 2009

Libraries

I was talking to Rod Evans about the diagnostic capabilities available in the runtime linker. These are available through the environment setting LD_DEBUG. The setting LD_DEBUG=files gives diagnostic information about which libraries were loaded by which other libraries. This is rather hard to interpret, and would look better as a graph. It's relatively easy to parse the output from LD_DEBUG into dot format. This script does the parsing. The full stesp to do this for the date command are:

$ LD_DEBUG=files date >ld_date 2>&1
$ ld_dot ld_date
$ dot -Tpng -o date.png dot.dot

The lines in the graph represent which libraries use which other libraries. Solid lines indicate "needed" or hard links, the dotted lines represent lazy loading or dynamic loading (dlopen). The resulting graph looks like:

More complex commands like ssh pull in a larger set of libraries:

It is possible to use this on much larger applications. Unfortunately, the library dependencies tend to get very complex. This is the library map for staroffice.

Comments:

Cool! For StarOffice you could remove the dotted lines, that might make it more readable. It might also be useful to remove the redundant dependencies. Is there a graph operation like a "reverse transitive closure"?

Posted by Chris Quenelle on May 20, 2009 at 07:21 PM PDT #

Wikipedia tells me that this might be transitive reduction
http://en.wikipedia.org/wiki/Transitive_reduction

which would certainly cull some of those lines.

....

and it's implemented by tred!

Hang on a minute....

Posted by Darryl Gove on May 20, 2009 at 08:59 PM PDT #

This is a neat tool. You should give a link to the package or binary for "dot" so others can try it out.

In the mean time, I found this webpage that translates .dot files to graphics (PNG, JPG, GIF, etc.):
http://graph.gafol.net/
- Dan Anderson

Posted by Dan Anderson on May 21, 2009 at 09:20 AM PDT #

Here's the wikipedia link: http://en.wikipedia.org/wiki/DOT_language

It's implemented by graphviz
http://graphviz.org/

There are versions of this on blastwave (http://www.blastwave.org/packages.php/graphviz) and sunfreeware (http://www.sunfreeware.com/ftp/pub/freeware/i386/5.11/graphviz-2.16.1-sol10-x86-local.gz).

I've not tested either of these versions myself.

Regards,

Darryl.

Posted by Darryl Gove on May 21, 2009 at 09:50 AM PDT #

Post a Comment:
Comments are closed for this entry.

Calendar

Search this blog

About

Solaris Application Programming

Book resources

The Developer's Edge

Book resources

OpenSPARC Internals

Book resources

Recent entries

Custom search

Tag cloud

book cmt communityone compiler cooltools cpu2006 dtrace gcc libraries linker openmp opensolaris opensparc optimisation optimization parallelisation parallelization performance performanceanalyzer programming solaris solarisapplicationprogramming sparc spec spot sunstudio t2 ultrasparc ultrasparct2 x86

Links

Webcasts

Articles

Presentations

Interesting docs

Navigation

Referers

Feeds