Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Stats/Heap.cc

    rc15085d r120a28c3  
    5353                const size_t passes_size = sizeof(passes) / sizeof(passes[0]);
    5454                size_t       passes_cnt = 1;
    55 
    56                 StatBlock    stacktrace_stats[100];
    57                 size_t       stacktrace_stats_count = 0;
    58                 bool         stacktrace_stats_enabled = true;
    59 
    60                 size_t       trace[1000];
    61                 const size_t stacktrace_max_depth = sizeof(trace) / sizeof(size_t);
    62                 size_t       stacktrace_depth;
    63 
    64                 size_t new_stacktrace_id(const char * const name) {
    65                         stacktrace_stats[stacktrace_stats_count].name = name;
    66                         return stacktrace_stats_count++;
    67                 }
    68 
    69                 void stacktrace_push(size_t id) {
    70                         ++stacktrace_depth;
    71                         assertf(stacktrace_depth < stacktrace_max_depth, "Stack trace too deep: increase size of array in Heap.cc");
    72                         trace[stacktrace_depth] = id;
    73                 }
    74 
    75                 void stacktrace_pop() {
    76                         assertf(stacktrace_depth > 0, "Invalid stack tracing operation: trace is empty");
    77                         --stacktrace_depth;
    78                 }
    7955
    8056                void newPass( const char * const name ) {
     
    140116                        for(size_t i = 0; i < passes_cnt; i++) {
    141117                                print(passes[i], nc, total_mallocs, total_frees, overall_peak);
    142                         }
    143 
    144                         print('-', nct);
    145                         std::cerr << std::setw(nc) << "Trace";
    146                         std::cerr << " |       Malloc Count |         Free Count |        Peak Allocs |" << std::endl;
    147 
    148                         print('-', nct);
    149                         for (size_t i = 0; i < stacktrace_stats_count; i++) {
    150                                 print(stacktrace_stats[i], nc, total_mallocs, total_frees, overall_peak);
    151118                        }
    152119                        print('-', nct);
     
    221188                                                = std::max(passes[passes_cnt - 1].peak_allocs, passes[passes_cnt - 1].n_allocs);
    222189                                }
    223 
    224                                 if ( stacktrace_stats_enabled && stacktrace_depth > 0) {
    225                                         stacktrace_stats[trace[stacktrace_depth]].mallocs++;
    226                                 }
    227190                                return __malloc( size );
    228191                        }
     
    233196                                        passes[passes_cnt - 1].frees++;
    234197                                        passes[passes_cnt - 1].n_allocs--;
    235                                 }
    236                                 if ( stacktrace_stats_enabled && stacktrace_depth > 0) {
    237                                         stacktrace_stats[trace[stacktrace_depth]].frees++;
    238198                                }
    239199                                return __free( ptr );
     
    248208                                                = std::max(passes[passes_cnt - 1].peak_allocs, passes[passes_cnt - 1].n_allocs);
    249209                                }
    250                                 if ( stacktrace_stats_enabled && stacktrace_depth > 0) {
    251                                         stacktrace_stats[trace[stacktrace_depth]].mallocs++;
    252                                 }
    253210                                return __calloc( nelem, size );
    254211                        }
     
    261218                                        passes[passes_cnt - 1].frees++;
    262219                                } // if
    263                                 if ( stacktrace_stats_enabled && stacktrace_depth > 0) {
    264                                         stacktrace_stats[trace[stacktrace_depth]].mallocs++;
    265                                         stacktrace_stats[trace[stacktrace_depth]].frees++;
    266                                 }
    267220                                return s;
    268221                        }
Note: See TracChangeset for help on using the changeset viewer.