Create DebugHelper.h
From now on, include DebugHelper.h for debug purpose.
diff --git a/lib/bcc/CacheReader.cpp b/lib/bcc/CacheReader.cpp
index 7288b19..4dd09d3 100644
--- a/lib/bcc/CacheReader.cpp
+++ b/lib/bcc/CacheReader.cpp
@@ -14,12 +14,10 @@
* limitations under the License.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "CacheReader.h"
#include "ContextManager.h"
+#include "DebugHelper.h"
#include "FileHandle.h"
#include "ScriptCached.h"
diff --git a/lib/bcc/CacheWriter.cpp b/lib/bcc/CacheWriter.cpp
index b0971ba..67def9b 100644
--- a/lib/bcc/CacheWriter.cpp
+++ b/lib/bcc/CacheWriter.cpp
@@ -14,12 +14,10 @@
* limitations under the License.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "CacheWriter.h"
#include "ContextManager.h"
+#include "DebugHelper.h"
#include "FileHandle.h"
#include "Script.h"
diff --git a/lib/bcc/Compiler.cpp b/lib/bcc/Compiler.cpp
index c7dfa29..b1bd093 100644
--- a/lib/bcc/Compiler.cpp
+++ b/lib/bcc/Compiler.cpp
@@ -14,14 +14,12 @@
* limitations under the License.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "Compiler.h"
#include "Config.h"
#include "ContextManager.h"
+#include "DebugHelper.h"
#include "ScriptCompiled.h"
#include "Sha1Helper.h"
diff --git a/lib/bcc/ContextManager.cpp b/lib/bcc/ContextManager.cpp
index 0fe9f78..e007fe9 100644
--- a/lib/bcc/ContextManager.cpp
+++ b/lib/bcc/ContextManager.cpp
@@ -14,11 +14,10 @@
* limitations under the license.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "ContextManager.h"
+#include "DebugHelper.h"
+
#include <llvm/System/Mutex.h>
#include <llvm/Support/MutexGuard.h>
diff --git a/lib/bcc/ContextManager.h b/lib/bcc/ContextManager.h
index 4267a9e..98cddfe 100644
--- a/lib/bcc/ContextManager.h
+++ b/lib/bcc/ContextManager.h
@@ -21,6 +21,7 @@
#include <llvm/System/Mutex.h>
+#include <unistd.h>
#include <stddef.h>
diff --git a/lib/bcc/DebugHelper.h b/lib/bcc/DebugHelper.h
new file mode 100644
index 0000000..8653a68
--- /dev/null
+++ b/lib/bcc/DebugHelper.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BCC_DEBUGHELPER_H
+#define BCC_DEBUGHELPER_H
+
+#include "Config.h"
+
+#if USE_LOGGER
+
+#define LOG_TAG "bcc"
+#include <cutils/log.h>
+
+#else // !USE_LOGGER
+
+#undef LOGV
+#undef LOGI
+#undef LOGD
+#undef LOGW
+#undef LOGE
+#undef LOGA
+
+#define LOGV(...)
+#define LOGI(...)
+#define LOGD(...)
+#define LOGW(...)
+#define LOGE(...)
+#define LOGA(...)
+
+#endif
+
+
+#if !USE_FUNC_LOGGER
+
+#define BCC_FUNC_LOGGER()
+
+#else // USE_FUNC_LOGGER
+
+namespace bcc {
+ class FuncLogger {
+ private:
+ char const *mFuncName;
+
+ public:
+ FuncLogger(char const *name) : mFuncName(name) {
+ LOGD("---> BEGIN: libbcc [ %s ]\n", name);
+ }
+
+ ~FuncLogger() {
+ LOGD("---> END: libbcc [ %s ]\n", mFuncName);
+ }
+ };
+} // namespace bcc
+
+#define BCC_FUNC_LOGGER() bcc::FuncLogger XX__FuncLogger(__func__)
+
+#endif
+
+#endif // BCC_DEBUGHELPER_H
diff --git a/lib/bcc/FileHandle.cpp b/lib/bcc/FileHandle.cpp
index 7dcb065..919cb48 100644
--- a/lib/bcc/FileHandle.cpp
+++ b/lib/bcc/FileHandle.cpp
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "FileHandle.h"
+#include "DebugHelper.h"
+
#include <errno.h>
#include <fcntl.h>
#include <sys/file.h>
diff --git a/lib/bcc/Script.cpp b/lib/bcc/Script.cpp
index 7e8e10d..8ee60c9 100644
--- a/lib/bcc/Script.cpp
+++ b/lib/bcc/Script.cpp
@@ -14,9 +14,6 @@
* limitations under the license.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "Script.h"
#include "Config.h"
@@ -24,6 +21,7 @@
#include "CacheReader.h"
#include "CacheWriter.h"
#include "ContextManager.h"
+#include "DebugHelper.h"
#include "FileHandle.h"
#include "ScriptCompiled.h"
#include "ScriptCached.h"
diff --git a/lib/bcc/ScriptCached.cpp b/lib/bcc/ScriptCached.cpp
index 183e552..b1dd9ce 100644
--- a/lib/bcc/ScriptCached.cpp
+++ b/lib/bcc/ScriptCached.cpp
@@ -14,14 +14,12 @@
* limitations under the License.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "ScriptCached.h"
#include <bcc/bcc_cache.h>
#include "ContextManager.h"
+#include "DebugHelper.h"
#include <stdlib.h>
diff --git a/lib/bcc/ScriptCompiled.cpp b/lib/bcc/ScriptCompiled.cpp
index 7aa29f1..d38b447 100644
--- a/lib/bcc/ScriptCompiled.cpp
+++ b/lib/bcc/ScriptCompiled.cpp
@@ -14,13 +14,11 @@
* limitations under the License.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "ScriptCompiled.h"
#include "bcc_internal.h"
#include "ContextManager.h"
+#include "DebugHelper.h"
namespace bcc {
diff --git a/lib/bcc/Sha1Helper.cpp b/lib/bcc/Sha1Helper.cpp
index 90d5ac6..f4589c9 100644
--- a/lib/bcc/Sha1Helper.cpp
+++ b/lib/bcc/Sha1Helper.cpp
@@ -14,13 +14,11 @@
* limitations under the license.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "Sha1Helper.h"
#include "Config.h"
+#include "DebugHelper.h"
#include "FileHandle.h"
#include <string.h>
diff --git a/lib/bcc/Sha1Helper.h b/lib/bcc/Sha1Helper.h
index 4a1a148..5e98036 100644
--- a/lib/bcc/Sha1Helper.h
+++ b/lib/bcc/Sha1Helper.h
@@ -19,7 +19,7 @@
#include "Config.h"
-#include <stdint.h>
+#include <stddef.h>
namespace bcc {
#if USE_LIBBCC_SHA1SUM
diff --git a/lib/bcc/SourceInfo.cpp b/lib/bcc/SourceInfo.cpp
index fb63cf4..e4704c7 100644
--- a/lib/bcc/SourceInfo.cpp
+++ b/lib/bcc/SourceInfo.cpp
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include "SourceInfo.h"
#if USE_CACHE
@@ -24,6 +21,7 @@
#include "CacheWriter.h"
#endif
+#include "DebugHelper.h"
#include "ScriptCompiled.h"
#include "Sha1Helper.h"
diff --git a/lib/bcc/bcc.cpp b/lib/bcc/bcc.cpp
index e6972fe..ce7d7d0 100644
--- a/lib/bcc/bcc.cpp
+++ b/lib/bcc/bcc.cpp
@@ -17,15 +17,13 @@
// Bitcode compiler (bcc) for Android:
// This is an eager-compilation JIT running on Android.
-#define LOG_TAG "bcc"
-#include <cutils/log.h>
-
#include <bcc/bcc.h>
#include "bcc_internal.h"
#include "Config.h"
#include "Compiler.h"
+#include "DebugHelper.h"
#include "Script.h"
#include <utils/StopWatch.h>
@@ -34,24 +32,6 @@
char const libbcc_build_time[24] = __DATE__ " " __TIME__;
-namespace bcc {
- class FuncLogger {
- private:
- char const *mFuncName;
-
- public:
- FuncLogger(char const *name) : mFuncName(name) {
- // LOGI("---> BEGIN: libbcc [ %s ]\n", name);
- }
-
- ~FuncLogger() {
- // LOGI("---> END: libbcc [ %s ]\n", mFuncName);
- }
- };
-
-#define BCC_FUNC_LOGGER() bcc::FuncLogger XX__funcLogger(__FUNCTION__)
-} // namespace bcc
-
namespace llvm {
class Module;