00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #ifdef _KEEP_RCS_ID
00066 #define ipo_tlog_utils_CXX "ipo_tlog_utils.cxx"
00067 static char *rcs_id = ipo_tlog_utils_CXX"$Revision: 1.4 $";
00068 #endif //-*-c++-
00069 #include <stdarg.h>
00070 #include <stdio.h>
00071 #include <strings.h>
00072 #include <time.h>
00073
00074 #ifndef USE_STANDARD_TYPES
00075 #define USE_STANDARD_TYPES
00076 #endif
00077 #include "defs.h"
00078 #include "errors.h"
00079 #include "tracing.h"
00080 #include "srcpos.h"
00081 #include "tlog.h"
00082 #include "ipo_tlog_utils.h"
00083
00084 const INT32 MAX_WARN_LEN = 1024;
00085
00086
00087
00088
00089
00090
00091 static void Ipa_Inline_tlog2( const char *, INT64, char * );
00092
00093 static const char *tlog_phase = NULL;
00094
00095 static BOOL
00096 Ipa_tlog_trace( void )
00097 {
00098 return Get_Trace ( TP_PTRACE1, TP_PTRACE1_IPA );
00099 }
00100
00101 static BOOL
00102 Inline_tlog_trace( void )
00103 {
00104 return Get_Trace ( TP_PTRACE1, TP_PTRACE1_INL );
00105 }
00106
00107
00108
00109 static void
00110 Ipa_Inline_tlog( const char *keyword, INT64 srcpos, const char *fmt,va_list vp)
00111 {
00112 char msg_buf[MAX_WARN_LEN];
00113 INT32 len;
00114
00115 vsprintf(msg_buf, fmt, vp);
00116 len = strlen(msg_buf);
00117
00118 if (len >= MAX_WARN_LEN) {
00119 fprintf(stderr, "Ipa_tlog message buffer too small.");
00120 }
00121
00122 Ipa_Inline_tlog2( keyword, srcpos, msg_buf );
00123 }
00124
00125 static void Ipa_Inline_tlog2(const char *keyword, INT64 srcpos, char *msg )
00126 {
00127
00128 Generate_Tlog( tlog_phase, keyword, (SRCPOS)srcpos, keyword, msg, "","" );
00129 }
00130
00131
00132
00133
00134
00135 extern "C" void
00136 Set_ipa_tlog_phase(const INT32 i)
00137 {
00138 if (i==PHASE_IPA)
00139 tlog_phase = "IPA";
00140 else
00141 tlog_phase = "INLINER";
00142 }
00143
00144 #ifdef KEY
00145 extern "C" PHASE_NAME
00146 Get_ipa_tlog_phase(void)
00147 {
00148 if (!tlog_phase)
00149 return INVALID;
00150 if (!strcmp(tlog_phase, "IPA"))
00151 return PHASE_IPA;
00152 return PHASE_INLINER;
00153 }
00154 #endif
00155
00156 extern "C" void
00157 Ipa_tlog(const char *keyword, SRCPOS srcpos, const char *fmt, ...)
00158 {
00159 va_list ap;
00160 va_start(ap, fmt);
00161
00162 if ( ! Ipa_tlog_trace() ) {
00163 return;
00164 }
00165 Ipa_Inline_tlog(keyword, srcpos, fmt, ap);
00166 va_end(ap);
00167 }
00168
00169 extern "C" void
00170 Inline_tlog(const char *keyword, SRCPOS srcpos, const char *fmt, ...)
00171 {
00172 va_list ap;
00173 va_start(ap, fmt);
00174
00175 if ( ! Inline_tlog_trace() ) {
00176 return;
00177 }
00178 Ipa_Inline_tlog(keyword, srcpos, fmt, ap);
00179 va_end(ap);
00180 }
00181