mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-22 22:09:12 +00:00
Add possibility for using the referenced debug stub version in the kernel tester.
Fixes #169
This commit is contained in:
parent
2c20ca8597
commit
e518b9c8e2
12 changed files with 146 additions and 54 deletions
|
|
@ -73,6 +73,10 @@
|
|||
<Compile Include="TaskFailedException.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\source\Cosmos.Assembler\Cosmos.Assembler.csproj">
|
||||
<Project>{1116130E-28E0-428A-A597-F4B3B676C0CA}</Project>
|
||||
<Name>Cosmos.Assembler</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\source\Cosmos.Build.Common\Cosmos.Build.Common.csproj">
|
||||
<Project>{0462E82B-8C29-41A9-8265-9C89038ADB29}</Project>
|
||||
<Name>Cosmos.Build.Common</Name>
|
||||
|
|
|
|||
|
|
@ -15,16 +15,16 @@ namespace Cosmos.TestRunner.Core
|
|||
engine.AllowedSecondsInKernel = 120;
|
||||
|
||||
// If you want to test only specific platforms, add them to the list, like next line. By default, all platforms are ran.
|
||||
// engine.RunTargets.Add(RunTargetEnum.Bochs);
|
||||
engine.RunTargets.Add(RunTargetEnum.Bochs);
|
||||
|
||||
// if you're working on the compiler (or other lower parts), you can choose to run the compiler in process
|
||||
// 1 thing to keep in mind though, is that this only works with 1 kernel at a time!
|
||||
engine.RunIL2CPUInProcess = false;
|
||||
|
||||
engine.AddKernel(typeof(Cosmos.Compiler.Tests.SimpleWriteLine.Kernel.Kernel).Assembly.Location);
|
||||
engine.AddKernel(typeof(SimpleStructsAndArraysTest.Kernel).Assembly.Location);
|
||||
engine.AddKernel(typeof(VGACompilerCrash.Kernel).Assembly.Location);
|
||||
engine.AddKernel(typeof(BoxingTests.Kernel).Assembly.Location);
|
||||
//engine.AddKernel(typeof(SimpleStructsAndArraysTest.Kernel).Assembly.Location);
|
||||
//engine.AddKernel(typeof(VGACompilerCrash.Kernel).Assembly.Location);
|
||||
//engine.AddKernel(typeof(BoxingTests.Kernel).Assembly.Location);
|
||||
// known bugs, therefor disabled for now:
|
||||
|
||||
// end of known bugs
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ namespace Cosmos.TestRunner.Core
|
|||
{
|
||||
throw new Exception("Cannot run multiple kernels with in-process compilation!");
|
||||
}
|
||||
// ensure we're using the referenced (= solution) version
|
||||
Assembler.Assembler.ReadDebugStubFromDisk = false;
|
||||
var xResult = Program.Run(xArguments, OutputHandler.LogMessage, OutputHandler.LogError);
|
||||
if (xResult != 0)
|
||||
{
|
||||
|
|
|
|||
2
source/Cosmos.Assembler/.editorconfig
Normal file
2
source/Cosmos.Assembler/.editorconfig
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[Assembler.cs]
|
||||
indent_size=2
|
||||
|
|
@ -11,6 +11,7 @@ using System.Reflection;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Xml;
|
||||
using Cosmos.Assembler.x86;
|
||||
using Cosmos.Debug.DebugStub;
|
||||
|
||||
namespace Cosmos.Assembler {
|
||||
public class Assembler {
|
||||
|
|
@ -511,13 +512,54 @@ namespace Cosmos.Assembler {
|
|||
|
||||
if (mComPort > 0) {
|
||||
var xGen = new XSharp.Compiler.AsmGenerator();
|
||||
foreach (var xFile in Directory.GetFiles(Cosmos.Build.Common.CosmosPaths.DebugStubSrc, "*.xs")) {
|
||||
var xAsm = xGen.Generate(xFile);
|
||||
foreach (var xData in xAsm.Data) {
|
||||
Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember() { RawAsm = xData });
|
||||
|
||||
var xGenerateAssembler =
|
||||
new Action<object>(i =>
|
||||
{
|
||||
XSharp.Nasm.Assembler xAsm;
|
||||
if (i is StreamReader)
|
||||
{
|
||||
xAsm = xGen.Generate((StreamReader)i);
|
||||
}
|
||||
else if (i is string)
|
||||
{
|
||||
xAsm = xGen.Generate((string)i);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Object type '" + i.ToString() + "' not supported!");
|
||||
}
|
||||
foreach (var xData in xAsm.Data)
|
||||
{
|
||||
Cosmos.Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember() {RawAsm = xData});
|
||||
}
|
||||
foreach (var xCode in xAsm.Code)
|
||||
{
|
||||
new LiteralAssemblerCode(xCode);
|
||||
}
|
||||
});
|
||||
if (ReadDebugStubFromDisk)
|
||||
{
|
||||
foreach (var xFile in Directory.GetFiles(Cosmos.Build.Common.CosmosPaths.DebugStubSrc, "*.xs"))
|
||||
{
|
||||
xGenerateAssembler(xFile);
|
||||
}
|
||||
foreach (var xCode in xAsm.Code) {
|
||||
new LiteralAssemblerCode(xCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var xManifestName in typeof(ReferenceHelper).Assembly.GetManifestResourceNames())
|
||||
{
|
||||
if (!xManifestName.EndsWith(".xs", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
using (var xStream = typeof(ReferenceHelper).Assembly.GetManifestResourceStream(xManifestName))
|
||||
{
|
||||
using (var xReader = new StreamReader(xStream))
|
||||
{
|
||||
xGenerateAssembler(xReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
OnAfterEmitDebugStub();
|
||||
|
|
@ -529,6 +571,12 @@ namespace Cosmos.Assembler {
|
|||
Cosmos.Assembler.Assembler.CurrentInstance.EmitAsmLabels = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setting this field to false means the .xs files for the debug stub are read from the DebugStub assembly.
|
||||
/// This allows the automated kernel tester to use the live ones, instead of the installed ones.
|
||||
/// </summary>
|
||||
public static bool ReadDebugStubFromDisk = true;
|
||||
|
||||
protected virtual void OnAfterEmitDebugStub()
|
||||
{
|
||||
//
|
||||
|
|
|
|||
|
|
@ -310,6 +310,7 @@
|
|||
<ItemGroup>
|
||||
<None Include="Cosmos.snk" />
|
||||
<None Include="x86\Cosmos.snk" />
|
||||
<None Include=".editorconfig" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\source\XSharp.Nasm\XSharp.Nasm.csproj">
|
||||
|
|
@ -324,6 +325,10 @@
|
|||
<Project>{A281A1B1-C718-4BCB-A7BE-ED840A70449A}</Project>
|
||||
<Name>XSharp.Compiler</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Cosmos.Debug.DebugStub\Cosmos.Debug.DebugStub.csproj">
|
||||
<Project>{A7F3F078-CF99-4018-9A35-2D6DC9517ADB}</Project>
|
||||
<Name>Cosmos.Debug.DebugStub</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
|
|
@ -124,6 +124,11 @@
|
|||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\XSharp.Compiler\.editorconfig.txt">
|
||||
<Link>.editorconfig.txt</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReferenceHelper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="AsmBreak.xs">
|
||||
|
|
@ -76,55 +77,55 @@
|
|||
<LastGenOutput>AsmBreak.asm</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include=".editorconfig" />
|
||||
<None Include="CmdMisc.xs">
|
||||
<EmbeddedResource Include="CmdMisc.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>CmdMisc.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="CmdProcess.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="CmdProcess.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>CmdProcess.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="CmdSend.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="CmdSend.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>CmdSend.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Consts.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Consts.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>Consts.asm</LastGenOutput>
|
||||
</None>
|
||||
</EmbeddedResource>
|
||||
<None Include="Cosmos.snk" />
|
||||
<None Include="DebugStub.xs">
|
||||
<EmbeddedResource Include="DebugStub.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>DebugStub.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Init.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Init.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>Init.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Screen.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Screen.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>Screen.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="SerialIO.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="SerialIO.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>SerialIO.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="SerialHelpers.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="SerialHelpers.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>SerialHelpers.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Serial.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Serial.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>Serial.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="TracerEntry.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="TracerEntry.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>TracerEntry.asm</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Utilities.xs">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Utilities.xs">
|
||||
<Generator>CosmosXSharpGenerator</Generator>
|
||||
<LastGenOutput>Utilities.asm</LastGenOutput>
|
||||
</None>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="AsmBreak.asm">
|
||||
|
|
|
|||
7
source/Cosmos.Debug.DebugStub/ReferenceHelper.cs
Normal file
7
source/Cosmos.Debug.DebugStub/ReferenceHelper.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace Cosmos.Debug.DebugStub
|
||||
{
|
||||
public static class ReferenceHelper
|
||||
{
|
||||
// dummy class to allow referencing this assembly
|
||||
}
|
||||
}
|
||||
2
source/XSharp.Compiler/.editorconfig
Normal file
2
source/XSharp.Compiler/.editorconfig
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[*.cs]
|
||||
indent_size = 2
|
||||
|
|
@ -27,36 +27,51 @@ namespace XSharp.Compiler {
|
|||
throw new Exception("The last function or interrupt handler from source code file is missing a curly brace.");
|
||||
}
|
||||
|
||||
/// <summary>Parse the input X# source code file and generate the matching target assembly
|
||||
/// language.</summary>
|
||||
/// <param name="aReader">X# source code reader.</param>
|
||||
/// <returns>The resulting target assembler content. The returned object contains
|
||||
/// a code and a data block.</returns>
|
||||
public Assembler Generate(StreamReader aReader)
|
||||
{
|
||||
if (aReader == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(aReader));
|
||||
}
|
||||
mPatterns.EmitUserComments = EmitUserComments;
|
||||
mLineNo = 0;
|
||||
var xResult = new Assembler();
|
||||
// Read one X# source code line at a time and process it.
|
||||
while (true)
|
||||
{
|
||||
mLineNo++;
|
||||
string xLine = aReader.ReadLine();
|
||||
if (xLine == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var xAsm = ProcessLine(xLine, mLineNo);
|
||||
xResult.Data.AddRange(xAsm.Data);
|
||||
xResult.Code.AddRange(xAsm.Code);
|
||||
}
|
||||
AssertLastFunctionComplete();
|
||||
return xResult;
|
||||
}
|
||||
|
||||
/// <summary>Parse the input X# source code file and generate the matching target assembly
|
||||
/// language.</summary>
|
||||
/// <param name="aSrcPathname">X# source code file.</param>
|
||||
/// <returns>The resulting target assembler content. The returned object contains
|
||||
/// a code and a data block.</returns>
|
||||
public Assembler Generate(string aSrcPathname) {
|
||||
public Assembler Generate(string aSrcPathname)
|
||||
{
|
||||
try
|
||||
{
|
||||
mPatterns.EmitUserComments = EmitUserComments;
|
||||
mLineNo = 0;
|
||||
var xResult = new Assembler();
|
||||
using (var xInput = new StreamReader(aSrcPathname))
|
||||
{
|
||||
// Read one X# source code line at a time and process it.
|
||||
while (true)
|
||||
{
|
||||
mLineNo++;
|
||||
string xLine = xInput.ReadLine();
|
||||
if (xLine == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var xAsm = ProcessLine(xLine, mLineNo);
|
||||
xResult.Data.AddRange(xAsm.Data);
|
||||
xResult.Code.AddRange(xAsm.Code);
|
||||
}
|
||||
return Generate(xInput);
|
||||
}
|
||||
AssertLastFunctionComplete();
|
||||
return xResult;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@
|
|||
<Content Include="Docs\Old.html" />
|
||||
<Content Include="Docs\ToDo.html" />
|
||||
<Content Include="Docs\XSharp.htm" />
|
||||
<None Include=".editorconfig" />
|
||||
<None Include="XSharp.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue