From a73183169cb8426e814f501ea97938c28c10a845 Mon Sep 17 00:00:00 2001 From: phil Date: Fri, 18 Jul 2003 18:03:04 +0000 Subject: [PATCH] More debug cleanup related to the subsystem; the old array is gone, it's a mask just like the debug level, everything is simpler (and works now, too). --- lnet/utils/debug.c | 29 +++++++---------------------- lustre/portals/utils/debug.c | 29 +++++++---------------------- 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/lnet/utils/debug.c b/lnet/utils/debug.c index fe7c242..0a009d2 100644 --- a/lnet/utils/debug.c +++ b/lnet/utils/debug.c @@ -53,7 +53,7 @@ static char rawbuf[8192]; static char *buf = rawbuf; static int max = 8192; //static int g_pfd = -1; -static int subsystem_array[1 << 8]; +static int subsystem_mask = ~0; static int debug_mask = ~0; static const char *portal_debug_subsystems[] = @@ -89,7 +89,10 @@ static int do_debug_mask(char *name, int enable) printf("%s output from subsystem \"%s\"\n", enable ? "Enabling" : "Disabling", portal_debug_subsystems[i]); - subsystem_array[i] = enable; + if (enable) + subsystem_mask |= (1 << i); + else + subsystem_mask &= ~(1 << i); found = 1; } } @@ -112,7 +115,6 @@ static int do_debug_mask(char *name, int enable) int dbg_initialize(int argc, char **argv) { - memset(subsystem_array, 1, sizeof(subsystem_array)); return 0; } @@ -214,12 +216,7 @@ int jt_dbg_list(int argc, char **argv) for (i = 0; portal_debug_masks[i] != NULL; i++) printf(", %s", portal_debug_masks[i]); printf("\n"); - } - else if (strcasecmp(argv[1], "applymasks") == 0) { - unsigned int subsystem_mask = 0; - for (i = 0; portal_debug_subsystems[i] != NULL; i++) { - if (subsystem_array[i]) subsystem_mask |= (1 << i); - } + } else if (strcasecmp(argv[1], "applymasks") == 0) { applymask_all(subsystem_mask, debug_mask); } return 0; @@ -231,12 +228,6 @@ static void dump_buffer(FILE *fd, char *buf, int size, int raw) { char *p, *z; unsigned long subsystem, debug, dropped = 0, kept = 0; - int max_sub, max_type, warn = 0; - - for (max_sub = 0; portal_debug_subsystems[max_sub] != NULL; max_sub++) - ; - for (max_type = 0; portal_debug_masks[max_type] != NULL; max_type++) - ; while (size) { p = memchr(buf, '\n', size); @@ -248,13 +239,7 @@ static void dump_buffer(FILE *fd, char *buf, int size, int raw) z++; /* for some reason %*s isn't working. */ *p = '\0'; - if (subsystem >= max_sub && warn == 0) { - fprintf(stderr, "warning: unrecognized debug subsystem " - "%lx; did someone update kp30.h but not " - "portals/utils/debug.c?\n", subsystem); - warn = 1; - } - if ((subsystem >= max_sub || subsystem_array[subsystem]) && + if ((subsystem_mask & subsystem) && (!debug || (debug_mask & debug))) { if (raw) fprintf(fd, "%s\n", buf); diff --git a/lustre/portals/utils/debug.c b/lustre/portals/utils/debug.c index fe7c242..0a009d2 100644 --- a/lustre/portals/utils/debug.c +++ b/lustre/portals/utils/debug.c @@ -53,7 +53,7 @@ static char rawbuf[8192]; static char *buf = rawbuf; static int max = 8192; //static int g_pfd = -1; -static int subsystem_array[1 << 8]; +static int subsystem_mask = ~0; static int debug_mask = ~0; static const char *portal_debug_subsystems[] = @@ -89,7 +89,10 @@ static int do_debug_mask(char *name, int enable) printf("%s output from subsystem \"%s\"\n", enable ? "Enabling" : "Disabling", portal_debug_subsystems[i]); - subsystem_array[i] = enable; + if (enable) + subsystem_mask |= (1 << i); + else + subsystem_mask &= ~(1 << i); found = 1; } } @@ -112,7 +115,6 @@ static int do_debug_mask(char *name, int enable) int dbg_initialize(int argc, char **argv) { - memset(subsystem_array, 1, sizeof(subsystem_array)); return 0; } @@ -214,12 +216,7 @@ int jt_dbg_list(int argc, char **argv) for (i = 0; portal_debug_masks[i] != NULL; i++) printf(", %s", portal_debug_masks[i]); printf("\n"); - } - else if (strcasecmp(argv[1], "applymasks") == 0) { - unsigned int subsystem_mask = 0; - for (i = 0; portal_debug_subsystems[i] != NULL; i++) { - if (subsystem_array[i]) subsystem_mask |= (1 << i); - } + } else if (strcasecmp(argv[1], "applymasks") == 0) { applymask_all(subsystem_mask, debug_mask); } return 0; @@ -231,12 +228,6 @@ static void dump_buffer(FILE *fd, char *buf, int size, int raw) { char *p, *z; unsigned long subsystem, debug, dropped = 0, kept = 0; - int max_sub, max_type, warn = 0; - - for (max_sub = 0; portal_debug_subsystems[max_sub] != NULL; max_sub++) - ; - for (max_type = 0; portal_debug_masks[max_type] != NULL; max_type++) - ; while (size) { p = memchr(buf, '\n', size); @@ -248,13 +239,7 @@ static void dump_buffer(FILE *fd, char *buf, int size, int raw) z++; /* for some reason %*s isn't working. */ *p = '\0'; - if (subsystem >= max_sub && warn == 0) { - fprintf(stderr, "warning: unrecognized debug subsystem " - "%lx; did someone update kp30.h but not " - "portals/utils/debug.c?\n", subsystem); - warn = 1; - } - if ((subsystem >= max_sub || subsystem_array[subsystem]) && + if ((subsystem_mask & subsystem) && (!debug || (debug_mask & debug))) { if (raw) fprintf(fd, "%s\n", buf); -- 1.8.3.1