void __end_ctrace__ (CTraceStruct *c, const char *name) { if (file_to_write == 0) return; ThreadInfo *tinfo = GetThreadInfo (); tinfo->stack_end_--; if (tinfo->stack_end_ < ThreadInfo::max_stack) { if (c->start_time_ != invalid_time) { if (tinfo->stack_end_ == 0) { tinfo->UpdateCurrentTime (); c->min_end_time_ = tinfo->current_time_ + ticks; } // we should record this RecordThis (c, tinfo); if (tinfo->stack_end_ != 0) { // propagate the back's mini end time tinfo->stack_[tinfo->stack_end_ - 1]->min_end_time_ = c->min_end_time_ + ticks; tinfo->stack_[tinfo->stack_end_ - 1]->min_end_time_thread_ = c->min_end_time_thread_ + ticks; tinfo->current_time_ += ticks; tinfo->current_time_thread_ += ticks; } } } }
void __start_ctrace__ (void *c, const char *name) { if (file_to_write == 0) return; CTraceStruct *cs = new (c) CTraceStruct (name); ThreadInfo *tinfo = GetThreadInfo (); if (tinfo->stack_end_ == 0) { // always update the time in the first entry. // Or if it sleep too long, will make this entry looks // very time consuming. tinfo->UpdateCurrentTime (); } if (tinfo->stack_end_ < ThreadInfo::max_stack) { tinfo->stack_[tinfo->stack_end_] = cs; } tinfo->stack_end_++; }