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 _GLIBCXX_PROFILE_PROFILER_H
00038 #define _GLIBCXX_PROFILE_PROFILER_H 1
00039
00040 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00041 #include <cstddef>
00042 #else
00043 #include <stddef.h>
00044 #endif
00045
00046
00047 #define _GLIBCXX_PROFILE_DEFINE_DATA(__type, __name, __initial_value...) \
00048 inline __type& __get_##__name() { \
00049 static __type __name(__initial_value); \
00050 return __name; \
00051 }
00052 #define _GLIBCXX_PROFILE_DATA(__name) \
00053 __get_##__name()
00054
00055 namespace __gnu_profile
00056 {
00057
00058
00059
00060
00061
00062 struct __reentrance_guard
00063 {
00064 static bool
00065 __get_in()
00066 {
00067 if (__inside() == true)
00068 return false;
00069 else
00070 {
00071 __inside() = true;
00072 return true;
00073 }
00074 }
00075
00076 static bool&
00077 __inside()
00078 {
00079 static __thread bool _S_inside(false);
00080 return _S_inside;
00081 }
00082
00083 __reentrance_guard() { }
00084 ~__reentrance_guard() { __inside() = false; }
00085 };
00086
00087 #define _GLIBCXX_PROFILE_REENTRANCE_GUARD(__x...) \
00088 { \
00089 if (__gnu_profile::__reentrance_guard::__get_in()) \
00090 { \
00091 __gnu_profile::__reentrance_guard __get_out; \
00092 __x; \
00093 } \
00094 }
00095
00096
00097
00098
00099 bool __turn_on();
00100 bool __turn_off();
00101 bool __is_invalid();
00102 bool __is_on();
00103 bool __is_off();
00104 void __report(void);
00105 void __trace_hashtable_size_resize(const void*, size_t, size_t);
00106 void __trace_hashtable_size_destruct(const void*, size_t, size_t);
00107 void __trace_hashtable_size_construct(const void*, size_t);
00108 void __trace_vector_size_resize(const void*, size_t, size_t);
00109 void __trace_vector_size_destruct(const void*, size_t, size_t);
00110 void __trace_vector_size_construct(const void*, size_t);
00111 void __trace_hash_func_destruct(const void*, size_t, size_t, size_t);
00112 void __trace_hash_func_construct(const void*);
00113 void __trace_vector_to_list_destruct(const void*);
00114 void __trace_vector_to_list_construct(const void*);
00115 void __trace_vector_to_list_insert(const void*, size_t, size_t);
00116 void __trace_vector_to_list_iterate(const void*, size_t);
00117 void __trace_vector_to_list_invalid_operator(const void*);
00118 void __trace_vector_to_list_resize(const void*, size_t, size_t);
00119 void __trace_vector_to_list_find(const void*, size_t);
00120
00121 void __trace_list_to_slist_destruct(const void*);
00122 void __trace_list_to_slist_construct(const void*);
00123 void __trace_list_to_slist_rewind(const void*);
00124 void __trace_list_to_slist_operation(const void*);
00125
00126 void __trace_list_to_vector_destruct(const void*);
00127 void __trace_list_to_vector_construct(const void*);
00128 void __trace_list_to_vector_insert(const void*, size_t, size_t);
00129 void __trace_list_to_vector_iterate(const void*, size_t);
00130 void __trace_list_to_vector_invalid_operator(const void*);
00131 void __trace_list_to_vector_resize(const void*, size_t, size_t);
00132
00133 void __trace_list_to_set_destruct(const void*);
00134 void __trace_list_to_set_construct(const void*);
00135 void __trace_list_to_set_insert(const void*, size_t, size_t);
00136 void __trace_list_to_set_iterate(const void*, size_t);
00137 void __trace_list_to_set_invalid_operator(const void*);
00138 void __trace_list_to_set_find(const void*, size_t);
00139
00140 void __trace_map_to_unordered_map_construct(const void*);
00141 void __trace_map_to_unordered_map_invalidate(const void*);
00142 void __trace_map_to_unordered_map_insert(const void*, size_t, size_t);
00143 void __trace_map_to_unordered_map_erase(const void*, size_t, size_t);
00144 void __trace_map_to_unordered_map_iterate(const void*, size_t);
00145 void __trace_map_to_unordered_map_find(const void*, size_t);
00146 void __trace_map_to_unordered_map_destruct(const void*);
00147 }
00148
00149
00150 #ifdef _GLIBCXX_PROFILE
00151 #ifndef _GLIBCXX_PROFILE_NO_HASHTABLE_TOO_SMALL
00152 #define _GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL
00153 #endif
00154 #ifndef _GLIBCXX_PROFILE_NO_HASHTABLE_TOO_LARGE
00155 #define _GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE
00156 #endif
00157 #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TOO_SMALL
00158 #define _GLIBCXX_PROFILE_VECTOR_TOO_SMALL
00159 #endif
00160 #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TOO_LARGE
00161 #define _GLIBCXX_PROFILE_VECTOR_TOO_LARGE
00162 #endif
00163 #ifndef _GLIBCXX_PROFILE_NO_INEFFICIENT_HASH
00164 #define _GLIBCXX_PROFILE_INEFFICIENT_HASH
00165 #endif
00166 #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TO_LIST
00167 #define _GLIBCXX_PROFILE_VECTOR_TO_LIST
00168 #endif
00169 #ifndef _GLIBCXX_PROFILE_NO_LIST_TO_SLIST
00170 #define _GLIBCXX_PROFILE_LIST_TO_SLIST
00171 #endif
00172 #ifndef _GLIBCXX_PROFILE_NO_LIST_TO_VECTOR
00173 #define _GLIBCXX_PROFILE_LIST_TO_VECTOR
00174 #endif
00175 #ifndef _GLIBCXX_PROFILE_NO_MAP_TO_UNORDERED_MAP
00176 #define _GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP
00177 #endif
00178 #endif
00179
00180
00181 #ifdef _GLIBCXX_PROFILE
00182 #define __profcxx_report() \
00183 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__report())
00184 #define __profcxx_turn_on() \
00185 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_on())
00186 #define __profcxx_turn_off() \
00187 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_off())
00188 #define __profcxx_is_invalid() \
00189 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_invalid())
00190 #define __profcxx_is_on() \
00191 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_on())
00192 #define __profcxx__is_off() \
00193 _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_off())
00194 #else
00195 #define __profcxx_report()
00196 #define __profcxx_turn_on()
00197 #define __profcxx_turn_off()
00198 #define __profcxx_is_invalid()
00199 #define __profcxx_is_on()
00200 #define __profcxx_is_off()
00201 #endif
00202
00203
00204 #if (defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL) \
00205 || defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE))
00206 #define __profcxx_hashtable_resize(__x...) \
00207 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00208 __gnu_profile::__trace_hashtable_size_resize(__x))
00209 #define __profcxx_hashtable_destruct(__x...) \
00210 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00211 __gnu_profile::__trace_hashtable_size_destruct(__x))
00212 #define __profcxx_hashtable_construct(__x...) \
00213 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00214 __gnu_profile::__trace_hashtable_size_construct(__x))
00215 #else
00216 #define __profcxx_hashtable_resize(__x...)
00217 #define __profcxx_hashtable_destruct(__x...)
00218 #define __profcxx_hashtable_construct(__x...)
00219 #endif
00220
00221
00222 #if (defined(_GLIBCXX_PROFILE_VECTOR_TOO_SMALL) \
00223 || defined(_GLIBCXX_PROFILE_VECTOR_TOO_LARGE))
00224 #define __profcxx_vector_resize(__x...) \
00225 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00226 __gnu_profile::__trace_vector_size_resize(__x))
00227 #define __profcxx_vector_destruct(__x...) \
00228 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00229 __gnu_profile::__trace_vector_size_destruct(__x))
00230 #define __profcxx_vector_construct(__x...) \
00231 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00232 __gnu_profile::__trace_vector_size_construct(__x))
00233 #else
00234 #define __profcxx_vector_resize(__x...)
00235 #define __profcxx_vector_destruct(__x...)
00236 #define __profcxx_vector_construct(__x...)
00237 #endif
00238
00239
00240 #if defined(_GLIBCXX_PROFILE_INEFFICIENT_HASH)
00241 #define __profcxx_hashtable_construct2(__x...) \
00242 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00243 __gnu_profile::__trace_hash_func_construct(__x))
00244 #define __profcxx_hashtable_destruct2(__x...) \
00245 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00246 __gnu_profile::__trace_hash_func_destruct(__x))
00247 #else
00248 #define __profcxx_hashtable_destruct2(__x...)
00249 #define __profcxx_hashtable_construct2(__x...)
00250 #endif
00251
00252
00253 #if defined(_GLIBCXX_PROFILE_VECTOR_TO_LIST)
00254 #define __profcxx_vector_construct2(__x...) \
00255 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00256 __gnu_profile::__trace_vector_to_list_construct(__x))
00257 #define __profcxx_vector_destruct2(__x...) \
00258 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00259 __gnu_profile::__trace_vector_to_list_destruct(__x))
00260 #define __profcxx_vector_insert(__x...) \
00261 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00262 __gnu_profile::__trace_vector_to_list_insert(__x))
00263 #define __profcxx_vector_iterate(__x...) \
00264 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00265 __gnu_profile::__trace_vector_to_list_iterate(__x))
00266 #define __profcxx_vector_invalid_operator(__x...) \
00267 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00268 __gnu_profile::__trace_vector_to_list_invalid_operator(__x))
00269 #define __profcxx_vector_resize2(__x...) \
00270 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00271 __gnu_profile::__trace_vector_to_list_resize(__x))
00272 #define __profcxx_vector_find(__x...) \
00273 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00274 __gnu_profile::__trace_vector_to_list_find(__x))
00275 #else
00276 #define __profcxx_vector_destruct2(__x...)
00277 #define __profcxx_vector_construct2(__x...)
00278 #define __profcxx_vector_insert(__x...)
00279 #define __profcxx_vector_iterate(__x...)
00280 #define __profcxx_vector_invalid_operator(__x...)
00281 #define __profcxx_vector_resize2(__x...)
00282 #define __profcxx_vector_find(__x...)
00283 #endif
00284
00285
00286 #if defined(_GLIBCXX_PROFILE_LIST_TO_VECTOR)
00287 #define __profcxx_list_construct2(__x...) \
00288 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00289 __gnu_profile::__trace_list_to_vector_construct(__x))
00290 #define __profcxx_list_destruct2(__x...) \
00291 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00292 __gnu_profile::__trace_list_to_vector_destruct(__x))
00293 #define __profcxx_list_insert(__x...) \
00294 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00295 __gnu_profile::__trace_list_to_vector_insert(__x))
00296 #define __profcxx_list_iterate(__x...) \
00297 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00298 __gnu_profile::__trace_list_to_vector_iterate(__x))
00299 #define __profcxx_list_invalid_operator(__x...) \
00300 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00301 __gnu_profile::__trace_list_to_vector_invalid_operator(__x))
00302 #else
00303 #define __profcxx_list_destruct2(__x...)
00304 #define __profcxx_list_construct2(__x...)
00305 #define __profcxx_list_insert(__x...)
00306 #define __profcxx_list_iterate(__x...)
00307 #define __profcxx_list_invalid_operator(__x...)
00308 #endif
00309
00310
00311 #if defined(_GLIBCXX_PROFILE_LIST_TO_SLIST)
00312 #define __profcxx_list_rewind(__x...) \
00313 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00314 __gnu_profile::__trace_list_to_slist_rewind(__x))
00315 #define __profcxx_list_operation(__x...) \
00316 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00317 __gnu_profile::__trace_list_to_slist_operation(__x))
00318 #define __profcxx_list_destruct(__x...) \
00319 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00320 __gnu_profile::__trace_list_to_slist_destruct(__x))
00321 #define __profcxx_list_construct(__x...) \
00322 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00323 __gnu_profile::__trace_list_to_slist_construct(__x))
00324 #else
00325 #define __profcxx_list_rewind(__x...)
00326 #define __profcxx_list_operation(__x...)
00327 #define __profcxx_list_destruct(__x...)
00328 #define __profcxx_list_construct(__x...)
00329 #endif
00330
00331
00332 #if defined(_GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP)
00333 #define __profcxx_map_to_unordered_map_construct(__x...) \
00334 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00335 __gnu_profile::__trace_map_to_unordered_map_construct(__x))
00336 #define __profcxx_map_to_unordered_map_destruct(__x...) \
00337 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00338 __gnu_profile::__trace_map_to_unordered_map_destruct(__x))
00339 #define __profcxx_map_to_unordered_map_insert(__x...) \
00340 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00341 __gnu_profile::__trace_map_to_unordered_map_insert(__x))
00342 #define __profcxx_map_to_unordered_map_erase(__x...) \
00343 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00344 __gnu_profile::__trace_map_to_unordered_map_erase(__x))
00345 #define __profcxx_map_to_unordered_map_iterate(__x...) \
00346 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00347 __gnu_profile::__trace_map_to_unordered_map_iterate(__x))
00348 #define __profcxx_map_to_unordered_map_invalidate(__x...) \
00349 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00350 __gnu_profile::__trace_map_to_unordered_map_invalidate(__x))
00351 #define __profcxx_map_to_unordered_map_find(__x...) \
00352 _GLIBCXX_PROFILE_REENTRANCE_GUARD( \
00353 __gnu_profile::__trace_map_to_unordered_map_find(__x))
00354 #else
00355 #define __profcxx_map_to_unordered_map_construct(__x...) \
00356
00357 #define __profcxx_map_to_unordered_map_destruct(__x...)
00358 #define __profcxx_map_to_unordered_map_insert(__x...)
00359 #define __profcxx_map_to_unordered_map_erase(__x...)
00360 #define __profcxx_map_to_unordered_map_iterate(__x...)
00361 #define __profcxx_map_to_unordered_map_invalidate(__x...)
00362 #define __profcxx_map_to_unordered_map_find(__x...)
00363 #endif
00364
00365
00366 #ifndef _GLIBCXX_PROFILE_NO_THREADS
00367 #define _GLIBCXX_PROFILE_THREADS
00368 #endif
00369
00370
00371 #ifndef _GLIBCXX_PROFILE_TRACE_PATH_ROOT
00372 #define _GLIBCXX_PROFILE_TRACE_PATH_ROOT "libstdcxx-profile"
00373 #endif
00374 #ifndef _GLIBCXX_PROFILE_TRACE_ENV_VAR
00375 #define _GLIBCXX_PROFILE_TRACE_ENV_VAR "_GLIBCXX_PROFILE_TRACE_PATH_ROOT"
00376 #endif
00377 #ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR
00378 #define _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR \
00379 "_GLIBCXX_PROFILE_MAX_WARN_COUNT"
00380 #endif
00381 #ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT
00382 #define _GLIBCXX_PROFILE_MAX_WARN_COUNT 10
00383 #endif
00384 #ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH
00385 #define _GLIBCXX_PROFILE_MAX_STACK_DEPTH 32
00386 #endif
00387 #ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR
00388 #define _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR \
00389 "_GLIBCXX_PROFILE_MAX_STACK_DEPTH"
00390 #endif
00391 #ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC
00392 #define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC 2 << 27
00393 #endif
00394 #ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR
00395 #define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR \
00396 "_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC"
00397 #endif
00398
00399
00400 #include "profile/impl/profiler_hash_func.h"
00401 #include "profile/impl/profiler_hashtable_size.h"
00402 #include "profile/impl/profiler_map_to_unordered_map.h"
00403 #include "profile/impl/profiler_vector_size.h"
00404 #include "profile/impl/profiler_vector_to_list.h"
00405 #include "profile/impl/profiler_list_to_slist.h"
00406 #include "profile/impl/profiler_list_to_vector.h"
00407
00408 #endif // _GLIBCXX_PROFILE_PROFILER_H