use gcov to measure the code coverage and return the measured data back
to the host

Change-Id: Ia9393ccb8dd3f3321f545abb9d20a6d37de5765f
diff --git a/sysfuzzer/common/component_loader/DllLoader.cpp b/sysfuzzer/common/component_loader/DllLoader.cpp
index a13745e..8dc3966 100644
--- a/sysfuzzer/common/component_loader/DllLoader.cpp
+++ b/sysfuzzer/common/component_loader/DllLoader.cpp
@@ -109,5 +109,50 @@
   return func;
 }
 
+bool DllLoader::SancovResetCoverage() {
+  const char* error;
+  void (*func)();
+
+  func = (void (*)()) dlsym(handle_, "__sanitizer_reset_coverage");
+  if ((error = dlerror()) != NULL)  {
+    fputs(error, stderr);
+    cerr << __FUNCTION__ << ": Can't find __sanitizer_reset_coverage" << endl;
+    return false;
+  }
+  func();
+  return true;
+}
+
+
+bool DllLoader::GcovInit(writeout_fn wfn, flush_fn ffn) {
+  const char* error;
+  void (*func)(writeout_fn, flush_fn);
+
+  func = (void (*)(writeout_fn, flush_fn)) dlsym(handle_, "llvm_gcov_init");
+  if ((error = dlerror()) != NULL)  {
+    fputs(error, stderr);
+    cerr << __FUNCTION__ << ": Can't find llvm_gcov_init" << endl;
+    return false;
+  }
+  func(wfn, ffn);
+  return true;
+}
+
+
+bool DllLoader::GcovFlush() {
+  const char* error;
+  void (*func)();
+
+  func = (void (*)()) dlsym(handle_, "__gcov_flush");
+  if ((error = dlerror()) != NULL)  {
+    fputs(error, stderr);
+    cerr << __FUNCTION__ << ": Can't find __gcov_flush" << endl;
+    return false;
+  }
+  func();
+
+  return true;
+}
+
 }  // namespace vts
 }  // namespace android