本文整理汇总了C++中std::unique_ptr::AddThread方法的典型用法代码示例。如果您正苦于以下问题:C++ unique_ptr::AddThread方法的具体用法?C++ unique_ptr::AddThread怎么用?C++ unique_ptr::AddThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::unique_ptr
的用法示例。
在下文中一共展示了unique_ptr::AddThread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadSampleTreeFromRecordFile
void ReportCommand::ReadSampleTreeFromRecordFile() {
sample_tree_->AddThread(0, 0, "swapper");
std::vector<std::unique_ptr<const Record>> records = record_file_reader_->DataSection();
for (auto& record : records) {
if (record->header.type == PERF_RECORD_MMAP) {
const MmapRecord& r = *static_cast<const MmapRecord*>(record.get());
if ((r.header.misc & PERF_RECORD_MISC_CPUMODE_MASK) == PERF_RECORD_MISC_KERNEL) {
sample_tree_->AddKernelMap(r.data.addr, r.data.len, r.data.pgoff,
r.sample_id.time_data.time, r.filename);
} else {
sample_tree_->AddThreadMap(r.data.pid, r.data.tid, r.data.addr, r.data.len, r.data.pgoff,
r.sample_id.time_data.time, r.filename);
}
} else if (record->header.type == PERF_RECORD_MMAP2) {
const Mmap2Record& r = *static_cast<const Mmap2Record*>(record.get());
if ((r.header.misc & PERF_RECORD_MISC_CPUMODE_MASK) == PERF_RECORD_MISC_KERNEL) {
sample_tree_->AddKernelMap(r.data.addr, r.data.len, r.data.pgoff,
r.sample_id.time_data.time, r.filename);
} else {
std::string filename =
(r.filename == DEFAULT_EXECNAME_FOR_THREAD_MMAP) ? "[unknown]" : r.filename;
sample_tree_->AddThreadMap(r.data.pid, r.data.tid, r.data.addr, r.data.len, r.data.pgoff,
r.sample_id.time_data.time, filename);
}
} else if (record->header.type == PERF_RECORD_SAMPLE) {
ProcessSampleRecord(*static_cast<const SampleRecord*>(record.get()));
} else if (record->header.type == PERF_RECORD_COMM) {
const CommRecord& r = *static_cast<const CommRecord*>(record.get());
sample_tree_->AddThread(r.data.pid, r.data.tid, r.comm);
} else if (record->header.type == PERF_RECORD_FORK) {
const ForkRecord& r = *static_cast<const ForkRecord*>(record.get());
sample_tree_->ForkThread(r.data.pid, r.data.tid, r.data.ppid, r.data.ptid);
}
}
}