|
From: Dirk S. <val...@ds...> - 2008-05-18 12:11:05
|
On Sat, 17 May 2008, jlh wrote: >> I really can not understand, why nowadays all prefer debuggers and forget >> the good old printf. > > I don't see how filling the program with lots of printf()s and then writing a > perl script that analyzes its output is different from using a debugger. Doing > that *is* using a debugger: the one you just wrote yourself. And when there > are good debuggers available already, why spend time reinventing the wheel? In > fact, mtrace works exactly like this: It generates lots of output and mtrace is > a perl script that analyzes it and tells you at which lines memory has been > allocated but never released. A debugger also needs to be told, what to output. But different to printfs you need to tell it everytime again. The old printfs otherwise output stuff, which was subject to intensive searches already. Don't know why, but usually that helps also with later searches. Seems bugs are always grouped together in the software ;-) Another advantage: It works everywhere, even on production machines :-) P.S. Writing a perl script is a bit strong. Usually these are 1-3 liners. > And valgrind is a really great tool. It points its finger to a line of code > and says "this malloc()ed memory has not been free'ed anywhere". Getting this > kind of comfort is not trivial with self-written printf()s + perl. Jup. valgrind is a very fine piece of software. I'm very happy it exists. The only problem is the speed :-) Was one of the first debug tools I used when I switched from Amiga to Unix development (oh, many years ago, time flies so fast, I get old :-) Ciao -- http://www.dstoecker.eu/ (PGP key available) |