am 802d1384: Revert "Remove USE_LOGGER and DebugHelper.c."
* commit '802d1384b9d2285780fd709222793e33c68c62b2':
Revert "Remove USE_LOGGER and DebugHelper.c."
diff --git a/helper/Android.mk b/helper/Android.mk
index 54b408b..ecba95f 100644
--- a/helper/Android.mk
+++ b/helper/Android.mk
@@ -57,6 +57,7 @@
LOCAL_C_INCLUDES := $(libbcc_C_INCLUDES)
LOCAL_SRC_FILES := \
+ DebugHelper.c \
sha1.c
include $(LIBBCC_ROOT_PATH)/libbcc-gen-config-from-mk.mk
diff --git a/helper/DebugHelper.c b/helper/DebugHelper.c
new file mode 100644
index 0000000..5c01b1b
--- /dev/null
+++ b/helper/DebugHelper.c
@@ -0,0 +1,29 @@
+#include "DebugHelper.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define LOG_BUF_SIZE 1024
+
+#if USE_LOGGER && !defined(__arm__)
+int __android_log_print(int prio, const char *tag, const char *fmt, ...) {
+ va_list ap;
+ char buf[LOG_BUF_SIZE];
+
+ va_start(ap, fmt);
+ vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
+ va_end(ap);
+
+ return __android_log_write(prio, tag, buf);
+}
+
+int __android_log_write(int prio, const char *tag, const char *msg) {
+ if (!tag) {
+ tag = "";
+ }
+
+ return fprintf(stderr, "[%s] %s\n", tag, msg);
+}
+#endif // USE_LOGGER && !defined(__arm__)
diff --git a/helper/DebugHelper.h b/helper/DebugHelper.h
index ae1d4af..ae68e3a 100644
--- a/helper/DebugHelper.h
+++ b/helper/DebugHelper.h
@@ -19,9 +19,30 @@
#include "Config.h"
+#if USE_LOGGER
+
#define LOG_TAG "bcc"
#include <cutils/log.h>
+#else // !USE_LOGGER
+
+#undef ALOGV
+#undef ALOGI
+#undef ALOGD
+#undef ALOGW
+#undef ALOGE
+#undef LOGA
+
+#define ALOGV(...)
+#define ALOGI(...)
+#define ALOGD(...)
+#define ALOGW(...)
+#define ALOGE(...)
+#define LOGA(...)
+
+#endif
+
+
#if !USE_FUNC_LOGGER
#define BCC_FUNC_LOGGER()
diff --git a/lib/ExecutionEngine/FileHandle.cpp b/lib/ExecutionEngine/FileHandle.cpp
index c659fb5..c0a344c 100644
--- a/lib/ExecutionEngine/FileHandle.cpp
+++ b/lib/ExecutionEngine/FileHandle.cpp
@@ -37,7 +37,9 @@
static int const lock_flags[2] = { LOCK_SH, LOCK_EX };
+#if USE_LOGGER
static char const *const open_mode_str[2] = { "read", "write" };
+#endif
static size_t const RETRY_MAX = 4;
diff --git a/libbcc-config.mk b/libbcc-config.mk
index 90e6fab..37cc848 100644
--- a/libbcc-config.mk
+++ b/libbcc-config.mk
@@ -30,6 +30,7 @@
libbcc_DEBUG_MC_DISASSEMBLER := 0
+libbcc_USE_LOGGER := 1
libbcc_USE_FUNC_LOGGER := 0
libbcc_DEBUG_BCC_REFLECT := 0
libbcc_DEBUG_MC_REFLECT := 0