httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Robert S. Thau)
Subject Re: nice try, no cigar
Date Sat, 08 Jun 1996 18:09:55 GMT
Looking over Ben's try, it seems to me that you can leave the MARK bit
out of the invocations of explain:

  #ifndef NDEBUG
  #define EXPLAIN(x) _explain x
  void _explain (int level, int line, const char *file, const char *fmt, ...);
  #define EXPLAIN(x) /* nothing */

  #define NOTE_LEVEL 0, __LINE__, __FILE__
  #define WARN_LEVEL 1, __LINE__, __FILE__
  #define ERR_LEVEL  2, __LINE__, __FILE__


  EXPLAIN ((WARN_LEVEL, "Faucet dripping at rate %f", drip_rate));

How far it's worth seeding these things through the code is another
matter.  I think it probably is worthwhile to provide enough of these
things to allow an end-user to determine which modules' code is being
invoked and when, in order to help in debugging weird config bugs.

On the other hand, the CERN server code is larded through with
invocations of EXPLAIN-type macros which could only be useful to
someone who is actually debugging the code itself.  This can, in my
experience (e.g., with that CERN code), actually make the code harder
to maintain, by burying the actual flow of control underneath a layer
of inessential clutter and making it harder for a reader to figure
out what's going on.  If you want to know what the server is doing
when it's in the debugger, you can just stop it, find out, and then
single-step it to find out where it goes next (or use breakpoints
with associated commands to print the values of variables at points
of interest, etc., and then let the code continue).

The sole exception I've run across to date is for debugging such
things as CGI script startup, where some of the action happens in a
subprocess which is inaccessible to the debugger --- there's actually
some EXPLAIN-type stuff #ifdeffed out in that code.  But if you *can*
use the debugger to get at whatever internal state you want to monitor,
as is almost always the case, then IMHO, that's the way to do it.


View raw message