1 /* Debugging macros and interface.
2   Copyright (c) 2005, 2011 Rocky Bernstein <rocky@gnu.org>
3 
4 GNU Make is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8 
9 GNU Make is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with GNU Make; see the file COPYING.  If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.  */
18 
19 #include "makeint.h"
20 #include "make.h"
21 #include "debug.h"
22 #include "print.h"
23 
24 debug_level_mask_t debug_dummy_level_mask;
25 debug_enter_debugger_t debug_dummy_enter_debugger_mask;
26 
27 int debug_flag = 0;
28 
29 /*! If true, enter the debugger before updating goal. */
30 bool b_debugger_goal = false;
31 
32 stringlist_t *db_flags;
33 
34 /** Toggle -d on receipt of SIGUSR1.  */
35 #ifdef SIGUSR1
36 RETSIGTYPE
debug_signal_handler(int sig)37 debug_signal_handler (int sig)
38 {
39   UNUSED_ARGUMENT(sig);
40   db_level = db_level ? DB_NONE : DB_BASIC;
41 }
42 #endif
43 
44 /*! Set the global db_level mask based on the command option list
45   db_flags.
46  */
47 void
decode_debug_flags(int b_debug_flag,stringlist_t * ppsz_db_flags)48 decode_debug_flags (int b_debug_flag, stringlist_t *ppsz_db_flags)
49 {
50   const char **pp;
51 
52   if (b_debug_flag)
53     db_level = DB_ALL;
54 
55   if (!ppsz_db_flags)
56     return;
57 
58   for (pp=ppsz_db_flags->list; *pp; ++pp)
59     {
60       const char *p = *pp;
61 
62       while (1)
63         {
64           switch (tolower (p[0]))
65             {
66             case 'a':
67               db_level |= DB_ALL;
68               break;
69             case 'b':
70               db_level |= DB_BASIC;
71               break;
72             case 'i':
73               db_level |= DB_BASIC | DB_IMPLICIT;
74               break;
75             case 'j':
76               db_level |= DB_JOBS;
77               break;
78             case 'm':
79               db_level |= DB_BASIC | DB_MAKEFILES;
80               break;
81             case 'r':
82               db_level |= DB_BASIC | DB_READ_MAKEFILES;
83               break;
84             case 'v':
85               db_level |= DB_BASIC | DB_VERBOSE;
86               break;
87             default:
88               OS ( fatal, NILF, _("unknown debug level specification `%s'"), p);
89             }
90 
91           while (*(++p) != '\0')
92             if (*p == ',' || *p == ' ')
93               break;
94 
95           if (*p == '\0')
96             break;
97 
98           ++p;
99         }
100     }
101 }
102 
103 /*
104  * Local variables:
105  * eval: (c-set-style "gnu")
106  * indent-tabs-mode: nil
107  * End:
108  */
109