mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
- VS crashes completely without VIX API - now just shows error message in Output window. - Colours of text in Cosmos windows invisble in dark theme. Tenp fix: Bg colour forced to light, - XSharo project referencing outdated libraries. Slowly fixing the debugger...
73 lines
No EOL
2.5 KiB
C#
73 lines
No EOL
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace Cosmos.Debug.VSDebugEngine
|
|
{
|
|
public static class AsmSource
|
|
{
|
|
// Extract out the relevant lines from the .asm file.
|
|
public static StringBuilder GetSourceForLabels(string aAsmFile, List<string> aLabels)
|
|
{
|
|
var xCode = new StringBuilder();
|
|
|
|
// Find line in ASM that starts the code block.
|
|
using (var xSR = new StreamReader(aAsmFile))
|
|
{
|
|
string xLine;
|
|
while (true)
|
|
{
|
|
xLine = xSR.ReadLine();
|
|
if (xLine == null)
|
|
{
|
|
break;
|
|
}
|
|
|
|
var xParts = xLine.Trim().Split(' ');
|
|
if (xParts.Length > 0 && xParts[0].EndsWith(":"))
|
|
{
|
|
if (aLabels.Contains(xParts[0]))
|
|
{
|
|
// Found the first match, break.
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Extract the pertinent lines
|
|
while (xLine != null)
|
|
{
|
|
var xParts = xLine.Trim().Split(' ');
|
|
if (xParts.Length > 0 && xParts[0].EndsWith(":"))
|
|
{
|
|
// Its a label, lets check it
|
|
if (xParts.Length > 1 && xParts[1] == ";Asm")
|
|
{
|
|
// ASM label
|
|
xCode.AppendLine(xLine);
|
|
}
|
|
else if (aLabels.Contains(xParts[0]))
|
|
{
|
|
// Normal label
|
|
xCode.AppendLine(xLine);
|
|
}
|
|
else
|
|
{
|
|
// Label with unrecognized comment, or IL label that doesn't match.
|
|
// We are done.
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{ // Not a label, just output it
|
|
xCode.AppendLine(xLine);
|
|
}
|
|
xLine = xSR.ReadLine();
|
|
}
|
|
}
|
|
return xCode;
|
|
}
|
|
}
|
|
} |