mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 12:44:19 +01:00
Add debug logging facilities.
This commit is contained in:
parent
737e74582b
commit
2afd6b966e
6 changed files with 50 additions and 4 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
||||||
Subproject commit 055f169572223fd1b59389549c88b4c861c94608
|
Subproject commit 3c1260c9833303c2d33d12d6f77dc2b1afea3f34
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit b9003b97da2d1191fa203a4d66956bc54c21db2a
|
Subproject commit 0bc2b0f66eee1a02c9575b2bb30f27ce166f8632
|
||||||
6
Penumbra/DebugConfiguration.cs
Normal file
6
Penumbra/DebugConfiguration.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace Penumbra;
|
||||||
|
|
||||||
|
public class DebugConfiguration
|
||||||
|
{
|
||||||
|
public static bool WriteImcBytesToLog = false;
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using OtterGui;
|
||||||
using Penumbra.GameData;
|
using Penumbra.GameData;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
using Penumbra.GameData.Structs;
|
using Penumbra.GameData.Structs;
|
||||||
|
|
@ -194,11 +195,28 @@ public unsafe class ImcFile : MetaBaseFile
|
||||||
{
|
{
|
||||||
var (data, length) = resource->GetData();
|
var (data, length) = resource->GetData();
|
||||||
var actualLength = ActualLength;
|
var actualLength = ActualLength;
|
||||||
|
|
||||||
|
if (DebugConfiguration.WriteImcBytesToLog)
|
||||||
|
{
|
||||||
|
Penumbra.Log.Information($"Default IMC file -> Modified IMC File for {Path}:");
|
||||||
|
Penumbra.Log.Information(new Span<byte>((void*)data, length).WriteHexBytes());
|
||||||
|
Penumbra.Log.Information(new Span<byte>(Data, actualLength).WriteHexBytes());
|
||||||
|
Penumbra.Log.Information(new Span<byte>(Data, actualLength).WriteHexByteDiff(new Span<byte>((void*)data, length)));
|
||||||
|
}
|
||||||
|
|
||||||
if (length >= actualLength)
|
if (length >= actualLength)
|
||||||
{
|
{
|
||||||
MemoryUtility.MemCpyUnchecked((byte*)data, Data, actualLength);
|
MemoryUtility.MemCpyUnchecked((byte*)data, Data, actualLength);
|
||||||
if (length > actualLength)
|
if (length > actualLength)
|
||||||
MemoryUtility.MemSet((byte*)(data + actualLength), 0, length - actualLength);
|
MemoryUtility.MemSet((byte*)(data + actualLength), 0, length - actualLength);
|
||||||
|
if (DebugConfiguration.WriteImcBytesToLog)
|
||||||
|
{
|
||||||
|
Penumbra.Log.Information(
|
||||||
|
$"Copied {actualLength} bytes from local IMC file into {length} available bytes.{(length > actualLength ? $" Filled remaining {length - actualLength} bytes with 0." : string.Empty)}");
|
||||||
|
Penumbra.Log.Information("Result IMC Resource Data:");
|
||||||
|
Penumbra.Log.Information(new Span<byte>((void*)data, length).WriteHexBytes());
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,11 +227,18 @@ public unsafe class ImcFile : MetaBaseFile
|
||||||
Penumbra.Log.Error($"Could not replace loaded IMC data at 0x{(ulong)resource:X}, allocation failed.");
|
Penumbra.Log.Error($"Could not replace loaded IMC data at 0x{(ulong)resource:X}, allocation failed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryUtility.MemCpyUnchecked(newData, Data, actualLength);
|
MemoryUtility.MemCpyUnchecked(newData, Data, actualLength);
|
||||||
if (paddedLength > actualLength)
|
if (paddedLength > actualLength)
|
||||||
MemoryUtility.MemSet(newData + actualLength, 0, paddedLength - actualLength);
|
MemoryUtility.MemSet(newData + actualLength, 0, paddedLength - actualLength);
|
||||||
|
if (DebugConfiguration.WriteImcBytesToLog)
|
||||||
|
{
|
||||||
|
Penumbra.Log.Information(
|
||||||
|
$"Allocated {paddedLength} bytes for IMC file, copied {actualLength} bytes from local IMC file. {(length > actualLength ? $" Filled remaining {length - actualLength} bytes with 0." : string.Empty)}");
|
||||||
|
Penumbra.Log.Information("Result IMC Resource Data:");
|
||||||
|
Penumbra.Log.Information(new Span<byte>(newData, paddedLength).WriteHexBytes());
|
||||||
|
}
|
||||||
|
|
||||||
Manager.XivFileAllocator.Release((void*)data, length);
|
Manager.XivFileAllocator.Release((void*)data, length);
|
||||||
resource->SetData((nint)newData, paddedLength);
|
resource->SetData((nint)newData, paddedLength);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
Penumbra/UI/Tabs/Debug/DebugConfigurationDrawer.cs
Normal file
14
Penumbra/UI/Tabs/Debug/DebugConfigurationDrawer.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
using OtterGui.Text;
|
||||||
|
|
||||||
|
namespace Penumbra.UI.Tabs.Debug;
|
||||||
|
|
||||||
|
public static class DebugConfigurationDrawer
|
||||||
|
{
|
||||||
|
public static void Draw()
|
||||||
|
{
|
||||||
|
if (!ImUtf8.CollapsingHeaderId("Debug Logging Options"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImUtf8.Checkbox("Log IMC File Replacements"u8, ref DebugConfiguration.WriteImcBytesToLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -181,6 +181,7 @@ public class DebugTab : Window, ITab, IUiService
|
||||||
|
|
||||||
DrawDebugTabGeneral();
|
DrawDebugTabGeneral();
|
||||||
_crashHandlerPanel.Draw();
|
_crashHandlerPanel.Draw();
|
||||||
|
DebugConfigurationDrawer.Draw();
|
||||||
_diagnostics.DrawDiagnostics();
|
_diagnostics.DrawDiagnostics();
|
||||||
DrawPerformanceTab();
|
DrawPerformanceTab();
|
||||||
DrawPathResolverDebug();
|
DrawPathResolverDebug();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue