1*e4b17023SJohn Marino // -*- C++ -*- 2*e4b17023SJohn Marino // 3*e4b17023SJohn Marino // Copyright (C) 2009, 2010 Free Software Foundation, Inc. 4*e4b17023SJohn Marino // 5*e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library. This library is free 6*e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the 7*e4b17023SJohn Marino // terms of the GNU General Public License as published by the 8*e4b17023SJohn Marino // Free Software Foundation; either version 3, or (at your option) 9*e4b17023SJohn Marino // any later version. 10*e4b17023SJohn Marino // 11*e4b17023SJohn Marino // This library is distributed in the hope that it will be useful, 12*e4b17023SJohn Marino // but WITHOUT ANY WARRANTY; without even the implied warranty of 13*e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*e4b17023SJohn Marino // GNU General Public License for more details. 15*e4b17023SJohn Marino 16*e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional 17*e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version 18*e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation. 19*e4b17023SJohn Marino 20*e4b17023SJohn Marino // You should have received a copy of the GNU General Public License along 21*e4b17023SJohn Marino // with this library; see the file COPYING3. If not see 22*e4b17023SJohn Marino // <http://www.gnu.org/licenses/>. 23*e4b17023SJohn Marino 24*e4b17023SJohn Marino /** @file profile/impl/profiler.h 25*e4b17023SJohn Marino * @brief Interface of the profiling runtime library. 26*e4b17023SJohn Marino */ 27*e4b17023SJohn Marino 28*e4b17023SJohn Marino // Written by Lixia Liu and Silvius Rus. 29*e4b17023SJohn Marino 30*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_PROFILER_H 31*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_PROFILER_H 1 32*e4b17023SJohn Marino 33*e4b17023SJohn Marino #include <bits/c++config.h> 34*e4b17023SJohn Marino 35*e4b17023SJohn Marino // Mechanism to define data with inline linkage. 36*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__type, __name) \ 37*e4b17023SJohn Marino inline __type& \ 38*e4b17023SJohn Marino __get_##__name() \ 39*e4b17023SJohn Marino { \ 40*e4b17023SJohn Marino static __type __name; \ 41*e4b17023SJohn Marino return __name; \ 42*e4b17023SJohn Marino } 43*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_DEFINE_DATA(__type, __name, __initial_value...) \ 44*e4b17023SJohn Marino inline __type& __get_##__name() { \ 45*e4b17023SJohn Marino static __type __name(__initial_value); \ 46*e4b17023SJohn Marino return __name; \ 47*e4b17023SJohn Marino } 48*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_DATA(__name) \ 49*e4b17023SJohn Marino __get_##__name() 50*e4b17023SJohn Marino 51*e4b17023SJohn Marino namespace __gnu_profile 52*e4b17023SJohn Marino { 53*e4b17023SJohn Marino /** @brief Reentrance guard. 54*e4b17023SJohn Marino * 55*e4b17023SJohn Marino * Mechanism to protect all __gnu_profile operations against recursion, 56*e4b17023SJohn Marino * multithreaded and exception reentrance. 57*e4b17023SJohn Marino */ 58*e4b17023SJohn Marino struct __reentrance_guard 59*e4b17023SJohn Marino { 60*e4b17023SJohn Marino static bool __get_in__reentrance_guard61*e4b17023SJohn Marino __get_in() 62*e4b17023SJohn Marino { 63*e4b17023SJohn Marino if (__inside() == true) 64*e4b17023SJohn Marino return false; 65*e4b17023SJohn Marino else 66*e4b17023SJohn Marino { 67*e4b17023SJohn Marino __inside() = true; 68*e4b17023SJohn Marino return true; 69*e4b17023SJohn Marino } 70*e4b17023SJohn Marino } 71*e4b17023SJohn Marino 72*e4b17023SJohn Marino static bool& __inside__reentrance_guard73*e4b17023SJohn Marino __inside() 74*e4b17023SJohn Marino { 75*e4b17023SJohn Marino static __thread bool _S_inside(false); 76*e4b17023SJohn Marino return _S_inside; 77*e4b17023SJohn Marino } 78*e4b17023SJohn Marino __reentrance_guard__reentrance_guard79*e4b17023SJohn Marino __reentrance_guard() { } ~__reentrance_guard__reentrance_guard80*e4b17023SJohn Marino ~__reentrance_guard() { __inside() = false; } 81*e4b17023SJohn Marino }; 82*e4b17023SJohn Marino 83*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_REENTRANCE_GUARD(__x...) \ 84*e4b17023SJohn Marino { \ 85*e4b17023SJohn Marino if (__gnu_profile::__reentrance_guard::__get_in()) \ 86*e4b17023SJohn Marino { \ 87*e4b17023SJohn Marino __gnu_profile::__reentrance_guard __get_out; \ 88*e4b17023SJohn Marino __x; \ 89*e4b17023SJohn Marino } \ 90*e4b17023SJohn Marino } 91*e4b17023SJohn Marino 92*e4b17023SJohn Marino // Forward declarations of implementation functions. 93*e4b17023SJohn Marino // Don't use any __gnu_profile:: in user code. 94*e4b17023SJohn Marino // Instead, use the __profcxx... macros, which offer guarded access. 95*e4b17023SJohn Marino bool __turn_on(); 96*e4b17023SJohn Marino bool __turn_off(); 97*e4b17023SJohn Marino bool __is_invalid(); 98*e4b17023SJohn Marino bool __is_on(); 99*e4b17023SJohn Marino bool __is_off(); 100*e4b17023SJohn Marino void __report(void); 101*e4b17023SJohn Marino void __trace_hashtable_size_resize(const void*, std::size_t, std::size_t); 102*e4b17023SJohn Marino void __trace_hashtable_size_destruct(const void*, std::size_t, std::size_t); 103*e4b17023SJohn Marino void __trace_hashtable_size_construct(const void*, std::size_t); 104*e4b17023SJohn Marino void __trace_vector_size_resize(const void*, std::size_t, std::size_t); 105*e4b17023SJohn Marino void __trace_vector_size_destruct(const void*, std::size_t, std::size_t); 106*e4b17023SJohn Marino void __trace_vector_size_construct(const void*, std::size_t); 107*e4b17023SJohn Marino void __trace_hash_func_destruct(const void*, std::size_t, std::size_t, 108*e4b17023SJohn Marino std::size_t); 109*e4b17023SJohn Marino void __trace_hash_func_construct(const void*); 110*e4b17023SJohn Marino void __trace_vector_to_list_destruct(const void*); 111*e4b17023SJohn Marino void __trace_vector_to_list_construct(const void*); 112*e4b17023SJohn Marino void __trace_vector_to_list_insert(const void*, std::size_t, std::size_t); 113*e4b17023SJohn Marino void __trace_vector_to_list_iterate(const void*, std::size_t); 114*e4b17023SJohn Marino void __trace_vector_to_list_invalid_operator(const void*); 115*e4b17023SJohn Marino void __trace_vector_to_list_resize(const void*, std::size_t, std::size_t); 116*e4b17023SJohn Marino void __trace_vector_to_list_find(const void*, std::size_t); 117*e4b17023SJohn Marino 118*e4b17023SJohn Marino void __trace_list_to_slist_destruct(const void*); 119*e4b17023SJohn Marino void __trace_list_to_slist_construct(const void*); 120*e4b17023SJohn Marino void __trace_list_to_slist_rewind(const void*); 121*e4b17023SJohn Marino void __trace_list_to_slist_operation(const void*); 122*e4b17023SJohn Marino 123*e4b17023SJohn Marino void __trace_list_to_vector_destruct(const void*); 124*e4b17023SJohn Marino void __trace_list_to_vector_construct(const void*); 125*e4b17023SJohn Marino void __trace_list_to_vector_insert(const void*, std::size_t, std::size_t); 126*e4b17023SJohn Marino void __trace_list_to_vector_iterate(const void*, std::size_t); 127*e4b17023SJohn Marino void __trace_list_to_vector_invalid_operator(const void*); 128*e4b17023SJohn Marino void __trace_list_to_vector_resize(const void*, std::size_t, std::size_t); 129*e4b17023SJohn Marino 130*e4b17023SJohn Marino void __trace_list_to_set_destruct(const void*); 131*e4b17023SJohn Marino void __trace_list_to_set_construct(const void*); 132*e4b17023SJohn Marino void __trace_list_to_set_insert(const void*, std::size_t, std::size_t); 133*e4b17023SJohn Marino void __trace_list_to_set_iterate(const void*, std::size_t); 134*e4b17023SJohn Marino void __trace_list_to_set_invalid_operator(const void*); 135*e4b17023SJohn Marino void __trace_list_to_set_find(const void*, std::size_t); 136*e4b17023SJohn Marino 137*e4b17023SJohn Marino void __trace_map_to_unordered_map_construct(const void*); 138*e4b17023SJohn Marino void __trace_map_to_unordered_map_invalidate(const void*); 139*e4b17023SJohn Marino void __trace_map_to_unordered_map_insert(const void*, std::size_t, 140*e4b17023SJohn Marino std::size_t); 141*e4b17023SJohn Marino void __trace_map_to_unordered_map_erase(const void*, std::size_t, 142*e4b17023SJohn Marino std::size_t); 143*e4b17023SJohn Marino void __trace_map_to_unordered_map_iterate(const void*, std::size_t); 144*e4b17023SJohn Marino void __trace_map_to_unordered_map_find(const void*, std::size_t); 145*e4b17023SJohn Marino void __trace_map_to_unordered_map_destruct(const void*); 146*e4b17023SJohn Marino } // namespace __gnu_profile 147*e4b17023SJohn Marino 148*e4b17023SJohn Marino // Master switch turns on all diagnostics that are not explicitly turned off. 149*e4b17023SJohn Marino #ifdef _GLIBCXX_PROFILE 150*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_HASHTABLE_TOO_SMALL 151*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL 152*e4b17023SJohn Marino #endif 153*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_HASHTABLE_TOO_LARGE 154*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE 155*e4b17023SJohn Marino #endif 156*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TOO_SMALL 157*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_VECTOR_TOO_SMALL 158*e4b17023SJohn Marino #endif 159*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TOO_LARGE 160*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_VECTOR_TOO_LARGE 161*e4b17023SJohn Marino #endif 162*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_INEFFICIENT_HASH 163*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_INEFFICIENT_HASH 164*e4b17023SJohn Marino #endif 165*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_VECTOR_TO_LIST 166*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_VECTOR_TO_LIST 167*e4b17023SJohn Marino #endif 168*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_LIST_TO_SLIST 169*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_LIST_TO_SLIST 170*e4b17023SJohn Marino #endif 171*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_LIST_TO_VECTOR 172*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_LIST_TO_VECTOR 173*e4b17023SJohn Marino #endif 174*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_NO_MAP_TO_UNORDERED_MAP 175*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP 176*e4b17023SJohn Marino #endif 177*e4b17023SJohn Marino #endif 178*e4b17023SJohn Marino 179*e4b17023SJohn Marino // Expose global management routines to user code. 180*e4b17023SJohn Marino #ifdef _GLIBCXX_PROFILE 181*e4b17023SJohn Marino #define __profcxx_report() \ 182*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__report()) 183*e4b17023SJohn Marino #define __profcxx_turn_on() \ 184*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_on()) 185*e4b17023SJohn Marino #define __profcxx_turn_off() \ 186*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_off()) 187*e4b17023SJohn Marino #define __profcxx_is_invalid() \ 188*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_invalid()) 189*e4b17023SJohn Marino #define __profcxx_is_on() \ 190*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_on()) 191*e4b17023SJohn Marino #define __profcxx__is_off() \ 192*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_off()) 193*e4b17023SJohn Marino #else 194*e4b17023SJohn Marino #define __profcxx_report() 195*e4b17023SJohn Marino #define __profcxx_turn_on() 196*e4b17023SJohn Marino #define __profcxx_turn_off() 197*e4b17023SJohn Marino #define __profcxx_is_invalid() 198*e4b17023SJohn Marino #define __profcxx_is_on() 199*e4b17023SJohn Marino #define __profcxx_is_off() 200*e4b17023SJohn Marino #endif 201*e4b17023SJohn Marino 202*e4b17023SJohn Marino // Turn on/off instrumentation for HASHTABLE_TOO_SMALL and HASHTABLE_TOO_LARGE. 203*e4b17023SJohn Marino #if (defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL) \ 204*e4b17023SJohn Marino || defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE)) 205*e4b17023SJohn Marino #define __profcxx_hashtable_resize(__x...) \ 206*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 207*e4b17023SJohn Marino __gnu_profile::__trace_hashtable_size_resize(__x)) 208*e4b17023SJohn Marino #define __profcxx_hashtable_destruct(__x...) \ 209*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 210*e4b17023SJohn Marino __gnu_profile::__trace_hashtable_size_destruct(__x)) 211*e4b17023SJohn Marino #define __profcxx_hashtable_construct(__x...) \ 212*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 213*e4b17023SJohn Marino __gnu_profile::__trace_hashtable_size_construct(__x)) 214*e4b17023SJohn Marino #else 215*e4b17023SJohn Marino #define __profcxx_hashtable_resize(__x...) 216*e4b17023SJohn Marino #define __profcxx_hashtable_destruct(__x...) 217*e4b17023SJohn Marino #define __profcxx_hashtable_construct(__x...) 218*e4b17023SJohn Marino #endif 219*e4b17023SJohn Marino 220*e4b17023SJohn Marino // Turn on/off instrumentation for VECTOR_TOO_SMALL and VECTOR_TOO_LARGE. 221*e4b17023SJohn Marino #if (defined(_GLIBCXX_PROFILE_VECTOR_TOO_SMALL) \ 222*e4b17023SJohn Marino || defined(_GLIBCXX_PROFILE_VECTOR_TOO_LARGE)) 223*e4b17023SJohn Marino #define __profcxx_vector_resize(__x...) \ 224*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 225*e4b17023SJohn Marino __gnu_profile::__trace_vector_size_resize(__x)) 226*e4b17023SJohn Marino #define __profcxx_vector_destruct(__x...) \ 227*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 228*e4b17023SJohn Marino __gnu_profile::__trace_vector_size_destruct(__x)) 229*e4b17023SJohn Marino #define __profcxx_vector_construct(__x...) \ 230*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 231*e4b17023SJohn Marino __gnu_profile::__trace_vector_size_construct(__x)) 232*e4b17023SJohn Marino #else 233*e4b17023SJohn Marino #define __profcxx_vector_resize(__x...) 234*e4b17023SJohn Marino #define __profcxx_vector_destruct(__x...) 235*e4b17023SJohn Marino #define __profcxx_vector_construct(__x...) 236*e4b17023SJohn Marino #endif 237*e4b17023SJohn Marino 238*e4b17023SJohn Marino // Turn on/off instrumentation for INEFFICIENT_HASH. 239*e4b17023SJohn Marino #if defined(_GLIBCXX_PROFILE_INEFFICIENT_HASH) 240*e4b17023SJohn Marino #define __profcxx_hashtable_construct2(__x...) \ 241*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 242*e4b17023SJohn Marino __gnu_profile::__trace_hash_func_construct(__x)) 243*e4b17023SJohn Marino #define __profcxx_hashtable_destruct2(__x...) \ 244*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 245*e4b17023SJohn Marino __gnu_profile::__trace_hash_func_destruct(__x)) 246*e4b17023SJohn Marino #else 247*e4b17023SJohn Marino #define __profcxx_hashtable_destruct2(__x...) 248*e4b17023SJohn Marino #define __profcxx_hashtable_construct2(__x...) 249*e4b17023SJohn Marino #endif 250*e4b17023SJohn Marino 251*e4b17023SJohn Marino // Turn on/off instrumentation for VECTOR_TO_LIST. 252*e4b17023SJohn Marino #if defined(_GLIBCXX_PROFILE_VECTOR_TO_LIST) 253*e4b17023SJohn Marino #define __profcxx_vector_construct2(__x...) \ 254*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 255*e4b17023SJohn Marino __gnu_profile::__trace_vector_to_list_construct(__x)) 256*e4b17023SJohn Marino #define __profcxx_vector_destruct2(__x...) \ 257*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 258*e4b17023SJohn Marino __gnu_profile::__trace_vector_to_list_destruct(__x)) 259*e4b17023SJohn Marino #define __profcxx_vector_insert(__x...) \ 260*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 261*e4b17023SJohn Marino __gnu_profile::__trace_vector_to_list_insert(__x)) 262*e4b17023SJohn Marino #define __profcxx_vector_iterate(__x...) \ 263*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 264*e4b17023SJohn Marino __gnu_profile::__trace_vector_to_list_iterate(__x)) 265*e4b17023SJohn Marino #define __profcxx_vector_invalid_operator(__x...) \ 266*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 267*e4b17023SJohn Marino __gnu_profile::__trace_vector_to_list_invalid_operator(__x)) 268*e4b17023SJohn Marino #define __profcxx_vector_resize2(__x...) \ 269*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 270*e4b17023SJohn Marino __gnu_profile::__trace_vector_to_list_resize(__x)) 271*e4b17023SJohn Marino #define __profcxx_vector_find(__x...) \ 272*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 273*e4b17023SJohn Marino __gnu_profile::__trace_vector_to_list_find(__x)) 274*e4b17023SJohn Marino #else 275*e4b17023SJohn Marino #define __profcxx_vector_destruct2(__x...) 276*e4b17023SJohn Marino #define __profcxx_vector_construct2(__x...) 277*e4b17023SJohn Marino #define __profcxx_vector_insert(__x...) 278*e4b17023SJohn Marino #define __profcxx_vector_iterate(__x...) 279*e4b17023SJohn Marino #define __profcxx_vector_invalid_operator(__x...) 280*e4b17023SJohn Marino #define __profcxx_vector_resize2(__x...) 281*e4b17023SJohn Marino #define __profcxx_vector_find(__x...) 282*e4b17023SJohn Marino #endif 283*e4b17023SJohn Marino 284*e4b17023SJohn Marino // Turn on/off instrumentation for LIST_TO_VECTOR. 285*e4b17023SJohn Marino #if defined(_GLIBCXX_PROFILE_LIST_TO_VECTOR) 286*e4b17023SJohn Marino #define __profcxx_list_construct2(__x...) \ 287*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 288*e4b17023SJohn Marino __gnu_profile::__trace_list_to_vector_construct(__x)) 289*e4b17023SJohn Marino #define __profcxx_list_destruct2(__x...) \ 290*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 291*e4b17023SJohn Marino __gnu_profile::__trace_list_to_vector_destruct(__x)) 292*e4b17023SJohn Marino #define __profcxx_list_insert(__x...) \ 293*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 294*e4b17023SJohn Marino __gnu_profile::__trace_list_to_vector_insert(__x)) 295*e4b17023SJohn Marino #define __profcxx_list_iterate(__x...) \ 296*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 297*e4b17023SJohn Marino __gnu_profile::__trace_list_to_vector_iterate(__x)) 298*e4b17023SJohn Marino #define __profcxx_list_invalid_operator(__x...) \ 299*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 300*e4b17023SJohn Marino __gnu_profile::__trace_list_to_vector_invalid_operator(__x)) 301*e4b17023SJohn Marino #else 302*e4b17023SJohn Marino #define __profcxx_list_destruct2(__x...) 303*e4b17023SJohn Marino #define __profcxx_list_construct2(__x...) 304*e4b17023SJohn Marino #define __profcxx_list_insert(__x...) 305*e4b17023SJohn Marino #define __profcxx_list_iterate(__x...) 306*e4b17023SJohn Marino #define __profcxx_list_invalid_operator(__x...) 307*e4b17023SJohn Marino #endif 308*e4b17023SJohn Marino 309*e4b17023SJohn Marino // Turn on/off instrumentation for LIST_TO_SLIST. 310*e4b17023SJohn Marino #if defined(_GLIBCXX_PROFILE_LIST_TO_SLIST) 311*e4b17023SJohn Marino #define __profcxx_list_rewind(__x...) \ 312*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 313*e4b17023SJohn Marino __gnu_profile::__trace_list_to_slist_rewind(__x)) 314*e4b17023SJohn Marino #define __profcxx_list_operation(__x...) \ 315*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 316*e4b17023SJohn Marino __gnu_profile::__trace_list_to_slist_operation(__x)) 317*e4b17023SJohn Marino #define __profcxx_list_destruct(__x...) \ 318*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 319*e4b17023SJohn Marino __gnu_profile::__trace_list_to_slist_destruct(__x)) 320*e4b17023SJohn Marino #define __profcxx_list_construct(__x...) \ 321*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 322*e4b17023SJohn Marino __gnu_profile::__trace_list_to_slist_construct(__x)) 323*e4b17023SJohn Marino #else 324*e4b17023SJohn Marino #define __profcxx_list_rewind(__x...) 325*e4b17023SJohn Marino #define __profcxx_list_operation(__x...) 326*e4b17023SJohn Marino #define __profcxx_list_destruct(__x...) 327*e4b17023SJohn Marino #define __profcxx_list_construct(__x...) 328*e4b17023SJohn Marino #endif 329*e4b17023SJohn Marino 330*e4b17023SJohn Marino // Turn on/off instrumentation for MAP_TO_UNORDERED_MAP. 331*e4b17023SJohn Marino #if defined(_GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP) 332*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_construct(__x...) \ 333*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 334*e4b17023SJohn Marino __gnu_profile::__trace_map_to_unordered_map_construct(__x)) 335*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_destruct(__x...) \ 336*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 337*e4b17023SJohn Marino __gnu_profile::__trace_map_to_unordered_map_destruct(__x)) 338*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_insert(__x...) \ 339*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 340*e4b17023SJohn Marino __gnu_profile::__trace_map_to_unordered_map_insert(__x)) 341*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_erase(__x...) \ 342*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 343*e4b17023SJohn Marino __gnu_profile::__trace_map_to_unordered_map_erase(__x)) 344*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_iterate(__x...) \ 345*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 346*e4b17023SJohn Marino __gnu_profile::__trace_map_to_unordered_map_iterate(__x)) 347*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_invalidate(__x...) \ 348*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 349*e4b17023SJohn Marino __gnu_profile::__trace_map_to_unordered_map_invalidate(__x)) 350*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_find(__x...) \ 351*e4b17023SJohn Marino _GLIBCXX_PROFILE_REENTRANCE_GUARD( \ 352*e4b17023SJohn Marino __gnu_profile::__trace_map_to_unordered_map_find(__x)) 353*e4b17023SJohn Marino #else 354*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_construct(__x...) \ 355*e4b17023SJohn Marino 356*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_destruct(__x...) 357*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_insert(__x...) 358*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_erase(__x...) 359*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_iterate(__x...) 360*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_invalidate(__x...) 361*e4b17023SJohn Marino #define __profcxx_map_to_unordered_map_find(__x...) 362*e4b17023SJohn Marino #endif 363*e4b17023SJohn Marino 364*e4b17023SJohn Marino // Set default values for compile-time customizable variables. 365*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_TRACE_PATH_ROOT 366*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_TRACE_PATH_ROOT "libstdcxx-profile" 367*e4b17023SJohn Marino #endif 368*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_TRACE_ENV_VAR 369*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_TRACE_ENV_VAR "_GLIBCXX_PROFILE_TRACE_PATH_ROOT" 370*e4b17023SJohn Marino #endif 371*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR 372*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR \ 373*e4b17023SJohn Marino "_GLIBCXX_PROFILE_MAX_WARN_COUNT" 374*e4b17023SJohn Marino #endif 375*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_MAX_WARN_COUNT 376*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_MAX_WARN_COUNT 10 377*e4b17023SJohn Marino #endif 378*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH 379*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_MAX_STACK_DEPTH 32 380*e4b17023SJohn Marino #endif 381*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR 382*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_MAX_STACK_DEPTH_ENV_VAR \ 383*e4b17023SJohn Marino "_GLIBCXX_PROFILE_MAX_STACK_DEPTH" 384*e4b17023SJohn Marino #endif 385*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC 386*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC (1 << 28) 387*e4b17023SJohn Marino #endif 388*e4b17023SJohn Marino #ifndef _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR 389*e4b17023SJohn Marino #define _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC_ENV_VAR \ 390*e4b17023SJohn Marino "_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC" 391*e4b17023SJohn Marino #endif 392*e4b17023SJohn Marino 393*e4b17023SJohn Marino // Instrumentation hook implementations. 394*e4b17023SJohn Marino #include "profile/impl/profiler_hash_func.h" 395*e4b17023SJohn Marino #include "profile/impl/profiler_hashtable_size.h" 396*e4b17023SJohn Marino #include "profile/impl/profiler_map_to_unordered_map.h" 397*e4b17023SJohn Marino #include "profile/impl/profiler_vector_size.h" 398*e4b17023SJohn Marino #include "profile/impl/profiler_vector_to_list.h" 399*e4b17023SJohn Marino #include "profile/impl/profiler_list_to_slist.h" 400*e4b17023SJohn Marino #include "profile/impl/profiler_list_to_vector.h" 401*e4b17023SJohn Marino 402*e4b17023SJohn Marino #endif // _GLIBCXX_PROFILE_PROFILER_H 403