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