thread_tree.cpp revision f8258896a364b6c996b6d6816b88849cc8d0a488
160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui/* 260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * Copyright (C) 2015 The Android Open Source Project 360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * 460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * Licensed under the Apache License, Version 2.0 (the "License"); 560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * you may not use this file except in compliance with the License. 660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * You may obtain a copy of the License at 760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * 860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * http://www.apache.org/licenses/LICENSE-2.0 960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * 1060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * Unless required by applicable law or agreed to in writing, software 1160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * distributed under the License is distributed on an "AS IS" BASIS, 1260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * See the License for the specific language governing permissions and 1460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui * limitations under the License. 1560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui */ 1660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 1760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui#include "thread_tree.h" 1860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 1960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui#include <base/logging.h> 2060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui#include "environment.h" 2173d8078e6e5ef92b2301386ce96260bd99efacbbYabin Cui#include "perf_event.h" 2273d8078e6e5ef92b2301386ce96260bd99efacbbYabin Cui#include "record.h" 2360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 2460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuibool MapComparator::operator()(const MapEntry* map1, const MapEntry* map2) const { 2560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (map1->start_addr != map2->start_addr) { 2660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return map1->start_addr < map2->start_addr; 2760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 2860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (map1->len != map2->len) { 2960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return map1->len < map2->len; 3060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 3160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (map1->time != map2->time) { 3260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return map1->time < map2->time; 3360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 3460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return false; 3560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 3660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 3760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuivoid ThreadTree::AddThread(int pid, int tid, const std::string& comm) { 3860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui auto it = thread_tree_.find(tid); 3960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (it == thread_tree_.end()) { 4060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui ThreadEntry* thread = new ThreadEntry{ 4160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui pid, tid, 4260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui "unknown", // comm 4360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui std::set<MapEntry*, MapComparator>(), // maps 4460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui }; 4560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui auto pair = thread_tree_.insert(std::make_pair(tid, std::unique_ptr<ThreadEntry>(thread))); 4660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui CHECK(pair.second); 4760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui it = pair.first; 4860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 4960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui thread_comm_storage_.push_back(std::unique_ptr<std::string>(new std::string(comm))); 5060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui it->second->comm = thread_comm_storage_.back()->c_str(); 5160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 5260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 5360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuivoid ThreadTree::ForkThread(int pid, int tid, int ppid, int ptid) { 5460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui ThreadEntry* parent = FindThreadOrNew(ppid, ptid); 5560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui ThreadEntry* child = FindThreadOrNew(pid, tid); 5660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui child->comm = parent->comm; 5760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui child->maps = parent->maps; 5860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 5960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 6060a0ea96c0fb9e807c899759256df5e20bd904bdYabin CuiThreadEntry* ThreadTree::FindThreadOrNew(int pid, int tid) { 6160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui auto it = thread_tree_.find(tid); 6260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (it == thread_tree_.end()) { 6360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui AddThread(pid, tid, "unknown"); 6460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui it = thread_tree_.find(tid); 6560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } else { 665f2a170a577258a2792bd768a8a776a562f4e6c2Yabin Cui if (pid != it->second.get()->pid) { 675f2a170a577258a2792bd768a8a776a562f4e6c2Yabin Cui // TODO: b/22185053. 685f2a170a577258a2792bd768a8a776a562f4e6c2Yabin Cui LOG(DEBUG) << "unexpected (pid, tid) pair: expected (" << it->second.get()->pid << ", " << tid 695f2a170a577258a2792bd768a8a776a562f4e6c2Yabin Cui << "), actual (" << pid << ", " << tid << ")"; 705f2a170a577258a2792bd768a8a776a562f4e6c2Yabin Cui } 7160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 7260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return it->second.get(); 7360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 7460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 7560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuistatic void RemoveOverlappedMap(std::set<MapEntry*, MapComparator>* map_set, const MapEntry* map) { 7660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui for (auto it = map_set->begin(); it != map_set->end();) { 7760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if ((*it)->start_addr >= map->start_addr + map->len) { 7860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui break; 7960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 8060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if ((*it)->start_addr + (*it)->len <= map->start_addr) { 8160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui ++it; 8260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } else { 8360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui it = map_set->erase(it); 8460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 8560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 8660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 8760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 8860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuivoid ThreadTree::AddKernelMap(uint64_t start_addr, uint64_t len, uint64_t pgoff, uint64_t time, 8960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui const std::string& filename) { 9060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui // kernel map len can be 0 when record command is not run in supervisor mode. 9160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (len == 0) { 9260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return; 9360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 9460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui DsoEntry* dso = FindKernelDsoOrNew(filename); 9560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui MapEntry* map = new MapEntry{ 9660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui start_addr, len, pgoff, time, dso, 9760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui }; 9860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui map_storage_.push_back(std::unique_ptr<MapEntry>(map)); 9960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui RemoveOverlappedMap(&kernel_map_tree_, map); 10060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui auto pair = kernel_map_tree_.insert(map); 10160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui CHECK(pair.second); 10260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 10360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 10460a0ea96c0fb9e807c899759256df5e20bd904bdYabin CuiDsoEntry* ThreadTree::FindKernelDsoOrNew(const std::string& filename) { 10560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (filename == DEFAULT_KERNEL_MMAP_NAME) { 10660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (kernel_dso_ == nullptr) { 10760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui kernel_dso_ = DsoFactory::GetInstance()->CreateDso(DSO_KERNEL); 10860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 10960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return kernel_dso_.get(); 11060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 11160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui auto it = module_dso_tree_.find(filename); 11260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (it == module_dso_tree_.end()) { 11360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui module_dso_tree_[filename] = DsoFactory::GetInstance()->CreateDso(DSO_KERNEL_MODULE, filename); 11460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui it = module_dso_tree_.find(filename); 11560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 11660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return it->second.get(); 11760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 11860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 11960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuivoid ThreadTree::AddThreadMap(int pid, int tid, uint64_t start_addr, uint64_t len, uint64_t pgoff, 12060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui uint64_t time, const std::string& filename) { 12160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui ThreadEntry* thread = FindThreadOrNew(pid, tid); 12260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui DsoEntry* dso = FindUserDsoOrNew(filename); 12360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui MapEntry* map = new MapEntry{ 12460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui start_addr, len, pgoff, time, dso, 12560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui }; 12660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui map_storage_.push_back(std::unique_ptr<MapEntry>(map)); 12760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui RemoveOverlappedMap(&thread->maps, map); 12860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui auto pair = thread->maps.insert(map); 12960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui CHECK(pair.second); 13060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 13160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 13260a0ea96c0fb9e807c899759256df5e20bd904bdYabin CuiDsoEntry* ThreadTree::FindUserDsoOrNew(const std::string& filename) { 13360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui auto it = user_dso_tree_.find(filename); 13460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (it == user_dso_tree_.end()) { 13560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui user_dso_tree_[filename] = DsoFactory::GetInstance()->CreateDso(DSO_ELF_FILE, filename); 13660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui it = user_dso_tree_.find(filename); 13760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 13860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return it->second.get(); 13960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 14060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 14160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuistatic bool IsAddrInMap(uint64_t addr, const MapEntry* map) { 14260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return (addr >= map->start_addr && addr < map->start_addr + map->len); 14360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 14460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 14560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuistatic MapEntry* FindMapByAddr(const std::set<MapEntry*, MapComparator>& maps, uint64_t addr) { 14660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui // Construct a map_entry which is strictly after the searched map_entry, based on MapComparator. 14760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui MapEntry find_map = { 14860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui addr, // start_addr 14960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui ULLONG_MAX, // len 15060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 0, // pgoff 15160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui ULLONG_MAX, // time 15260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui nullptr, // dso 15360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui }; 15460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui auto it = maps.upper_bound(&find_map); 15560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (it != maps.begin() && IsAddrInMap(addr, *--it)) { 15660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return *it; 15760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 15860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return nullptr; 15960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 16060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 16160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuiconst MapEntry* ThreadTree::FindMap(const ThreadEntry* thread, uint64_t ip, bool in_kernel) { 16260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui MapEntry* result = nullptr; 16360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (!in_kernel) { 16460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui result = FindMapByAddr(thread->maps, ip); 16560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } else { 16660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui result = FindMapByAddr(kernel_map_tree_, ip); 16760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 16860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return result != nullptr ? result : &unknown_map_; 16960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 17060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui 17160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cuiconst SymbolEntry* ThreadTree::FindSymbol(const MapEntry* map, uint64_t ip) { 17260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui uint64_t offset_in_file; 17360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (map->dso == kernel_dso_.get()) { 17460a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui offset_in_file = ip; 17560a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } else { 17660a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui offset_in_file = ip - map->start_addr + map->pgoff; 17760a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 17860a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui const SymbolEntry* symbol = map->dso->FindSymbol(offset_in_file); 17960a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui if (symbol == nullptr) { 18060a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui symbol = &unknown_symbol_; 18160a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui } 18260a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui return symbol; 18360a0ea96c0fb9e807c899759256df5e20bd904bdYabin Cui} 18473d8078e6e5ef92b2301386ce96260bd99efacbbYabin Cui 185f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cuivoid BuildThreadTree(const Record& record, ThreadTree* thread_tree) { 186f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui if (record.header.type == PERF_RECORD_MMAP) { 187f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui const MmapRecord& r = *static_cast<const MmapRecord*>(&record); 188f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui if ((r.header.misc & PERF_RECORD_MISC_CPUMODE_MASK) == PERF_RECORD_MISC_KERNEL) { 189f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui thread_tree->AddKernelMap(r.data.addr, r.data.len, r.data.pgoff, r.sample_id.time_data.time, 190f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui r.filename); 191f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui } else { 192f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui thread_tree->AddThreadMap(r.data.pid, r.data.tid, r.data.addr, r.data.len, r.data.pgoff, 193f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui r.sample_id.time_data.time, r.filename); 194f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui } 195f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui } else if (record.header.type == PERF_RECORD_MMAP2) { 196f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui const Mmap2Record& r = *static_cast<const Mmap2Record*>(&record); 197f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui if ((r.header.misc & PERF_RECORD_MISC_CPUMODE_MASK) == PERF_RECORD_MISC_KERNEL) { 198f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui thread_tree->AddKernelMap(r.data.addr, r.data.len, r.data.pgoff, r.sample_id.time_data.time, 199f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui r.filename); 200f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui } else { 201f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui std::string filename = 202f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui (r.filename == DEFAULT_EXECNAME_FOR_THREAD_MMAP) ? "[unknown]" : r.filename; 203f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui thread_tree->AddThreadMap(r.data.pid, r.data.tid, r.data.addr, r.data.len, r.data.pgoff, 204f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui r.sample_id.time_data.time, filename); 20573d8078e6e5ef92b2301386ce96260bd99efacbbYabin Cui } 206f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui } else if (record.header.type == PERF_RECORD_COMM) { 207f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui const CommRecord& r = *static_cast<const CommRecord*>(&record); 208f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui thread_tree->AddThread(r.data.pid, r.data.tid, r.comm); 209f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui } else if (record.header.type == PERF_RECORD_FORK) { 210f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui const ForkRecord& r = *static_cast<const ForkRecord*>(&record); 211f8258896a364b6c996b6d6816b88849cc8d0a488Yabin Cui thread_tree->ForkThread(r.data.pid, r.data.tid, r.data.ppid, r.data.ptid); 21273d8078e6e5ef92b2301386ce96260bd99efacbbYabin Cui } 21373d8078e6e5ef92b2301386ce96260bd99efacbbYabin Cui} 214