summaryrefslogtreecommitdiff
path: root/src/vm/eventreporter.cpp
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-10-29 19:09:52 -0700
committerJan Kotas <jkotas@microsoft.com>2015-10-29 19:09:52 -0700
commita8192fbc7064ed96cfeb8872bcb6479c217f7b5f (patch)
tree738c092202d3ce5c7ed4ec08114c3c41b7b005d8 /src/vm/eventreporter.cpp
parent3c50dec5796206c6042fd6adc3133a0ad22649e5 (diff)
downloadcoreclr-a8192fbc7064ed96cfeb8872bcb6479c217f7b5f.tar.gz
coreclr-a8192fbc7064ed96cfeb8872bcb6479c217f7b5f.tar.bz2
coreclr-a8192fbc7064ed96cfeb8872bcb6479c217f7b5f.zip
Port .NET Framework 4.6.1 changes
Core runtime and GC changes from https://github.com/Microsoft/dotnet/blob/master/docs/releases/net461/dotnet461-changes.md that are not in CoreCLR yet [tfs-changeset: 1543382]
Diffstat (limited to 'src/vm/eventreporter.cpp')
-rw-r--r--src/vm/eventreporter.cpp102
1 files changed, 86 insertions, 16 deletions
diff --git a/src/vm/eventreporter.cpp b/src/vm/eventreporter.cpp
index 747a0454ef..1657bc72eb 100644
--- a/src/vm/eventreporter.cpp
+++ b/src/vm/eventreporter.cpp
@@ -17,6 +17,7 @@
#include "utilcode.h"
#include "eventreporter.h"
#include "typestring.h"
+#include "debugdebugger.h"
#include "../dlls/mscorrc/resource.h"
@@ -596,6 +597,73 @@ void LogCallstackForEventReporter(EventReporter& reporter)
LogCallstackForEventReporterWorker(reporter);
}
+void ReportExceptionStackHelper(OBJECTREF exObj, EventReporter& reporter, SmallStackSString& wordAt, int recursionLimit)
+{
+ CONTRACTL
+ {
+ THROWS;
+ GC_TRIGGERS;
+ MODE_COOPERATIVE;
+ }
+ CONTRACTL_END;
+
+ if (exObj == NULL || recursionLimit == 0)
+ {
+ return;
+ }
+
+ struct
+ {
+ OBJECTREF exObj;
+ EXCEPTIONREF ex;
+ STRINGREF remoteStackTraceString;
+ } gc;
+ ZeroMemory(&gc, sizeof(gc));
+ gc.exObj = exObj;
+ gc.ex = (EXCEPTIONREF)exObj;
+
+ GCPROTECT_BEGIN(gc);
+
+ ReportExceptionStackHelper((gc.ex)->GetInnerException(), reporter, wordAt, recursionLimit - 1);
+
+ StackSString exTypeStr;
+ TypeString::AppendType(exTypeStr, TypeHandle((gc.ex)->GetMethodTable()), TypeString::FormatNamespace | TypeString::FormatFullInst);
+ reporter.AddDescription(exTypeStr);
+
+ gc.remoteStackTraceString = (gc.ex)->GetRemoteStackTraceString();
+ if (gc.remoteStackTraceString != NULL && gc.remoteStackTraceString->GetStringLength())
+ {
+ SString remoteStackTrace;
+ gc.remoteStackTraceString->GetSString(remoteStackTrace);
+
+ // If source info is contained, trim it
+ StripFileInfoFromStackTrace(remoteStackTrace);
+
+ reporter.AddStackTrace(remoteStackTrace);
+ }
+
+ DebugStackTrace::GetStackFramesData stackFramesData;
+ stackFramesData.pDomain = NULL;
+ stackFramesData.skip = 0;
+ stackFramesData.NumFramesRequested = 0;
+
+ DebugStackTrace::GetStackFramesFromException(&(gc.exObj), &stackFramesData);
+
+ for (int j = 0; j < stackFramesData.cElements; j++)
+ {
+ StackSString str;
+ str = wordAt;
+ TypeString::AppendMethodInternal(str, stackFramesData.pElements[j].pFunc, TypeString::FormatNamespace | TypeString::FormatFullInst | TypeString::FormatSignature);
+ reporter.AddStackTrace(str);
+ }
+
+ StackSString separator(L""); // This will result in blank line
+ reporter.AddStackTrace(separator);
+
+ GCPROTECT_END();
+}
+
+
//---------------------------------------------------------------------------------------
//
// Generate an EventLog entry for unhandled exception.
@@ -609,7 +677,7 @@ void LogCallstackForEventReporter(EventReporter& reporter)
void DoReportForUnhandledException(PEXCEPTION_POINTERS pExceptionInfo)
{
WRAPPER_NO_CONTRACT;
-
+
if (ShouldLogInEventLog())
{
Thread *pThread = GetThread();
@@ -623,7 +691,6 @@ void DoReportForUnhandledException(PEXCEPTION_POINTERS pExceptionInfo)
struct
{
OBJECTREF throwable;
- STRINGREF remoteStackTraceString;
STRINGREF originalExceptionMessage;
} gc;
ZeroMemory(&gc, sizeof(gc));
@@ -677,25 +744,28 @@ void DoReportForUnhandledException(PEXCEPTION_POINTERS pExceptionInfo)
else
#endif // FEATURE_CORECLR
{
- // Add the details of the exception object to the event reporter.
- TypeString::AppendType(s, TypeHandle(gc.throwable->GetMethodTable()), TypeString::FormatNamespace|TypeString::FormatFullInst);
- reporter.AddDescription(s);
- reporter.BeginStackTrace();
if (IsException(gc.throwable->GetMethodTable()))
{
- gc.remoteStackTraceString = ((EXCEPTIONREF)gc.throwable)->GetRemoteStackTraceString();
- if (gc.remoteStackTraceString != NULL && gc.remoteStackTraceString->GetStringLength())
+ SmallStackSString wordAt;
+ if (!wordAt.LoadResource(CCompRC::Optional, IDS_ER_WORDAT))
{
- SString remoteStackTrace;
- gc.remoteStackTraceString->GetSString(remoteStackTrace);
-
- // If source info is contained, trim it
- StripFileInfoFromStackTrace(remoteStackTrace);
-
- reporter.AddStackTrace(remoteStackTrace);
+ wordAt.Set(W(" at"));
}
+ else
+ {
+ wordAt.Insert(wordAt.Begin(), W(" "));
+ }
+ wordAt += W(" ");
+
+ ReportExceptionStackHelper(gc.throwable, reporter, wordAt, /* recursionLimit = */10);
+ }
+ else
+ {
+ TypeString::AppendType(s, TypeHandle(gc.throwable->GetMethodTable()), TypeString::FormatNamespace | TypeString::FormatFullInst);
+ reporter.AddDescription(s);
+ reporter.BeginStackTrace();
+ LogCallstackForEventReporterWorker(reporter);
}
- LogCallstackForEventReporterWorker(reporter);
}
GCPROTECT_END();