@@ -48,7 +48,7 @@ void SafeExitProcess(UINT exitCode, ShutdownCompleteAction sca = SCA_ExitProcess
4848            {
4949                _ASSERTE (!" Bad Exit value"  );
5050                FAULT_NOT_FATAL ();      //  if we OOM we can simply give up
51-                 fprintf (stderr,  " Error 0x%08x.\n\n BreakOnBadExit: returning bad exit code."  , exitCode);
51+                 minipal_log_print_stderr ( " Error 0x%08x.\n\n BreakOnBadExit: returning bad exit code."  , exitCode);
5252                DebugBreak ();
5353            }
5454        }
@@ -233,8 +233,10 @@ class CallStackLogger
233233
234234        MethodDesc* pMD = m_frames[index];
235235        TypeString::AppendMethodInternal (str, pMD, TypeString::FormatNamespace|TypeString::FormatFullInst|TypeString::FormatSignature);
236-         PrintToStdErrW (str.GetUnicode ());
237-         PrintToStdErrA (" \n "  );
236+         str.Append (W (" \n "  ));
237+ 
238+         MAKE_MULTIBYTE_FROMWIDE_BESTFIT (strUTF8, str.GetUnicode (), CP_UTF8);
239+         minipal_log_write_stderr (strUTF8);
238240    }
239241
240242public: 
@@ -264,13 +266,15 @@ class CallStackLogger
264266            SmallStackSString repeatStr;
265267            repeatStr.AppendPrintf (" Repeated %d times:\n "  , m_largestCommonStartRepeat);
266268
267-             PrintToStdErrW (repeatStr.GetUnicode ());
268-             PrintToStdErrA (" --------------------------------\n "  );
269+             MAKE_MULTIBYTE_FROMWIDE_BESTFIT (repeatStrUTF8, repeatStr.GetUnicode (), CP_UTF8);
270+             minipal_log_write_stderr (repeatStrUTF8);
271+ 
272+             minipal_log_write_stderr (" --------------------------------\n "  );
269273            for  (int  i = 0 ; i < m_largestCommonStartLength; i++)
270274            {
271275                PrintFrame (i, pWordAt);
272276            }
273-             PrintToStdErrA (" --------------------------------\n "  );
277+             minipal_log_write_stderr (" --------------------------------\n "  );
274278        }
275279
276280        for  (int  i = m_largestCommonStartLength * m_largestCommonStartRepeat; i < m_frames.Count (); i++)
@@ -347,7 +351,7 @@ void LogInfoForFatalError(UINT exitCode, LPCWSTR pszMessage, PEXCEPTION_POINTERS
347351    {
348352        if  (previousThreadID == currentThreadID)
349353        {
350-             PrintToStdErrA (" Fatal error while logging another fatal error.\n "  );
354+             minipal_log_write_stderr (" Fatal error while logging another fatal error.\n "  );
351355        }
352356        else 
353357        {
@@ -362,42 +366,47 @@ void LogInfoForFatalError(UINT exitCode, LPCWSTR pszMessage, PEXCEPTION_POINTERS
362366
363367    EX_TRY
364368    {
369+         SString message;
365370        if  (exitCode == (UINT)COR_E_FAILFAST)
366371        {
367-             PrintToStdErrA ( " Process terminated. "  );
372+             message. Append ( W ( " Process terminated. " ) );
368373        }
369374        else 
370375        {
371-             PrintToStdErrA ( " Fatal error. "  );
376+             message. Append ( W ( " Fatal error. " ) );
372377        }
373378
374379        if  (errorSource != NULL )
375380        {
376-             PrintToStdErrW (errorSource);
377-             PrintToStdErrA ( " \n "  );
381+             message. Append (errorSource);
382+             message. Append ( W ( " \n " ) );
378383        }
379384
380385        if  (pszMessage != NULL )
381386        {
382-             PrintToStdErrW (pszMessage);
387+             message. Append (pszMessage);
383388        }
384389        else 
385390        {
386391            //  If no message was passed in, generate it from the exitCode
387392            SString exitCodeMessage;
388393            GetHRMsg (exitCode, exitCodeMessage);
389-             PrintToStdErrW ((LPCWSTR) exitCodeMessage);
394+             message. Append ( exitCodeMessage);
390395        }
391396
392-         PrintToStdErrA (" \n "  );
397+         message.Append (W (" \n "  ));
398+ 
399+         MAKE_MULTIBYTE_FROMWIDE_BESTFIT (messageUTF8, message.GetUnicode (), CP_UTF8);
400+         minipal_log_write_stderr (messageUTF8);
393401
394402        Thread* pThread = GetThreadNULLOk ();
395403        if  (pThread && errorSource == NULL )
396404        {
397405            LogCallstackForLogWorker (pThread, pExceptionInfo);
398406
399407            if  (argExceptionString != NULL ) {
400-                 PrintToStdErrW (argExceptionString);
408+                 MAKE_MULTIBYTE_FROMWIDE_BESTFIT (argExceptionStringUTF8, argExceptionString, CP_UTF8);
409+                 minipal_log_write_stderr (argExceptionStringUTF8);
401410            }
402411        }
403412    }
@@ -589,7 +598,7 @@ void DisplayStackOverflowException()
589598{
590599    LIMITED_METHOD_CONTRACT;
591600
592-     PrintToStdErrA (" Stack overflow.\n "  );
601+     minipal_log_write_stderr (" Stack overflow.\n "  );
593602}
594603
595604DWORD LogStackOverflowStackTraceThread (void * arg)
0 commit comments