zoukankan      html  css  js  c++  java
  • ios如何生成crash报告

    #include <signal.h>
    #include <execinfo.h>
    
    void  OnProcessExceptionHandler(int sigl)
    {
        do 
        {
            std::string str = "";
    
            void* arrayList[128];
            int count = backtrace(arrayList, 128);
            char** pStr = backtrace_symbols(arrayList, count);
            if (pStr == NULL)
                break;
    
            for (int i=0; i<count; i++)
            {
                str += pStr[i];
                str += "
    ";
            }
    
            if (str.size() <= 0)
                break;
    
            char buffer[1024] = "";
            time_t t = time(NULL);
            tm* pTm  = localtime(&t);
            sprintf(buffer, "[TRACE]%02d:%02d:%02d : 
    ", pTm->tm_hour,pTm->tm_min,pTm->tm_sec);
    
            std::string logFile = "";//writeable dir
            logFile += "exception.txt";
            FILE* pFile = fopen(logFile.c_str(), "ab");
            if (pFile == NULL)
                break;
    
            fwrite(buffer, strlen(buffer), 1, pFile);
            fwrite(str.c_str(), str.size(), 1, pFile);
            fclose(pFile);
        } 
        while (false);
    
        exit(1);
    }
    
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        signal(SIGQUIT, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGILL, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGTRAP, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGABRT, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGEMT, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGFPE, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGBUS, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGSEGV, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGSYS, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGPIPE, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGALRM, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGXCPU, CrashReportSystem::OnProcessExceptionHandler);
        signal(SIGXFSZ, CrashReportSystem::OnProcessExceptionHandler);
    
        return 1;
    }
  • 相关阅读:
    python
    redis
    mongodb replica on aws ec2
    mysql
    java正则表达式
    终端make命令和Git学习
    linux和shell学习
    centos普通用户安装jenkins
    centos7普通用户安装jdk
    WPF动画
  • 原文地址:https://www.cnblogs.com/mrblue/p/3407670.html
Copyright © 2011-2022 走看看