@@ -292,7 +292,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * /*context*
292292 const char * const signame = signal_name (signo);
293293 const char * const sigtext = strsignal (signo);
294294 bool bPrintCallstack=true ;
295- FILE* f=stderr;
295+ FILE* f=CppCheckExecutor::getExceptionOutput ()== " stderr" ? stderr : stdout ;
296296 fputs (" Internal error: cppcheck received signal " , f);
297297 fputs (signame, f);
298298 fputs (" , " , f);
@@ -334,15 +334,16 @@ static int filterException(int code, PEXCEPTION_POINTERS ex)
334334{
335335 // TODO we should try to extract more information here
336336 // - address, read/write
337+ FILE *f = stdout;
337338 switch (ex->ExceptionRecord ->ExceptionCode ) {
338339 case EXCEPTION_ACCESS_VIOLATION:
339- fprintf (stderr , " Internal error (EXCEPTION_ACCESS_VIOLATION)\n " );
340+ fprintf (f , " Internal error (EXCEPTION_ACCESS_VIOLATION)\n " );
340341 break ;
341342 case EXCEPTION_IN_PAGE_ERROR:
342- fprintf (stderr , " Internal error (EXCEPTION_IN_PAGE_ERROR)\n " );
343+ fprintf (f , " Internal error (EXCEPTION_IN_PAGE_ERROR)\n " );
343344 break ;
344345 default :
345- fprintf (stderr , " Internal error (%d)\n " ,
346+ fprintf (f , " Internal error (%d)\n " ,
346347 code);
347348 break ;
348349 }
@@ -359,11 +360,12 @@ static int filterException(int code, PEXCEPTION_POINTERS ex)
359360int CppCheckExecutor::check_wrapper (CppCheck& cppcheck, int argc, const char * const argv[])
360361{
361362#ifdef USE_WINDOWS_SEH
363+ FILE *f = stdout;
362364 __try {
363365 return check_internal (cppcheck, argc, argv);
364366 } __except (filterException (GetExceptionCode (), GetExceptionInformation ())) {
365367 // reporting to stdout may not be helpful within a GUI application..
366- fprintf (stderr , " Please report this to the cppcheck developers!\n " );
368+ fprintf (f , " Please report this to the cppcheck developers!\n " );
367369 return -1 ;
368370 }
369371#elif defined(USE_UNIX_SIGNAL_HANDLING)
@@ -558,3 +560,13 @@ void CppCheckExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
558560 reportErr (msg.toString (_settings->_verbose , _settings->_outputFormat ));
559561 }
560562}
563+
564+ void CppCheckExecutor::setExceptionOutput (const std::string& fn)
565+ {
566+ exceptionOutput=fn;
567+ }
568+ const std::string& CppCheckExecutor::getExceptionOutput ()
569+ {
570+ return exceptionOutput;
571+ }
572+ std::string CppCheckExecutor::exceptionOutput;
0 commit comments