帮客户公司分析游戏的安全性,对方给过来的是ipa格式的游戏包,通过解压解密,拿到了游戏包里面的lua源码
但是在调试lua源码时,在代码里使用print、release_print等 都无法在手机的控制台里看到输出日志
这种情况大家一般怎么处理的?
帮客户公司分析游戏的安全性,对方给过来的是ipa格式的游戏包,通过解压解密,拿到了游戏包里面的lua源码
但是在调试lua源码时,在代码里使用print、release_print等 都无法在手机的控制台里看到输出日志
这种情况大家一般怎么处理的?
在线求助 紫薯布丁
如果我没有记错的话
print 在c++是处理过的
release模式下是没有日志的
这种情况 有什么办法能打印日志吗?
安卓原生日志可以打印 或者你修改他so代码也可以打印
release_print=print
// Register our version of the global "print" function
const luaL_reg global_functions [] = {
{"print", lua_print},
{"release_print",lua_release_print},
{nullptr, nullptr}
};
int lua_release_print(lua_State * L)
{
std::string t;
get_string_for_print(L, &t);
log("[LUA-print] %s", t.c_str());
return 0;
}
所以重点就在这个log函数
void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
/** @def CC_FORMAT_PRINTF(formatPos, argPos)
* Only certain compiler support __attribute__((format))
*
* @param formatPos 1-based position of format string argument.
* @param argPos 1-based position of first format-dependent argument.
*/
#if defined(__GNUC__) && (__GNUC__ >= 4)
#define CC_FORMAT_PRINTF(formatPos, argPos) __attribute__((__format__(printf, formatPos, argPos)))
#elif defined(__has_attribute) && __has_attribute(format)
#define CC_FORMAT_PRINTF(formatPos, argPos) __attribute__((__format__(printf, formatPos, argPos)))
#else
#define CC_FORMAT_PRINTF(formatPos, argPos)
#endif
格式:#define <宏名>(<参数表>) <字符串>
举例:#define S(a,b) a*b
area=S(3,2);
第一步被换为area=ab;第二步换为area=32;
所以这个CC_FORMAT_PRINTF
可以不用关心,__attribute__
等全部都是编译指令
log的真正实现,如果你是在手机上打印最终会走到这里
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf);
网上有人说打印的结果通过 logcat 查看。
从源码角度分析,只能帮你到这里了。