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