This commit is contained in:
mterwoord_cp 2011-03-11 13:23:06 +00:00
parent bd59ac6966
commit bd82fa4238
9 changed files with 181 additions and 116 deletions

View file

@ -173,7 +173,7 @@ namespace Cosmos.Debug.Common
+ ", INDEXINMETHOD INT NOT NULL" + ", INDEXINMETHOD INT NOT NULL"
+ ", OFFSET INT NOT NULL" + ", OFFSET INT NOT NULL"
+ ", NAME VARCHAR(255) NOT NULL" + ", NAME VARCHAR(255) NOT NULL"
+ ", TYPENAME VARCHAR(255) NOT NULL" + ", TYPENAME VARCHAR(4000) NOT NULL"
+ ");" + ");"
); );

View file

@ -62,115 +62,116 @@ namespace Cosmos.Debug.VSDebugEngine
if (dwFields.HasFlag(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE)) if (dwFields.HasFlag(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE))
{ {
byte[] xData; byte[] xData;
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4); if (mDebugInfo.Type == typeof(string).AssemblyQualifiedName)
propertyInfo.bstrValue = xData.Aggregate("", (r, b) => r + " " + b.ToString("X2").ToUpper()); {
//if (mDebugInfo.Type == typeof(string).AssemblyQualifiedName) #region string support
//{ const uint xStringLengthOffset = 16;
// #region string support const uint xStringFirstCharPtrOffset = 20;
// const uint xStringLengthOffset = 16; xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
// const uint xStringFirstCharPtrOffset = 20; uint xStrPointer = BitConverter.ToUInt32(xData, 0);
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4); if (xStrPointer == 0)
// uint xStrPointer = BitConverter.ToUInt32(xData, 0); {
// if (xStrPointer == 0) propertyInfo.bstrValue = "(null)";
// { }
// propertyInfo.bstrValue = "(null)"; else
// } {
// else xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringLengthOffset, 4, 4);
// { uint xStringLength = BitConverter.ToUInt32(xData, 0);
// xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringLengthOffset, 4, 4); if (xStringLength > 100)
// uint xStringLength = BitConverter.ToUInt32(xData, 0); {
// if (xStringLength > 100) propertyInfo.bstrValue = "For now, strings larger than 100 chars are not supported..";
// { }
// propertyInfo.bstrValue = "For now, strings larger than 100 chars are not supported.."; else if (xStringLength == 0)
// } else if (xStringLength == 0) { {
// propertyInfo.bstrValue = "\"\""; propertyInfo.bstrValue = "\"\"";
// }else }
// { else
// xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringFirstCharPtrOffset, 4, 4); {
// uint xFirstCharPtr = BitConverter.ToUInt32(xData, 0); xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringFirstCharPtrOffset, 4, 4);
// xData = mProcess.mDbgConnector.GetMemoryData(xFirstCharPtr, xStringLength * 2, 2); uint xFirstCharPtr = BitConverter.ToUInt32(xData, 0);
// propertyInfo.bstrValue = "\"" + Encoding.Unicode.GetString(xData) + "\""; xData = mProcess.mDbgConnector.GetMemoryData(xFirstCharPtr, xStringLength * 2, 2);
// } propertyInfo.bstrValue = "\"" + Encoding.Unicode.GetString(xData) + "\"";
// } }
// #endregion string support }
//} #endregion string support
//else if (mDebugInfo.Type == typeof(byte[]).AssemblyQualifiedName) }
//{ else if (mDebugInfo.Type == typeof(byte[]).AssemblyQualifiedName)
// const uint xArrayLengthOffset = 8; {
// const uint xArrayFirstElementOffset = 16; const uint xArrayLengthOffset = 8;
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4); const uint xArrayFirstElementOffset = 16;
// uint xArrayPointer = BitConverter.ToUInt32(xData, 0); xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
// if (xArrayPointer == 0) uint xArrayPointer = BitConverter.ToUInt32(xData, 0);
// { if (xArrayPointer == 0)
// propertyInfo.bstrValue = "(null)"; {
// } propertyInfo.bstrValue = "(null)";
// else }
// { else
// xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayLengthOffset, 4, 4); {
// uint xDataLength = BitConverter.ToUInt32(xData, 0); xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayLengthOffset, 4, 4);
// bool xIsTooLong = xDataLength > 512; uint xDataLength = BitConverter.ToUInt32(xData, 0);
// var xSB = new StringBuilder(); bool xIsTooLong = xDataLength > 512;
// xSB.AppendFormat("Byte[{0}] at 0x{1} {{ ", xDataLength, xArrayPointer.ToString("X")); var xSB = new StringBuilder();
// if (xIsTooLong) xSB.AppendFormat("Byte[{0}] at 0x{1} {{ ", xDataLength, xArrayPointer.ToString("X"));
// { if (xIsTooLong)
// xDataLength = 512; {
// } xDataLength = 512;
// xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayFirstElementOffset, xDataLength); }
// for (int i = 0; i < xData.Length; i++) xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayFirstElementOffset, xDataLength);
// { for (int i = 0; i < xData.Length; i++)
// xSB.Append(xData[i].ToString("X2").ToUpper()); {
// if (i < (xData.Length - 1)) xSB.Append(xData[i].ToString("X2").ToUpper());
// { if (i < (xData.Length - 1))
// xSB.Append(" "); {
// } xSB.Append(" ");
// } }
// if (xIsTooLong) }
// { if (xIsTooLong)
// xSB.Append(", .."); {
// } xSB.Append(", ..");
}
// xSB.Append(" }"); xSB.Append(" }");
// propertyInfo.bstrValue = xSB.ToString(); propertyInfo.bstrValue = xSB.ToString();
// } }
//} }
//else if (mDebugInfo.Type == typeof(char).AssemblyQualifiedName) else if (mDebugInfo.Type == typeof(char).AssemblyQualifiedName)
//{ {
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 2); xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 2);
// var xTypedCharValue = BitConverter.ToChar(xData, 0); var xTypedCharValue = BitConverter.ToChar(xData, 0);
// propertyInfo.bstrValue = String.Format("{0} '{1}'", (ushort)xTypedCharValue, xTypedCharValue); propertyInfo.bstrValue = String.Format("{0} '{1}'", (ushort)xTypedCharValue, xTypedCharValue);
//} }
//else if (mDebugInfo.Type == typeof(int).AssemblyQualifiedName) else if (mDebugInfo.Type == typeof(int).AssemblyQualifiedName)
//{ {
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4); xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
// var xTypedIntValue = BitConverter.ToInt32(xData, 0); var xTypedIntValue = BitConverter.ToInt32(xData, 0);
// propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedIntValue, xTypedIntValue.ToString("X").ToUpper()); propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedIntValue, xTypedIntValue.ToString("X").ToUpper());
//} }
//else if (mDebugInfo.Type == typeof(long).AssemblyQualifiedName) else if (mDebugInfo.Type == typeof(long).AssemblyQualifiedName)
//{ {
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 8); xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 8);
// if (xData.Length != 8) if (xData.Length != 8)
// { {
// throw new Exception("Length should have been 8, but is " + xData.Length); throw new Exception("Length should have been 8, but is " + xData.Length);
// } }
// var xTypedLongValue = BitConverter.ToInt64(xData, 0); var xTypedLongValue = BitConverter.ToInt64(xData, 0);
// propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedLongValue, xTypedLongValue.ToString("X").ToUpper()); propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedLongValue, xTypedLongValue.ToString("X").ToUpper());
//} }
//else if (mDebugInfo.Type == typeof(ulong).AssemblyQualifiedName) else if (mDebugInfo.Type == typeof(ulong).AssemblyQualifiedName)
//{ {
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 8); xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 8);
// if (xData.Length != 8) if (xData.Length != 8)
// { {
// throw new Exception("Length should have been 8, but is " + xData.Length); throw new Exception("Length should have been 8, but is " + xData.Length);
// } }
// var xTypedULongValue = BitConverter.ToUInt64(xData, 0); var xTypedULongValue = BitConverter.ToUInt64(xData, 0);
// propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedULongValue, xTypedULongValue.ToString("X").ToUpper()); propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedULongValue, xTypedULongValue.ToString("X").ToUpper());
//} }
//else else
//{ {
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4); xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
// var xTypedUIntValue = BitConverter.ToUInt32(xData, 0); var xTypedUIntValue = BitConverter.ToUInt32(xData, 0);
// propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedUIntValue, xTypedUIntValue.ToString("X").ToUpper()); propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedUIntValue, xTypedUIntValue.ToString("X").ToUpper());
//} }
propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE; propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE;
} }

View file

@ -67,6 +67,7 @@
<Reference Include="System.Data" /> <Reference Include="System.Data" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DictionaryImpl.cs" />
<Compile Include="IO\FileStreamImpl.cs" /> <Compile Include="IO\FileStreamImpl.cs" />
<Compile Include="Text\DecoderFallbackImpl.cs" /> <Compile Include="Text\DecoderFallbackImpl.cs" />
<Compile Include="Text\EncoderFallbackImpl.cs" /> <Compile Include="Text\EncoderFallbackImpl.cs" />

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.IL2CPU.Plugs;
namespace Cosmos.System.Plugs.System
{
[Plug(Target=typeof(Dictionary<int, string>))]
public static class DictionaryImpl
{
public static void Ctor(Dictionary<int, string> aThis, int capacity, IEqualityComparer<int> comparer)
{
if (capacity != 0)
{
throw new Exception("Capacity != 0 not supported yet!");
}
}
}
}

View file

@ -9,10 +9,15 @@ namespace Cosmos.System.Plugs.System.IO {
[Plug(Target = typeof(IO::FileStream))] [Plug(Target = typeof(IO::FileStream))]
public class FileStreamImpl { public class FileStreamImpl {
static public void FileStream(String aPathname, IO::FileMode aMode) { static public void Ctor(IO::FileStream aThis, String aPathname, IO::FileMode aMode) {
global::System.Console.WriteLine("File open"); global::System.Console.WriteLine("File open");
} }
static public void CCtor()
{
// plug cctor as it (indirectly) uses Thread.MemoryBarrier()
}
//static void Init(IO::FileStream aThis, string path, IO::FileMode mode, IO::FileAccess access, int rights, bool useRights, IO::FileShare share, int bufferSize //static void Init(IO::FileStream aThis, string path, IO::FileMode mode, IO::FileAccess access, int rights, bool useRights, IO::FileShare share, int bufferSize
// , IO::FileOptions options, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy) { } // , IO::FileOptions options, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy) { }

View file

@ -24,6 +24,13 @@ namespace Cosmos.System.Plugs.System
return "<type>"; return "<type>";
} }
[PlugMethod(Signature="System_Boolean__System_Type_op_Equality_System_Type__System_Type_")]
public static bool op_Equality(uint left, uint right)
{
// for now, type info is the type id.
return left == right;
}
//System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle) //System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)
} }
} }

View file

@ -7,6 +7,7 @@ using Cosmos.IL2CPU.Plugs;
namespace Cosmos.Core.Plugs { namespace Cosmos.Core.Plugs {
//TODO: Move this and other FCL plugs to Cosmos.Plugs assembly. some plugs like Console need hardware //TODO: Move this and other FCL plugs to Cosmos.Plugs assembly. some plugs like Console need hardware
// but these generics ones should be moved, this does not depend on kernel // but these generics ones should be moved, this does not depend on kernel
[Plug(Target=typeof(string))]
public class StringImpl { public class StringImpl {
/*public int IndexOf(char c) /*public int IndexOf(char c)
{ {
@ -308,6 +309,11 @@ namespace Cosmos.Core.Plugs {
return ChangeCasing(aThis, 97, 122, -32); return ChangeCasing(aThis, 97, 122, -32);
} }
public static string ToUpper(string aThis)
{
return ChangeCasing(aThis, 97, 122, -32);
}
private static string ChangeCasing(string aValue, int lowerAscii, int upperAscii, int offset) { private static string ChangeCasing(string aValue, int lowerAscii, int upperAscii, int offset) {
char[] xChars = new char[aValue.Length]; char[] xChars = new char[aValue.Length];

View file

@ -3,11 +3,25 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using Sys = Cosmos.System; using Sys = Cosmos.System;
using Cosmos.Common.Extensions; using Cosmos.Common.Extensions;
using System.IO;
using Cosmos.Debug.Kernel;
namespace MatthijsPlayground namespace MatthijsPlayground
{ {
public class Kernel : Sys.Kernel public class Kernel : Sys.Kernel
{ {
private class TestComparer : IEqualityComparer<int>
{
public bool Equals(int x, int y)
{
return x == y;
}
public int GetHashCode(int obj)
{
return obj.GetHashCode();
}
}
protected override void BeforeRun() protected override void BeforeRun()
{ {
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back."); Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
@ -23,18 +37,26 @@ namespace MatthijsPlayground
private static void DoSomething() private static void DoSomething()
{ {
int xValue1 = 0x00000001; Console.WriteLine("Before Everything");
int xValue2 = 0x00000002;
int xValue3 = 0x00000003;
Console.WriteLine("Done"); var xString = "";
//WriteLine("Line1"); var xDbg = new Debugger("kernel", "kernel");
xDbg.Send(xString);
//var xSB = new StringBuilder();
//xSB.Append("Hello");
//xSB.Append("Hello");
//var xDisplay = xSB.ToString();
//Console.WriteLine(xDisplay.Length);
//Console.WriteLine(xDisplay);
Console.WriteLine("After everything");
//WriteLine("Line2"); //WriteLine("Line2");
//WriteLine("Line3"); //WriteLine("Line3");
} }
private static void WriteLine(string line) private static void WriteLine(string line)
{ {
var xTheLine = line.ToUpper();
Console.WriteLine(line); Console.WriteLine(line);
} }
} }

View file

@ -17,7 +17,7 @@
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<Framework>MicrosoftNET</Framework> <Framework>MicrosoftNET</Framework>
<UseInternalAssembler>False</UseInternalAssembler> <UseInternalAssembler>False</UseInternalAssembler>
<EnableGDB>True</EnableGDB> <EnableGDB>False</EnableGDB>
<DebugMode>Source</DebugMode> <DebugMode>Source</DebugMode>
<TraceMode>User</TraceMode> <TraceMode>User</TraceMode>
<BuildTarget>VMWare</BuildTarget> <BuildTarget>VMWare</BuildTarget>