profiler.h
Go to the documentation of this file.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 #ifndef PROFCXX_PROFILER_H__
00038 #define PROFCXX_PROFILER_H__ 1
00039
00040 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00041 #include <cstddef>
00042 #else
00043 #include <stddef.h>
00044 #endif
00045
00046
00047
00048
00049
00050 namespace __gnu_profile
00051 {
00052
00053
00054
00055
00056
00057 struct __reentrance_guard
00058 {
00059 static bool
00060 _S_set_in()
00061 {
00062 if (_S_get_in())
00063 return false;
00064 else
00065 {
00066 _S_get_in() = true;
00067 return true;
00068 }
00069 }
00070
00071 static bool&
00072 _S_get_in()
00073 {
00074 static __thread bool _S_inside(false);
00075 return _S_inside;
00076 }
00077
00078 __reentrance_guard() { }
00079 ~__reentrance_guard() { _S_get_in() = false; }
00080 };
00081
00082 #define _GLIBCXX_PROFILE_REENTRANCE_GUARD(__x...) \
00083 { \
00084 if (__gnu_profile::__reentrance_guard::_S_get_in()) \
00085 { \
00086 __gnu_profile::__reentrance_guard __get_out; \
00087 __x; \
00088 } \
00089 }
00090
00091
00092
00093
00094
00095 void __turn_on();
00096 void __turn_off();
00097 bool __is_invalid();
00098 bool __is_on();
00099 bool __is_off();
00100 void __report(void);
00101 void __trace_hashtable_size_resize(const void*, size_t, size_t);
00102 void __trace_hashtable_size_destruct(const void*, size_t, size_t);
00103 void __trace_hashtable_size_construct(const void*, size_t);
00104 void __trace_vector_size_resize(const void*, size_t, size_t);
00105 void __trace_vector_size_destruct(const void*, size_t, size_t);
00106 void __trace_vector_size_construct(const void*, size_t);
00107 void __trace_hash_func_destruct(const void*, size_t, size_t, size_t);
00108 void __trace_hash_func_construct(const void*);
00109 void __trace_vector_to_list_destruct(const void*);
00110 void __trace_vector_to_list_construct(const void*);
00111 void __trace_vector_to_list_insert(const void*, size_t, size_t);
00112 void __trace_vector_to_list_iterate(const void*, size_t);
00113 void __trace_vector_to_list_invalid_operator(const void*);
00114 void __trace_vector_to_list_resize(const void*, size_t, size_t);
00115 void __trace_map_to_unordered_map_construct(const void*);
00116 void __trace_map_to_unordered_map_invalidate(const void*);
00117 void __trace_map_to_unordered_map_insert(const void*, size_t, size_t);
00118 void __trace_map_to_unordered_map_erase(const void*, size_t, size_t);
00119 void __trace_map_to_unordered_map_iterate(const void*, size_t);
00120 void __trace_map_to_unordered_map_find(const void*, size_t);
00121 void __trace_map_to_unordered_map_destruct(const void*);
00122 }
00123
00124
00125 #ifdef _GLIBCXX_PROFILE
00126 #define _GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL
00127 #define _GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE
00128 #define _GLIBCXX_PROFILE_VECTOR_TOO_SMALL
00129 #define _GLIBCXX_PROFILE_VECTOR_TOO_LARGE
00130 #define _GLIBCXX_PROFILE_INEFFICIENT_HASH
00131 #define _GLIBCXX_PROFILE_VECTOR_TO_LIST
00132 #define _GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP
00133 #endif
00134
00135
00136 #ifdef _GLIBCXX_PROFILE
00137 #define __profcxx_report() \
00138 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__report())
00139 #define __profcxx_turn_on() \
00140 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_on())
00141 #define __profcxx_turn_off() \
00142 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_off())
00143 #define __profcxx_is_invalid() \
00144 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_invalid())
00145 #define __profcxx_is_on() \
00146 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_on())
00147 #define __profcxx__is_off() \
00148 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_off())
00149 #else
00150 #define __profcxx_report()
00151 #define __profcxx_turn_on()
00152 #define __profcxx_turn_off()
00153 #define __profcxx_is_invalid()
00154 #define __profcxx_is_on()
00155 #define __profcxx_is_off()
00156 #endif
00157
00158
00159 #if ((defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL) \
00160 && !defined(_NO_GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL)) \
00161 || (defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE) \
00162 && !defined(_NO_GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE)))
00163 #define __profcxx_hashtable_resize(__x...) \
00164 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00165 __gnu_profile::__trace_hashtable_size_resize(__x))
00166 #define __profcxx_hashtable_destruct(__x...) \
00167 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00168 __gnu_profile::__trace_hashtable_size_destruct(__x))
00169 #define __profcxx_hashtable_construct(__x...) \
00170 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00171 __gnu_profile::__trace_hashtable_size_construct(__x))
00172 #else
00173 #define __profcxx_hashtable_resize(__x...)
00174 #define __profcxx_hashtable_destruct(__x...)
00175 #define __profcxx_hashtable_construct(__x...)
00176 #endif
00177
00178
00179 #if ((defined(_GLIBCXX_PROFILE_VECTOR_TOO_SMALL) \
00180 && !defined(_NO_GLIBCXX_PROFILE_VECTOR_TOO_SMALL)) \
00181 || (defined(_GLIBCXX_PROFILE_VECTOR_TOO_LARGE) \
00182 && !defined(_NO_GLIBCXX_PROFILE_VECTOR_TOO_LARGE)))
00183 #define __profcxx_vector_resize(__x...) \
00184 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00185 __gnu_profile::__trace_vector_size_resize(__x))
00186 #define __profcxx_vector_destruct(__x...) \
00187 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00188 __gnu_profile::__trace_vector_size_destruct(__x))
00189 #define __profcxx_vector_construct(__x...) \
00190 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00191 __gnu_profile::__trace_vector_size_construct(__x))
00192 #else
00193 #define __profcxx_vector_resize(__x...)
00194 #define __profcxx_vector_destruct(__x...)
00195 #define __profcxx_vector_construct(__x...)
00196 #endif
00197
00198
00199 #if (defined(_GLIBCXX_PROFILE_INEFFICIENT_HASH) \
00200 && !defined(_NO_GLIBCXX_PROFILE_INEFFICIENT_HASH))
00201 #define __profcxx_hashtable_construct2(__x...) \
00202 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00203 __gnu_profile::__trace_hash_func_construct(__x))
00204 #define __profcxx_hashtable_destruct2(__x...) \
00205 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00206 __gnu_profile::__trace_hash_func_destruct(__x))
00207 #else
00208 #define __profcxx_hashtable_destruct2(__x...)
00209 #define __profcxx_hashtable_construct2(__x...)
00210 #endif
00211
00212
00213 #if (defined(_GLIBCXX_PROFILE_VECTOR_TO_LIST) \
00214 && !defined(_NO_GLIBCXX_PROFILE_VECTOR_TO_LIST))
00215 #define __profcxx_vector_construct2(__x...) \
00216 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00217 __gnu_profile::__trace_vector_to_list_construct(__x))
00218 #define __profcxx_vector_destruct2(__x...) \
00219 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00220 __gnu_profile::__trace_vector_to_list_destruct(__x))
00221 #define __profcxx_vector_insert(__x...) \
00222 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00223 __gnu_profile::__trace_vector_to_list_insert(__x))
00224 #define __profcxx_vector_iterate(__x...) \
00225 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00226 __gnu_profile::__trace_vector_to_list_iterate(__x))
00227 #define __profcxx_vector_invalid_operator(__x...) \
00228 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00229 __gnu_profile::__trace_vector_to_list_invalid_operator(__x))
00230 #define __profcxx_vector_resize2(__x...) \
00231 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00232 __gnu_profile::__trace_vector_to_list_resize(__x))
00233 #else
00234 #define __profcxx_vector_destruct2(__x...)
00235 #define __profcxx_vector_construct2(__x...)
00236 #define __profcxx_vector_insert(__x...)
00237 #define __profcxx_vector_iterate(__x...)
00238 #define __profcxx_vector_invalid_operator(__x...)
00239 #define __profcxx_vector_resize2(__x...)
00240 #endif
00241
00242
00243 #if (defined(_GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP) \
00244 && !defined(_NO_GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP))
00245 #define __profcxx_map_to_unordered_map_construct(__x...) \
00246 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00247 __gnu_profile::__trace_map_to_unordered_map_construct(__x))
00248 #define __profcxx_map_to_unordered_map_destruct(__x...) \
00249 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00250 __gnu_profile::__trace_map_to_unordered_map_destruct(__x))
00251 #define __profcxx_map_to_unordered_map_insert(__x...) \
00252 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00253 __gnu_profile::__trace_map_to_unordered_map_insert(__x))
00254 #define __profcxx_map_to_unordered_map_erase(__x...) \
00255 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00256 __gnu_profile::__trace_map_to_unordered_map_erase(__x))
00257 #define __profcxx_map_to_unordered_map_iterate(__x...) \
00258 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00259 __gnu_profile::__trace_map_to_unordered_map_iterate(__x))
00260 #define __profcxx_map_to_unordered_map_invalidate(__x...) \
00261 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00262 __gnu_profile::__trace_map_to_unordered_map_invalidate(__x))
00263 #define __profcxx_map_to_unordered_map_find(__x...) \
00264 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00265 __gnu_profile::__trace_map_to_unordered_map_find(__x))
00266 #else
00267 #define __profcxx_map_to_unordered_map_construct(__x...) \
00268
00269 #define __profcxx_map_to_unordered_map_destruct(__x...)
00270 #define __profcxx_map_to_unordered_map_insert(__x...)
00271 #define __profcxx_map_to_unordered_map_erase(__x...)
00272 #define __profcxx_map_to_unordered_map_iterate(__x...)
00273 #define __profcxx_map_to_unordered_map_invalidate(__x...)
00274 #define __profcxx_map_to_unordered_map_find(__x...)
00275 #endif
00276
00277
00278 #ifndef _GLIBCXX_PROFILE_NOTHREADS
00279 #define _GLIBCXX_PROFILE_THREADS
00280 #endif
00281
00282
00283 #ifndef _GLIBCXX_PROFILE_TRACE_PATH_ROOT
00284 #define _GLIBCXX_PROFILE_TRACE_PATH_ROOT "libstdcxx-profile"
00285 #endif
00286 #ifndef _GLIBCXX_PROFILE_TRACE_ENV_VAR
00287 #define _GLIBCXX_PROFILE_TRACE_ENV_VAR "GLIBCXX_PROFILE_TRACE_PATH_ROOT"
00288 #endif
00289 #ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR
00290 #define _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR \
00291 "GLIBCXX_PROFILE_MAX_WARN_COUNT"
00292 #endif
00293 #ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT
00294 #define _GLIBCXX_PROFILE_MAX_WARN_COUNT 10
00295 #endif
00296 #ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH
00297 #define _GLIBCXX_PROFILE_MAX_STACK_DEPTH 32
00298 #endif
00299 #ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR
00300 #define _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR \
00301 "GLIBCXX_PROFILE_MAX_STACK_DEPTH"
00302 #endif
00303 #ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC
00304 #define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC 2 << 27
00305 #endif
00306 #ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR
00307 #define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR \
00308 "GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC"
00309 #endif
00310
00311
00312 #include "profile/impl/profiler_hash_func.h"
00313 #include "profile/impl/profiler_hashtable_size.h"
00314 #include "profile/impl/profiler_map_to_unordered_map.h"
00315 #include "profile/impl/profiler_vector_size.h"
00316 #include "profile/impl/profiler_vector_to_list.h"
00317
00318 #endif // PROFCXX_PROFILER_H__