mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Implement symbols for XML elements
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Iris.Debug;
|
||||
using Microsoft.Iris.Debug.Symbols;
|
||||
using Microsoft.Iris.Debug.SystemNet;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Cli;
|
||||
@@ -24,7 +25,7 @@ public class DebugCommand : Command<DebugCommand.Settings>
|
||||
if (settings.SymbolDir is not null)
|
||||
{
|
||||
Directory.CreateDirectory(settings.SymbolDir);
|
||||
symbolResolver = new(settings.SymbolDir);
|
||||
symbolResolver = new(settings.SymbolDir, settings.SourceDir);
|
||||
}
|
||||
|
||||
AnsiConsole.MarkupLineInterpolated($"Connecting to '{settings.ServerUri}'...");
|
||||
@@ -86,11 +87,26 @@ public class DebugCommand : Command<DebugCommand.Settings>
|
||||
|
||||
var line = int.Parse(inputParts[2]);
|
||||
var column = int.Parse(inputParts[3]);
|
||||
breakOffset = fsym!.OffsetByLineAndColumn(line, column);
|
||||
var position = new SourcePosition(line, column);
|
||||
|
||||
var location = fsym!.SourceMap.GetLocationFromPosition(position);
|
||||
if (location is null)
|
||||
{
|
||||
AnsiConsole.MarkupLineInterpolated($"[red]Line {line}, column {column} has known offset in '{fileName}'.[/]");
|
||||
break;
|
||||
}
|
||||
|
||||
breakOffset = location.Value.Offset;
|
||||
|
||||
if (fsym.HasSourceCode())
|
||||
{
|
||||
var sourceCode = fsym.GetSourceSubstring(location.Value.Span);
|
||||
AnsiConsole.Write(new Panel(sourceCode));
|
||||
}
|
||||
}
|
||||
|
||||
client.UpdateBreakpoint(new(path, breakOffset));
|
||||
AnsiConsole.MarkupLineInterpolated($"[green]Breakpoint set in '{fileName}' at offset 0x{breakOffset:X4}.[/]");
|
||||
client.UpdateBreakpoint(new(path, breakOffset));
|
||||
|
||||
break;
|
||||
|
||||
@@ -115,6 +131,10 @@ public class DebugCommand : Command<DebugCommand.Settings>
|
||||
[CommandOption("-s|--symbols <symbolDir>")]
|
||||
public string? SymbolDir { get; init; }
|
||||
|
||||
[Description("The directory containing source code.")]
|
||||
[CommandOption("--sources <sourceDir>")]
|
||||
public string? SourceDir { get; init; }
|
||||
|
||||
[Description("Whether to decompile the current file when a breakpoint is hit. Generated symbols will be written to the symbol directory if specified.")]
|
||||
[CommandOption("-d|--decompile")]
|
||||
public bool Decompile { get; init; }
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace UIXC;
|
||||
|
||||
public class DebugSymbolResolver(string symbolDir)
|
||||
public class DebugSymbolResolver(string symbolDir, string? sourceDir)
|
||||
{
|
||||
private readonly DirectoryInfo _symbolDir = new(symbolDir);
|
||||
private readonly DirectoryInfo? _sourceDir = sourceDir is not null ? new(sourceDir) : null;
|
||||
|
||||
public ApplicationDebugSymbols? GetForApplication(string application)
|
||||
{
|
||||
var fileName = $"{application}.asym.json";
|
||||
var asymFile = _symbolDir.EnumerateFiles()
|
||||
.FirstOrDefault(f => f.Name == fileName);
|
||||
var asymFile = FindFile(fileName, _symbolDir);
|
||||
|
||||
if (asymFile is null)
|
||||
return null;
|
||||
@@ -23,13 +23,23 @@ public class DebugSymbolResolver(string symbolDir)
|
||||
public FileDebugSymbols? GetForFile(string file, string? application = null)
|
||||
{
|
||||
var fileName = $"{file}.fsym.json";
|
||||
var fsymFile = FindFile(fileName);
|
||||
var fsymFile = FindFile(fileName, _symbolDir);
|
||||
|
||||
if (fsymFile is not null)
|
||||
{
|
||||
using var stream = fsymFile.OpenRead();
|
||||
using var reader = new StreamReader(stream);
|
||||
return DebugSymbolsJsonParser.ParseForFile(reader.ReadToEnd());
|
||||
var fsym = DebugSymbolsJsonParser.ParseForFile(reader.ReadToEnd());
|
||||
|
||||
var sourceFile = FindFile(file, _sourceDir);
|
||||
if (sourceFile is not null)
|
||||
{
|
||||
using var sourceStream = sourceFile.OpenRead();
|
||||
using var sourceReader = new StreamReader(sourceStream);
|
||||
fsym.SetSourceCode(sourceReader.ReadToEnd());
|
||||
}
|
||||
|
||||
return fsym;
|
||||
}
|
||||
|
||||
if (application is null)
|
||||
@@ -42,9 +52,9 @@ public class DebugSymbolResolver(string symbolDir)
|
||||
return asym.Files.FirstOrDefault(f => f.CompiledFileName == file || f.SourceFileName == file);
|
||||
}
|
||||
|
||||
private FileInfo? FindFile(string fileName)
|
||||
private static FileInfo? FindFile(string fileName, DirectoryInfo? dir)
|
||||
{
|
||||
return _symbolDir
|
||||
return dir?
|
||||
.EnumerateFiles()
|
||||
.FirstOrDefault(f => AreEquivalentFileNames(f.Name, fileName));
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
"UIXC": {
|
||||
"commandName": "Project",
|
||||
|
||||
"commandLineArgs": "debug --symbols E:\\Repos\\ZuneDev\\ZuneUIXTools\\test\\syms",
|
||||
//"commandLineArgs": "debug --symbols E:\\Repos\\ZuneDev\\ZuneUIXTools\\test\\syms --sources E:\\Repos\\ZuneDev\\ZuneUIXTools\\test",
|
||||
"commandLineArgs": "decompile E:\\Documents\\REProj\\Zune\\Resources\\ZuneShellResources48\\NOWPLAYINGMUSICBACKGROUND.UIX -l xml -A ZuneShell.dll -A UIXControls.dll -A ZuneDBApi.dll -o E:\\Repos\\ZuneDev\\ZuneUIXTools\\test --symbols E:\\Repos\\ZuneDev\\ZuneUIXTools\\test\\syms",
|
||||
|
||||
//"commandLineArgs": "decompile E:\\Documents\\REProj\\Zune\\Resources\\ZuneMarketplaceResources48\\MarketplaceData.schema.xml -l xml -A ZuneShell.dll -A UIXControls.dll -A ZuneDBApi.dll -o E:\\Repos\\ZuneDev\\ZuneUIXTools\\test",
|
||||
//"commandLineArgs": "decompile E:\\Documents\\REProj\\Zune\\Resources\\ZuneShellResources48\\DeviceLandElements.uix -l xml -A ZuneShell.dll -A UIXControls.dll -A ZuneDBApi.dll -o E:\\Repos\\ZuneDev\\ZuneUIXTools\\test",
|
||||
//"commandLineArgs": "decompile E:\\Documents\\REProj\\Zune\\Resources\\ZuneShellResources48\\NOWPLAYINGMUSICBACKGROUND.UIX -l xml -A ZuneShell.dll -A UIXControls.dll -A ZuneDBApi.dll -o E:\\Repos\\ZuneDev\\ZuneUIXTools\\test --symbols E:\\Repos\\ZuneDev\\ZuneUIXTools\\test\\syms",
|
||||
//"commandLineArgs": "decompile E:\\Repos\\ZuneDev\\ZuneShell.dll\\libs\\MicrosoftIris\\UIXcontrols\\Resources\\RCDATA\\STYLES.UIX -l xml -A ZuneShell.dll -A UIXControls.dll -A ZuneDBApi.dll -o E:\\Repos\\ZuneDev\\ZuneShell.dll\\ZuneShell\\Resources\\RCDATA\\Dark\\Controls",
|
||||
//"commandLineArgs": "compile E:\\Repos\\ZuneDev\\ZuneUIXTools\\test\\ADDTOCOLLECTION.31_48.UIX -A ZuneShell.dll -A UIXControls.dll -A ZuneDBApi.dll -o E:\\Repos\\ZuneDev\\ZuneUIXTools\\test",
|
||||
//"commandLineArgs": "compile E:\\Documents\\REProj\\Zune\\Resources\\ZuneMarketplaceResources31\\MARKETPLACEDATA.SCHEMA.31_48.XML -A ZuneShell.dll -A UIXControls.dll -A ZuneDBApi.dll -o E:\\Repos\\ZuneDev\\ZuneUIXTools\\test",
|
||||
|
||||
Reference in New Issue
Block a user