xref: /netbsd-src/external/gpl3/binutils.old/dist/gprofng/src/debug.h (revision c42dbd0ed2e61fe6eda8590caa852ccf34719964)
1*c42dbd0eSchristos /* Copyright (C) 2021 Free Software Foundation, Inc.
2*c42dbd0eSchristos    Contributed by Oracle.
3*c42dbd0eSchristos 
4*c42dbd0eSchristos    This file is part of GNU Binutils.
5*c42dbd0eSchristos 
6*c42dbd0eSchristos    This program is free software; you can redistribute it and/or modify
7*c42dbd0eSchristos    it under the terms of the GNU General Public License as published by
8*c42dbd0eSchristos    the Free Software Foundation; either version 3, or (at your option)
9*c42dbd0eSchristos    any later version.
10*c42dbd0eSchristos 
11*c42dbd0eSchristos    This program is distributed in the hope that it will be useful,
12*c42dbd0eSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*c42dbd0eSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*c42dbd0eSchristos    GNU General Public License for more details.
15*c42dbd0eSchristos 
16*c42dbd0eSchristos    You should have received a copy of the GNU General Public License
17*c42dbd0eSchristos    along with this program; if not, write to the Free Software
18*c42dbd0eSchristos    Foundation, 51 Franklin Street - Fifth Floor, Boston,
19*c42dbd0eSchristos    MA 02110-1301, USA.  */
20*c42dbd0eSchristos 
21*c42dbd0eSchristos #ifndef _PERFAN_DEBUG_H
22*c42dbd0eSchristos #define _PERFAN_DEBUG_H
23*c42dbd0eSchristos 
24*c42dbd0eSchristos extern unsigned int mpmt_debug_opt;
25*c42dbd0eSchristos // To set mpmt_debug_opt use:
26*c42dbd0eSchristos //   MPMT_DEBUG=4095 ; export MPMT_DEBUG
27*c42dbd0eSchristos #define DEBUG_FLAG          (mpmt_debug_opt & 1)
28*c42dbd0eSchristos #define DUMP_ELF_SEC        (mpmt_debug_opt & 2)
29*c42dbd0eSchristos #define DUMP_ELF_SYM        (mpmt_debug_opt & 4)
30*c42dbd0eSchristos #define DUMP_RELA_SEC       (mpmt_debug_opt & 8)
31*c42dbd0eSchristos #define DUMP_ELF_RELOC      DUMP_RELA_SEC
32*c42dbd0eSchristos #define DUMP_DWARFLIB       (mpmt_debug_opt & 16)
33*c42dbd0eSchristos #define DUMP_DWR_LINE_REGS  (mpmt_debug_opt & 32)
34*c42dbd0eSchristos #define DUMP_USER_LABELS    (mpmt_debug_opt & 64)
35*c42dbd0eSchristos #define DEBUG_MAPS          (mpmt_debug_opt & 128)
36*c42dbd0eSchristos #define DEBUG_DBE_FILE      (mpmt_debug_opt & 256)
37*c42dbd0eSchristos #define DEBUG_DATA_WINDOW   (mpmt_debug_opt & 512)
38*c42dbd0eSchristos #define DEBUG_STABS         (mpmt_debug_opt & 1024)
39*c42dbd0eSchristos #define DEBUG_DATAOBJ       (mpmt_debug_opt & 2048)
40*c42dbd0eSchristos #define DEBUG_LOADOBJ       (mpmt_debug_opt & 4096)
41*c42dbd0eSchristos #define DEBUG_SAXPARSER     (mpmt_debug_opt & 8192)
42*c42dbd0eSchristos #define DUMP_JAVA_CLASS     (mpmt_debug_opt & 16384)
43*c42dbd0eSchristos #define DEBUG_COMPARISON    (mpmt_debug_opt & 32768)
44*c42dbd0eSchristos #define DEBUG_READ_AR       (mpmt_debug_opt & 65536)
45*c42dbd0eSchristos #define DEBUG_ERR_MSG       (mpmt_debug_opt & 131072)
46*c42dbd0eSchristos #define DUMP_JCLASS_READER  (mpmt_debug_opt & 262144)
47*c42dbd0eSchristos #define DEBUG_DBE           (mpmt_debug_opt & 524288)
48*c42dbd0eSchristos #define DEBUG_ARCHIVE       (mpmt_debug_opt & 1048576)
49*c42dbd0eSchristos #define DEBUG_IO            (mpmt_debug_opt & 2097152)
50*c42dbd0eSchristos #define DUMP_DYN_FILE       (mpmt_debug_opt & 4194304)
51*c42dbd0eSchristos #define DUMP_JAR_FILE       (mpmt_debug_opt & 8388608)
52*c42dbd0eSchristos #define DUMP_CALL_STACK     (mpmt_debug_opt & 16777216)
53*c42dbd0eSchristos #define DEBUG_THREADS       (mpmt_debug_opt & 33554432)
54*c42dbd0eSchristos #define DBE_USE_MMAP        (mpmt_debug_opt & 67108864)
55*c42dbd0eSchristos 
56*c42dbd0eSchristos #ifdef DEBUG
57*c42dbd0eSchristos 
58*c42dbd0eSchristos // Turn on assertion checking whenever debugging
59*c42dbd0eSchristos #define ASSERTS 1
60*c42dbd0eSchristos 
61*c42dbd0eSchristos // debug macro - provides a clean way of inserting debugging code without
62*c42dbd0eSchristos //  having the distracting #ifdef DEBUG ... #else ... #endif directives
63*c42dbd0eSchristos //  interspersed throughout the code.  It also provides an easy way
64*c42dbd0eSchristos //  to turn them off with no loss of efficiency.  It is not limited
65*c42dbd0eSchristos //  to printf() commands; any code may be inserted.  Variables
66*c42dbd0eSchristos //  needed only by the debugging code can be declared inside a
67*c42dbd0eSchristos //  debug { ... } statement.
68*c42dbd0eSchristos //
69*c42dbd0eSchristos // usage:
70*c42dbd0eSchristos //      debug <statement>
71*c42dbd0eSchristos //  or,	debug { <statements> }
72*c42dbd0eSchristos // If DEBUG is on, map "DEBUG_CODE" to nothing!
73*c42dbd0eSchristos // This results in the <statement> being executed normally
74*c42dbd0eSchristos 
75*c42dbd0eSchristos #define DEBUG_CODE
76*c42dbd0eSchristos 
77*c42dbd0eSchristos #else
78*c42dbd0eSchristos // If DEBUG is off, map "DEBUG_CODE" to something harmless.
79*c42dbd0eSchristos // The clever hack used here is to use a conditional with a
80*c42dbd0eSchristos // constant condition, which is optimized out by the compiler,
81*c42dbd0eSchristos // so that <statement> is not present in the compiled code!
82*c42dbd0eSchristos 
83*c42dbd0eSchristos #define DEBUG_CODE if (0)
84*c42dbd0eSchristos 
85*c42dbd0eSchristos #endif /*DEBUG*/
86*c42dbd0eSchristos 
87*c42dbd0eSchristos #define Dprintf(x, ...) DEBUG_CODE if(x) fprintf(stderr, __VA_ARGS__)
88*c42dbd0eSchristos 
89*c42dbd0eSchristos #endif /* ! _DEBUG_H */
90