MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / ensureCoverageMapLoaded

Function ensureCoverageMapLoaded

src/Common/CoverageCollection.cpp:60–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58std::once_flag g_coverage_map_once;
59
60void ensureCoverageMapLoaded()
61{
62 std::call_once(g_coverage_map_once, []
63 {
64 const auto regions = readLLVMCoverageMapping("/proc/self/exe");
65 g_coverage_map.reserve(regions.size());
66 for (const CoverageRegion & r : regions)
67 {
68 const CoverageKey key{r.name_hash, r.func_hash, r.counter_id};
69 auto [it, inserted] = g_coverage_map.emplace(key, r);
70 if (!inserted)
71 {
72 /// Keep the narrowest region for this counter. Prefer branch regions
73 /// over code regions of the same width — they carry directional info.
74 const uint32_t existing_width = it->second.line_end - it->second.line_start;
75 const uint32_t new_width = r.line_end - r.line_start;
76 if (new_width < existing_width
77 || (new_width == existing_width && r.is_branch && !it->second.is_branch))
78 it->second = r;
79 }
80 }
81
82 LOG_INFO(
83 getLogger("CoverageCollection"),
84 "Loaded {} counter regions from LLVM coverage mapping ({} raw regions)",
85 g_coverage_map.size(), regions.size());
86 });
87}
88
89} // anonymous namespace
90

Callers 6

collectAndInsertCoverageFunction · 0.85
getCoverageMapSizeFunction · 0.85
countCoverageMatchesFunction · 0.85
getFirstCoverageMapKeyFunction · 0.85
diagCoverageRegionsFunction · 0.85

Calls 5

readLLVMCoverageMappingFunction · 0.85
getLoggerFunction · 0.70
reserveMethod · 0.45
sizeMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected