Merge "Add support for coverage flushing."
am: ae0e2fc891
Change-Id: I0895c9a91e84b59a02f3f3034c3de75d3ea9826e
diff --git a/base/HidlInternal.cpp b/base/HidlInternal.cpp
index b0d867f..5fae1c4 100644
--- a/base/HidlInternal.cpp
+++ b/base/HidlInternal.cpp
@@ -25,13 +25,16 @@
#include <dirent.h>
#include <dlfcn.h>
#include <regex>
+#include <utils/misc.h>
+
+extern "C" __attribute__((weak)) void __sanitizer_cov_dump();
#endif
namespace android {
namespace hardware {
namespace details {
-void logAlwaysFatal(const char *message) {
+void logAlwaysFatal(const char* message) {
LOG(FATAL) << message;
}
@@ -42,9 +45,21 @@
mInstrumentationLibPackage(package),
mInterfaceName(interface) {
configureInstrumentation(false);
+#ifdef LIBHIDL_TARGET_DEBUGGABLE
+ if (__sanitizer_cov_dump != nullptr) {
+ ::android::add_sysprop_change_callback(
+ []() {
+ bool enableCoverage = property_get_bool("hal.coverage.enable", false);
+ if (enableCoverage) {
+ __sanitizer_cov_dump();
+ }
+ },
+ 0);
+ }
+#endif
}
-HidlInstrumentor:: ~HidlInstrumentor() {}
+HidlInstrumentor::~HidlInstrumentor() {}
void HidlInstrumentor::configureInstrumentation(bool log) {
bool enableInstrumentation = property_get_bool(