cocos2d-x 安卓 ios崩溃dump
static void dumpHandler(int cause, siginfo_t * info, void *uap) { CCLOG("Crash dump:"); CCLuaEngine* pEngine = CCLuaEngine::defaultEngine(); me_traceStack(pEngine->getLuaStack()->getLuaState()); exit(1); } static void setupCrashReport() { struct sigaction sa; sa.sa_sigaction = dumpHandler; sigemptyset (&sa.sa_mask); sa.sa_flags = SA_SIGINFO; for (int i=0; i<kNumSignals; ++i) { if (sigaction(kSignals[i], &sa, NULL) == -1) CCLOG("sigaction [%d] failed", i); } if (sigaction (SIGSEGV, &sa, 0)) { CCLOG("setup sigaction"); } } #define SETUP_CRASH_REPORT() {setupCrashReport();} void me_traceStack (lua_State *L) { lua_print(L); int level; lua_Debug ar; std::string t; char buff[1024]; for (level = 1; level<11; ++level) { if (lua_getstack(L, level, &ar)) { lua_getinfo(L, "Snl", &ar); sprintf(buff, "frame %d \n%s :%d in function [%s], %d\n", level, ar.short_src, ar.currentline, ar.name, ar.linedefined); t += buff; } else { sprintf(buff, "frame %d \nunknown\n", level); t += buff; } } CCLOG("Lua frame stack:\n%s", t.c_str()); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。