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(); m_Time = Stopwatch.StartNew();
} }
public static void RestartTime()
{
m_Time.Restart();
}
public static void AddTarget(ILogTarget target) public static void AddTarget(ILogTarget target)
{ {
m_LogTargets.Add(target); m_LogTargets.Add(target);

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. // Print all the arguments for debugging purposes.
int inputArgsCount = methodArgs.Length - byRefArgsCount; int inputArgsCount = methodArgs.Length - byRefArgsCount;
generator.Emit(OpCodes.Ldc_I4_S, inputArgsCount); if (inputArgsCount != 0)
generator.Emit(OpCodes.Newarr, typeof(object));
string argsFormat = svcName;
for (int index = 0; index < inputArgsCount; index++)
{ {
argsFormat += $" {methodArgs[index].Name}: 0x{{{index}:X8}},"; generator.Emit(OpCodes.Ldc_I4, inputArgsCount);
generator.Emit(OpCodes.Dup); generator.Emit(OpCodes.Newarr, typeof(object));
generator.Emit(OpCodes.Ldc_I4_S, index);
generator.Emit(OpCodes.Conv_I);
generator.Emit(OpCodes.Ldarg_1); string argsFormat = svcName;
generator.Emit(OpCodes.Ldc_I4, byRefArgsCount + index);
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, svcName);
}
generator.Emit(OpCodes.Ldstr, argsFormat);
BindingFlags staticNonPublic = BindingFlags.NonPublic | BindingFlags.Static;
MethodInfo printArgsMethod = typeof(SvcTable).GetMethod(nameof(PrintArguments), staticNonPublic); 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}\"."); 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 else
{ {
@ -325,6 +333,18 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
throw new InvalidSvcException($"Method \"{svcName}\" has a invalid ref type \"{type.Name}\"."); 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) private static void PrintResult(KernelResult result, string svcName)
{ {
if (result != KernelResult.Success && if (result != KernelResult.Success &&
@ -339,10 +359,5 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
Logger.PrintDebug(LogClass.KernelSvc, $"{svcName} returned result {result}."); 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 Gtk;
using GUI = Gtk.Builder.ObjectAttribute; using GUI = Gtk.Builder.ObjectAttribute;
using Ryujinx.Audio; using Ryujinx.Audio;
@ -208,6 +208,8 @@ namespace Ryujinx.UI
} }
else else
{ {
Logger.RestartTime();
if (Directory.Exists(path)) if (Directory.Exists(path))
{ {
string[] romFsFiles = Directory.GetFiles(path, "*.istorage"); string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
@ -228,7 +230,6 @@ namespace Ryujinx.UI
_device.LoadCart(path); _device.LoadCart(path);
} }
} }
else if (File.Exists(path)) else if (File.Exists(path))
{ {
switch (System.IO.Path.GetExtension(path).ToLowerInvariant()) switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
@ -254,14 +255,14 @@ namespace Ryujinx.UI
} }
catch (ArgumentOutOfRangeException) 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; break;
} }
} }
else 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(); End();
} }
@ -396,7 +397,7 @@ namespace Ryujinx.UI
Profile.FinishProfiling(); Profile.FinishProfiling();
_device.Dispose(); _device.Dispose();
_audioOut.Dispose(); _audioOut.Dispose();
DiscordClient.Dispose(); DiscordClient?.Dispose();
Logger.Shutdown(); Logger.Shutdown();
Environment.Exit(0); Environment.Exit(0);
} }