Beispiel #1
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.StackTraceUtility o;
     o = new UnityEngine.StackTraceUtility();
     pushObject(l, o);
     return(1);
 }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.StackTraceUtility o;
         o = new UnityEngine.StackTraceUtility();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.StackTraceUtility o;
         o=new UnityEngine.StackTraceUtility();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Beispiel #4
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.StackTraceUtility o;
         o = new UnityEngine.StackTraceUtility();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #5
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.StackTraceUtility o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.StackTraceUtility();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.StackTraceUtility o;
         o=new UnityEngine.StackTraceUtility();
         pushValue(l,true);
         pushValue(l,o);
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.StackTraceUtility o;
         o = new UnityEngine.StackTraceUtility();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
    static int _CreateStackTraceUtility(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            StackTraceUtility obj = new StackTraceUtility();
            LuaScriptMgr.PushObject(L, obj);
            return 1;
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: StackTraceUtility.New");
        }

        return 0;
    }
Beispiel #9
0
        public static string ExtractStackTrace()
        {
            StackTrace stackTrace = new StackTrace(1, true);

            return(StackTraceUtility.ExtractFormattedStackTrace(stackTrace).ToString());
        }
Beispiel #10
0
        internal static string PostprocessStacktrace(string oldString, bool stripEngineInternalInformation)
        {
            string result;

            if (oldString == null)
            {
                result = string.Empty;
            }
            else
            {
                string[] array = oldString.Split(new char[]
                {
                    '\n'
                });
                StringBuilder stringBuilder = new StringBuilder(oldString.Length);
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = array[i].Trim();
                }
                for (int j = 0; j < array.Length; j++)
                {
                    string text = array[j];
                    if (text.Length != 0 && text[0] != '\n')
                    {
                        if (!text.StartsWith("in (unmanaged)"))
                        {
                            if (stripEngineInternalInformation && text.StartsWith("UnityEditor.EditorGUIUtility:RenderGameViewCameras"))
                            {
                                break;
                            }
                            if (stripEngineInternalInformation && j < array.Length - 1 && StackTraceUtility.IsSystemStacktraceType(text))
                            {
                                if (StackTraceUtility.IsSystemStacktraceType(array[j + 1]))
                                {
                                    goto IL_297;
                                }
                                int num = text.IndexOf(" (at");
                                if (num != -1)
                                {
                                    text = text.Substring(0, num);
                                }
                            }
                            if (text.IndexOf("(wrapper managed-to-native)") == -1)
                            {
                                if (text.IndexOf("(wrapper delegate-invoke)") == -1)
                                {
                                    if (text.IndexOf("at <0x00000> <unknown method>") == -1)
                                    {
                                        if (!stripEngineInternalInformation || !text.StartsWith("[") || !text.EndsWith("]"))
                                        {
                                            if (text.StartsWith("at "))
                                            {
                                                text = text.Remove(0, 3);
                                            }
                                            int num2 = text.IndexOf("[0x");
                                            int num3 = -1;
                                            if (num2 != -1)
                                            {
                                                num3 = text.IndexOf("]", num2);
                                            }
                                            if (num2 != -1 && num3 > num2)
                                            {
                                                text = text.Remove(num2, num3 - num2 + 1);
                                            }
                                            text = text.Replace("  in <filename unknown>:0", "");
                                            text = text.Replace("\\", "/");
                                            if (!string.IsNullOrEmpty(StackTraceUtility.projectFolder))
                                            {
                                                text = text.Replace(StackTraceUtility.projectFolder, "");
                                            }
                                            text = text.Replace('\\', '/');
                                            int num4 = text.LastIndexOf("  in ");
                                            if (num4 != -1)
                                            {
                                                text = text.Remove(num4, 5);
                                                text = text.Insert(num4, " (at ");
                                                text = text.Insert(text.Length, ")");
                                            }
                                            stringBuilder.Append(text + "\n");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    IL_297 :;
                }
                result = stringBuilder.ToString();
            }
            return(result);
        }
Beispiel #11
0
        internal static string PostprocessStacktrace(string oldString, bool stripEngineInternalInformation)
        {
            if (oldString == null)
            {
                return(string.Empty);
            }
            string[]      strArray      = oldString.Split('\n');
            StringBuilder stringBuilder = new StringBuilder(oldString.Length);

            for (int index = 0; index < strArray.Length; ++index)
            {
                strArray[index] = strArray[index].Trim();
            }
            for (int index = 0; index < strArray.Length; ++index)
            {
                string str1 = strArray[index];
                if (str1.Length != 0 && (int)str1[0] != 10 && !str1.StartsWith("in (unmanaged)"))
                {
                    if (!stripEngineInternalInformation || !str1.StartsWith("UnityEditor.EditorGUIUtility:RenderGameViewCameras"))
                    {
                        if (stripEngineInternalInformation && index < strArray.Length - 1 && StackTraceUtility.IsSystemStacktraceType((object)str1))
                        {
                            if (!StackTraceUtility.IsSystemStacktraceType((object)strArray[index + 1]))
                            {
                                int length = str1.IndexOf(" (at");
                                if (length != -1)
                                {
                                    str1 = str1.Substring(0, length);
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (str1.IndexOf("(wrapper managed-to-native)") == -1 && str1.IndexOf("(wrapper delegate-invoke)") == -1 && str1.IndexOf("at <0x00000> <unknown method>") == -1 && (!stripEngineInternalInformation || !str1.StartsWith("[") || !str1.EndsWith("]")))
                        {
                            if (str1.StartsWith("at "))
                            {
                                str1 = str1.Remove(0, 3);
                            }
                            int startIndex1 = str1.IndexOf("[0x");
                            int num         = -1;
                            if (startIndex1 != -1)
                            {
                                num = str1.IndexOf("]", startIndex1);
                            }
                            if (startIndex1 != -1 && num > startIndex1)
                            {
                                str1 = str1.Remove(startIndex1, num - startIndex1 + 1);
                            }
                            string str2        = str1.Replace("  in <filename unknown>:0", string.Empty).Replace(StackTraceUtility.projectFolder, string.Empty).Replace('\\', '/');
                            int    startIndex2 = str2.LastIndexOf("  in ");
                            if (startIndex2 != -1)
                            {
                                string str3 = str2.Remove(startIndex2, 5).Insert(startIndex2, " (at ");
                                str2 = str3.Insert(str3.Length, ")");
                            }
                            stringBuilder.Append(str2 + "\n");
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(stringBuilder.ToString());
        }
Beispiel #12
0
        /// <summary>
        /// 将日志写入到文件中
        /// </summary>
        /// <param name="message"></param>
        /// <param name="EnableStack"></param>
        private static void LogToFile(string message, bool EnableStack = false)
        {
            if (!EnableSave)
            {
                return;
            }

            if (LogFileWriter == null)
            {
                LogFileName = DateTime.Now.GetDateTimeFormats('s')[0].ToString();
                LogFileName = LogFileName.Replace("-", "_");
                LogFileName = LogFileName.Replace(":", "_");
                LogFileName = LogFileName.Replace(" ", "");
                LogFileName = LogFileName + ".log";
                if (string.IsNullOrEmpty(LogFileDir))
                {
                    try
                    {
#if UNITY_EDITOR
                        if (!Directory.Exists("d:/UnityLog"))
                        {
                            Directory.CreateDirectory("d:/UnityLog");
                        }
                        LogFileDir = "d:/UnityLog/";
#else
                        if ((Application.platform == RuntimePlatform.Android) || (Application.platform == RuntimePlatform.IPhonePlayer))
                        {
                            LogFileDir = Application.persistentDataPath + "/DebuggerLog/";
                        }
#endif
                    }
                    catch (Exception exception)
                    {
                        Debug.Log(Prefix + "获取 Application.persistentDataPath 报错!" + exception.Message, null);
                        return;
                    }
                }
                string path = LogFileDir + LogFileName;
                try
                {
                    if (!Directory.Exists(LogFileDir))
                    {
                        Directory.CreateDirectory(LogFileDir);
                    }
                    LogFileWriter           = File.AppendText(path);
                    LogFileWriter.AutoFlush = true;
                }
                catch (Exception exception2)
                {
                    LogFileWriter = null;
                    Debug.Log("LogToCache() " + exception2.Message + exception2.StackTrace, null);
                    return;
                }
            }
            if (LogFileWriter != null)
            {
                try
                {
                    if (FirstLogTag)
                    {
                        FirstLogTag = false;
                        PhoneSystemInfo(LogFileWriter);
                    }
                    LogFileWriter.WriteLine(message);
                    if (EnableStack)
                    {
                        LogFileWriter.WriteLine(StackTraceUtility.ExtractStackTrace());
                    }
                }
                catch (Exception)
                {
                }
            }
        }