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 12: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 01: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 02: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 02:50 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

Darryl Gove is a senior engineer in the Solaris Studio team, working on optimising applications and benchmarks for current and future processors. He is also the author of the books:
Multicore Application Programming
Solaris Application Programming
The Developer's Edge

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
5
6
8
9
10
12
13
14
15
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks
The Developer's Edge
Solaris Application Programming
Publications
Webcasts
Presentations
OpenSPARC Book
Multicore Application Programming
Docs