MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / LookUpMapping

Function LookUpMapping

Source/ThirdParty/tracy/client/TracyProfiler.cpp:209–222  ·  view source on GitHub ↗

Internal implementation helper for LookUpMapping(address). Takes as input an `address` and a known vector `mappings`, assumed to be sorted by increasing addresses, as /proc/self/maps seems to be. Returns a pointer to the MappingInfo describing the mapping that this address belongs to, or nullptr if the address isn't in `mappings`.

Source from the content-addressed store, hash-verified

207// Returns a pointer to the MappingInfo describing the mapping that this
208// address belongs to, or nullptr if the address isn't in `mappings`.
209static MappingInfo* LookUpMapping(std::vector<MappingInfo>& mappings, uintptr_t address)
210{
211 // Comparison function for std::lower_bound. Returns true if all addresses in `m1`
212 // are lower than `addr`.
213 auto Compare = []( const MappingInfo& m1, uintptr_t addr ) {
214 // '<=' because the address ranges are half-open intervals, [start, end).
215 return m1.end_address <= addr;
216 };
217 auto iter = std::lower_bound( mappings.begin(), mappings.end(), address, Compare );
218 if( iter == mappings.end() || iter->start_address > address) {
219 return nullptr;
220 }
221 return &*iter;
222}
223
224// Internal implementation helper for EnsureReadable(address).
225//

Callers 1

EnsureReadableFunction · 0.85

Calls 3

ParseMappingsFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected