From 262f0080df061e932d7aa43d9e89ce40dce448ea Mon Sep 17 00:00:00 2001 From: sschocke_cp <7f003704bc94ef3acf0afcda2bf5f827e6e21455CS9agd82> Date: Fri, 3 Feb 2012 17:32:53 +0000 Subject: [PATCH] Added a new Attribute called DebugStub. Has a property Off which when set to true specifies that no debugstub calls should be inserted for code in this function. NOT FOR GENERAL USE!! CAUTION: No debugging what so ever is possible on a function with this attribute applied. Useful for large loops of tested code where speed is of the essence --- .../Cosmos.IL2CPU.Plugs.csproj | 1 + .../Cosmos.IL2CPU.Plugs/DebugStubAttribute.cs | 13 +++++++++++++ .../Cosmos.IL2CPU.X86/AppAssemblerNasm.cs | 6 ++++++ source2/IL2CPU/Cosmos.IL2CPU/MethodInfo.cs | 19 ++++++++++++++----- .../Core/Cosmos.Core/Cosmos.Core.csproj | 4 ++++ .../Hardware/Core/Cosmos.Core/MemoryBlock.cs | 4 ++++ .../SSchocke/SSchockeTest/SSchockeTest.csproj | 1 + 7 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 source2/IL2CPU/Cosmos.IL2CPU.Plugs/DebugStubAttribute.cs diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Plugs/Cosmos.IL2CPU.Plugs.csproj b/source2/IL2CPU/Cosmos.IL2CPU.Plugs/Cosmos.IL2CPU.Plugs.csproj index ef4afea10..75330fe69 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU.Plugs/Cosmos.IL2CPU.Plugs.csproj +++ b/source2/IL2CPU/Cosmos.IL2CPU.Plugs/Cosmos.IL2CPU.Plugs.csproj @@ -65,6 +65,7 @@ + diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Plugs/DebugStubAttribute.cs b/source2/IL2CPU/Cosmos.IL2CPU.Plugs/DebugStubAttribute.cs new file mode 100644 index 000000000..3a5a48f56 --- /dev/null +++ b/source2/IL2CPU/Cosmos.IL2CPU.Plugs/DebugStubAttribute.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cosmos.IL2CPU.Plugs +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public sealed class DebugStubAttribute : Attribute + { + public bool Off = false; + } +} diff --git a/source2/IL2CPU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs b/source2/IL2CPU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs index 6b4b2c1cb..6ac4b076c 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs @@ -456,6 +456,12 @@ namespace Cosmos.IL2CPU.X86 { } } + // Check if the DebugStub has been disabled for this method + if (aMethod.DebugStubOff) + { + return; + } + // Check options for Debug Level // Set based on TracedAssemblies if (TraceAssemblies == TraceAssemblies.Cosmos || TraceAssemblies == TraceAssemblies.User) { diff --git a/source2/IL2CPU/Cosmos.IL2CPU/MethodInfo.cs b/source2/IL2CPU/Cosmos.IL2CPU/MethodInfo.cs index 5bdc11e5a..3a373b641 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/MethodInfo.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/MethodInfo.cs @@ -16,20 +16,22 @@ namespace Cosmos.IL2CPU public readonly MethodInfo PlugMethod; public readonly Type MethodAssembler; public readonly bool IsInlineAssembler = false; + public readonly bool DebugStubOff; public MethodInfo PluggedMethod; - public MethodInfo(MethodBase aMethodBase, UInt32 aUID, TypeEnum aType, MethodInfo aPlugMethod, Type aMethodAssembler) : this(aMethodBase, aUID, aType, aPlugMethod) + public MethodInfo(MethodBase aMethodBase, UInt32 aUID, TypeEnum aType, MethodInfo aPlugMethod, Type aMethodAssembler) : this(aMethodBase, aUID, aType, aPlugMethod, false) { MethodAssembler = aMethodAssembler; } public MethodInfo(MethodBase aMethodBase, UInt32 aUID, TypeEnum aType, MethodInfo aPlugMethod) + : this(aMethodBase, aUID, aType, aPlugMethod, false) { - MethodBase = aMethodBase; - UID = aUID; - Type = aType; - PlugMethod = aPlugMethod; + //MethodBase = aMethodBase; + //UID = aUID; + //Type = aType; + //PlugMethod = aPlugMethod; } public MethodInfo(MethodBase aMethodBase, UInt32 aUID, TypeEnum aType, MethodInfo aPlugMethod, bool isInlineAssembler) @@ -39,6 +41,13 @@ namespace Cosmos.IL2CPU Type = aType; PlugMethod = aPlugMethod; IsInlineAssembler = isInlineAssembler; + + Object[] attribs = this.MethodBase.GetCustomAttributes(typeof(Cosmos.IL2CPU.Plugs.DebugStubAttribute), false); + if (attribs.Length > 0) + { + Cosmos.IL2CPU.Plugs.DebugStubAttribute attrib = attribs[0] as Cosmos.IL2CPU.Plugs.DebugStubAttribute; + DebugStubOff = attrib.Off; + } } } diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/Cosmos.Core.csproj b/source2/Kernel/System/Hardware/Core/Cosmos.Core/Cosmos.Core.csproj index 3011c4ab0..b98368278 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/Cosmos.Core.csproj +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/Cosmos.Core.csproj @@ -102,6 +102,10 @@ + + {C801F19C-A9D3-42D5-9A57-9FFDF9B4D05E} + Cosmos.IL2CPU.Plugs + {1FAC100C-D732-4EA4-B518-5AF4BAF64F2E} Cosmos.Common.Extensions diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/MemoryBlock.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/MemoryBlock.cs index e219ba0fd..00de17a68 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/MemoryBlock.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/MemoryBlock.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Cosmos.Common.Extensions; using System.Linq; using System.Text; +using Cosmos.IL2CPU.Plugs; namespace Cosmos.Core { @@ -53,6 +54,7 @@ namespace Cosmos.Core Fill(0, Size / 4, aData); } + [DebugStub(Off = true)] public unsafe void Fill(UInt32 aStart, UInt32 aCount, UInt32 aData) { //TODO: before next step can at least check bounds here and do the addition just once to @@ -70,6 +72,7 @@ namespace Cosmos.Core Fill(0, Size, aData); } + [DebugStub(Off = true)] public unsafe void Fill(UInt32 aStart, UInt32 aCount, byte aData) { //TODO: before next step can at least check bounds here and do the addition just once to @@ -83,6 +86,7 @@ namespace Cosmos.Core } } + [DebugStub(Off = true)] public unsafe void MoveDown(UInt32 aDest, UInt32 aSrc, UInt32 aCount) { byte* xDest = (byte*)(this.Base + aDest); diff --git a/source2/Users/SSchocke/SSchockeTest/SSchockeTest.csproj b/source2/Users/SSchocke/SSchockeTest/SSchockeTest.csproj index 33d567210..c4f036865 100644 --- a/source2/Users/SSchocke/SSchockeTest/SSchockeTest.csproj +++ b/source2/Users/SSchocke/SSchockeTest/SSchockeTest.csproj @@ -33,6 +33,7 @@ TRACE prompt 4 + true