Unity crash search

Unity crash search

android crash log collection

  • Directly use logcat log positioning
    Unity will capture the crash itself, and then output the crash stack in logcat, whether it is a java, c#, or c++ crash
    So as long as you get the logcat log, you can get the crash stack

    1. Use logcat to get logs
    2. Use dropbox to get logs
    3. Use bugreport to get logs
  • Manually dump the crash log
    Mainly consider 3 parts:

    • c# exception
      This part has been processed by unity and will be printed through Debug.Log. You only need to capture the log through Application.logMessageReceived and write it to the file
      Principle referenceCapturing global exceptions
      Code referenceUnity log output to file
    • java exception
      You can use Thread.setDefaultUncaughtExceptionHandler to capture java exception and write it to a file
      Principle referenceUse Code capture android crash log
      Code referenceUnity crash output to file
    • c++ exception
      This part has been processed by unity and will be converted into a java exception and thrown, so no additional processing is required

ios crash log collection

  • Use the built-in crash log

  • Manually dump crash logs

    • IOS only has two layers, C++ and C#. As for C#, it is exactly the same as Android, so needless to say.
      For the C++ layer, Unity has provided a crash report module for ios. It requires us to set ENABLE_CUSTOM_CRASH_REPORTER in Classes/Crashreport.h to 1 after generating the project. Unity’s built-in crash report is actually implemented using the third-party library plcrashreport. This library has many applications on iOS.
      In this way, after a C++ crash, Unity will save the crash file for us. After the next startup, we can access these dmp files through the crashreport module. These dmp files are standard dmp files on ios and can be used Use the ios development tool symbolicatecrash to view it.
    • In addition, for ios, a function NSSetUncaughtExceptionHandler is actually provided, which is used to enter this processing when uncaught exceptions occur. It can intercept some things,
      But some things such as memory If there is an access error, it will exit directly without entering here. In addition, the program will still exit after entering here, just so that we can record it, but with Unity's own crashreport, this is useless.
    • Also when Unity is running C# on iOS, there is an optimization for running the code in the player settings. Choose slow but safe or fast but no exception. If you choose the former, all C# execution errors will be like scripts. If it is caught in the same way, a c# exception will be reported.
      If the latter does not happen, it will not be caught directly, which will cause the program to exit, but the operating efficiency is high. We usually choose slow but safe. This is a characteristic of the mono architecture.

Restore call stack address to symbol

  • Symbol table introduction

    • First of all, the symbol table is divided into two types according to the compilation parameters used, debug and public, both of which can convert addresses into function names. The difference is that debug will have more information. If you want to debug, you can only use debug symbols. Table
      The debug symbol table suffix is ​​.dbg.so, and the public symbol table suffix is ​​.sym.so. Generally, the unity engine only has a public symbol table. Your game logic will generate both debug and public symbol tables at the same time.
      Remove the .dbg or .sym suffix when using it, for example, change libunity.sym.so to libunity.so
    • Secondly, debug and release will also generate different symbol tables, so there are four types of symbol tables, the debug and public symbol tables of the debug version, and the debug and public symbol tables of the release version.
  • First locate the symbol table location

    • Android
      Reference Unity User Manual 2020.3 (LTS)/Platform Development/Android/Building Android Applications/Android symbols
      • The unity engine only has a public symbol table, located at
        /PlaybackEngines/AndroidPlayer/Variations///Symbols//
        After turning on Strip Engine Code enabled, libunity will generate a trimmed symbol table/Temp/StagingArea/symbols//
      • User code will have a symbol table only if IL2CPP is turned on
        Il2cpp.so is compiled by game logic, and its symbol table is generated when packaging the project
        • Build Settings Check Create symbols.zip
        • After packaging, {application name}-{internal version number}-v{version number}.symbols.zip will be generated in the apk output directory,
          which contains Il2cpp.so public and debug symbol tables, and libunity's public symbol table after code pruning
  • Then use the symbol table to convert the address into a function
    Assume the stack is like this

        I/DEBUG(242): backtrace:
        I/DEBUG(242):     #00  pc 006d4960  /data/app-lib/com.u.demo-1/libunity.so
        I/DEBUG(242):     #01  pc 006d4c0c  /data/app-lib/com.u.demo-1/libunity.so
    

    You can get the function name corresponding to 006d4960 through the following command
    arm-linux-androideabi-addr2line -f -C -e {unity installation directory}/PlaybackEngines/AndroidPlayer/Variations/ {mono or il2cpp}/Release/Symbols/armeabi-v7a/libunity.sym.so 006d4960
    -f - Show function names
    -C - Demangle function names
    -e - Set the input file name
    arm-linux-androideabi-addr2line is located in {NDK installation directory}/toolchains/arm-linux-androideabi-4.9/ prebuilt/darwin-x86_64/bin/arm-linux-androideabi-addr2line

Unity log output to file

    [DefaultExecutionOrder(-10000)]
    public clas

おすすめ

転載: blog.csdn.net/qmladm/article/details/131030687