std::vector<int> GetOnlineCpus();
-static const char* DEFAULT_KERNEL_MMAP_NAME = "[kernel.kallsyms]_text";
+constexpr char DEFAULT_KERNEL_MMAP_NAME[] = "[kernel.kallsyms]_text";
struct KernelMmap {
std::string name;
bool GetThreadComms(std::vector<ThreadComm>* thread_comms);
-static const char* DEFAULT_EXECNAME_FOR_THREAD_MMAP = "//anon";
+constexpr char DEFAULT_EXECNAME_FOR_THREAD_MMAP[] = "//anon";
struct ThreadMmap {
uint64_t start_addr;
bool GetThreadMmapsInProcess(pid_t pid, std::vector<ThreadMmap>* thread_mmaps);
-static const char* DEFAULT_KERNEL_FILENAME_FOR_BUILD_ID = "[kernel.kallsyms]";
+constexpr char DEFAULT_KERNEL_FILENAME_FOR_BUILD_ID[] = "[kernel.kallsyms]";
bool GetKernelBuildId(BuildId* build_id);
bool GetModuleBuildId(const std::string& module_name, BuildId* build_id);
auto it = thread_tree_.find(tid);
if (it == thread_tree_.end()) {
ThreadEntry* thread = new ThreadEntry{
- .pid = pid, .tid = tid,
+ pid, tid,
+ "unknown", // comm
+ std::set<MapEntry*, MapComparator>(), // maps
};
auto pair = thread_tree_.insert(std::make_pair(tid, std::unique_ptr<ThreadEntry>(thread)));
CHECK(pair.second);
}
DsoEntry* dso = FindKernelDsoOrNew(filename);
MapEntry* map = new MapEntry{
- .start_addr = start_addr, .len = len, .pgoff = pgoff, .time = time, .dso = dso,
+ start_addr, len, pgoff, time, dso,
};
map_storage_.push_back(std::unique_ptr<MapEntry>(map));
RemoveOverlappedMap(&kernel_map_tree_, map);
ThreadEntry* thread = FindThreadOrNew(pid, tid);
DsoEntry* dso = FindUserDsoOrNew(filename);
MapEntry* map = new MapEntry{
- .start_addr = start_addr, .len = len, .pgoff = pgoff, .time = time, .dso = dso,
+ start_addr, len, pgoff, time, dso,
};
map_storage_.push_back(std::unique_ptr<MapEntry>(map));
RemoveOverlappedMap(&thread->maps, map);
const MapEntry* SampleTree::FindMap(const ThreadEntry* thread, uint64_t ip, bool in_kernel) {
// Construct a map_entry which is strictly after the searched map_entry, based on MapComparator.
MapEntry find_map = {
- .start_addr = ip, .len = static_cast<uint64_t>(-1), .time = static_cast<uint64_t>(-1),
+ ip, // start_addr
+ ULLONG_MAX, // len
+ 0, // pgoff
+ ULLONG_MAX, // time
+ nullptr, // dso
};
if (!in_kernel) {
auto it = thread->maps.upper_bound(&find_map);
const SymbolEntry* symbol = FindSymbol(map, ip);
SampleEntry sample = {
- .ip = ip,
- .time = time,
- .period = period,
- .sample_count = 1,
- .thread = thread,
- .thread_comm = thread->comm,
- .map = map,
- .symbol = symbol,
+ ip, time, period,
+ 1, // sample_count
+ thread,
+ thread->comm, // thead_comm
+ map, symbol,
+ BranchFromEntry{
+ 0, // ip
+ nullptr, // map
+ nullptr, // symbol
+ 0, // flags
+ },
};
InsertSample(sample);
}
}
const SymbolEntry* to_symbol = FindSymbol(to_map, to_ip);
- BranchFromEntry branch_from = {
- .ip = from_ip, .map = from_map, .symbol = from_symbol, .flags = branch_flags,
- };
- SampleEntry sample = {
- .ip = to_ip,
- .time = time,
- .period = period,
- .sample_count = 1,
- .thread = thread,
- .thread_comm = thread->comm,
- .map = to_map,
- .symbol = to_symbol,
- .branch_from = branch_from,
- };
+ SampleEntry sample = {to_ip, // ip
+ time, period,
+ 1, // sample_count
+ thread,
+ thread->comm, // thread_comm
+ to_map, // map
+ to_symbol, // symbol
+ BranchFromEntry{
+ from_ip, // ip
+ from_map, // map
+ from_symbol, // symbol
+ branch_flags, // flags
+ }};
InsertSample(sample);
}
sorted_sample_tree_(sorted_sample_comparator_),
total_samples_(0),
total_period_(0) {
- unknown_map_ = {
- .start_addr = 0, .len = ULLONG_MAX, .pgoff = 0, .time = 0, .dso = &unknown_dso_,
+ unknown_map_ = MapEntry{
+ 0, // start_addr
+ ULLONG_MAX, // len
+ 0, // pgoff
+ 0, // time
+ &unknown_dso_, // dso
};
- unknown_dso_ = {
- .path = "unknown",
- };
- unknown_symbol_ = {
- .name = "unknown", .addr = 0, .len = ULLONG_MAX,
+ unknown_dso_.path = "unknown";
+ unknown_symbol_ = SymbolEntry{
+ "unknown", // name
+ 0, // addr
+ ULLONG_MAX, // len
};
}