From dbffb4ba8003c254612bfa989650f2d1f285e112 Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Thu, 8 Jun 2023 14:39:56 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BB=D0=B0=D0=B4=D1=87=D0=B8?= =?UTF-8?q?=D0=BA:=20=D0=9E=D0=BA=D0=BD=D0=BE=20"=D0=9B=D0=BE=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IB/Debugger/Debugger.cs | 7 +- .../IB/Debugger/LocalVars.cs | 116 ++++++------------ .../IB/TreeGridView/TreeGridNode.cs | 4 +- .../Workbench/VisibilityService.cs | 9 +- .../Workbench/WindowOperations.cs | 23 ++-- 5 files changed, 67 insertions(+), 92 deletions(-) diff --git a/VisualPascalABCNETLinux/IB/Debugger/Debugger.cs b/VisualPascalABCNETLinux/IB/Debugger/Debugger.cs index 3c3d88221..2380d3369 100644 --- a/VisualPascalABCNETLinux/IB/Debugger/Debugger.cs +++ b/VisualPascalABCNETLinux/IB/Debugger/Debugger.cs @@ -546,7 +546,8 @@ namespace VisualPascalABC return null; } - + + private delegate void EndDebuggerSessionDelegate(); public void EndDebuggerSession() { @@ -596,9 +597,10 @@ namespace VisualPascalABC monoDebuggerSession = new Mono.Debugging.Soft.SoftDebuggerSession(); } + private void Process_Exited(object sender, EventArgs e) { - EndDebuggerSession(); + VisualPABCSingleton.MainForm.Invoke(new EndDebuggerSessionDelegate(EndDebuggerSession)); } @@ -613,6 +615,7 @@ namespace VisualPascalABC stackFrame = e.Thread.Backtrace.GetFrame(0); JumpToCurrentLine(); workbench.WidgetController.SetStartDebugEnabled(); + WorkbenchServiceFactory.DebuggerOperationsService.RefreshPad(new FunctionItem(stackFrame).SubItems); } private void MonoDebuggerSession_TargetStarted(object sender, EventArgs e) diff --git a/VisualPascalABCNETLinux/IB/Debugger/LocalVars.cs b/VisualPascalABCNETLinux/IB/Debugger/LocalVars.cs index 4436a9c8b..877709749 100644 --- a/VisualPascalABCNETLinux/IB/Debugger/LocalVars.cs +++ b/VisualPascalABCNETLinux/IB/Debugger/LocalVars.cs @@ -141,34 +141,17 @@ namespace VisualPascalABC public class ModuleItem : ListItem { - private NamedValue val; - private string ns_name; private Function func; private List types; - - /*public ModuleItem(NamedValue val, Function func) + private Mono.Debugging.Client.StackFrame frame; + private List monoTypes; + + public ModuleItem(List monoTypes, Mono.Debugging.Client.StackFrame frame) { - this.val = val; - ns_name = val.Type.FullName.Substring(0, val.Type.FullName.LastIndexOf('.')); - this.func = func; - this.func.Process.DebuggeeStateChanged += delegate - { - this.OnChanged(new ListItemEventArgs(this)); - }; - }*/ - - public ModuleItem(List types, Function func) - { - //this.val = val; - //ns_name = val.Type.FullName.Substring(0, val.Type.FullName.LastIndexOf('.')); - this.types = types; - this.func = func; - this.func.Process.DebuggeeStateChanged += delegate - { - this.OnChanged(new ListItemEventArgs(this)); - }; + this.monoTypes = monoTypes; + this.frame = frame; } - + public override int ImageIndex { get @@ -228,12 +211,12 @@ namespace VisualPascalABC get { List ret = new List(); - foreach (DebugType dt in types) + foreach (var tr in monoTypes) { - //IList fis = val.Type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); - IList fis = dt.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); - foreach (FieldInfo fi in fis) - if (!fi.Name.Contains("$")) ret.Add(new ValueItem(fi.GetValue(null),fi.DeclaringType)); + var fields = tr.GetChildReferences(Mono.Debugging.Client.EvaluationOptions.DefaultOptions); + foreach (var fi in fields) + if (!fi.Name.Contains("$")) + ret.Add(new ValueItem(fi.CreateObjectValue(false, Mono.Debugging.Client.EvaluationOptions.DefaultOptions))); } return ret; } @@ -242,15 +225,8 @@ namespace VisualPascalABC public class FunctionItem : ListItem { - Function function; + Mono.Debugging.Client.StackFrame frame; - public Function Function - { - get - { - return function; - } - } public override bool IsLiteral { @@ -271,7 +247,7 @@ namespace VisualPascalABC { get { - return function.Name; + return frame.SourceLocation.MethodName; } } @@ -314,45 +290,42 @@ namespace VisualPascalABC { List ret = new List(); Hashtable ht = new Hashtable(StringComparer.CurrentCultureIgnoreCase); - foreach (NamedValue val in function.LocalVariables) + foreach (var val in frame.GetAllLocals()) { - if (val.Name.Contains("$class_var") /*&& !val.Type.FullName.Contains("$")*/) + if (val.Name.Contains("$class_var")) { - //IList fis = val.Type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); - //if (fis.Count != 0) - List types = new List(); + List types = new List(); try { - if (val.Type.FullName.Contains(PascalABCCompiler.TreeConverter.compiler_string_consts.ImplementationSectionNamespaceName)) + if (val.TypeName.Contains(PascalABCCompiler.TreeConverter.compiler_string_consts.ImplementationSectionNamespaceName)) { - string interf_name = val.Type.FullName.Substring(0, val.Type.FullName.IndexOf(PascalABCCompiler.TreeConverter.compiler_string_consts.ImplementationSectionNamespaceName)); + string interf_name = val.TypeName.Substring(0, val.TypeName.IndexOf(PascalABCCompiler.TreeConverter.compiler_string_consts.ImplementationSectionNamespaceName)); Type t = AssemblyHelper.GetTypeForStatic(interf_name); - DebugType dt = DebugUtils.GetDebugType(t); - types.Add(dt); + var tr = new Mono.Debugging.Evaluation.TypeValueReference(frame.SourceBacktrace.GetEvaluationContext(frame.Index, Mono.Debugging.Client.EvaluationOptions.DefaultOptions), + (frame.DebuggerSession as Mono.Debugging.Soft.SoftDebuggerSession).GetType(t.FullName)); + types.Add(tr); } - types.Add(val.Type); + var valtr = new Mono.Debugging.Evaluation.TypeValueReference(frame.SourceBacktrace.GetEvaluationContext(frame.Index, Mono.Debugging.Client.EvaluationOptions.DefaultOptions), + (frame.DebuggerSession as Mono.Debugging.Soft.SoftDebuggerSession).GetType(val.TypeName)); + types.Add(valtr); } catch (System.Exception e) { - + Console.WriteLine(e.Message + " " + e.StackTrace); } - ret.Add(new ModuleItem(types, function)); - //foreach (FieldInfo fi in fis) - // if (!fi.Name.Contains("$")) ret.Add(new ValueItem(fi.GetValue(val))); + ret.Add(new ModuleItem(types, frame)); } } - foreach (NamedValue val in function.LocalVariables) + foreach (var val in frame.GetAllLocals()) { - //if (val.IsObject) - if (!val.Name.Contains("$")) - ret.Add(new ValueItem(val,null)); + ret.Add(new ValueItem(val)); else if (val.Name.Contains("$rv")) { - ret.Add(new ValueItem(val,null)); + ret.Add(new ValueItem(val)); } - else if (val.Name == "$disp$") + /*else if (val.Name == "$disp$") { IList fields = val.Type.GetFields(BindingFlags.All); foreach (FieldInfo fi in fields) @@ -361,15 +334,15 @@ namespace VisualPascalABC ret.Add(new ValueItem(fi.GetValue(val),fi.DeclaringType)); ht[fi.Name] = fi.Name; } - } + }*/ } - NamedValue self_nv = null; + Mono.Debugging.Client.ObjectValue self_nv = null; try { - foreach (NamedValue val in function.Arguments) + foreach (var val in frame.GetParameters()) { if (!val.Name.Contains("$") && !ht.ContainsKey(val.Name)) - ret.Add(new ValueItem(val, null)); + ret.Add(new ValueItem(val)); else if (val.Name == "$obj$") self_nv = val; } @@ -377,26 +350,17 @@ namespace VisualPascalABC catch { } - if (!function.IsStatic) ret.Add(new ValueItem(function.ThisValue,null)); + if (frame.GetThisReference() != null) + ret.Add(new ValueItem(frame.GetThisReference())); else if (self_nv != null) - ret.Add(new ValueItem(self_nv,"self",null)); - - /*foreach (NamedValue val in function.ContaingClassVariables) - { - if (!val.Name.Contains("$")) - ret.Add(new ValueItem(val)); - }*/ + ret.Add(new ValueItem(self_nv)); return ret.AsReadOnly(); } } - public FunctionItem(Function function) + public FunctionItem(Mono.Debugging.Client.StackFrame frame) { - this.function = function; - this.function.Process.DebuggeeStateChanged += delegate - { - this.OnChanged(new ListItemEventArgs(this)); - }; + this.frame = frame; } } diff --git a/VisualPascalABCNETLinux/IB/TreeGridView/TreeGridNode.cs b/VisualPascalABCNETLinux/IB/TreeGridView/TreeGridNode.cs index ad399e1d9..72fc84a76 100644 --- a/VisualPascalABCNETLinux/IB/TreeGridView/TreeGridNode.cs +++ b/VisualPascalABCNETLinux/IB/TreeGridView/TreeGridNode.cs @@ -489,7 +489,7 @@ namespace AdvancedDataGridView private void Update() { - DateTime start = Debugger.Util.HighPrecisionTimer.Now; + //DateTime start = Debugger.Util.HighPrecisionTimer.Now; updated = false; //this.HasChildren = Content.HasSubItems; //this._image = content.Image; @@ -513,7 +513,7 @@ namespace AdvancedDataGridView if (this.Cells[2].Value == null) this.Cells[2].Value = this.type; //this.Cells[2].Value = this.type; - DateTime end = Debugger.Util.HighPrecisionTimer.Now; + //DateTime end = Debugger.Util.HighPrecisionTimer.Now; //LoggingService.InfoFormatted("Updated node {0} ({1} ms)", FullName, (end - start).TotalMilliseconds); diff --git a/VisualPascalABCNETLinux/Workbench/VisibilityService.cs b/VisualPascalABCNETLinux/Workbench/VisibilityService.cs index 464d1dd18..5f100e12e 100644 --- a/VisualPascalABCNETLinux/Workbench/VisibilityService.cs +++ b/VisualPascalABCNETLinux/Workbench/VisibilityService.cs @@ -633,11 +633,9 @@ namespace VisualPascalABC private bool watch_vis = false; public void SetDebugTabsVisible(bool flag) { - if (DebugWatchListWindow == null) - return; if (flag) { - if (!DebugWatchListWindow.IsHidden) + if (DebugWatchListWindow != null && !DebugWatchListWindow.IsHidden) { watch_vis = true; } @@ -645,14 +643,15 @@ namespace VisualPascalABC { if (!BottomTabsVisible) BottomTabsVisible = true; - ShowContent(DebugWatchListWindow, false); + if (DebugWatchListWindow != null) + ShowContent(DebugWatchListWindow, false); ShowContent(DebugVariablesListWindow, false); } } else { //HideContent(DebugWatchListWindow); - if (!watch_vis) + if (!watch_vis && DebugWatchListWindow != null) { HideContent(DebugWatchListWindow); } diff --git a/VisualPascalABCNETLinux/Workbench/WindowOperations.cs b/VisualPascalABCNETLinux/Workbench/WindowOperations.cs index a303bb59d..5fa937421 100644 --- a/VisualPascalABCNETLinux/Workbench/WindowOperations.cs +++ b/VisualPascalABCNETLinux/Workbench/WindowOperations.cs @@ -341,9 +341,10 @@ namespace VisualPascalABC AddDisassemblyWindow(); // Это нельзя убирать - почему то оболочка закрывается при запуске программы!!! HideContent(FindSymbolsResultWindow); HideContent(DisassemblyWindow); - + AddDebugVariablesListWindow(); + HideContent(DebugVariablesListWindow); /*AddImmediateWindow(); - //AddDebugVariablesListWindow(); + //AddDebugWatchListWindow(); if (!Tools.IsUnix()) { @@ -355,7 +356,7 @@ namespace VisualPascalABC // SelectContent(ProjectExplorerWindow, false); //HideContent(ImmediateWindow); - //HideContent(DebugVariablesListWindow); + //HideContent(DebugWatchListWindow); if (!Tools.IsUnix()) @@ -685,19 +686,27 @@ namespace VisualPascalABC DebugVariablesListWindow.ClearAllSubTrees(); } - public void RefreshPad(IList items) + private delegate void RefreshPadDelegate(IList items); + + private void RefreshPadInvoke(IList items) { try { - DebugWatchListWindow.RefreshWatch(); + if (DebugWatchListWindow != null) + DebugWatchListWindow.RefreshWatch(); AdvancedDataGridView.TreeGridNode.UpdateNodesForLocalList(DebugVariablesListWindow.watchList, DebugVariablesListWindow.watchList.Nodes, items); } - catch (System.Exception) + catch (System.Exception ex) { - + Console.WriteLine(ex.Message + " " + ex.StackTrace); } } + public void RefreshPad(IList items) + { + Invoke(new RefreshPadDelegate(RefreshPadInvoke), items); + } + public void GotoWatch() { BottomTabsVisible = true;