protected void ShowStackLevel(int n) { LuaFunctionInfo lfi = this.debugEngine.CurrentStackTrace[n]; if (this.ls.LoadedFiles.Count == 0 && this.fileSaveTimeout > 0) { this.ls.RestoreLoadedFiles(); } if (this.ls.UpdateFileList) { UpdateView(); } LuaFile file; if (this.ls.LoadedFiles.TryGetValue(lfi.Source, out file)) { file.Arrow.NormalLineNr = lfi.Line; file.Arrow.IsEnabled = true; SwitchToFile(file, lfi.Line); this.ls.DebugEngine.FakeEnvironment(lfi); } else { ShowSourceUnavailable(); } }
public void ShowStackTrace(LuaStackTrace st) { this.lvStackTrace.Items.Clear(); for (int i = 0; i < st.Count; i++) { LuaFunctionInfo lfi = st[i]; ListViewItem item = new ListViewItem(new string[] { lfi.FunctionName, lfi.Source, lfi.Line.ToString() }); item.Tag = i; item.Selected = i == 0; this.lvStackTrace.Items.Add(item); } }
public static LuaFunctionInfo ReadFunctionInfo(LuaState ls, int level) { IntPtr memBlock = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LuaDebugRecord))); if (BBLua.lua_getstack(ls.L, level, memBlock) == 0) { return(null); } BBLua.lua_getinfo(ls.L, "nSlu", memBlock); LuaDebugRecord ldr = (LuaDebugRecord)Marshal.PtrToStructure(memBlock, typeof(LuaDebugRecord)); LuaFunctionInfo lfi = new LuaFunctionInfo(memBlock, ls, ldr.nups); if (ldr.source.Length > 1 && ldr.source[0] != '=') { lfi.Source = ldr.source; lfi.Line = ldr.currentline; } else { lfi.Source = "unavailable"; lfi.Line = 0; } if (ldr.what == "C") { lfi.FunctionName = "Game Engine (direct call)"; } else if (ldr.what == "main") { lfi.FunctionName = "Game Engine (code outside function)"; } else if (ldr.name != "" && ldr.namewhat != "") { lfi.FunctionName = ldr.namewhat + " " + ldr.name + "()"; } else if (ldr.what == "Lua" || ldr.what == "tail") { lfi.FunctionName = "Lua Code"; } if (ls.LoadedFiles.ContainsKey(lfi.Source)) { lfi.CanFakeEnvironment = true; } return(lfi); }
public LuaStackTrace(LuaState ls, int startLevel) { lfiStack = new List <LuaFunctionInfo>(); for (int level = startLevel; ; level++) { LuaFunctionInfo lfi = LuaFunctionInfo.ReadFunctionInfo(ls, level); if (lfi == null) { break; } else { this.lfiStack.Add(lfi); } } }
public void FakeEnvironment(LuaFunctionInfo lfi) { UnfakeIfNeccessary(); lfi.FakeG(); this.unfakeCallback = new Action(lfi.UnFakeG); }