src/java.desktop/share/native/libfreetype/src/base/ftdebug.c
changeset 54876 da3834261f0c
parent 49234 3375a8039fde
equal deleted inserted replaced
54875:bcfedddcf4ce 54876:da3834261f0c
     1 /***************************************************************************/
     1 /****************************************************************************
     2 /*                                                                         */
     2  *
     3 /*  ftdebug.c                                                              */
     3  * ftdebug.c
     4 /*                                                                         */
     4  *
     5 /*    Debugging and logging component (body).                              */
     5  *   Debugging and logging component (body).
     6 /*                                                                         */
     6  *
     7 /*  Copyright 1996-2018 by                                                 */
     7  * Copyright (C) 1996-2019 by
     8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
     8  * David Turner, Robert Wilhelm, and Werner Lemberg.
     9 /*                                                                         */
     9  *
    10 /*  This file is part of the FreeType project, and may only be used,       */
    10  * This file is part of the FreeType project, and may only be used,
    11 /*  modified, and distributed under the terms of the FreeType project      */
    11  * modified, and distributed under the terms of the FreeType project
    12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
    12  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    13 /*  this file you indicate that you have read the license and              */
    13  * this file you indicate that you have read the license and
    14 /*  understand and accept it fully.                                        */
    14  * understand and accept it fully.
    15 /*                                                                         */
    15  *
    16 /***************************************************************************/
    16  */
    17 
    17 
    18 
    18 
    19   /*************************************************************************/
    19   /**************************************************************************
    20   /*                                                                       */
    20    *
    21   /* This component contains various macros and functions used to ease the */
    21    * This component contains various macros and functions used to ease the
    22   /* debugging of the FreeType engine.  Its main purpose is in assertion   */
    22    * debugging of the FreeType engine.  Its main purpose is in assertion
    23   /* checking, tracing, and error detection.                               */
    23    * checking, tracing, and error detection.
    24   /*                                                                       */
    24    *
    25   /* There are now three debugging modes:                                  */
    25    * There are now three debugging modes:
    26   /*                                                                       */
    26    *
    27   /* - trace mode                                                          */
    27    * - trace mode
    28   /*                                                                       */
    28    *
    29   /*   Error and trace messages are sent to the log file (which can be the */
    29    *   Error and trace messages are sent to the log file (which can be the
    30   /*   standard error output).                                             */
    30    *   standard error output).
    31   /*                                                                       */
    31    *
    32   /* - error mode                                                          */
    32    * - error mode
    33   /*                                                                       */
    33    *
    34   /*   Only error messages are generated.                                  */
    34    *   Only error messages are generated.
    35   /*                                                                       */
    35    *
    36   /* - release mode:                                                       */
    36    * - release mode:
    37   /*                                                                       */
    37    *
    38   /*   No error message is sent or generated.  The code is free from any   */
    38    *   No error message is sent or generated.  The code is free from any
    39   /*   debugging parts.                                                    */
    39    *   debugging parts.
    40   /*                                                                       */
    40    *
    41   /*************************************************************************/
    41    */
    42 
    42 
    43 
    43 
    44 #include <ft2build.h>
    44 #include <ft2build.h>
    45 #include FT_FREETYPE_H
    45 #include FT_FREETYPE_H
    46 #include FT_INTERNAL_DEBUG_H
    46 #include FT_INTERNAL_DEBUG_H
    85   FT_BASE_DEF( int )
    85   FT_BASE_DEF( int )
    86   FT_Throw( FT_Error     error,
    86   FT_Throw( FT_Error     error,
    87             int          line,
    87             int          line,
    88             const char*  file )
    88             const char*  file )
    89   {
    89   {
       
    90 #if 0
       
    91     /* activating the code in this block makes FreeType very chatty */
       
    92     fprintf( stderr,
       
    93              "%s:%d: error 0x%02x: %s\n",
       
    94              file,
       
    95              line,
       
    96              error,
       
    97              FT_Error_String( error ) );
       
    98 #else
    90     FT_UNUSED( error );
    99     FT_UNUSED( error );
    91     FT_UNUSED( line );
   100     FT_UNUSED( line );
    92     FT_UNUSED( file );
   101     FT_UNUSED( file );
       
   102 #endif
    93 
   103 
    94     return 0;
   104     return 0;
    95   }
   105   }
    96 
   106 
    97 #endif /* FT_DEBUG_LEVEL_ERROR */
   107 #endif /* FT_DEBUG_LEVEL_ERROR */
    98 
   108 
    99 
   109 
   100 
   110 
   101 #ifdef FT_DEBUG_LEVEL_TRACE
   111 #ifdef FT_DEBUG_LEVEL_TRACE
   102 
   112 
   103   /* array of trace levels, initialized to 0 */
   113   /* array of trace levels, initialized to 0; */
   104   int  ft_trace_levels[trace_count];
   114   /* this gets adjusted at run-time           */
   105 
   115   static int  ft_trace_levels_enabled[trace_count];
       
   116 
       
   117   /* array of trace levels, always initialized to 0 */
       
   118   static int  ft_trace_levels_disabled[trace_count];
       
   119 
       
   120   /* a pointer to either `ft_trace_levels_enabled' */
       
   121   /* or `ft_trace_levels_disabled'                 */
       
   122   int*  ft_trace_levels;
   106 
   123 
   107   /* define array of trace toggle names */
   124   /* define array of trace toggle names */
   108 #define FT_TRACE_DEF( x )  #x ,
   125 #define FT_TRACE_DEF( x )  #x ,
   109 
   126 
   110   static const char*  ft_trace_toggles[trace_count + 1] =
   127   static const char*  ft_trace_toggles[trace_count + 1] =
   138     else
   155     else
   139       return NULL;
   156       return NULL;
   140   }
   157   }
   141 
   158 
   142 
   159 
   143   /*************************************************************************/
   160   /* documentation is in ftdebug.h */
   144   /*                                                                       */
   161 
   145   /* Initialize the tracing sub-system.  This is done by retrieving the    */
   162   FT_BASE_DEF( void )
   146   /* value of the `FT2_DEBUG' environment variable.  It must be a list of  */
   163   FT_Trace_Disable( void )
   147   /* toggles, separated by spaces, `;', or `,'.  Example:                  */
   164   {
   148   /*                                                                       */
   165     ft_trace_levels = ft_trace_levels_disabled;
   149   /*    export FT2_DEBUG="any:3 memory:7 stream:5"                         */
   166   }
   150   /*                                                                       */
   167 
   151   /* This requests that all levels be set to 3, except the trace level for */
   168 
   152   /* the memory and stream components which are set to 7 and 5,            */
   169   /* documentation is in ftdebug.h */
   153   /* respectively.                                                         */
   170 
   154   /*                                                                       */
   171   FT_BASE_DEF( void )
   155   /* See the file `include/freetype/internal/fttrace.h' for details of     */
   172   FT_Trace_Enable( void )
   156   /* the available toggle names.                                           */
   173   {
   157   /*                                                                       */
   174     ft_trace_levels = ft_trace_levels_enabled;
   158   /* The level must be between 0 and 7; 0 means quiet (except for serious  */
   175   }
   159   /* runtime errors), and 7 means _very_ verbose.                          */
   176 
   160   /*                                                                       */
   177 
       
   178   /**************************************************************************
       
   179    *
       
   180    * Initialize the tracing sub-system.  This is done by retrieving the
       
   181    * value of the `FT2_DEBUG' environment variable.  It must be a list of
       
   182    * toggles, separated by spaces, `;', or `,'.  Example:
       
   183    *
       
   184    *   export FT2_DEBUG="any:3 memory:7 stream:5"
       
   185    *
       
   186    * This requests that all levels be set to 3, except the trace level for
       
   187    * the memory and stream components which are set to 7 and 5,
       
   188    * respectively.
       
   189    *
       
   190    * See the file `include/freetype/internal/fttrace.h' for details of
       
   191    * the available toggle names.
       
   192    *
       
   193    * The level must be between 0 and 7; 0 means quiet (except for serious
       
   194    * runtime errors), and 7 means _very_ verbose.
       
   195    */
   161   FT_BASE_DEF( void )
   196   FT_BASE_DEF( void )
   162   ft_debug_init( void )
   197   ft_debug_init( void )
   163   {
   198   {
   164     const char*  ft2_debug = ft_getenv( "FT2_DEBUG" );
   199     const char*  ft2_debug = ft_getenv( "FT2_DEBUG" );
   165 
   200 
   221           {
   256           {
   222             if ( found == trace_any )
   257             if ( found == trace_any )
   223             {
   258             {
   224               /* special case for `any' */
   259               /* special case for `any' */
   225               for ( n = 0; n < trace_count; n++ )
   260               for ( n = 0; n < trace_count; n++ )
   226                 ft_trace_levels[n] = level;
   261                 ft_trace_levels_enabled[n] = level;
   227             }
   262             }
   228             else
   263             else
   229               ft_trace_levels[found] = level;
   264               ft_trace_levels_enabled[found] = level;
   230           }
   265           }
   231         }
   266         }
   232       }
   267       }
   233     }
   268     }
       
   269 
       
   270     ft_trace_levels = ft_trace_levels_enabled;
   234   }
   271   }
   235 
   272 
   236 
   273 
   237 #else  /* !FT_DEBUG_LEVEL_TRACE */
   274 #else  /* !FT_DEBUG_LEVEL_TRACE */
   238 
   275 
   258 
   295 
   259     return NULL;
   296     return NULL;
   260   }
   297   }
   261 
   298 
   262 
   299 
       
   300   FT_BASE_DEF( void )
       
   301   FT_Trace_Disable( void )
       
   302   {
       
   303     /* nothing */
       
   304   }
       
   305 
       
   306 
       
   307   /* documentation is in ftdebug.h */
       
   308 
       
   309   FT_BASE_DEF( void )
       
   310   FT_Trace_Enable( void )
       
   311   {
       
   312     /* nothing */
       
   313   }
       
   314 
       
   315 
   263 #endif /* !FT_DEBUG_LEVEL_TRACE */
   316 #endif /* !FT_DEBUG_LEVEL_TRACE */
   264 
   317 
   265 
   318 
   266 /* END */
   319 /* END */