Skip to content

Commit

Permalink
- Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Jun 28, 2018
1 parent 8564a7d commit db52b2c
Show file tree
Hide file tree
Showing 18 changed files with 511 additions and 69 deletions.
Binary file removed Documentation/Screenshots/MOSA Debugger.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Source/MOSA.sln
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{624E8284
Inno-Setup-Script\Mosa-Installer.iss = Inno-Setup-Script\Mosa-Installer.iss
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mosa.Workspace.Generator.Debug", "Mosa.Workspace.Generator.Debug\Mosa.Workspace.Generator.Debug.csproj", "{A8765C3C-1194-4A3A-8579-745CA47C36D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -792,6 +794,18 @@ Global
{7B8FBA4E-D6AC-4DAD-A607-43BA112F8EC1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7B8FBA4E-D6AC-4DAD-A607-43BA112F8EC1}.Release|x86.ActiveCfg = Release|Any CPU
{7B8FBA4E-D6AC-4DAD-A607-43BA112F8EC1}.Release|x86.Build.0 = Release|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Debug|x86.ActiveCfg = Debug|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Debug|x86.Build.0 = Debug|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Release|Any CPU.Build.0 = Release|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Release|x86.ActiveCfg = Release|Any CPU
{A8765C3C-1194-4A3A-8579-745CA47C36D1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -850,6 +864,7 @@ Global
{7B8FBA4E-D6AC-4DAD-A607-43BA112F8EC1} = {90065B0F-1BFE-40D8-AED5-11096B2535B0}
{A13B9E8A-DC5E-4396-B071-3671CC148E64} = {F0EFF742-92D5-4219-939A-8F6F8DAB24E5}
{624E8284-4F0A-4C3F-B5F2-271105E48ECF} = {F0EFF742-92D5-4219-939A-8F6F8DAB24E5}
{A8765C3C-1194-4A3A-8579-745CA47C36D1} = {AC7C3CDA-E0E8-408C-BB32-DBCBB905E3E1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C22A5C94-6B05-4B1B-845A-A2EA7615E093}
Expand Down
1 change: 1 addition & 0 deletions Source/Mosa.Korlib/Mosa.Korlib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<Compile Include="System.Threading\Monitor.cs" />
<Compile Include="System.Threading\Thread.cs" />
<Compile Include="System.Threading\SpinLock.cs" />
<Compile Include="System\BitConverter.cs" />
<Compile Include="System\ConsoleColor.cs" />
<Compile Include="System\PlatformNotSupportedException.cs" />
<Compile Include="System\Action.cs" />
Expand Down
124 changes: 124 additions & 0 deletions Source/Mosa.Korlib/System/BitConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace System
{
public static class BitConverter
{
public static readonly bool IsLittleEndian = true;

// Converts a Boolean into an array of bytes with length one.
public static byte[] GetBytes(bool value)
{
byte[] r = new byte[1];
r[0] = (value ? (byte)1 : (byte)0);
return r;
}

// Converts a char into an array of bytes with length two.
public static byte[] GetBytes(char value)
{
byte[] bytes = new byte[sizeof(char)];
Unsafe.As<byte, char>(ref bytes[0]) = value;
return bytes;
}

// Converts a short into an array of bytes with length
// two.
public static byte[] GetBytes(short value)
{
byte[] bytes = new byte[sizeof(short)];
Unsafe.As<byte, short>(ref bytes[0]) = value;
return bytes;
}

// Converts an int into an array of bytes with length
// four.
public static byte[] GetBytes(int value)
{
byte[] bytes = new byte[sizeof(int)];
Unsafe.As<byte, int>(ref bytes[0]) = value;
return bytes;
}

// Converts a long into an array of bytes with length
// eight.
public static byte[] GetBytes(long value)
{
byte[] bytes = new byte[sizeof(long)];
Unsafe.As<byte, long>(ref bytes[0]) = value;
return bytes;
}

// Converts an ushort into an array of bytes with
// length two.
public static byte[] GetBytes(ushort value)
{
byte[] bytes = new byte[sizeof(ushort)];
Unsafe.As<byte, ushort>(ref bytes[0]) = value;
return bytes;
}

// Converts an uint into an array of bytes with
// length four.
public static byte[] GetBytes(uint value)
{
byte[] bytes = new byte[sizeof(uint)];
Unsafe.As<byte, uint>(ref bytes[0]) = value;
return bytes;
}

// Converts an unsigned long into an array of bytes with
// length eight.
public static byte[] GetBytes(ulong value)
{
byte[] bytes = new byte[sizeof(ulong)];
Unsafe.As<byte, ulong>(ref bytes[0]) = value;
return bytes;
}

// Converts a float into an array of bytes with length
// four.
public static byte[] GetBytes(float value)
{
byte[] bytes = new byte[sizeof(float)];
Unsafe.As<byte, float>(ref bytes[0]) = value;
return bytes;
}

// Converts a double into an array of bytes with length
// eight.
public static byte[] GetBytes(double value)
{
byte[] bytes = new byte[sizeof(double)];
Unsafe.As<byte, double>(ref bytes[0]) = value;
return bytes;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe long DoubleToInt64Bits(double value)
{
return *((long*)&value);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe double Int64BitsToDouble(long value)
{
return *((double*)&value);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int SingleToInt32Bits(float value)
{
return *((int*)&value);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe float Int32BitsToSingle(int value)
{
return *((float*)&value);
}
}
}
12 changes: 11 additions & 1 deletion Source/Mosa.Korlib/System/Double.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using System.Runtime.CompilerServices;

namespace System
{
/// <summary>
Expand Down Expand Up @@ -83,9 +85,17 @@ public override bool Equals(object obj)
return (value == _value);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)] // 64-bit constants make the IL unusually large that makes the inliner to reject the method
public override int GetHashCode()
{
return (int)_value;
var bits = BitConverter.DoubleToInt64Bits(_value);

if (((bits - 1) & 0x7FFFFFFFFFFFFFFF) >= 0x7FF0000000000000)
{
bits &= 0x7FF0000000000000;
}

return unchecked((int)bits) ^ ((int)(bits >> 32));
}
}
}
9 changes: 8 additions & 1 deletion Source/Mosa.Korlib/System/Single.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
return (int)_value;
var bits = BitConverter.SingleToInt32Bits(_value);

if (((bits - 1) & 0x7FFFFFFF) >= 0x7F800000)
{
bits &= 0x7F800000;
}

return bits;
}
}
}
7 changes: 7 additions & 0 deletions Source/Mosa.Tool.GDBDebugger/DebugData/DebugSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ public MethodInfo GetMethod(ulong address)
return null;
}

public MethodInfo GetMethodByID(int methodID)
{
MethodIDLookup.TryGetValue(methodID, out MethodInfo methodInfo);

return methodInfo;
}

public List<SourceLabelInfo> GetSourceLabels(int methodID)
{
return SourceLabelLookup.Get(methodID);
Expand Down
40 changes: 39 additions & 1 deletion Source/Mosa.Tool.GDBDebugger/DebugData/Source.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Mosa.Tool.GDBDebugger.DebugData
{
public static class Source
{
public static SourceLocation Find(DebugSource debugSource, ulong address)
public static SourceLocation GetSourceLocationByAddress(DebugSource debugSource, ulong address)
{
var method = debugSource.GetMethod(address);

Expand Down Expand Up @@ -41,6 +41,44 @@ public static SourceLocation Find(DebugSource debugSource, ulong address)

return sourceLocation;
}

public static SourceLocation GetSourceLocationByMethodID(DebugSource debugSource, int methodID)
{
var method = debugSource.GetMethodByID(methodID);

if (method == null)
return null;

var sourceLabel = debugSource.GetSourceLabel(methodID, 0);

if (sourceLabel == null)
return null;

var sourceInfo = debugSource.GetSourcePreviousClosest(methodID, sourceLabel.Label);

if (sourceInfo == null)
return null;

var sourceFileInfo = debugSource.GetSourceFile(sourceInfo.SourceFileID);

var sourceLocation = new SourceLocation()
{
Address = method.Address + (ulong)sourceLabel.StartOffset,
Length = sourceLabel.Length,
Label = sourceLabel.Label,
SourceLabel = sourceInfo.Label,
MethodFullName = method.FullName,
StartLine = sourceInfo.StartLine,
StartColumn = sourceInfo.StartColumn,
EndLine = sourceInfo.EndLine,
EndColumn = sourceInfo.EndColumn,
SourceFilename = sourceFileInfo.Filename,
MethodID = method.ID,
SourceFileID = sourceInfo.SourceFileID,
};

return sourceLocation;
}
}
}

Expand Down
Loading

0 comments on commit db52b2c

Please sign in to comment.