From efebd8f94de03ef5cab63803f0cf37fc39258682 Mon Sep 17 00:00:00 2001
From: jduncanator <1518948+jduncanator@users.noreply.github.com>
Date: Fri, 15 Mar 2019 14:37:54 +1100
Subject: Print Guest Stack Trace in ServiceNotImplemented Exception (#650)

* Print Guest Stack Trace in ServiceNotImplemented Exception

* Remove PrintGuestStackTrace

* Print Process Name and PID at the start of guest stack trace
---
 .../Exceptions/ServiceNotImplementedException.cs   | 82 ++++++++++++----------
 1 file changed, 46 insertions(+), 36 deletions(-)

(limited to 'Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs')

diff --git a/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs b/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs
index d5ea3bbf..893ce26e 100644
--- a/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs
+++ b/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs
@@ -76,60 +76,70 @@ namespace Ryujinx.HLE.Exceptions
                 }
             }
 
-            // Print buffer information
-            sb.AppendLine("Buffer Information");
+            sb.AppendLine("Guest Stack Trace:");
+            sb.AppendLine(Context.Thread.GetGuestStackTrace());
 
-            if (Request.PtrBuff.Count > 0)
+            // Print buffer information
+            if (Request.PtrBuff.Count > 0 ||
+                Request.SendBuff.Count > 0 ||
+                Request.ReceiveBuff.Count > 0 ||
+                Request.ExchangeBuff.Count > 0 ||
+                Request.RecvListBuff.Count > 0)
             {
-                sb.AppendLine("\tPtrBuff:");
+                sb.AppendLine("Buffer Information:");
 
-                foreach (var buff in Request.PtrBuff)
+                if (Request.PtrBuff.Count > 0)
                 {
-                    sb.AppendLine($"\t[{buff.Index}] Position: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}");
-                }
-            }
+                    sb.AppendLine("\tPtrBuff:");
 
-            if (Request.SendBuff.Count > 0)
-            {
-                sb.AppendLine("\tSendBuff:");
+                    foreach (var buff in Request.PtrBuff)
+                    {
+                        sb.AppendLine($"\t[{buff.Index}] Position: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}");
+                    }
+                }
 
-                foreach (var buff in Request.SendBuff)
+                if (Request.SendBuff.Count > 0)
                 {
-                    sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
-                }
-            }
+                    sb.AppendLine("\tSendBuff:");
 
-            if (Request.ReceiveBuff.Count > 0)
-            {
-                sb.AppendLine("\tReceiveBuff:");
+                    foreach (var buff in Request.SendBuff)
+                    {
+                        sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
+                    }
+                }
 
-                foreach (var buff in Request.ReceiveBuff)
+                if (Request.ReceiveBuff.Count > 0)
                 {
-                    sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
-                }
-            }
+                    sb.AppendLine("\tReceiveBuff:");
 
-            if (Request.ExchangeBuff.Count > 0)
-            {
-                sb.AppendLine("\tExchangeBuff:");
+                    foreach (var buff in Request.ReceiveBuff)
+                    {
+                        sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
+                    }
+                }
 
-                foreach (var buff in Request.ExchangeBuff)
+                if (Request.ExchangeBuff.Count > 0)
                 {
-                    sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
-                }
-            }
+                    sb.AppendLine("\tExchangeBuff:");
 
-            if (Request.RecvListBuff.Count > 0)
-            {
-                sb.AppendLine("\tRecvListBuff:");
+                    foreach (var buff in Request.ExchangeBuff)
+                    {
+                        sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
+                    }
+                }
 
-                foreach (var buff in Request.RecvListBuff)
+                if (Request.RecvListBuff.Count > 0)
                 {
-                    sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}");
+                    sb.AppendLine("\tRecvListBuff:");
+
+                    foreach (var buff in Request.RecvListBuff)
+                    {
+                        sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}");
+                    }
                 }
-            }
 
-            sb.AppendLine();
+                sb.AppendLine();
+            }
 
             sb.AppendLine("Raw Request Data:");
             sb.Append(HexUtils.HexTable(Request.RawData));
-- 
cgit v1.2.3-70-g09d2