| 521 | } |
| 522 | |
| 523 | void TFCode::Format(const CodeNode* root, const std::vector<CodeNode*>& nodes, |
| 524 | const Options& opts, string* display_str, |
| 525 | MultiGraphNodeProto* proto, std::vector<uint64>* call_ids) { |
| 526 | if (nodes.empty() && root->has_trace() && opts.output_type == kOutput[3]) { |
| 527 | pprof_profile_->AddSample(root, call_ids); |
| 528 | } |
| 529 | |
| 530 | for (CodeNode* node : nodes) { |
| 531 | if (root->has_trace() && opts.output_type == kOutput[3]) { |
| 532 | uint64 loc_id = pprof_profile_->AddLocation(node, root); |
| 533 | call_ids->push_back(loc_id); |
| 534 | } |
| 535 | display_str->append(node->formatted_str); |
| 536 | MultiGraphNodeProto* child = proto->add_children(); |
| 537 | child->MergeFrom(node->proto()); |
| 538 | Format(node, node->show_children, opts, display_str, child, call_ids); |
| 539 | if (root->has_trace() && opts.output_type == kOutput[3]) { |
| 540 | call_ids->pop_back(); |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | std::vector<CodeNode*> TFCode::SearchRoot(std::vector<CodeNode*> roots, |
| 546 | const std::vector<string>& regexes) { |