This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ldmdot


On 4/10/06, Dave Korn <dave.korn@artimi.com> wrote:
> On 10 April 2006 18:08, pedro_alves wrote:
> > While searching the archives for something totally unrelated, I stumbled on
> > this great little gem from Shaun.
> > [http://sourceware.org/ml/newlib/2005/msg00817.html]
> >
> > It saved my day, so I want to give something back.
> >
> > Here is my version. No need to replace dots and slashes if we quote the
> > vars.
>
>   Nice one, that's certainly preferable to replacing them all with
> underscores!
>
>   We should probably tidy this up, slap a GPL header on it, and offer it up
> for the top-level contrib directory, it's just the sort of thing to go in
> there.  Texi2pod.pl is looking a little bit lonely and it's awfully quiet and
> echoey in there compared to gcc's contrib dir!

I'm glad you found my script useful! I'm a huge fan of dotty. I've
found all sorts of cases where hundreds of lines of output from some
program (typically an assembler/compiler/linker) could be succinctly
summed up by a ten line script that translated the output to graphviz
format.

I've appended two companion scripts, nmdot and ldddot, to this email. Run
	nmdot `find . -name *.o` | dotty -
or
	ldd /bin/* | ldddot | dotty -
... for some interesting viewing. The transitive reduction script,
tred, is useful to clean up the graph before piping it to dotty.

You have my permission to distribute this work (ldddot, ldmdot, and
nmdot) under the terms of the GPL.

Cheers,
Shaun

========== nmdot ==========
#!/bin/sh

echo 'digraph nmdotty {'

nm "$@" | sed -nr '
/:/ { y/\/.-/___/; s/^(.*):$/\1 -> {/; p; s/.*/}\n/;h }
/ U / { s/ *U (.*)/\1/; p }
/^$/ { g;p }
$ { g;p }
'

nm "$@" | sed -nr '
/:/ { y/\/.-/___/; s/^(.*):$/} -> \1\n/; h; a{
}
/ T / { s/[0-9a-f ]*T (.*)/\1/; p }
/^$/ { g;p }
$ { g;p }
'

echo }

========== ldddot ==========
#!/usr/bin/perl -w
use strict;

print "digraph ldd {\n";

my $footer = "";
while (<>) {
	chomp;
	if (!/^\t/) {
		s/:$//;
		y/-.\//___/;
		s/^_//;
		print "$footer$_ -> { ";
		$footer = "}\n";
	} else {
		s/^\t//;
		next if /ld-linux|^linux-gate|^libc|^libm|^not/;
		s/ .*//;
		y/-.\//___/;
		print "$_ ";
	}
}

print "$footer}\n";

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]