mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-12 11:11:45 +00:00
This commit is contained in:
parent
22a9fb8cef
commit
159c436aca
3 changed files with 58 additions and 46 deletions
|
|
@ -617,53 +617,8 @@ namespace Cosmos.Debug.VSDebugEngine {
|
|||
xLabels.Add(xLabel + ":");
|
||||
}
|
||||
}
|
||||
|
||||
// Extract out the relevant lines from the .asm file.
|
||||
var xCode = new StringBuilder();
|
||||
using (var xSR = new StreamReader(Path.ChangeExtension(mISO, ".asm"))) {
|
||||
// Find line in ASM that starts the code block.
|
||||
string xLine;
|
||||
while (true) {
|
||||
xLine = xSR.ReadLine();
|
||||
if (xLine == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
var xParts = xLine.Trim().Split(' ');
|
||||
if (xParts.Length > 0 && xParts[0].EndsWith(":")) {
|
||||
if (xLabels.Contains(xParts[0])) {
|
||||
// Found the first match, break.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (xLine != null) {
|
||||
// Extract the pertinent lines
|
||||
var xParts = xLine.Trim().Split(' ');
|
||||
if (xParts.Length > 0 && xParts[0].EndsWith(":")) {
|
||||
// Its a label, lets check it
|
||||
if (xParts.Length == 1) {
|
||||
// Found an normal label.
|
||||
xCode.AppendLine(xLine);
|
||||
} else if (xParts[1] == ";Asm") {
|
||||
// Found an ASM label.
|
||||
xCode.AppendLine(xLine);
|
||||
} else if (xParts[1] == ";IL" && xLabels.Contains(xParts[0])) {
|
||||
// Found an exact match. Our label is in the label list
|
||||
xCode.AppendLine(xLine);
|
||||
} else {
|
||||
// Its a label with an unrecognized comment, or its an IL label that doesn't match.
|
||||
// We are done.
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Not a label, just output it
|
||||
xCode.AppendLine(xLine);
|
||||
}
|
||||
xLine = xSR.ReadLine();
|
||||
}
|
||||
}
|
||||
var xCode = AsmSource.GetSourceForLabels(Path.ChangeExtension(mISO, ".asm"), xLabels);
|
||||
|
||||
// Send source code to the tool window
|
||||
mDebugDownPipe.SendCommand(VsipUi.AssemblySource, Encoding.UTF8.GetBytes(xCode.ToString()));
|
||||
|
|
|
|||
56
source2/Debug/Cosmos.Debug.VSDebugEngine/AsmSource.cs
Normal file
56
source2/Debug/Cosmos.Debug.VSDebugEngine/AsmSource.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
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) { // Normal label
|
||||
xCode.AppendLine(xLine);
|
||||
} else if (xParts[1] == ";Asm") { // ASM label
|
||||
xCode.AppendLine(xLine);
|
||||
} else if (xParts[1] == ";IL" && aLabels.Contains(xParts[0])) { // Exact match to label in our list
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -119,6 +119,7 @@
|
|||
<Compile Include="AD7.Definitions\AD7Hresult.cs" />
|
||||
<Compile Include="AD7.Impl\AD7PendingBreakpoint.cs" />
|
||||
<Compile Include="AD7.Impl\DebugLocalInfo.cs" />
|
||||
<Compile Include="AsmSource.cs" />
|
||||
<Compile Include="Engine.Impl\BreakpointManager.cs" />
|
||||
<Compile Include="Engine.Impl\OperationThread.cs" />
|
||||
<Compile Include="AD7.Impl\AD7Engine.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue