libcutils: add support for app tracing

This change adds support for tracing using the ATRACE_TAG_APP tag.  This tag is
enabled only for processes in which the /proc/<pid>/cmdline value appears in
the comma-separated list of such values in the debug.atrace.app_cmdlines system
property.  It is also only enabled if either the ro.debuggable system property
is set to 1 or the application has declared itself debuggable in its manifest,
which gets reported to libcutils by the framework.

Change-Id: Ic94ba55f4e70a9cf994056acbf151e523428b65d
diff --git a/include/cutils/trace.h b/include/cutils/trace.h
index ad65dfb..55aabdd 100644
--- a/include/cutils/trace.h
+++ b/include/cutils/trace.h
@@ -20,6 +20,7 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <unistd.h>
 #include <cutils/compiler.h>
 
@@ -62,7 +63,8 @@
 #define ATRACE_TAG_VIDEO            (1<<9)
 #define ATRACE_TAG_CAMERA           (1<<10)
 #define ATRACE_TAG_HAL              (1<<11)
-#define ATRACE_TAG_LAST             ATRACE_TAG_HAL
+#define ATRACE_TAG_APP              (1<<12)
+#define ATRACE_TAG_LAST             ATRACE_TAG_APP
 
 // Reserved for initialization.
 #define ATRACE_TAG_NOT_READY        (1LL<<63)
@@ -97,6 +99,14 @@
 void atrace_update_tags();
 
 /**
+ * Set whether the process is debuggable.  By default the process is not
+ * considered debuggable.  If the process is not debuggable then application-
+ * level tracing is not allowed unless the ro.debuggable system property is
+ * set to '1'.
+ */
+void atrace_set_debuggable(bool debuggable);
+
+/**
  * Flag indicating whether setup has been completed, initialized to 0.
  * Nonzero indicates setup has completed.
  * Note: This does NOT indicate whether or not setup was successful.