[dmd-internals] Asserts

David Held dmd at wyntrmute.com
Fri Nov 9 22:41:56 PST 2012


On 11/9/2012 10:17 PM, Jonathan M Davis wrote:
> [...]
> Logging is extremely useful for applications which are constantly up and/or
> which involve a lot of network traffic or user interaction (which is typically
> non-repeatable and often can't be examined with the debugge running). However,
> that doesn't apply at all to a compiler. Compilers are incredibly
> deterministic, and errors are very, very repeatable. All you have to do is run
> the compiler on the same input, and you'll see the problem again, and stopping
> the compiler in a debugger causes no problems. So, I'd say that logging is
> completely inappropriate for a compiler.

If there were no logging statements in the compiler, you might have a 
point.  The fact that the dmd source is littered with them puts the lie 
to your insistence that they are "inappropriate". Obviously, Walter 
found them very useful at times.

Also, the compiler is only deterministic because it isn't yet 
multi-threaded.  That doesn't mean Walter hasn't attempted to make it 
such on more than one occasion.  If the compiler had more immutable data 
structures, this would probably be an easier effort. ;)

Finally, what the debugger cannot do is provide you with a history of 
what happened, except insofar as you are willing to manually capture the 
state change of various memory locations as you step through the 
program.  Although I tend to use debuggers as the tool of last resort, I 
will still insist that logs are even more powerful when used with the 
debugger, because they can often give you a good idea where you should 
set breakpoints, avoiding having to step through large portions of the 
code which aren't relevant to the problem at hand (after all, not all 
bugs are as obvious as a segfault/AV).

Dave



More information about the dmd-internals mailing list