GuardData::GuardData(DebugData* debug_data, int init_value, size_t num_bytes)
: OptionData(debug_data) { // Create a buffer for fast comparisons of the front guard.
cmp_mem_.resize(num_bytes);
memset(cmp_mem_.data(), init_value, cmp_mem_.size());
}
// Log all of the failing bytes. const uint8_t* expected = cmp_mem_.data(); int pointer_idx = reinterpret_cast<uintptr_t>(data) - reinterpret_cast<uintptr_t>(pointer); const uint8_t* real = reinterpret_cast<const uint8_t*>(data); for (size_t i = 0; i < cmp_mem_.size(); i++, pointer_idx++) { if (real[i] != expected[i]) {
error_log(" allocation[%d] = 0x%02x (expected 0x%02x)", pointer_idx, real[i], expected[i]);
}
}
error_log("Backtrace at time of failure:");
BacktraceAndLog();
error_log(LOG_DIVIDER); if (g_debug->config().options() & ABORT_ON_ERROR) {
abort();
}
}
FrontGuardData::FrontGuardData(DebugData* debug_data, const Config& config, size_t* offset)
: GuardData(debug_data, config.front_guard_value(), config.front_guard_bytes()) { // Create a buffer for fast comparisons of the front guard.
cmp_mem_.resize(config.front_guard_bytes());
memset(cmp_mem_.data(), config.front_guard_value(), cmp_mem_.size()); // Assumes that front_bytes is a multiple of MINIMUM_ALIGNMENT_BYTES.
offset_ = *offset;
*offset += config.front_guard_bytes();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.