From 4d5c556f00ae97b16696cc1ff779ac8e45d6fc27 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 27 Nov 1999 08:09:42 +0000 Subject: * Update debugging to use string flags instead of integers. --- debug.h | 4 +++- function.c | 2 +- main.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++------------- read.c | 2 +- remake.c | 28 +++++++++++----------- 5 files changed, 83 insertions(+), 34 deletions(-) diff --git a/debug.h b/debug.h index 6b9d1cb..30c2d62 100644 --- a/debug.h +++ b/debug.h @@ -20,11 +20,13 @@ Boston, MA 02111-1307, USA. */ #define DB_NONE (0x000) #define DB_BASIC (0x001) -#define DB_EXTRA (0x002) +#define DB_VERBOSE (0x002) #define DB_JOBS (0x004) #define DB_IMPLICIT (0x008) #define DB_MAKEFILES (0x100) +#define DB_ALL (0xfff) + extern int db_level; #define ISDB(_l) ((_l)&db_level) diff --git a/function.c b/function.c index 5ce56b5..988ea7f 100644 --- a/function.c +++ b/function.c @@ -1455,7 +1455,7 @@ func_shell (o, argv, funcname) reap_children (1, 0); if (batch_filename) { - DB (DB_EXTRA, (_("Cleaning up temporary batch file %s\n"), + DB (DB_VERBOSE, (_("Cleaning up temporary batch file %s\n"), batch_filename)); remove(batch_filename); free(batch_filename); diff --git a/main.c b/main.c index 96bab63..7f48b8b 100644 --- a/main.c +++ b/main.c @@ -141,9 +141,9 @@ int just_print_flag; /* Print debugging info (--debug). */ +static struct stringlist *db_flags; + int db_level = 0; -int noarg_db_level = 1; -int default_db_level = 0; #ifdef WINDOWS32 /* Suspend make in main for a short time to allow debugger to attach */ @@ -260,9 +260,9 @@ static const struct command_switch switches[] = { 'C', string, (char *) &directories, 0, 0, 0, 0, 0, "directory", _("DIRECTORY"), _("Change to DIRECTORY before doing anything") }, - { 'd', positive_int, (char *) &db_level, 1, 1, 0, - (char *) &noarg_db_level, (char *) &default_db_level, - "debug", "L", + { 'd', string, (char *) &db_flags, 1, 1, 0, + "basic", 0, + "debug", _("FLAGS"), _("Print different types of debugging information") }, #ifdef WINDOWS32 { 'D', flag, (char *) &suspend_flag, 1, 1, 0, 0, 0, @@ -489,7 +489,57 @@ static RETSIGTYPE debug_signal_handler (sig) int sig; { - db_level = DB_NONE; + db_level = db_level ? DB_NONE : DB_BASIC; +} + +static void +decode_debug_flags () +{ + char **pp; + + if (!db_flags) + return; + + for (pp=db_flags->list; *pp; ++pp) + { + const char *p = *pp; + + while (1) + { + switch (tolower (p[0])) + { + case 'a': + db_level |= DB_ALL; + break; + case 'b': + db_level |= DB_BASIC; + break; + case 'i': + db_level |= DB_IMPLICIT; + break; + case 'j': + db_level |= DB_JOBS; + break; + case 'm': + db_level |= DB_MAKEFILES; + break; + case 'v': + db_level |= DB_BASIC | DB_VERBOSE; + break; + default: + fatal (NILF, _("unknown debug level specification `%s'"), p); + } + + while (*(++p) != '\0') + if (*p == ',' || *p == ' ') + break; + + if (*p == '\0') + break; + + ++p; + } + } } #ifdef WINDOWS32 @@ -497,8 +547,8 @@ debug_signal_handler (sig) * HANDLE runtime exceptions by avoiding a requestor on the GUI. Capture * exception and print it to stderr instead. * - * If ! DB_EXTRA, just print a simple message and exit. - * If DB_EXTRA, print a more verbose message. + * If ! DB_VERBOSE, just print a simple message and exit. + * If DB_VERBOSE, print a more verbose message. * If compiled for DEBUG, let exception pass through to GUI so that * debuggers can attach. */ @@ -514,7 +564,7 @@ handle_runtime_exceptions( struct _EXCEPTION_POINTERS *exinfo ) LPTSTR lpszStrings[1]; #endif - if (! ISDB (DB_EXTRA)) + if (! ISDB (DB_VERBOSE)) { sprintf(errmsg, _("%s: Interrupt/Exception caught "), prg); sprintf(&errmsg[strlen(errmsg)], @@ -601,7 +651,7 @@ find_and_set_default_shell(char *token) /* search token path was found */ sprintf(sh_path, "%s", search_token); default_shell = xstrdup(w32ify(sh_path,0)); - DB (DB_EXTRA, + DB (DB_VERBOSE, (_("find_and_set_shell setting default_shell = %s\n"), default_shell)); sh_found = 1; } else { @@ -644,7 +694,7 @@ find_and_set_default_shell(char *token) } if (sh_found) - DB (DB_EXTRA, + DB (DB_VERBOSE, (_("find_and_set_shell path search set default_shell = %s\n"), default_shell)); } @@ -949,10 +999,7 @@ int main (int argc, char ** argv) } #endif - /* If we have the "extra" level, force the basic level too. */ - - if (ISDB (DB_EXTRA)) - db_level |= DB_BASIC; + decode_debug_flags (); /* Print version information. */ @@ -1514,7 +1561,7 @@ int main (int argc, char ** argv) stupidly; but if you work for Athena, that's how you write your makefiles.) */ - DB (DB_EXTRA, + DB (DB_VERBOSE, (_("Makefile `%s' might loop; not remaking it.\n"), f->name)); @@ -2133,7 +2180,7 @@ decode_switches (argc, argv, env) case positive_int: if (optarg == 0 && argc > optind - && ISDIGIT (argv[optind][0])) + && ISDIGIT (argv[optind][0])) optarg = argv[optind++]; if (!doit) diff --git a/read.c b/read.c index 1072bda..67d78d0 100644 --- a/read.c +++ b/read.c @@ -329,7 +329,7 @@ read_makefile (filename, flags) pattern_percent = 0; cmds_started = fileinfo.lineno; - if (ISDB (DB_EXTRA)) + if (ISDB (DB_VERBOSE)) { printf (_("Reading makefile `%s'"), fileinfo.filenm); if (flags & RM_NO_DEFAULT_GOAL) diff --git a/remake.c b/remake.c index cd2b09f..398d027 100644 --- a/remake.c +++ b/remake.c @@ -319,7 +319,7 @@ update_file (file, depth) change is possible below here until then. */ if (f->considered == considered) { - DBF (DB_EXTRA, _("Pruning file `%s'.\n")); + DBF (DB_VERBOSE, _("Pruning file `%s'.\n")); continue; } f->considered = considered; @@ -364,19 +364,19 @@ update_file_1 (file, depth) register struct dep *d, *lastd; int running = 0; - DBF (DB_EXTRA, _("Considering target file `%s'.\n")); + DBF (DB_VERBOSE, _("Considering target file `%s'.\n")); if (file->updated) { if (file->update_status > 0) { - DBF (DB_EXTRA, + DBF (DB_VERBOSE, _("Recently tried and failed to update file `%s'.\n")); no_rule_error(file); return file->update_status; } - DBF (DB_EXTRA, _("File `%s' was considered already.\n")); + DBF (DB_VERBOSE, _("File `%s' was considered already.\n")); return 0; } @@ -386,10 +386,10 @@ update_file_1 (file, depth) case cs_deps_running: break; case cs_running: - DBF (DB_EXTRA, _("Still updating file `%s'.\n")); + DBF (DB_VERBOSE, _("Still updating file `%s'.\n")); return 0; case cs_finished: - DBF (DB_EXTRA, _("Finished updating file `%s'.\n")); + DBF (DB_VERBOSE, _("Finished updating file `%s'.\n")); return file->update_status; default: abort (); @@ -526,13 +526,13 @@ update_file_1 (file, depth) file->updating = 0; - DBF (DB_EXTRA, _("Finished prerequisites of target file `%s'.\n")); + DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n")); if (running) { set_command_state (file, cs_deps_running); --depth; - DBF (DB_EXTRA, _("The prerequisites of `%s' are being made.\n")); + DBF (DB_VERBOSE, _("The prerequisites of `%s' are being made.\n")); return 0; } @@ -545,7 +545,7 @@ update_file_1 (file, depth) depth--; - DBF (DB_EXTRA, _("Giving up on target file `%s'.\n")); + DBF (DB_VERBOSE, _("Giving up on target file `%s'.\n")); if (depth == 0 && keep_going_flag && !just_print_flag && !question_flag) @@ -591,7 +591,7 @@ update_file_1 (file, depth) or its dependent, FILE, is older or does not exist. */ d->changed |= noexist || d_mtime > this_mtime; - if (!noexist && ISDB (DB_BASIC|DB_EXTRA)) + if (!noexist && ISDB (DB_BASIC|DB_VERBOSE)) { const char *fmt = 0; @@ -605,7 +605,7 @@ update_file_1 (file, depth) if (ISDB (DB_BASIC)) fmt = _("Prerequisite `%s' is newer than target `%s'.\n"); } - else if (ISDB (DB_EXTRA)) + else if (ISDB (DB_VERBOSE)) fmt = _("Prerequisite `%s' is older than target `%s'.\n"); if (fmt) @@ -629,13 +629,13 @@ update_file_1 (file, depth) else if (!noexist && file->is_target && !deps_changed && file->cmds == 0) { must_make = 0; - DBF (DB_EXTRA, + DBF (DB_VERBOSE, _("No commands for `%s' and no prerequisites actually changed.\n")); } if (!must_make) { - if (ISDB (DB_EXTRA)) + if (ISDB (DB_VERBOSE)) { print_spaces (depth); printf (_("No need to remake target `%s'"), file->name); @@ -675,7 +675,7 @@ update_file_1 (file, depth) if (file->command_state != cs_finished) { - DBF (DB_EXTRA, _("Commands of `%s' are being run.\n")); + DBF (DB_VERBOSE, _("Commands of `%s' are being run.\n")); return 0; } -- cgit v1.2.3