mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 06:22:53 +00:00
Merge "Audio: Add memory leak checking for HAL" into sc-v2-dev am: 6a95f0508c
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/15239828 Change-Id: I28e787f0b3d2755a9d7c39cc05d84bbc4541fab3
This commit is contained in:
@@ -48,6 +48,8 @@ cc_defaults {
|
||||
"libhidlbase",
|
||||
"liblog",
|
||||
"libmedia_helper",
|
||||
"libmediautils_vendor",
|
||||
"libmemunreachable",
|
||||
"libutils",
|
||||
"android.hardware.audio.common-util",
|
||||
],
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <android/log.h>
|
||||
#include <mediautils/MemoryLeakTrackUtil.h>
|
||||
#include <memunreachable/memunreachable.h>
|
||||
|
||||
#include <HidlUtils.h>
|
||||
|
||||
@@ -456,9 +458,32 @@ Return<void> Device::debugDump(const hidl_handle& fd) {
|
||||
}
|
||||
#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) {
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user