return Offset;
}
-void GuardedPoolAllocator::reportError(uintptr_t AccessPtr, Error Error) {
+void GuardedPoolAllocator::reportError(uintptr_t AccessPtr, Error E) {
if (SingletonPtr)
- SingletonPtr->reportErrorInternal(AccessPtr, Error);
+ SingletonPtr->reportErrorInternal(AccessPtr, E);
}
size_t GuardedPoolAllocator::getNearestSlot(uintptr_t Ptr) const {
// Prints the provided error and metadata information. Returns true if there is
// additional context that can be provided, false otherwise (i.e. returns false
// if Error == {UNKNOWN, INVALID_FREE without metadata}).
-bool printErrorType(Error Error, uintptr_t AccessPtr, AllocationMetadata *Meta,
+bool printErrorType(Error E, uintptr_t AccessPtr, AllocationMetadata *Meta,
options::Printf_t Printf) {
- switch (Error) {
+ switch (E) {
case Error::UNKNOWN:
Printf("GWP-ASan couldn't automatically determine the source of the "
"memory error when accessing 0x%zx. It was likely caused by a wild "
return true;
}
-void printThreadInformation(Error Error, uintptr_t AccessPtr,
+void printThreadInformation(Error E, uintptr_t AccessPtr,
AllocationMetadata *Meta,
options::Printf_t Printf) {
Printf("0x%zx was allocated by thread ", AccessPtr);
else
Printf("%zu.\n", Meta->AllocationTrace.ThreadID);
- if (Error == Error::USE_AFTER_FREE || Error == Error::DOUBLE_FREE) {
+ if (E == Error::USE_AFTER_FREE || E == Error::DOUBLE_FREE) {
Printf("0x%zx was freed by thread ", AccessPtr);
if (Meta->AllocationTrace.ThreadID == UINT64_MAX)
Printf("UNKNOWN.\n");
};
void GuardedPoolAllocator::reportErrorInternal(uintptr_t AccessPtr,
- Error Error) {
+ Error E) {
if (!pointerIsMine(reinterpret_cast<void *>(AccessPtr))) {
return;
}
AllocationMetadata *Meta = nullptr;
- if (Error == Error::UNKNOWN) {
- Error = diagnoseUnknownError(AccessPtr, &Meta);
+ if (E == Error::UNKNOWN) {
+ E = diagnoseUnknownError(AccessPtr, &Meta);
} else {
size_t Slot = getNearestSlot(AccessPtr);
Meta = addrToMetadata(slotToAddr(Slot));
}
// Print the error information, and if there is no valid metadata, stop here.
- if (!printErrorType(Error, AccessPtr, Meta, Printf)) {
+ if (!printErrorType(E, AccessPtr, Meta, Printf)) {
return;
}
return;
}
- printThreadInformation(Error, AccessPtr, Meta, Printf);
+ printThreadInformation(E, AccessPtr, Meta, Printf);
// TODO(hctim): Implement stack unwinding here. Ask the caller to provide us
// with the base pointer, and we unwind the stack to give a stack trace for
// the access.
// singleton pointer and call the internal version of this function. This
// method is never thread safe, and should only be called when fatal errors
// occur.
- static void reportError(uintptr_t AccessPtr, Error Error = Error::UNKNOWN);
+ static void reportError(uintptr_t AccessPtr, Error E = Error::UNKNOWN);
private:
static constexpr size_t kInvalidSlotID = SIZE_MAX;
// responsible for the error is placed in *Meta.
Error diagnoseUnknownError(uintptr_t AccessPtr, AllocationMetadata **Meta);
- void reportErrorInternal(uintptr_t AccessPtr, Error Error);
+ void reportErrorInternal(uintptr_t AccessPtr, Error E);
// Cached page size for this system in bytes.
size_t PageSize = 0;