Capture actionable STEP-LIMIT diagnostics
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
<Compile Include="..\..\godot\PageLocatorState.cs" Link="PageLocatorState.cs" />
|
||||
<Compile Include="..\..\godot\GodotTimelineLog.cs" Link="GodotTimelineLog.cs" />
|
||||
<Compile Include="..\..\godot\GodotTraceSink.cs" Link="GodotTraceSink.cs" />
|
||||
<Compile Include="..\..\godot\StepLimitDiagnosticFormatter.cs" Link="StepLimitDiagnosticFormatter.cs" />
|
||||
<Compile Include="..\..\godot\PerformanceFrameLog.cs" Link="PerformanceFrameLog.cs" />
|
||||
<Compile Include="..\..\godot\MovieSurfaceRegistry.cs" Link="MovieSurfaceRegistry.cs" />
|
||||
<Compile Include="..\..\godot\RiffWaveSanitizer.cs" Link="RiffWaveSanitizer.cs" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Age.Engine.Diagnostics;
|
||||
using Age.Engine.Model;
|
||||
using Age.Engine.Sys4;
|
||||
|
||||
public class GodotTraceSinkTests
|
||||
{
|
||||
@@ -28,4 +29,48 @@ public class GodotTraceSinkTests
|
||||
Assert.Equal(0x2400 + 12, snapshot.RecentSteps[0].Offset);
|
||||
Assert.Equal(0x2400 + 139, snapshot.RecentSteps[^1].Offset);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HaltSnapshotRetainsDeepestStackBeforeFramesUnwind()
|
||||
{
|
||||
using var locator = new PageLocatorState("SYSTEM4", null);
|
||||
var sink = new GodotTraceSink(locator);
|
||||
sink.Emit(TraceEvent.FrameEnter("SYSTEM4.BIN", 0, FrameCause.TopScene));
|
||||
sink.Emit(TraceEvent.FrameEnter("FIELD.BIN", 1, FrameCause.CallScript, 0x337d));
|
||||
sink.Emit(TraceEvent.FrameEnter("SC0600.BIN", 2, FrameCause.CallScript, 0x1202));
|
||||
sink.Emit(TraceEvent.Step(10,
|
||||
new Instruction(0x3403, 0x8f, new[] { new Operand(0, 0x6f28) }), 2));
|
||||
|
||||
sink.Emit(TraceEvent.FrameExit("SC0600.BIN", 2, "Halted"));
|
||||
sink.Emit(TraceEvent.FrameExit("FIELD.BIN", 1, "Halted"));
|
||||
sink.Emit(TraceEvent.FrameExit("SYSTEM4.BIN", 0, "Halted"));
|
||||
|
||||
GodotTraceSnapshot snapshot = Assert.IsType<GodotTraceSnapshot>(sink.HaltSnapshot);
|
||||
Assert.Equal("SC0600.BIN", snapshot.CurrentScript);
|
||||
Assert.Equal(0x3403, snapshot.CurrentOffset);
|
||||
Assert.Equal(new[] { "SYSTEM4.BIN", "FIELD.BIN", "SC0600.BIN" }, snapshot.CallStack);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StepLimitReportShowsCoordinateFramesHotSitesAndTail()
|
||||
{
|
||||
OpcodeTable table = OpcodeTableJson.Load(Paths.OpcodesJson);
|
||||
var recent = new[]
|
||||
{
|
||||
new GodotTraceStepSnapshot("FIELD.BIN", 0x100, 0x55, 1),
|
||||
new GodotTraceStepSnapshot("FIELD.BIN", 0x107, 0x8e, 1),
|
||||
new GodotTraceStepSnapshot("FIELD.BIN", 0x100, 0x55, 1),
|
||||
};
|
||||
var snapshot = new GodotTraceSnapshot(
|
||||
"FIELD.BIN", 0x100, 0x55, 1,
|
||||
new[] { "SYSTEM4.BIN", "FIELD.BIN" }, recent);
|
||||
|
||||
string report = StepLimitDiagnosticFormatter.Format(snapshot, table, topSites: 2, tailSteps: 2);
|
||||
|
||||
Assert.Contains("[step-limit] last: FIELD@0x100 op=0x055 mov depth=1", report);
|
||||
Assert.Contains("[step-limit] frames: SYSTEM4 > FIELD", report);
|
||||
Assert.Contains("2x FIELD@0x100 op=0x055 mov", report);
|
||||
Assert.DoesNotContain("SYSTEM4@0x", report);
|
||||
Assert.EndsWith("[step-limit] FIELD@0x100 op=0x055 mov", report);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user