diff options
author | 2021-02-10 21:06:27 -0800 | |
---|---|---|
committer | 2021-02-16 14:40:30 -0800 | |
commit | beba6f0a81de3145552713c2aee75c34fa0a8cdb (patch) | |
tree | f9b3dc0b0f7711dd59935b7591e6b4db3dbaaaf1 /services/surfaceflinger/ClientCache.cpp | |
parent | 7381d4840a469be409390009c2aa1b11b1d7edf1 (diff) |
SurfaceFlinger: Add ClientCache dumps
Can be useful in debugging buffer leaks.
Bug: 176691195
Test: Existing tests pass
Change-Id: I8b318f272a7da3dde76d9153b21ced94127f0d8b
Diffstat (limited to 'services/surfaceflinger/ClientCache.cpp')
-rw-r--r-- | services/surfaceflinger/ClientCache.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/services/surfaceflinger/ClientCache.cpp b/services/surfaceflinger/ClientCache.cpp index a5be01c75c..2ae49fa6bb 100644 --- a/services/surfaceflinger/ClientCache.cpp +++ b/services/surfaceflinger/ClientCache.cpp @@ -25,6 +25,8 @@ namespace android { +using base::StringAppendF; + ANDROID_SINGLETON_STATIC_INSTANCE(ClientCache); ClientCache::ClientCache() : mDeathRecipient(new CacheDeathRecipient) {} @@ -203,4 +205,18 @@ void ClientCache::CacheDeathRecipient::binderDied(const wp<IBinder>& who) { ClientCache::getInstance().removeProcess(who); } +void ClientCache::dump(std::string& result) { + std::lock_guard lock(mMutex); + for (auto i : mBuffers) { + const sp<IBinder>& cacheOwner = i.second.first; + StringAppendF(&result," Cache owner: %p\n", cacheOwner.get()); + auto &buffers = i.second.second; + for (auto& [id, clientCacheBuffer] : buffers) { + StringAppendF(&result, "\t ID: %d, Width/Height: %d,%d\n", (int)id, + (int)clientCacheBuffer.buffer->getWidth(), + (int)clientCacheBuffer.buffer->getHeight()); + } + } +} + }; // namespace android |