debug.C

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 // $Id: Object-xcoff.C,v 1.32 2008/09/20 03:56:10 jaw Exp $
00032 
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include <stdarg.h>
00036 
00037 #include "debug.h"
00038 
00039 int sym_debug_create = 0;
00040 int sym_debug_parsing = 0;
00041 int sym_debug_aggregate = 0;
00042 int sym_debug_object = 0;
00043 int sym_debug_types = 0;
00044 int sym_debug_translate = 0;
00045 int sym_debug_rewrite = 0;
00046 
00047 #if defined(_MSC_VER)
00048 #pragma warning(push)
00049 #pragma warning(disable:4996) 
00050 #endif
00051 
00052 bool init_debug_symtabAPI() {
00053     static bool initialized = false;
00054     if (initialized) return true;
00055     initialized = true;
00056     if (getenv("SYMTAB_DEBUG_PARSING")) {
00057         sym_debug_parsing = 1;
00058     }
00059     if (getenv("SYMTAB_DEBUG_AGG") ||
00060         getenv("SYMTAB_DEBUG_AGGREGATE") ||
00061         getenv("SYMTAB_DEBUG_AGGREGATES")) {
00062         sym_debug_aggregate = 1;
00063     }
00064     if (getenv("SYMTAB_DEBUG_CREATE")) {
00065         sym_debug_create = 1;
00066     }
00067     if (getenv("SYMTAB_DEBUG_OBJECT")) {
00068         sym_debug_object = 1;
00069     }
00070     if (getenv("SYMTAB_DEBUG_TYPES")) {
00071         sym_debug_types = 1;
00072     }
00073     if (getenv("SYMTAB_DEBUG_REWRITE") ||
00074     getenv("SYMTAB_DEBUG_REWRITER")) {
00075         sym_debug_rewrite = 1;
00076     }
00077 
00078     return true;
00079 }
00080 
00081 int parsing_printf(const char *format, ...)
00082 {
00083   if (!sym_debug_parsing) return 0;
00084   if (NULL == format) return -1;
00085 
00086   va_list va;
00087   va_start(va, format);
00088   int ret = vfprintf(stderr, format, va);
00089   va_end(va);
00090 
00091   return ret;
00092 }
00093 
00094 int create_printf(const char *format, ...)
00095 {
00096   if (!sym_debug_create) return 0;
00097   if (NULL == format) return -1;
00098 
00099   va_list va;
00100   va_start(va, format);
00101   int ret = vfprintf(stderr, format, va);
00102   va_end(va);
00103 
00104   return ret;
00105 }
00106 
00107 int aggregate_printf(const char *format, ...)
00108 {
00109   if (!sym_debug_parsing) return 0;
00110   if (NULL == format) return -1;
00111 
00112   va_list va;
00113   va_start(va, format);
00114   int ret = vfprintf(stderr, format, va);
00115   va_end(va);
00116 
00117   return ret;
00118 }
00119 
00120 int object_printf(const char *format, ...)
00121 {
00122   if (!sym_debug_object) return 0;
00123   if (NULL == format) return -1;
00124 
00125   va_list va;
00126   va_start(va, format);
00127   int ret = vfprintf(stderr, format, va);
00128   va_end(va);
00129 
00130   return ret;
00131 }
00132 
00133 int types_printf(const char *format, ...)
00134 {
00135   if (!sym_debug_types) return 0;
00136   if (NULL == format) return -1;
00137 
00138   va_list va;
00139   va_start(va, format);
00140   int ret = vfprintf(stderr, format, va);
00141   va_end(va);
00142 
00143   return ret;
00144 }
00145 
00146 int rewrite_printf(const char *format, ...)
00147 {
00148   init_debug_symtabAPI();
00149   if (!sym_debug_rewrite) return 0;
00150   if (NULL == format) return -1;
00151 
00152   va_list va;
00153   va_start(va, format);
00154   int ret = vfprintf(stderr, format, va);
00155   va_end(va);
00156 
00157   return ret;
00158 }
00159 
00160 
00161 #if defined(_MSC_VER)
00162 #pragma warning(pop)    
00163 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1