Improve adb tracing.
The existing format was unreadable; putting the pid and tid first helps
somewhat. Also remove the unused qemu tracing which wasn't called anywhere.
Change-Id: I37ef3c556fe17b237ba1d8ca3216e2155ce5d0de
diff --git a/adb_trace.h b/adb_trace.h
index dbc7ec8..4e03165 100644
--- a/adb_trace.h
+++ b/adb_trace.h
@@ -40,22 +40,7 @@
TRACE_SERVICES,
TRACE_AUTH,
TRACE_FDEVENT,
-} ;
-
-#if !ADB_HOST
-/*
- * When running inside the emulator, guest's adbd can connect to 'adb-debug'
- * qemud service that can display adb trace messages (on condition that emulator
- * has been started with '-debug adb' option).
- */
-
-/* Delivers a trace message to the emulator via QEMU pipe. */
-void adb_qemu_trace(const char* fmt, ...);
-/* Macro to use to send ADB trace messages to the emulator. */
-#define DQ(...) adb_qemu_trace(__VA_ARGS__)
-#else
-#define DQ(...) ((void)0)
-#endif /* !ADB_HOST */
+};
extern int adb_trace_mask;
extern unsigned char adb_trace_output_count;
@@ -65,51 +50,43 @@
/* you must define TRACE_TAG before using this macro */
#if ADB_HOST
-# define D(...) \
- do { \
- if (ADB_TRACING) { \
- int save_errno = errno; \
- adb_mutex_lock(&D_lock); \
- fprintf(stderr, "%16s: %5d:%5lu | ", \
- __FUNCTION__, \
- getpid(), adb_thread_id()); \
- errno = save_errno; \
- fprintf(stderr, __VA_ARGS__ ); \
- fflush(stderr); \
- adb_mutex_unlock(&D_lock); \
- errno = save_errno; \
- } \
+# define D(fmt, ...) \
+ do { \
+ if (ADB_TRACING) { \
+ int saved_errno = errno; \
+ adb_mutex_lock(&D_lock); \
+ errno = saved_errno; \
+ fprintf(stderr, "%5d:%5lu %s | " fmt, \
+ getpid(), adb_thread_id(), __FUNCTION__, ## __VA_ARGS__); \
+ fflush(stderr); \
+ adb_mutex_unlock(&D_lock); \
+ errno = saved_errno; \
+ } \
} while (0)
-# define DR(...) \
- do { \
- if (ADB_TRACING) { \
- int save_errno = errno; \
- adb_mutex_lock(&D_lock); \
- errno = save_errno; \
- fprintf(stderr, __VA_ARGS__ ); \
- fflush(stderr); \
- adb_mutex_unlock(&D_lock); \
- errno = save_errno; \
- } \
+# define DR(...) \
+ do { \
+ if (ADB_TRACING) { \
+ int saved_errno = errno; \
+ adb_mutex_lock(&D_lock); \
+ errno = saved_errno; \
+ fprintf(stderr, __VA_ARGS__); \
+ fflush(stderr); \
+ adb_mutex_unlock(&D_lock); \
+ errno = saved_errno; \
+ } \
} while (0)
#else
-# define D(...) \
- do { \
- if (ADB_TRACING) { \
- __android_log_print( \
- ANDROID_LOG_INFO, \
- __FUNCTION__, \
- __VA_ARGS__ ); \
- } \
+# define D(...) \
+ do { \
+ if (ADB_TRACING) { \
+ __android_log_print(ANDROID_LOG_INFO, __FUNCTION__, __VA_ARGS__); \
+ } \
} while (0)
-# define DR(...) \
- do { \
- if (ADB_TRACING) { \
- __android_log_print( \
- ANDROID_LOG_INFO, \
- __FUNCTION__, \
- __VA_ARGS__ ); \
- } \
+# define DR(...) \
+ do { \
+ if (ADB_TRACING) { \
+ __android_log_print(ANDROID_LOG_INFO, __FUNCTION__, __VA_ARGS__); \
+ } \
} while (0)
#endif /* ADB_HOST */