Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add printing managed assert message to console #8399

Merged
merged 1 commit into from
Dec 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions src/vm/debugdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,11 +1367,6 @@ FCIMPL4(INT32, DebuggerAssert::ShowDefaultAssertDialog,

int result = IDRETRY;

if (NoGuiOnAssert())
{
return FailTerminate;
}

struct _gc {
STRINGREF strCondition;
STRINGREF strMessage;
Expand Down Expand Up @@ -1419,25 +1414,33 @@ FCIMPL4(INT32, DebuggerAssert::ShowDefaultAssertDialog,
windowTitle.Set(W("Assert Failure"));
}

// We're taking a string from managed code, and we can't be sure it doesn't have stuff like %s or \n in it.
// So, pass a format string of %s and pass the text as a vararg to our message box method.
// Also, varargs and StackSString don't mix. Convert to string first.
const WCHAR* msgTextAsUnicode = msgText.GetUnicode();
result = EEMessageBoxNonLocalizedNonFatal(W("%s"), windowTitle, stackTraceText, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION, msgTextAsUnicode);

// map the user's choice to the values recognized by
// the System.Diagnostics.Assert package
if (result == IDRETRY)
{
result = FailDebug;
}
else if (result == IDIGNORE)
if (NoGuiOnAssert())
{
result = FailIgnore;
fwprintf(stderr, W("%s\n%s\n%s\n"), windowTitle.GetUnicode(), msgText.GetUnicode(), stackTraceText.GetUnicode());
result = FailTerminate;
}
else
{
result = FailTerminate;
// We're taking a string from managed code, and we can't be sure it doesn't have stuff like %s or \n in it.
// So, pass a format string of %s and pass the text as a vararg to our message box method.
// Also, varargs and StackSString don't mix. Convert to string first.
const WCHAR* msgTextAsUnicode = msgText.GetUnicode();
result = EEMessageBoxNonLocalizedNonFatal(W("%s"), windowTitle, stackTraceText, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION, msgTextAsUnicode);

// map the user's choice to the values recognized by
// the System.Diagnostics.Assert package
if (result == IDRETRY)
{
result = FailDebug;
}
else if (result == IDIGNORE)
{
result = FailIgnore;
}
else
{
result = FailTerminate;
}
}

HELPER_METHOD_FRAME_END();
Expand Down