Traces: add temporary debug info to LoadBinaryData

Unable to repro the bug by triggering tasks on swarming, hopefully this
eventually catches something.

Bug: angleproject:8307
Change-Id: I34dd0c8a9e82e54f3a07e2d7a249ddfaa543bae7
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4794110
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Commit-Queue: Roman Lavrov <romanl@google.com>
This commit is contained in:
Roman Lavrov
2023-08-18 17:46:27 -04:00
committed by Angle LUCI CQ
parent be60f87972
commit 0d701c81d0

View File

@@ -33,6 +33,23 @@ bool LoadJSONFromFile(const std::string &fileName, rapidjson::Document *doc)
doc->ParseStream(inWrapper);
return !doc->HasParseError();
}
// https://anglebug.com/8307: temporary checks (copied from RendererVk.cpp)
uint16_t ComputeCRC16(const uint8_t *data, const size_t size)
{
constexpr uint16_t kPolynomialCRC16 = 0x8408;
uint16_t rem = 0;
for (size_t i = 0; i < size; i++)
{
rem ^= data[i];
for (int j = 0; j < 8; j++)
{
rem = (rem & 1) ? kPolynomialCRC16 ^ (rem >> 1) : rem >> 1;
}
}
return rem;
}
} // namespace
bool LoadTraceNamesFromJSON(const std::string jsonFilePath, std::vector<std::string> *namesOut)
@@ -212,6 +229,10 @@ uint8_t *TraceLibrary::LoadBinaryData(const char *fileName)
std::vector<uint8_t> compressedData(size);
(void)fread(compressedData.data(), 1, size, fp);
// https://anglebug.com/8307: temporary checks
std::cout << "Compressed binary data size=" << size
<< " crc16=" << ComputeCRC16(compressedData.data(), size) << "\n";
uint32_t uncompressedSize =
zlib_internal::GetGzipUncompressedSize(compressedData.data(), compressedData.size());