Beispiel #1
0
        static int HandleError(IntPtr L)
        {
            string error = LPLuaHook.GetRefString(L, 1);

            Debug.LogError(error);
            return(0);
        }
Beispiel #2
0
        private static void SetTable(int refIndex, Dictionary <LuaTypes, HashSet <string> > dict, Dictionary <string, List <string> > detailDict)
        {
            IntPtr L = LPLuaProfiler.mainL;

            if (L == IntPtr.Zero)
            {
                return;
            }
            dict.Clear();
            int oldTop = LuaDLL.lua_gettop(L);

            LuaDLL.lua_getref(L, refIndex);
            if (LuaDLL.lua_type(L, -1) != LuaTypes.LUA_TTABLE)
            {
                LuaDLL.lua_pop(L, 1);
                return;
            }
            int t = oldTop + 1;

            LuaDLL.lua_pushnil(L);  /* 第一个 key */
            while (LuaDLL.lua_next(L, t) != 0)
            {
                /* 用一下 'key' (在索引 -2 处) 和 'value' (在索引 -1 处) */
                int key_t = LuaDLL.lua_gettop(L);
                LuaDLL.lua_pushnil(L);  /* 第一个 key */
                string        firstKey   = null;
                List <string> detailList = new List <string>();
                while (LuaDLL.lua_next(L, key_t) != 0)
                {
                    string key = LPLuaHook.GetRefString(L, -1);
                    if (string.IsNullOrEmpty(firstKey))
                    {
                        firstKey = key;
                    }
                    detailList.Add(key);
                    LuaDLL.lua_pop(L, 1);
                }
                LuaDLL.lua_settop(L, key_t);
                if (!string.IsNullOrEmpty(firstKey))
                {
                    HashSet <string> list;
                    LuaTypes         luaType = (LuaTypes)LuaDLL.lua_type(L, -2);
                    if (!dict.TryGetValue(luaType, out list))
                    {
                        list = new HashSet <string>();
                        dict.Add(luaType, list);
                    }
                    if (!list.Contains(firstKey))
                    {
                        list.Add(firstKey);
                    }
                    detailDict[firstKey] = detailList;
                }

                /* 移除 'value' ;保留 'key' 做下一次迭代 */
                LuaDLL.lua_pop(L, 1);
            }
            LuaDLL.lua_settop(L, oldTop);
        }
Beispiel #3
0
        static int RemoveRefFunInfo(IntPtr L)
        {
            string funName = LPLuaHook.GetRefString(L, 1);
            string funAddr = LPLuaHook.GetRefString(L, 2);
            byte   type    = (byte)LuaDLL.lua_tonumber(L, 3);

            LPLuaProfiler.RemoveRef(funName, funAddr, type);
            return(0);
        }
Beispiel #4
0
 public void Clear()
 {
     m_isRecord       = false;
     m_isStaticRecord = false;
     luaDiff          = null;
     m_dateTime       = "";
     m_staticDateTime = "";
     m_detailList     = null;
     LPLuaHook.ClearStaticRecord();
     LPLuaHook.ClearRecord();
 }
Beispiel #5
0
 public static void toluaL_unref_replace(IntPtr L, int reference)
 {
     lock (m_Lock)
     {
         if (isHook)
         {
             LPLuaHook.HookUnRef(L, reference, tolua_Getref_Fun);
         }
         toluaL_unref(L, reference);
     }
 }
Beispiel #6
0
 public static void luaL_unref_replace(IntPtr luaState, int registryIndex, int reference)
 {
     lock (m_Lock)
     {
         if (isHook)
         {
             LPLuaHook.HookUnRef(luaState, reference);
         }
         LuaDLL.luaL_unref(luaState, registryIndex, reference);
     }
 }
Beispiel #7
0
 public static int toluaL_ref_replace(IntPtr L)
 {
     lock (m_Lock)
     {
         int num = toluaL_ref(L);
         if (isHook)
         {
             LPLuaHook.HookRef(L, num, tolua_Getref_Fun);
         }
         return(num);
     }
 }
Beispiel #8
0
 public static int luaL_ref_replace(IntPtr luaState, int t)
 {
     lock (m_Lock)
     {
         int num = LuaDLL.luaL_ref(luaState, t);
         if (isHook)
         {
             LPLuaHook.HookRef(luaState, num);
         }
         return(num);
     }
 }
Beispiel #9
0
 public static int luaL_loadbuffer_replace(IntPtr luaState, IntPtr buff, IntPtr size, string name, IntPtr mode)
 {
     lock (m_Lock)
     {
         if (isHook)
         {
             byte[] buffer = new byte[(int)size];
             Marshal.Copy(buff, buffer, 0, buffer.Length);
             // dostring
             if (name.Length == (int)size)
             {
                 name = "chunk";
             }
             buffer = LPLuaHook.Hookloadbuffer(luaState, buffer, name);
             buff   = NativeUtility.ConvertByteArrayToPtr(buffer);
             size   = (IntPtr)buffer.Length;
         }
         return(luaL_loadbufferx(luaState, buff, size, name, mode));
     }
 }
        void DoToolbar()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            #region clear
            bool isClear = GUILayout.Button("Clear", EditorStyles.toolbarButton, GUILayout.Height(30));
            if (isClear)
            {
                currentFrameIndex = 0;
                m_TreeView.Clear(true);
                m_luaRefScrollView.ClearRefInfo(true);
                m_luaDiffScrollView.Clear();
                ClearConsole();
            }
            GUILayout.Space(5);
            #endregion

            #region history
            string recordName = "Record";
            bool   flag       = GUILayout.Toggle(LuaDeepProfilerSetting.Instance.isRecord, recordName, EditorStyles.toolbarButton, GUILayout.Height(30));
            if (flag != LuaDeepProfilerSetting.Instance.isRecord)
            {
                LuaDeepProfilerSetting.Instance.isRecord = flag;
            }
            GUILayout.Space(25);
            #endregion

            var setting = LuaDeepProfilerSetting.Instance;

            #region socket
            bool   oldIsLocal = LuaDeepProfilerSetting.Instance.isLocal;
            string localName  = "local mode";
            if (!LuaDeepProfilerSetting.Instance.isLocal)
            {
                localName = "remote mode";
            }
            LuaDeepProfilerSetting.Instance.isLocal = GUILayout.Toggle(LuaDeepProfilerSetting.Instance.isLocal, localName, EditorStyles.toolbarButton, GUILayout.Height(30));
            if (!oldIsLocal && LuaDeepProfilerSetting.Instance.isLocal)
            {
                OpenLocalMode();
            }

            if (!LuaDeepProfilerSetting.Instance.isLocal)
            {
                if (GUILayout.Button("OpenService", EditorStyles.toolbarButton, GUILayout.Height(30)))
                {
                    ClearConsole();
                    NetWorkServer.RealClose();
                    currentFrameIndex = 0;
                    m_TreeView.Clear(true);
                    LPLuaProfiler.UnRegistReceive();
                    NetWorkServer.UnRegisterReceive();
                    NetWorkServer.RegisterOnReceiveSample(m_TreeView.LoadRootSample);
                    NetWorkServer.RegisterOnReceiveRefInfo(m_luaRefScrollView.DelRefInfo);
                    NetWorkServer.RegisterOnReceiveDiffInfo(m_luaDiffScrollView.DelDiffInfo);
                    NetWorkServer.BeginListen("0.0.0.0", port);
                }
                GUILayout.Label("port:", GUILayout.Height(30), GUILayout.Width(35));
                port = EditorGUILayout.IntField(port, GUILayout.Height(16), GUILayout.Width(50));

                if (GUILayout.Button("CloseService", EditorStyles.toolbarButton, GUILayout.Height(30)))
                {
                    ClearConsole();
                    NetWorkServer.RealClose();
                    UnityEngine.Debug.Log("<color=#ff0000>disconnect</color>");
                }
            }
            else
            {
                GUILayout.Space(10);
                flag = GUILayout.Toggle(setting.isDeepLuaProfiler, "Deep Lua", EditorStyles.toolbarButton);
                if (flag != setting.isDeepLuaProfiler)
                {
                    setting.isDeepLuaProfiler = flag;
                    if (!flag)
                    {
                        setting.isCleanMode = false;
                    }
                    EditorApplication.isPlaying = false;
                }

                flag = GUILayout.Toggle(setting.isDeepMonoProfiler, "Deep Mono", EditorStyles.toolbarButton);
                if (flag != setting.isDeepMonoProfiler)
                {
                    setting.isDeepMonoProfiler  = flag;
                    EditorApplication.isPlaying = false;
                    InjectMethods.Recompile();
                }

                flag = GUILayout.Toggle(setting.discardInvalid, "Discard Invalid", EditorStyles.toolbarButton);
                if (flag != setting.discardInvalid)
                {
                    setting.discardInvalid = flag;
                }

                flag = GUILayout.Toggle(setting.isCleanMode, "PreCompile Lua(Use InjectLua.exe)", EditorStyles.toolbarButton);
                if (flag != setting.isCleanMode)
                {
                    setting.isCleanMode = flag;
                    if (setting.isCleanMode)
                    {
                        setting.isDeepLuaProfiler = true;
                    }
                    EditorApplication.isPlaying = false;
                }
            }

            GUILayout.Space(25);
            if (GUILayout.Button("MarkStaticRecord", EditorStyles.toolbarButton, GUILayout.Height(30)))
            {
                if (!LuaDeepProfilerSetting.Instance.isLocal)
                {
                    NetWorkServer.SendCmd(3);
                }
                else
                {
                    m_luaDiffScrollView.DelDiffInfo(LPLuaHook.RecordStatic());
                }
                m_luaDiffScrollView.MarkIsStaticRecord();
            }

            if (GUILayout.Button("MarkLuaRecord", EditorStyles.toolbarButton, GUILayout.Height(30)))
            {
                if (!LuaDeepProfilerSetting.Instance.isLocal)
                {
                    NetWorkServer.SendCmd(1);
                }
                else
                {
                    m_luaDiffScrollView.DelDiffInfo(LPLuaHook.Record());
                }
                m_luaDiffScrollView.MarkIsRecord();
            }
            if (GUILayout.Button("DiffRecord", EditorStyles.toolbarButton, GUILayout.Height(30)))
            {
                if (!LuaDeepProfilerSetting.Instance.isLocal)
                {
                    NetWorkServer.SendCmd(2);
                }
                else
                {
                    m_luaDiffScrollView.DelDiffInfo(LPLuaHook.Diff());
                }
            }
            if (GUILayout.Button("ClearDiff", EditorStyles.toolbarButton, GUILayout.Height(30)))
            {
                m_luaDiffScrollView.Clear();
            }

            GUILayout.Space(20);
            if (GUILayout.Button("AddLuaDir", EditorStyles.toolbarButton, GUILayout.Height(30)))
            {
                LocalToLuaIDE.AddExternalProjectRootPath();
            }
            if (GUILayout.Button("SetIDE", EditorStyles.toolbarButton, GUILayout.Height(30)))
            {
                LocalToLuaIDE.SetExternalEditorPath();
            }
            if (GUILayout.Button("ClearLuaDir", EditorStyles.toolbarButton, GUILayout.Height(30)))
            {
                LocalToLuaIDE.ClearPath();
            }

            GUILayout.Space(10);
            if (NetWorkServer.acceptThread != null)
            {
                Color c = GUI.color;
                GUI.color = Color.green;
                GUILayout.Label("listerning..");
                GUI.color = c;
            }
            #endregion

            #region gc value
            GUILayout.Space(100);
            GUILayout.FlexibleSpace();
            #endregion

            if (m_TreeView != null)
            {
                m_TreeView.searchString = m_SearchField.OnToolbarGUI(m_TreeView.searchString);
                m_TreeView.toggleMerge  = GUILayout.Toggle(m_TreeView.toggleMerge, "merge", EditorStyles.toolbarButton, GUILayout.Height(30));
            }
            isShowRef = GUILayout.Toggle(isShowRef, "show refInfo", EditorStyles.toolbarButton, GUILayout.Height(30));

            EditorGUILayout.EndHorizontal();
        }
Beispiel #11
0
 static int BeginSampleCustom(IntPtr L)
 {
     LPLuaProfiler.BeginSample(L, LPLuaHook.GetRefString(L, 1), true);
     return(0);
 }