colour_trace version 1.0.5
I like to debug programs by printing out lots of trace messages. These often contain the value of pointers (in C) or references (in Perl). It's tedious to have to match up one 0x14f83e06 with another, so I wrote this to colour each pointer value so that you can instantly see what goes with what.
Usage: just pipe your trace output through colour_trace and view the result on an ANSI terminal. If you use less(1) you should use the -R flag, and if you use Emacs then ansi-display.el might be useful. Xterm and its derivatives seem to have a bug with resetting colour attributes in a line that wraps, so it's best to have a wide terminal window.
Each hex string will get its own colour, used for all occurences of that value (so 0x0abc and 0xabc are treated as the same). After a while the program runs out of ANSI colour combinations to use and stops assigning new colours, printing new values in black and white. The null pointer value 0x0 is also printed in black and white.
Often you find that the pointer values at the end of the trace file are the interesting ones, rather than those at the beginning; in this case you could say 'tac trace.out | colour_trace | tac'.
The regexps used should work for anything that has hex strings beginning '0x', but there is special support for Perl's stringified references. You can easily add your own regexp to match some new output format, provided it prints values in hex.
There are 103 colour combinations altogether; you can list them with 'colour_trace --list'. You should probably check that they all look different on your system.
All the files are in the public domain. This means there are no copyright restrictions, you may do what you wish with them. Of course, giving credit would be appeciated (but not required). They are offered as-is with no warranty whatsoever.
-- Ed Avis, firstname.lastname@example.org, 2000-12-21