Misc fixes (#772)

* Update Logger.cs

* Update MainWindow.cs

* Update SvcTable.cs

* Update SvcTable.cs

* Update SvcTable.cs
This commit is contained in:
LDj3SNuD 2019-09-20 01:59:48 +02:00 committed by gdkchan
parent f17b772c56
commit 72b9f8f0a0
3 changed files with 56 additions and 35 deletions

View File

@ -39,6 +39,11 @@ namespace Ryujinx.Common.Logging
m_Time = Stopwatch.StartNew();
}
public static void RestartTime()
{
m_Time.Restart();
}
public static void AddTarget(ILogTarget target)
{
m_LogTargets.Add(target);
@ -134,4 +139,4 @@ namespace Ryujinx.Common.Logging
return $"{Class} {Caller}: {Message}";
}
}
}
}

View File

@ -165,40 +165,48 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
}
}
BindingFlags staticNonPublic = BindingFlags.NonPublic | BindingFlags.Static;
// Print all the arguments for debugging purposes.
int inputArgsCount = methodArgs.Length - byRefArgsCount;
generator.Emit(OpCodes.Ldc_I4_S, inputArgsCount);
generator.Emit(OpCodes.Newarr, typeof(object));
string argsFormat = svcName;
for (int index = 0; index < inputArgsCount; index++)
if (inputArgsCount != 0)
{
argsFormat += $" {methodArgs[index].Name}: 0x{{{index}:X8}},";
generator.Emit(OpCodes.Ldc_I4, inputArgsCount);
generator.Emit(OpCodes.Dup);
generator.Emit(OpCodes.Ldc_I4_S, index);
generator.Emit(OpCodes.Conv_I);
generator.Emit(OpCodes.Newarr, typeof(object));
generator.Emit(OpCodes.Ldarg_1);
generator.Emit(OpCodes.Ldc_I4, byRefArgsCount + index);
string argsFormat = svcName;
MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.GetX));
for (int index = 0; index < inputArgsCount; index++)
{
argsFormat += $" {methodArgs[index].Name}: 0x{{{index}:X8}},";
generator.Emit(OpCodes.Call, info);
generator.Emit(OpCodes.Dup);
generator.Emit(OpCodes.Ldc_I4, index);
generator.Emit(OpCodes.Box, typeof(ulong));
generator.Emit(OpCodes.Ldarg_1);
generator.Emit(OpCodes.Ldc_I4, byRefArgsCount + index);
generator.Emit(OpCodes.Stelem_Ref);
MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.GetX));
generator.Emit(OpCodes.Call, info);
generator.Emit(OpCodes.Box, typeof(ulong));
generator.Emit(OpCodes.Stelem_Ref);
}
argsFormat = argsFormat.Substring(0, argsFormat.Length - 1);
generator.Emit(OpCodes.Ldstr, argsFormat);
}
else
{
generator.Emit(OpCodes.Ldnull);
argsFormat = argsFormat.Substring(0, argsFormat.Length - 1);
generator.Emit(OpCodes.Ldstr, argsFormat);
BindingFlags staticNonPublic = BindingFlags.NonPublic | BindingFlags.Static;
generator.Emit(OpCodes.Ldstr, svcName);
}
MethodInfo printArgsMethod = typeof(SvcTable).GetMethod(nameof(PrintArguments), staticNonPublic);
@ -226,7 +234,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
throw new InvalidOperationException($"Method \"{svcName}\" has a invalid ref type \"{argType.Name}\".");
}
generator.Emit(OpCodes.Ldloca_S, (byte)local.LocalIndex);
generator.Emit(OpCodes.Ldloca, local);
}
else
{
@ -325,6 +333,18 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
throw new InvalidSvcException($"Method \"{svcName}\" has a invalid ref type \"{type.Name}\".");
}
private static void PrintArguments(object[] argValues, string formatOrSvcName)
{
if (argValues != null)
{
Logger.PrintDebug(LogClass.KernelSvc, string.Format(formatOrSvcName, argValues));
}
else
{
Logger.PrintDebug(LogClass.KernelSvc, formatOrSvcName);
}
}
private static void PrintResult(KernelResult result, string svcName)
{
if (result != KernelResult.Success &&
@ -339,10 +359,5 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
Logger.PrintDebug(LogClass.KernelSvc, $"{svcName} returned result {result}.");
}
}
private static void PrintArguments(object[] argValues, string format)
{
Logger.PrintDebug(LogClass.KernelSvc, string.Format(format, argValues));
}
}
}
}

View File

@ -1,4 +1,4 @@
using DiscordRPC;
using DiscordRPC;
using Gtk;
using GUI = Gtk.Builder.ObjectAttribute;
using Ryujinx.Audio;
@ -208,6 +208,8 @@ namespace Ryujinx.UI
}
else
{
Logger.RestartTime();
if (Directory.Exists(path))
{
string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
@ -228,7 +230,6 @@ namespace Ryujinx.UI
_device.LoadCart(path);
}
}
else if (File.Exists(path))
{
switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
@ -254,14 +255,14 @@ namespace Ryujinx.UI
}
catch (ArgumentOutOfRangeException)
{
Logger.PrintError(LogClass.Application, $"The file which you have specified is unsupported by Ryujinx");
Logger.PrintError(LogClass.Application, "The file which you have specified is unsupported by Ryujinx.");
}
break;
}
}
else
{
Logger.PrintWarning(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file");
Logger.PrintWarning(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
End();
}
@ -396,7 +397,7 @@ namespace Ryujinx.UI
Profile.FinishProfiling();
_device.Dispose();
_audioOut.Dispose();
DiscordClient.Dispose();
DiscordClient?.Dispose();
Logger.Shutdown();
Environment.Exit(0);
}