mcvoy@rsch.WISC.EDU (Lawrence W. McVoy) (09/26/86)
[munch munch] Read the readme. Needs to be installed by root unless you have a publicly writable /usr/include/xxxx directory. Enjoy. # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # Makefile README debug.3 debug.h echo x - Makefile cat > "Makefile" << '//E*O*F Makefile//' # # Everybody wants a makefile (sigh) # MAN = /usr/man/man3 INCLUDE = /usr/include/local install: $(INCLUDE)/debug.h cp debug.h $(INCLUDE) cp debug.3 $(MAN) //E*O*F Makefile// echo x - README cat > "README" << '//E*O*F README//' OK, here are the routines you've all been waiting for. There are (at least) two reasons why you should use these debugging routines instead of your (probably wonderful) routines; 1) If everyone used these then we would have *standardization*. And we all like that. 2) They get around the var args problem of debugging. No more dprintf1, dprintf2, ... dprintfN macros. Look at the man page or debug.h. They are trivial; just like assert. //E*O*F README// echo x - debug.3 cat > "debug.3" << '//E*O*F debug.3//' .TH DEBUG 3 LOCAL .SH DEBUG debug, trace - compile time debugging routines .SH SYNOPSIS #include <local/debug.h> .sp \fBdebug((stream, control, arg1, arg2, ... argn));\fR .br \fBtrace((stream, control, arg1, arg2, ... argn));\fR .SH DESCRIPTION .I Debug() and/or .I trace() are debugging routines that can be conditionally compiled in/out of your \fBC\fR program source files. These are macros that get around the variable number of arguments problem. They are used exactly as you would use \fIfprintf(3x)\fR with one exception: you must use 2 levels of parentheses. For example: .sp .in +4 #include <local/debug.h> .sp ... .sp debug((stderr, "%s: index = %d\n", argv[0], i)); .in .PP The default is that these macros are turned \fBoff\fR. To turn them on, the preprocessor (see cc(1)) manifests DEBUG and TRACE must be defined to enable \fIdebug()\fR and \fItrace()\fR, respectively. .PP .I Debug() and .I trace() are functionally equivalent; .I Trace() exists only to allow 2 distinct levels of debugging and to possibly avoid name conflicts. .SH "SEE ALSO" cc(1) //E*O*F debug.3// echo x - debug.h cat > "debug.h" << '//E*O*F debug.h//' # ifndef KILL_THOSE_BUGS # define KILL_THOSE_BUGS /* * debug.h 1.0 - debug, trace * * Written 9-25-86, Larry McVoy (idea seen before but I forget where) * * usage: cc [-DDEBUG] [-DTRACE] src files.... * * c src: debug((stream, control, args, args, args, ...)); * trace((stream, control, args)); */ # ifdef DEBUG # define debug(x) fprintf x # else # define debug(x) # endif DEBUG # ifdef TRACE # define trace(x) fprintf x # else # define trace(x) # endif TRACE # endif !KILL_THOSE_BUGS //E*O*F debug.h// echo Possible errors detected by \'wc\' [hopefully none]: temp=/tmp/shar$$ trap "rm -f $temp; exit" 0 1 2 3 15 cat > $temp <<\!!! 10 22 161 Makefile 11 74 452 README 40 163 1081 debug.3 27 84 513 debug.h 88 343 2207 total !!! wc Makefile README debug.3 debug.h | sed 's=[^ ]*/==' | diff -b $temp - exit 0