Audio: Add memory leak checking for HAL
$ adb shell setprop libc.debug.malloc.program android.hardware.audio.service $ adb shell setprop libc.debug.malloc.options backtrace=8 $ adb shell setenforce 0 $ adb shell pkill audioserver $ adb shell dumpsys media.audio_flinger Test: Check the audio flinger dumpsys as above. Bug: 186054996 Bug: 187462632 Change-Id: I2e8db14b816cc4cd7e1420c538505bf71fa58c97
This commit is contained in:
parent
0bb1ef2e10
commit
8f836b9499
2 changed files with 29 additions and 2 deletions
|
@ -48,6 +48,8 @@ cc_defaults {
|
||||||
"libhidlbase",
|
"libhidlbase",
|
||||||
"liblog",
|
"liblog",
|
||||||
"libmedia_helper",
|
"libmedia_helper",
|
||||||
|
"libmediautils_vendor",
|
||||||
|
"libmemunreachable",
|
||||||
"libutils",
|
"libutils",
|
||||||
"android.hardware.audio.common-util",
|
"android.hardware.audio.common-util",
|
||||||
],
|
],
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
#include <mediautils/MemoryLeakTrackUtil.h>
|
||||||
|
#include <memunreachable/memunreachable.h>
|
||||||
|
|
||||||
#include <HidlUtils.h>
|
#include <HidlUtils.h>
|
||||||
|
|
||||||
|
@ -456,9 +458,32 @@ Return<void> Device::debugDump(const hidl_handle& fd) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Return<void> Device::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& /* options */) {
|
Return<void> Device::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) {
|
||||||
if (fd.getNativeHandle() != nullptr && fd->numFds == 1) {
|
if (fd.getNativeHandle() != nullptr && fd->numFds == 1) {
|
||||||
analyzeStatus("dump", mDevice->dump(mDevice, fd->data[0]));
|
const int fd0 = fd->data[0];
|
||||||
|
bool dumpMem = false;
|
||||||
|
bool unreachableMemory = false;
|
||||||
|
for (const auto& option : options) {
|
||||||
|
if (option == "-m") {
|
||||||
|
dumpMem = true;
|
||||||
|
} else if (option == "--unreachable") {
|
||||||
|
unreachableMemory = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dumpMem) {
|
||||||
|
dprintf(fd0, "\nDumping memory:\n");
|
||||||
|
std::string s = dumpMemoryAddresses(100 /* limit */);
|
||||||
|
write(fd0, s.c_str(), s.size());
|
||||||
|
}
|
||||||
|
if (unreachableMemory) {
|
||||||
|
dprintf(fd0, "\nDumping unreachable memory:\n");
|
||||||
|
// TODO - should limit be an argument parameter?
|
||||||
|
std::string s = GetUnreachableMemoryString(true /* contents */, 100 /* limit */);
|
||||||
|
write(fd0, s.c_str(), s.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
analyzeStatus("dump", mDevice->dump(mDevice, fd0));
|
||||||
}
|
}
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue