Hash :
58d7ace2
Author :
Date :
2022-11-22T16:08:07
Vulkan: Add memory allocation log support in debug
* Added a memory tracker to the renderer object to keep track of the
memory allocations and deallocations in more detail.
* This feature is used for debugging only.
* To enable it, set angle_enable_memory_alloc_logging=true in GN args
(added in renderer/vulkan/BUILD).
* It is related to ANGLE_ENABLE_MEMORY_ALLOC_LOGGING in the code.
* The tracker are updated in the memory allocation tracking functions
if the feature is enabled. (The counter is always updated, even if
the feature is disabled.)
* At the end of a RendererVk object, it checks for and logs any
remaining allocated memory from MemoryAllocationType members.
* The data is stored in the map object "mMemoryAllocationTracker".
The key used for it is currently of type angle::BacktraceInfo.
* If angle_enable_unwind_backtrace_support is disabled, or not on
Android, the key is an empty object.
* MemoryAllocInfoMapKey is used as a key to access the allocation
information.
Bug: b/242641395
Change-Id: If701a4bdea2f8738a830ee47e0c7c5cdacf95b87
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4050103
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
//
// Copyright 2022 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// backtrace_utils.h:
// Tools to extract the backtrace from the ANGLE code during execution.
//
#ifndef COMMON_BACKTRACEUTILS_H_
#define COMMON_BACKTRACEUTILS_H_
#include <string>
#include <vector>
#include "debug.h"
#include "hash_utils.h"
namespace angle
{
// Used to store the backtrace information, such as the stack addresses and symbols.
class BacktraceInfo
{
public:
BacktraceInfo() {}
~BacktraceInfo() {}
void clear()
{
mStackAddresses.clear();
mStackSymbols.clear();
}
size_t getSize() const
{
ASSERT(mStackAddresses.size() == mStackSymbols.size());
return mStackAddresses.size();
}
std::vector<void *> getStackAddresses() const { return mStackAddresses; }
std::vector<std::string> getStackSymbols() const { return mStackSymbols; }
bool operator==(const BacktraceInfo &rhs) const
{
return mStackAddresses == rhs.mStackAddresses;
}
void *getStackAddress(size_t index) const
{
ASSERT(index < mStackAddresses.size());
return mStackAddresses[index];
}
std::string getStackSymbol(size_t index) const
{
ASSERT(index < mStackSymbols.size());
return mStackSymbols[index];
}
size_t hash() const { return ComputeGenericHash(*this); }
// Used to add the stack addresses and their corresponding symbols to the object, when
// angle_enable_unwind_backtrace_support is enabled on Android.
void populateBacktraceInfo(void **stackAddressBuffer, size_t stackAddressCount);
private:
std::vector<void *> mStackAddresses;
std::vector<std::string> mStackSymbols;
};
// Used to obtain the stack addresses and symbols from the device, when
// angle_enable_unwind_backtrace_support is enabled on Android. Otherwise , it returns an empty
// object.
BacktraceInfo getBacktraceInfo();
// Used to print the stack addresses and symbols embedded in the BacktraceInfo object.
void printBacktraceInfo(BacktraceInfo backtraceInfo);
} // namespace angle
// Introduce std::hash for BacktraceInfo so it can be used as key for angle::HashMap.
namespace std
{
template <>
struct hash<angle::BacktraceInfo>
{
size_t operator()(const angle::BacktraceInfo &key) const { return key.hash(); }
};
} // namespace std
#endif // COMMON_BACKTRACEUTILS_H_