MCPcopy Create free account
hub / github.com/apple/foundationdb / debugFileCheck

Function debugFileCheck

fdbrpc/TraceFileIO.cpp:67–123  ·  view source on GitHub ↗

Checks that a given block of data is the same as what has been written by a call to debugFileSet

Source from the content-addressed store, hash-verified

65
66// Checks that a given block of data is the same as what has been written by a call to debugFileSet
67void debugFileCheck(std::string context, std::string file, const void* data, int64_t offset, int length) {
68 if (debugFileRegions.empty())
69 debugFileSetup();
70 if (debugFileTrim(file) == debugFileName) {
71 bool found = false;
72 for (auto itr = debugFileRegions.begin(); itr != debugFileRegions.end(); ++itr) {
73 if (offset + length > itr->first && offset < itr->first + itr->second) {
74 found = true;
75 uint8_t* storeData = debugFileData[itr->first];
76 uint8_t* storeMask = debugFileMask[itr->first];
77
78 ASSERT(storeData && storeMask);
79
80 int64_t dataOffset = std::max((int64_t)0, itr->first - offset);
81 int64_t dbgOffset = std::max((int64_t)0, offset - itr->first);
82 int64_t cmpLength = std::min(length - dataOffset, itr->second - dbgOffset);
83 ASSERT(cmpLength > 0);
84 TraceEvent("DebugFileCheck")
85 .detail("Context", context)
86 .detail("Filename", file)
87 .detail("Offset", offset)
88 .detail("Length", length);
89 bool success = true;
90 if (debugFileIsSet(storeMask, dbgOffset, cmpLength)) {
91 //TraceEvent("DebugFileCheckMemCmp").detail("Context", context).detail("Filename", file).detail("Offset", offset).detail("Length", length).detail("DataOffset", dataOffset).detail("DbgOffset", dbgOffset).detail("OverlapLength", cmpLength);
92 if (memcmp(&((uint8_t*)data)[dataOffset], &storeData[dbgOffset], cmpLength))
93 success = false;
94 } else {
95 TraceEvent("DebugFileUnsetCheck")
96 .detail("Context", context)
97 .detail("Filename", file)
98 .detail("Offset", offset)
99 .detail("Length", length);
100 for (int64_t i = 0; i < cmpLength; i++) {
101 if (storeMask[dbgOffset + i] && storeData[dbgOffset + i] != ((uint8_t*)data)[dataOffset + i]) {
102 success = false;
103 break;
104 }
105 }
106 }
107
108 if (!success)
109 TraceEvent(SevWarnAlways, "DebugFileFail")
110 .detail("Context", context)
111 .detail("Filename", file)
112 .detail("Offset", offset)
113 .detail("Length", length);
114 }
115 }
116 if (!found)
117 TraceEvent("DebugFileSkippingCheck")
118 .detail("Context", context)
119 .detail("Filename", file)
120 .detail("Offset", offset)
121 .detail("Length", length);
122 }
123}
124

Callers 3

read_implMethod · 0.85
write_implMethod · 0.85
onReadFunction · 0.85

Calls 8

debugFileSetupFunction · 0.85
debugFileTrimFunction · 0.85
TraceEventClass · 0.85
debugFileIsSetFunction · 0.85
detailMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected