00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2 of the GNU General Public License as 00011 published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with this program; if not, write the Free Software Foundation, Inc., 59 00026 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00027 00028 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00029 Mountain View, CA 94043, or: 00030 00031 http://www.sgi.com 00032 00033 For further information regarding this notice, see: 00034 00035 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00036 00037 */ 00038 00039 00040 /* ==================================================================== 00041 * ==================================================================== 00042 * 00043 * Module: ipl_tlog.cxx 00044 * $Revision: 1.1.1.1 $ 00045 * $Date: 2005/10/21 19:00:00 $ 00046 * $Author: marcel $ 00047 * $Source: /proj/osprey/CVS/open64/osprey1.0/ipa/local/ipl_tlog.cxx,v $ 00048 * 00049 * Description: Defines tlog utilities for IPL, originated from OPT 00050 * 00051 * ==================================================================== 00052 * ==================================================================== 00053 */ 00054 // ==================================================================== 00055 // Usage: -Wi,-tt1:18 -keep : generates file.tlog for IPL 00056 // ==================================================================== 00057 #include <stdarg.h> 00058 #include <stdio.h> 00059 #include <strings.h> 00060 #include <time.h> 00061 00062 #ifndef USE_STANDARD_TYPES 00063 #define USE_STANDARD_TYPES 00064 #endif 00065 #include "defs.h" 00066 #include "errors.h" 00067 #include "tracing.h" 00068 #include "srcpos.h" 00069 #include "tlog.h" 00070 #include "ipl_tlog.h" 00071 const INT32 MAX_WARN_LEN = 1024; 00072 00073 static const char* tlog_phase = "IPL"; 00074 00075 static BOOL 00076 Ipl_tlog_trace( void ) 00077 { 00078 return Get_Trace ( TP_PTRACE1, TP_IPL ); 00079 } 00080 00081 static 00082 void Ipl_tlog2(const char *keyword, INT64 srcpos, const char *msg ) 00083 { 00084 // use the keyword as both the transformation name and keyword 00085 Generate_Tlog( tlog_phase, keyword, (SRCPOS)srcpos, keyword, msg, "","" ); 00086 } 00087 00088 static void 00089 Ipl_tlog( const char *keyword, INT64 srcpos, const char *fmt, va_list vp) 00090 { 00091 char msg_buf[MAX_WARN_LEN]; 00092 INT32 len; 00093 vsprintf(msg_buf, fmt, vp); // if msg is too long, it might overrun the buf 00094 len = strlen(msg_buf); 00095 // FmtAssert doesn't work here! 00096 if (len >= MAX_WARN_LEN) { 00097 fprintf(stderr, "Ipa_tlog message buffer too small."); 00098 } 00099 00100 Ipl_tlog2( keyword, srcpos, msg_buf ); 00101 } 00102 00103 00104 00105 00106 // ==================================================================== 00107 // TLOG external interface for reporting optimizations 00108 // ==================================================================== 00109 extern "C" void 00110 Ipl_record_tlog(const char *keyword, SRCPOS srcpos, const char *fmt, ...) 00111 { 00112 va_list ap; 00113 va_start(ap, fmt); 00114 if ( ! Ipl_tlog_trace() ) { 00115 return; 00116 } 00117 Ipl_tlog(keyword, srcpos, fmt, ap); 00118 va_end(ap); 00119 }
1.5.6