Tuesday, 19 July 2011

warning! warning! warning! In the beginning was more. Then there was less.

In the very old days of computing, you could sit in front of a screen
or a teletype and watch the output, a character at a time.
110 baud or 300 baud was eminently readable.

As output devices progress to 9600 baud serial lines, one could fill
a screen in a second (80x24). And "cat" or "make" on its own was
not good enough to read the text frantically scrolling off the screen.

Zoom forward a few years, and with todays multi-GHz cpus and fast
screens, one can 'cat' a 10MB file in a few seconds to the screen.

Did you see the error on line 12,723,104 ? No? Didnt think so.

Tools like "more" and "less" are great for paging slowly
through a file and allow searching and backwards motion.

Or, one can use an editor, such as vim/emacs/CRiSP.

These are great.

When building software, e.g. with gcc/g++, and as projects have
gotten bigger, it can be difficult to spot an error in the middle
of a huge amount of benign output. Worse, gcc has a tendency to
overdo the warnings. Scrolling in an xterm to review the output is
frustrating, trying to spot the magic "error" in the midst of warnings
(or other output).

There are many solutions (such as viewing the output in "more" or "less",
and relying on highlighting to find the item you are after). "less" can
do highlight, but "more" cannot. CRiSP can do highlighting too.

fcterm (my own personal terminal emulator) can do this too, but
you have to tell it what to search for. (I must modify it to have
a default set of words - having a single search pattern is not good enough).

I wrote a simple tool called "warn". You use it like this:


$ warn make
...


and all error output lines are shown in red, with warnings in yellow.
(My default console is green on black).

Very useful for spotting the wood for the trees.

I havent released it as a standalone tool (it has bare minimum
requirements - its plain C code). If people are interested, I will put it
out.

Next up is to fix fcterm...


Post created by CRiSP v10.0.12a-b6034


2 comments:

  1. Hi Paul. I sent you bugreport about dtrace/linux, but got no reply yet :( could you please check if you got it? if not - i can resend it. My mail is samm at net-art.cz

    Thank you.

    ReplyDelete
  2. Excellent! I've been using a similar script that highlights based on a regex pattern. Very helpful with mountains of compiler warnings/errors. :-) Like this:

    http://badassdev.com/articles/2010/7/12/easy-output-highlighting.html

    ReplyDelete