MCPcopy Create free account
hub / github.com/JRickey/BattleShip / portRelocResolvePointerDebug

Function portRelocResolvePointerDebug

port/resource/RelocPointerTable.cpp:155–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155void *portRelocResolvePointerDebug(uint32_t token, const char *file, int line)
156{
157 if (token == 0) {
158 return nullptr;
159 }
160 uint32_t index = 0;
161 if (!decodeToken(token, &index)) {
162 /* Rate-limit: an APPEAR figatree binding pass can resolve the same
163 * stale token thousands of times per frame (each joint stream re-
164 * checks). spdlog flushes on error so unrate-limited logging stalls
165 * the main thread. Cap to one log per 1024 misses; the message is
166 * the same value anyway. */
167 static uint32_t sStaleLogCount = 0;
168 if ((sStaleLogCount++ & 0x3FF) == 0) {
169 uint32_t tokenGen = token >> TOKEN_GENERATION_SHIFT;
170 uint32_t tokenIndex = token & TOKEN_INDEX_MASK;
171 uint32_t slotGen = (sSlots && tokenIndex < sNextIndex) ? sSlots[tokenIndex].gen : 0;
172 if (file != nullptr) {
173 spdlog::error("RelocPointerTable: invalid/stale token 0x{:08X} "
174 "(token_gen=0x{:03X} slot_gen=0x{:03X} index={} max={}, caller={}:{}, miss_count={})",
175 token, tokenGen, slotGen, tokenIndex, sNextIndex - 1, file, line, sStaleLogCount);
176 } else {
177 spdlog::error("RelocPointerTable: invalid/stale token 0x{:08X} "
178 "(token_gen=0x{:03X} slot_gen=0x{:03X} index={} max={}, miss_count={})",
179 token, tokenGen, slotGen, tokenIndex, sNextIndex - 1, sStaleLogCount);
180 }
181 }
182 return nullptr;
183 }
184 return sSlots[index].ptr;
185}
186
187void *portRelocTryResolvePointer(uint32_t token)
188{

Callers 1

portRelocResolvePointerFunction · 0.85

Calls 1

decodeTokenFunction · 0.85

Tested by

no test coverage detected