mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-05 15:51:56 +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"
|
+ ", 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"
|
||||||
+ ");"
|
+ ");"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
if (mDebugInfo.Type == typeof(string).AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
#region string support
|
||||||
|
const uint xStringLengthOffset = 16;
|
||||||
|
const uint xStringFirstCharPtrOffset = 20;
|
||||||
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||||
propertyInfo.bstrValue = xData.Aggregate("", (r, b) => r + " " + b.ToString("X2").ToUpper());
|
uint xStrPointer = BitConverter.ToUInt32(xData, 0);
|
||||||
//if (mDebugInfo.Type == typeof(string).AssemblyQualifiedName)
|
if (xStrPointer == 0)
|
||||||
//{
|
{
|
||||||
// #region string support
|
propertyInfo.bstrValue = "(null)";
|
||||||
// const uint xStringLengthOffset = 16;
|
}
|
||||||
// const uint xStringFirstCharPtrOffset = 20;
|
else
|
||||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
{
|
||||||
// uint xStrPointer = BitConverter.ToUInt32(xData, 0);
|
xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringLengthOffset, 4, 4);
|
||||||
// if (xStrPointer == 0)
|
uint xStringLength = BitConverter.ToUInt32(xData, 0);
|
||||||
// {
|
if (xStringLength > 100)
|
||||||
// propertyInfo.bstrValue = "(null)";
|
{
|
||||||
// }
|
propertyInfo.bstrValue = "For now, strings larger than 100 chars are not supported..";
|
||||||
// else
|
}
|
||||||
// {
|
else if (xStringLength == 0)
|
||||||
// xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringLengthOffset, 4, 4);
|
{
|
||||||
// uint xStringLength = BitConverter.ToUInt32(xData, 0);
|
propertyInfo.bstrValue = "\"\"";
|
||||||
// if (xStringLength > 100)
|
}
|
||||||
// {
|
else
|
||||||
// propertyInfo.bstrValue = "For now, strings larger than 100 chars are not supported..";
|
{
|
||||||
// } else if (xStringLength == 0) {
|
xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringFirstCharPtrOffset, 4, 4);
|
||||||
// propertyInfo.bstrValue = "\"\"";
|
uint xFirstCharPtr = BitConverter.ToUInt32(xData, 0);
|
||||||
// }else
|
xData = mProcess.mDbgConnector.GetMemoryData(xFirstCharPtr, xStringLength * 2, 2);
|
||||||
// {
|
propertyInfo.bstrValue = "\"" + Encoding.Unicode.GetString(xData) + "\"";
|
||||||
// xData = mProcess.mDbgConnector.GetMemoryData(xStrPointer + xStringFirstCharPtrOffset, 4, 4);
|
}
|
||||||
// uint xFirstCharPtr = BitConverter.ToUInt32(xData, 0);
|
}
|
||||||
// xData = mProcess.mDbgConnector.GetMemoryData(xFirstCharPtr, xStringLength * 2, 2);
|
#endregion string support
|
||||||
// propertyInfo.bstrValue = "\"" + Encoding.Unicode.GetString(xData) + "\"";
|
}
|
||||||
// }
|
else if (mDebugInfo.Type == typeof(byte[]).AssemblyQualifiedName)
|
||||||
// }
|
{
|
||||||
// #endregion string support
|
const uint xArrayLengthOffset = 8;
|
||||||
//}
|
const uint xArrayFirstElementOffset = 16;
|
||||||
//else if (mDebugInfo.Type == typeof(byte[]).AssemblyQualifiedName)
|
xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
||||||
//{
|
uint xArrayPointer = BitConverter.ToUInt32(xData, 0);
|
||||||
// const uint xArrayLengthOffset = 8;
|
if (xArrayPointer == 0)
|
||||||
// const uint xArrayFirstElementOffset = 16;
|
{
|
||||||
// xData = mProcess.mDbgConnector.GetStackData(mDebugInfo.Offset, 4);
|
propertyInfo.bstrValue = "(null)";
|
||||||
// uint xArrayPointer = BitConverter.ToUInt32(xData, 0);
|
}
|
||||||
// if (xArrayPointer == 0)
|
else
|
||||||
// {
|
{
|
||||||
// propertyInfo.bstrValue = "(null)";
|
xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayLengthOffset, 4, 4);
|
||||||
// }
|
uint xDataLength = BitConverter.ToUInt32(xData, 0);
|
||||||
// else
|
bool xIsTooLong = xDataLength > 512;
|
||||||
// {
|
var xSB = new StringBuilder();
|
||||||
// xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayLengthOffset, 4, 4);
|
xSB.AppendFormat("Byte[{0}] at 0x{1} {{ ", xDataLength, xArrayPointer.ToString("X"));
|
||||||
// uint xDataLength = BitConverter.ToUInt32(xData, 0);
|
if (xIsTooLong)
|
||||||
// bool xIsTooLong = xDataLength > 512;
|
{
|
||||||
// var xSB = new StringBuilder();
|
xDataLength = 512;
|
||||||
// xSB.AppendFormat("Byte[{0}] at 0x{1} {{ ", xDataLength, xArrayPointer.ToString("X"));
|
}
|
||||||
// if (xIsTooLong)
|
xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayFirstElementOffset, xDataLength);
|
||||||
// {
|
for (int i = 0; i < xData.Length; i++)
|
||||||
// xDataLength = 512;
|
{
|
||||||
// }
|
xSB.Append(xData[i].ToString("X2").ToUpper());
|
||||||
// xData = mProcess.mDbgConnector.GetMemoryData(xArrayPointer + xArrayFirstElementOffset, xDataLength);
|
if (i < (xData.Length - 1))
|
||||||
// for (int i = 0; i < xData.Length; i++)
|
{
|
||||||
// {
|
xSB.Append(" ");
|
||||||
// xSB.Append(xData[i].ToString("X2").ToUpper());
|
}
|
||||||
// if (i < (xData.Length - 1))
|
}
|
||||||
// {
|
if (xIsTooLong)
|
||||||
// xSB.Append(" ");
|
{
|
||||||
// }
|
xSB.Append(", ..");
|
||||||
// }
|
}
|
||||||
// if (xIsTooLong)
|
|
||||||
// {
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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" />
|
||||||
|
|
|
||||||
|
|
@ -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))]
|
[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) { }
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue