2015-05-08 06:23:20 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef memory_profiler_UncensoredAllocator_h
|
|
|
|
#define memory_profiler_UncensoredAllocator_h
|
|
|
|
|
2015-08-26 13:55:55 +03:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ThreadLocal.h"
|
2015-05-08 06:23:20 +03:00
|
|
|
|
2015-08-26 13:55:55 +03:00
|
|
|
#ifdef MOZ_REPLACE_MALLOC
|
|
|
|
#include "replace_malloc_bridge.h"
|
|
|
|
#endif
|
2015-05-08 06:23:20 +03:00
|
|
|
|
|
|
|
class NativeProfiler;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-08-26 13:55:55 +03:00
|
|
|
class MallocHook final
|
2015-05-08 06:23:20 +03:00
|
|
|
{
|
2015-08-26 13:55:55 +03:00
|
|
|
public:
|
|
|
|
static void Initialize();
|
|
|
|
static void Enable(NativeProfiler* aNativeProfiler);
|
|
|
|
static void Disable();
|
|
|
|
static bool Enabled();
|
|
|
|
private:
|
|
|
|
static void* SampleNative(void* aAddr, size_t aSize);
|
|
|
|
static void RemoveNative(void* aAddr);
|
|
|
|
#ifdef MOZ_REPLACE_MALLOC
|
2015-11-23 22:11:22 +03:00
|
|
|
static MOZ_THREAD_LOCAL(bool) mEnabledTLS;
|
2015-08-26 13:55:55 +03:00
|
|
|
static NativeProfiler* mNativeProfiler;
|
|
|
|
static malloc_hook_table_t mMallocHook;
|
|
|
|
#endif
|
|
|
|
friend class AutoUseUncensoredAllocator;
|
2015-05-08 06:23:20 +03:00
|
|
|
};
|
|
|
|
|
2015-08-26 13:55:55 +03:00
|
|
|
class MOZ_RAII AutoUseUncensoredAllocator final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoUseUncensoredAllocator();
|
|
|
|
~AutoUseUncensoredAllocator();
|
|
|
|
};
|
2015-05-08 06:23:20 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // memory_profiler_UncensoredAllocator_h
|