Add a utility class QemuTracerAuto when WEBCORE_INSTRUMENTATION is on.
diff --git a/Android.jsc.mk b/Android.jsc.mk
index 2643afd..be45278 100644
--- a/Android.jsc.mk
+++ b/Android.jsc.mk
@@ -207,6 +207,10 @@
 	libicui18n \
 	libmedia
 
+ifeq ($(WEBCORE_INSTRUMENTATION),true)
+LOCAL_SHARED_LIBRARIES += libhardware_legacy
+endif
+
 # We have to use the android version of libdl when we are not on the simulator
 ifneq ($(TARGET_SIMULATOR),true)
 LOCAL_SHARED_LIBRARIES += libdl
diff --git a/Android.v8.mk b/Android.v8.mk
index 577a884..070338c 100644
--- a/Android.v8.mk
+++ b/Android.v8.mk
@@ -203,6 +203,10 @@
 	libicui18n \
 	libmedia
 
+ifeq ($(WEBCORE_INSTRUMENTATION),true)
+LOCAL_SHARED_LIBRARIES += libhardware_legacy
+endif
+
 # We have to use the android version of libdl when we are not on the simulator
 ifneq ($(TARGET_SIMULATOR),true)
 LOCAL_SHARED_LIBRARIES += libdl
diff --git a/WebKit/android/TimeCounter.h b/WebKit/android/TimeCounter.h
index c78d10f..47e681b 100644
--- a/WebKit/android/TimeCounter.h
+++ b/WebKit/android/TimeCounter.h
@@ -28,6 +28,7 @@
 
 #ifdef ANDROID_INSTRUMENT
 
+#include "hardware_legacy/qemu_tracing.h"
 #include <wtf/CurrentTime.h>
 
 namespace WebCore {
@@ -95,6 +96,12 @@
     uint32_t m_startTime;
 };
 
+class QemuTracerAuto {
+public:
+    QemuTracerAuto() { qemu_start_tracing(); }
+    ~QemuTracerAuto() { qemu_stop_tracing(); }
+};
+
 }
 #endif