Add bcc function logger to ease debug.
diff --git a/lib/bcc/bcc.cpp b/lib/bcc/bcc.cpp
index 03a9306..451be3d 100644
--- a/lib/bcc/bcc.cpp
+++ b/lib/bcc/bcc.cpp
@@ -27,6 +27,24 @@
#include <utils/StopWatch.h>
+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;
@@ -34,25 +52,29 @@
extern "C" BCCscript *bccCreateScript() {
+ BCC_FUNC_LOGGER();
return new BCCscript();
}
extern "C" BCCenum bccGetError(BCCscript *script) {
+ BCC_FUNC_LOGGER();
return script->getError();
}
extern "C" void bccDeleteScript(BCCscript *script) {
- //LOGE("Script deleted"); sliao
+ BCC_FUNC_LOGGER();
delete script;
}
extern "C" void bccRegisterSymbolCallback(BCCscript *script,
BCCSymbolLookupFn pFn,
BCCvoid *pContext) {
+ BCC_FUNC_LOGGER();
script->registerSymbolCallback(pFn, pContext);
}
extern "C" int bccReadModule(BCCscript *script, BCCvoid *module) {
+ BCC_FUNC_LOGGER();
return script->compiler.readModule(reinterpret_cast<llvm::Module*>(module));
}
@@ -63,6 +85,7 @@
long bitcodeFileCRC32,
const BCCchar *resName,
const BCCchar *cacheDir) {
+ BCC_FUNC_LOGGER();
return script->compiler.readBC(bitcode, bitcodeSize,
bitcodeFileModTime, bitcodeFileCRC32,
resName, cacheDir);
@@ -71,10 +94,12 @@
extern "C" void bccLinkBC(BCCscript *script,
const BCCchar *bitcode,
BCCint size) {
+ BCC_FUNC_LOGGER();
script->compiler.linkBC(bitcode, size);
}
extern "C" int bccLoadBinary(BCCscript *script) {
+ BCC_FUNC_LOGGER();
int result = script->compiler.loadCacheFile();
#if defined(USE_DISASSEMBLER_FILE)
@@ -88,6 +113,7 @@
}
extern "C" int bccCompileBC(BCCscript *script) {
+ BCC_FUNC_LOGGER();
#if defined(__arm__)
android::StopWatch compileTimer("RenderScript compile time");
#endif
@@ -103,6 +129,7 @@
BCCsizei maxLength,
BCCsizei *length,
BCCchar *infoLog) {
+ BCC_FUNC_LOGGER();
char const *message = script->compiler.getErrorMessage();
int messageLength = strlen(message) + 1;
if (length)
@@ -121,6 +148,7 @@
extern "C" void bccGetScriptLabel(BCCscript *script,
const BCCchar *name,
BCCvoid **address) {
+ BCC_FUNC_LOGGER();
void *value = script->compiler.lookup(name);
if (value) {
*address = value;
@@ -136,6 +164,7 @@
BCCsizei *actualVarCount,
BCCsizei maxVarCount,
BCCvoid **vars) {
+ BCC_FUNC_LOGGER();
script->compiler.getExportVars(actualVarCount, maxVarCount, vars);
#if defined(USE_DISASSEMBLER_FILE)
@@ -154,6 +183,7 @@
BCCsizei *actualFuncCount,
BCCsizei maxFuncCount,
BCCvoid **funcs) {
+ BCC_FUNC_LOGGER();
script->compiler.getExportFuncs(actualFuncCount, maxFuncCount, funcs);
#if defined(USE_DISASSEMBLER_FILE)
@@ -172,6 +202,7 @@
BCCsizei *actualStringCount,
BCCsizei maxStringCount,
BCCchar **strings) {
+ BCC_FUNC_LOGGER();
script->compiler.getPragmas(actualStringCount, maxStringCount, strings);
#if defined(USE_DISASSEMBLER_FILE)
@@ -187,6 +218,7 @@
BCCsizei *actualFunctionCount,
BCCsizei maxFunctionCount,
BCCchar **functions) {
+ BCC_FUNC_LOGGER();
script->compiler.getFunctions(actualFunctionCount,
maxFunctionCount,
functions);
@@ -196,5 +228,6 @@
BCCchar *function,
BCCvoid **base,
BCCsizei *length) {
+ BCC_FUNC_LOGGER();
script->compiler.getFunctionBinary(function, base, length);
}