fix in linux debugger

This commit is contained in:
Ivan Bondarev 2023-10-01 12:15:08 +02:00
parent 43383d6f11
commit 9e68cf0071
4 changed files with 59 additions and 38 deletions

View file

@ -204,8 +204,8 @@ namespace VisualPascalABC
ValueItem vi = new ValueItem(rv.monoValue, this.watchList.Rows[i].Cells[0].Value as string, WorkbenchServiceFactory.DebuggerManager.evaluator.declaringType);
(this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid = this.watchList;
(this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = vi;
this.watchList.Rows[i].Cells[1].Value = WorkbenchServiceFactory.DebuggerManager.MakeValueView(rv.obj_val);//rv.obj_val.AsString;
this.watchList.Rows[i].Cells[2].Value = DebugUtils.WrapTypeName(rv.obj_val.Type);
this.watchList.Rows[i].Cells[1].Value = rv.monoValue.Value;//rv.obj_val.AsString;
this.watchList.Rows[i].Cells[2].Value = rv.monoValue.TypeName;
this.watchList.InvalidateCell(0, i);
}
catch (System.Exception e)

View file

@ -554,7 +554,7 @@ namespace VisualPascalABC
private delegate void EndDebuggerSessionDelegate();
public void EndDebuggerSession()
private void EndDebuggerSessionSafe()
{
if (Mono.Debugger.Soft.VirtualMachineManager.currentProcess == null)
return;
@ -606,8 +606,12 @@ namespace VisualPascalABC
private void Process_Exited(object sender, EventArgs e)
{
VisualPABCSingleton.MainForm.Invoke(new EndDebuggerSessionDelegate(EndDebuggerSession));
EndDebuggerSession();
}
public void EndDebuggerSession()
{
VisualPABCSingleton.MainForm.Invoke(new EndDebuggerSessionDelegate(EndDebuggerSessionSafe));
}
private void MonoDebuggerSession_TargetThreadStopped(object sender, Mono.Debugging.Client.TargetEventArgs e)

View file

@ -585,11 +585,6 @@ namespace VisualPascalABC
if (monoValue.Name.IndexOf(':') != -1)
return monoValue.Name.Substring(0, monoValue.Name.IndexOf(':'));
return monoValue.Name;
if (!string.IsNullOrEmpty(name))
return name;
if (!((val is NamedValue) ? (val as NamedValue).Name : name).Contains("$rv"))
return (val is NamedValue) ? ((val as NamedValue).Name.IndexOf(':') != -1 ? (val as NamedValue).Name.Substring(0, (val as NamedValue).Name.IndexOf(':')) : (val as NamedValue).Name) : name;
return "Result";
}
catch
{
@ -745,17 +740,6 @@ namespace VisualPascalABC
get
{
return false;
try
{
if (!failed)
return val.IsInteger && !ShowValuesInHexadecimal || val.IsPrimitive;
else
return false;
}
catch
{
return false;
}
}
}

View file

@ -33,6 +33,7 @@ using System.Linq;
using Mono.Debugging.Backend;
using Mono.Debugging.Evaluation;
using System.Text;
namespace Mono.Debugging.Client
{
@ -67,29 +68,61 @@ namespace Mono.Debugging.Client
[NonSerialized]
public StackFrame parentFrame;
static Dictionary<string, string> pascalTypes;
static ObjectValue()
{
pascalTypes = new Dictionary<string, string>();
pascalTypes.Add("int", "integer");
pascalTypes.Add("double", "real");
pascalTypes.Add("float", "single");
pascalTypes.Add("uint", "longword");
pascalTypes.Add("long", "int64");
pascalTypes.Add("short", "smallint");
pascalTypes.Add("ushort", "word");
pascalTypes.Add("sbyte", "shortint");
pascalTypes.Add("bool", "boolean");
}
static ObjectValue Create(IObjectValueSource source, ObjectPath path, string typeName)
{
var val = new ObjectValue();
val.typeName = typeName;
int ptr_ind = val.typeName.IndexOf('*');
string ptr = "";
if (ptr_ind != -1)
ptr = val.typeName.Substring(ptr_ind).Replace('*', '^');
switch (val.typeName.Replace("*",""))
{
case "int": val.typeName = "integer"; break;
case "double": val.typeName = "real"; break;
case "float": val.typeName = "single"; break;
case "uint": val.typeName = "longword"; break;
case "long": val.typeName = "int64"; break;
case "ulong": val.typeName = "uint64"; break;
case "short": val.typeName = "smallint"; break;
case "ushort": val.typeName = "word"; break;
case "sbyte": val.typeName = "shortint"; break;
case "bool": val.typeName = "boolean"; break;
StringBuilder sb = new StringBuilder();
StringBuilder buf = new StringBuilder();
int i = 0;
while (i < val.typeName.Length)
{
char c = val.typeName[i];
if (char.IsLetterOrDigit(c))
buf.Append(c);
else if (c != ']')
{
string type = buf.ToString();
string pascalType = "";
if (c == '*')
sb.Append("^");
else if (c == '[')
sb.Append("array of ");
if (pascalTypes.TryGetValue(type, out pascalType))
sb.Append(pascalType);
else
sb.Append(type);
if (c != '*' && c != ']' && c != '[')
sb.Append(c);
buf.Clear();
}
i++;
}
if (buf.Length > 0)
{
string type = buf.ToString();
string pascalType = "";
if (pascalTypes.TryGetValue(type, out pascalType))
sb.Append(pascalType);
else
sb.Append(type);
}
val.typeName = ptr+val.typeName.Replace("*", "");
val.typeName = sb.ToString();
val.source = source;
val.path = path;
return val;