mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
This commit is contained in:
parent
bd59ac6966
commit
bd82fa4238
9 changed files with 181 additions and 116 deletions
|
|
@ -173,7 +173,7 @@ namespace Cosmos.Debug.Common
|
|||
+ ", INDEXINMETHOD INT NOT NULL"
|
||||
+ ", OFFSET INT NOT NULL"
|
||||
+ ", NAME VARCHAR(255) NOT NULL"
|
||||
+ ", TYPENAME VARCHAR(255) NOT NULL"
|
||||
+ ", TYPENAME VARCHAR(4000) NOT NULL"
|
||||
+ ");"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -62,115 +62,116 @@ namespace Cosmos.Debug.VSDebugEngine
|
|||
if (dwFields.HasFlag(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE))
|
||||
{
|
||||
byte[] xData;
|
||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
propertyInfo.bstrValue = xData.Aggregate("", (r, b) => r + " " + b.ToString("X2").ToUpper());
|
||||
//if (mDebugInfo.Type == typeof(string).AssemblyQualifiedName)
|
||||
//{
|
||||
// #region string support
|
||||
// const uint xStringLengthOffset = 16;
|
||||
// const uint xStringFirstCharPtrOffset = 20;
|
||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
// uint xStrPointer = BitConverter.ToUInt32(xData, 0);
|
||||
// if (xStrPointer == 0)
|
||||
// {
|
||||
// propertyInfo.bstrValue = "(null)";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringLengthOffset, 4, 4);
|
||||
// uint xStringLength = BitConverter.ToUInt32(xData, 0);
|
||||
// if (xStringLength > 100)
|
||||
// {
|
||||
// propertyInfo.bstrValue = "For now, strings larger than 100 chars are not supported..";
|
||||
// } else if (xStringLength == 0) {
|
||||
// propertyInfo.bstrValue = "\"\"";
|
||||
// }else
|
||||
// {
|
||||
// xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringFirstCharPtrOffset, 4, 4);
|
||||
// uint xFirstCharPtr = BitConverter.ToUInt32(xData, 0);
|
||||
// xData = mProcess.mDbgConnector.GetMemoryData(xFirstCharPtr, xStringLength * 2, 2);
|
||||
// propertyInfo.bstrValue = "\"" + Encoding.Unicode.GetString(xData) + "\"";
|
||||
// }
|
||||
// }
|
||||
// #endregion string support
|
||||
//}
|
||||
//else if (mDebugInfo.Type == typeof(byte[]).AssemblyQualifiedName)
|
||||
//{
|
||||
// const uint xArrayLengthOffset = 8;
|
||||
// const uint xArrayFirstElementOffset = 16;
|
||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
// uint xArrayPointer = BitConverter.ToUInt32(xData, 0);
|
||||
// if (xArrayPointer == 0)
|
||||
// {
|
||||
// propertyInfo.bstrValue = "(null)";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayLengthOffset, 4, 4);
|
||||
// uint xDataLength = BitConverter.ToUInt32(xData, 0);
|
||||
// bool xIsTooLong = xDataLength > 512;
|
||||
// var xSB = new StringBuilder();
|
||||
// xSB.AppendFormat("Byte[{0}] at 0x{1} {{ ", xDataLength, xArrayPointer.ToString("X"));
|
||||
// if (xIsTooLong)
|
||||
// {
|
||||
// xDataLength = 512;
|
||||
// }
|
||||
// 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(" ");
|
||||
// }
|
||||
// }
|
||||
// if (xIsTooLong)
|
||||
// {
|
||||
// xSB.Append(", ..");
|
||||
// }
|
||||
if (mDebugInfo.Type == typeof(string).AssemblyQualifiedName)
|
||||
{
|
||||
#region string support
|
||||
const uint xStringLengthOffset = 16;
|
||||
const uint xStringFirstCharPtrOffset = 20;
|
||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
uint xStrPointer = BitConverter.ToUInt32(xData, 0);
|
||||
if (xStrPointer == 0)
|
||||
{
|
||||
propertyInfo.bstrValue = "(null)";
|
||||
}
|
||||
else
|
||||
{
|
||||
xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringLengthOffset, 4, 4);
|
||||
uint xStringLength = BitConverter.ToUInt32(xData, 0);
|
||||
if (xStringLength > 100)
|
||||
{
|
||||
propertyInfo.bstrValue = "For now, strings larger than 100 chars are not supported..";
|
||||
}
|
||||
else if (xStringLength == 0)
|
||||
{
|
||||
propertyInfo.bstrValue = "\"\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringFirstCharPtrOffset, 4, 4);
|
||||
uint xFirstCharPtr = BitConverter.ToUInt32(xData, 0);
|
||||
xData = mProcess.mDbgConnector.GetMemoryData(xFirstCharPtr, xStringLength * 2, 2);
|
||||
propertyInfo.bstrValue = "\"" + Encoding.Unicode.GetString(xData) + "\"";
|
||||
}
|
||||
}
|
||||
#endregion string support
|
||||
}
|
||||
else if (mDebugInfo.Type == typeof(byte[]).AssemblyQualifiedName)
|
||||
{
|
||||
const uint xArrayLengthOffset = 8;
|
||||
const uint xArrayFirstElementOffset = 16;
|
||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
uint xArrayPointer = BitConverter.ToUInt32(xData, 0);
|
||||
if (xArrayPointer == 0)
|
||||
{
|
||||
propertyInfo.bstrValue = "(null)";
|
||||
}
|
||||
else
|
||||
{
|
||||
xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayLengthOffset, 4, 4);
|
||||
uint xDataLength = BitConverter.ToUInt32(xData, 0);
|
||||
bool xIsTooLong = xDataLength > 512;
|
||||
var xSB = new StringBuilder();
|
||||
xSB.AppendFormat("Byte[{0}] at 0x{1} {{ ", xDataLength, xArrayPointer.ToString("X"));
|
||||
if (xIsTooLong)
|
||||
{
|
||||
xDataLength = 512;
|
||||
}
|
||||
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(" ");
|
||||
}
|
||||
}
|
||||
if (xIsTooLong)
|
||||
{
|
||||
xSB.Append(", ..");
|
||||
}
|
||||
|
||||
// xSB.Append(" }");
|
||||
// propertyInfo.bstrValue = xSB.ToString();
|
||||
// }
|
||||
//}
|
||||
//else if (mDebugInfo.Type == typeof(char).AssemblyQualifiedName)
|
||||
//{
|
||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 2);
|
||||
// var xTypedCharValue = BitConverter.ToChar(xData, 0);
|
||||
// propertyInfo.bstrValue = String.Format("{0} '{1}'", (ushort)xTypedCharValue, xTypedCharValue);
|
||||
//}
|
||||
//else if (mDebugInfo.Type == typeof(int).AssemblyQualifiedName)
|
||||
//{
|
||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
// var xTypedIntValue = BitConverter.ToInt32(xData, 0);
|
||||
// propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedIntValue, xTypedIntValue.ToString("X").ToUpper());
|
||||
//}
|
||||
//else if (mDebugInfo.Type == typeof(long).AssemblyQualifiedName)
|
||||
//{
|
||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 8);
|
||||
// if (xData.Length != 8)
|
||||
// {
|
||||
// throw new Exception("Length should have been 8, but is " + xData.Length);
|
||||
// }
|
||||
// var xTypedLongValue = BitConverter.ToInt64(xData, 0);
|
||||
// propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedLongValue, xTypedLongValue.ToString("X").ToUpper());
|
||||
//}
|
||||
//else if (mDebugInfo.Type == typeof(ulong).AssemblyQualifiedName)
|
||||
//{
|
||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 8);
|
||||
// if (xData.Length != 8)
|
||||
// {
|
||||
// throw new Exception("Length should have been 8, but is " + xData.Length);
|
||||
// }
|
||||
// var xTypedULongValue = BitConverter.ToUInt64(xData, 0);
|
||||
// propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedULongValue, xTypedULongValue.ToString("X").ToUpper());
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
// var xTypedUIntValue = BitConverter.ToUInt32(xData, 0);
|
||||
// propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedUIntValue, xTypedUIntValue.ToString("X").ToUpper());
|
||||
//}
|
||||
xSB.Append(" }");
|
||||
propertyInfo.bstrValue = xSB.ToString();
|
||||
}
|
||||
}
|
||||
else if (mDebugInfo.Type == typeof(char).AssemblyQualifiedName)
|
||||
{
|
||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 2);
|
||||
var xTypedCharValue = BitConverter.ToChar(xData, 0);
|
||||
propertyInfo.bstrValue = String.Format("{0} '{1}'", (ushort)xTypedCharValue, xTypedCharValue);
|
||||
}
|
||||
else if (mDebugInfo.Type == typeof(int).AssemblyQualifiedName)
|
||||
{
|
||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
var xTypedIntValue = BitConverter.ToInt32(xData, 0);
|
||||
propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedIntValue, xTypedIntValue.ToString("X").ToUpper());
|
||||
}
|
||||
else if (mDebugInfo.Type == typeof(long).AssemblyQualifiedName)
|
||||
{
|
||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 8);
|
||||
if (xData.Length != 8)
|
||||
{
|
||||
throw new Exception("Length should have been 8, but is " + xData.Length);
|
||||
}
|
||||
var xTypedLongValue = BitConverter.ToInt64(xData, 0);
|
||||
propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedLongValue, xTypedLongValue.ToString("X").ToUpper());
|
||||
}
|
||||
else if (mDebugInfo.Type == typeof(ulong).AssemblyQualifiedName)
|
||||
{
|
||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 8);
|
||||
if (xData.Length != 8)
|
||||
{
|
||||
throw new Exception("Length should have been 8, but is " + xData.Length);
|
||||
}
|
||||
var xTypedULongValue = BitConverter.ToUInt64(xData, 0);
|
||||
propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedULongValue, xTypedULongValue.ToString("X").ToUpper());
|
||||
}
|
||||
else
|
||||
{
|
||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||
var xTypedUIntValue = BitConverter.ToUInt32(xData, 0);
|
||||
propertyInfo.bstrValue = String.Format("{0} (0x{1})", xTypedUIntValue, xTypedUIntValue.ToString("X").ToUpper());
|
||||
}
|
||||
propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@
|
|||
<Reference Include="System.Data" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DictionaryImpl.cs" />
|
||||
<Compile Include="IO\FileStreamImpl.cs" />
|
||||
<Compile Include="Text\DecoderFallbackImpl.cs" />
|
||||
<Compile Include="Text\EncoderFallbackImpl.cs" />
|
||||
|
|
|
|||
|
|
@ -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!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -9,10 +9,15 @@ namespace Cosmos.System.Plugs.System.IO {
|
|||
[Plug(Target = typeof(IO::FileStream))]
|
||||
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");
|
||||
}
|
||||
|
||||
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
|
||||
// , IO::FileOptions options, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy) { }
|
||||
|
|
|
|||
|
|
@ -24,6 +24,13 @@ namespace Cosmos.System.Plugs.System
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Cosmos.IL2CPU.Plugs;
|
|||
namespace Cosmos.Core.Plugs {
|
||||
//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
|
||||
[Plug(Target=typeof(string))]
|
||||
public class StringImpl {
|
||||
/*public int IndexOf(char c)
|
||||
{
|
||||
|
|
@ -308,6 +309,11 @@ namespace Cosmos.Core.Plugs {
|
|||
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) {
|
||||
char[] xChars = new char[aValue.Length];
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,25 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using Sys = Cosmos.System;
|
||||
using Cosmos.Common.Extensions;
|
||||
using System.IO;
|
||||
using Cosmos.Debug.Kernel;
|
||||
|
||||
namespace MatthijsPlayground
|
||||
{
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
int xValue1 = 0x00000001;
|
||||
int xValue2 = 0x00000002;
|
||||
int xValue3 = 0x00000003;
|
||||
Console.WriteLine("Before Everything");
|
||||
|
||||
Console.WriteLine("Done");
|
||||
//WriteLine("Line1");
|
||||
var xString = "";
|
||||
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("Line3");
|
||||
}
|
||||
|
||||
private static void WriteLine(string line)
|
||||
{
|
||||
var xTheLine = line.ToUpper();
|
||||
Console.WriteLine(line);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<Framework>MicrosoftNET</Framework>
|
||||
<UseInternalAssembler>False</UseInternalAssembler>
|
||||
<EnableGDB>True</EnableGDB>
|
||||
<EnableGDB>False</EnableGDB>
|
||||
<DebugMode>Source</DebugMode>
|
||||
<TraceMode>User</TraceMode>
|
||||
<BuildTarget>VMWare</BuildTarget>
|
||||
|
|
|
|||
Loading…
Reference in a new issue