debug patch
bill <[email protected]> Fri, 23 Dec 2005 10:10:04 +0000
| Newsgroups | gmane.comp.gnu.screen |
|---|---|
| Message-ID | <[email protected]> |
Here's a patch to screen.h that puts file names and line numbers on each line of the debug statements. I've been doing this for a few weeks, but the easy implementation was putting the __LINE__ and __FILE__ expansions in excessively, since calls to the debug macros that didn't include a newline would each get the data appended. I wasted about an hour this morning playing with the macros so that doesn't happen, and thought I'd share...
wrp_extra_debug-4.0.2.diff
(text/x-patch, 1.4 KB)
Common subdirectories: screen-4.0.2/doc and debug-screen-4.0.2/doc
Common subdirectories: screen-4.0.2/etc and debug-screen-4.0.2/etc
diff -u screen-4.0.2/screen.h debug-screen-4.0.2/screen.h
--- screen-4.0.2/screen.h 2003-08-22 13:28:43.000000000 +0100
+++ debug-screen-4.0.2/screen.h 2005-12-23 09:56:52.875671848 +0000
@@ -53,11 +53,15 @@
#ifdef DEBUG
# define DEBUGDIR "/tmp/debug"
+#define NEW_LINE(x) (*((x) + (strlen(x)-1))=='\n')
+#define META_FILE(x) (NEW_LINE(x))?__FILE__:""
+#define META_LINE(x) (NEW_LINE(x))?__LINE__:(int)""
+#define META_STRING(x) (NEW_LINE(x))?"%s %d: " x:"%s %s" x
# define debugf(a) do {if(dfp){fprintf a;fflush(dfp);}} while (0)
-# define debug(x) debugf((dfp,x))
-# define debug1(x,a) debugf((dfp,x,a))
-# define debug2(x,a,b) debugf((dfp,x,a,b))
-# define debug3(x,a,b,c) debugf((dfp,x,a,b,c))
+# define debug(x) debugf((dfp,META_STRING(x) ,META_FILE(x),META_LINE(x)))
+# define debug1(x,a) debugf((dfp,META_STRING(x) ,META_FILE(x),META_LINE(x),a))
+# define debug2(x,a,b) debugf((dfp,META_STRING(x) ,META_FILE(x),META_LINE(x),a,b))
+# define debug3(x,a,b,c) debugf((dfp,META_STRING(x) ,META_FILE(x),META_LINE(x),a,b,c))
extern FILE *dfp;
#else
# define debugf(a) do {} while (0)
Common subdirectories: screen-4.0.2/terminfo and debug-screen-4.0.2/terminfo
Common subdirectories: screen-4.0.2/utf8encodings and debug-screen-4.0.2/utf8encodings