Skip to content

Commit e0eb3a2

Browse files
authored
Native crashreporter: add stacktrace to managed exceptions (#3838)
1 parent 028b6b5 commit e0eb3a2

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

engine/Launcher/CrashReporter/ManagedStackExtractor.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,29 @@ static class ManagedStackExtractor
8686

8787
if ( thread.CurrentException != null )
8888
{
89-
sb.AppendLine( $" ** EXCEPTION: {thread.CurrentException.Type?.Name}: {thread.CurrentException.Message}" );
89+
var ex = thread.CurrentException;
90+
sb.AppendLine( $" ** EXCEPTION: {ex.Type?.Name}: {ex.Message}" );
91+
92+
// Print the exception's stack trace if available
93+
foreach ( var frame in ex.StackTrace )
94+
{
95+
var method = frame.Method;
96+
if ( method != null )
97+
{
98+
var typeName = method.Type?.Name ?? "<unknown type>";
99+
var methodName = method.Name ?? "<unknown method>";
100+
var signature = GetMethodSignature( method );
101+
sb.AppendLine( $" at {typeName}.{methodName}{signature}" );
102+
}
103+
else
104+
{
105+
sb.AppendLine( $" at 0x{frame.InstructionPointer:X16} <native>" );
106+
}
107+
}
90108
}
91109

110+
sb.AppendLine( "" );
111+
92112
var frames = thread.EnumerateStackTrace().ToList();
93113
var frameIndex = 0;
94114

0 commit comments

Comments
 (0)