blob: ac74083cbd09b21294c6ce7ab5fc70eaa81f9476 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WTF_ContainerAnnotations_h
#define WTF_ContainerAnnotations_h
#include "build/build_config.h"
#include "platform/wtf/AddressSanitizer.h"
// TODO(ochang): Remove the ARCH_CPU_X86_64 condition to enable this for X86
// once the crashes there have been fixed: http://crbug.com/461406
#if defined(ADDRESS_SANITIZER) && defined(OS_LINUX) && defined(ARCH_CPU_X86_64)
#define ANNOTATE_CONTIGUOUS_CONTAINER
#define ANNOTATE_NEW_BUFFER(buffer, capacity, newSize) \
if (buffer) { \
__sanitizer_annotate_contiguous_container(buffer, (buffer) + (capacity), \
(buffer) + (capacity), \
(buffer) + (newSize)); \
}
#define ANNOTATE_DELETE_BUFFER(buffer, capacity, oldSize) \
if (buffer) { \
__sanitizer_annotate_contiguous_container(buffer, (buffer) + (capacity), \
(buffer) + (oldSize), \
(buffer) + (capacity)); \
}
#define ANNOTATE_CHANGE_SIZE(buffer, capacity, oldSize, newSize) \
if (buffer) { \
__sanitizer_annotate_contiguous_container(buffer, (buffer) + (capacity), \
(buffer) + (oldSize), \
(buffer) + (newSize)); \
}
#define ANNOTATE_CHANGE_CAPACITY(buffer, oldCapacity, bufferSize, newCapacity) \
ANNOTATE_DELETE_BUFFER(buffer, oldCapacity, bufferSize); \
ANNOTATE_NEW_BUFFER(buffer, newCapacity, bufferSize);
// Annotations require buffers to begin on an 8-byte boundary.
#else // ADDRESS_SANITIZER && OS_LINUX && ARCH_CPU_X86_64
#define ANNOTATE_NEW_BUFFER(buffer, capacity, newSize)
#define ANNOTATE_DELETE_BUFFER(buffer, capacity, oldSize)
#define ANNOTATE_CHANGE_SIZE(buffer, capacity, oldSize, newSize)
#define ANNOTATE_CHANGE_CAPACITY(buffer, oldCapacity, bufferSize, newCapacity)
#endif // ADDRESS_SANITIZER && OS_LINUX && ARCH_CPU_X86_64
#endif // WTF_ContainerAnnotations_h