diff --git a/dll/win32/msvcrt/msvcrt.spec b/dll/win32/msvcrt/msvcrt.spec index 6a7b5372c51..0cd58fe0fd0 100644 --- a/dll/win32/msvcrt/msvcrt.spec +++ b/dll/win32/msvcrt/msvcrt.spec @@ -200,9 +200,9 @@ @ stub -version=0x600+ _CrtCheckMemory @ stub -version=0x600+ _CrtDbgBreak @ cdecl -version=0x600+ _CrtDbgReport(long str long str str) -@ stub -version=0x600+ _CrtDbgReportV +@ cdecl -version=0x600+ _CrtDbgReportV(long str long str str ptr) @ cdecl -version=0x600+ _CrtDbgReportW(long wstr long wstr wstr) -@ stub -version=0x600+ _CrtDbgReportWV +@ cdecl -version=0x600+ _CrtDbgReportWV(long wstr long wstr wstr ptr) @ stub -version=0x600+ _CrtDoForAllClientObjects @ stub -version=0x600+ _CrtDumpMemoryLeaks @ stub -version=0x600+ _CrtIsMemoryBlock diff --git a/sdk/include/crt/crtdbg.h b/sdk/include/crt/crtdbg.h index f9545698e89..13c16f66f50 100644 --- a/sdk/include/crt/crtdbg.h +++ b/sdk/include/crt/crtdbg.h @@ -81,6 +81,7 @@ extern "C" { size_t lTotalCount; } _CrtMemState; + // Debug reporting functions #ifdef _DEBUG @@ -88,6 +89,9 @@ extern "C" { int __cdecl _CrtDbgReport(int reportType, const char *filename, int linenumber, const char *moduleName, const char *format, ...); int __cdecl _CrtDbgReportW(int reportType, const wchar_t *filename, int linenumber, const wchar_t *moduleName, const wchar_t *format, ...); + int __cdecl _CrtDbgReportV(int reportType, const char *filename, int linenumber, const char *moduleName, const char *format, va_list arglist); + int __cdecl _CrtDbgReportWV(int reportType, const wchar_t *filename, int linenumber, const wchar_t *moduleName, const wchar_t *format, va_list arglist); + #endif diff --git a/sdk/lib/atl/atltrace.h b/sdk/lib/atl/atltrace.h index 6230af9f1fc..fcd81faad6e 100644 --- a/sdk/lib/atl/atltrace.h +++ b/sdk/lib/atl/atltrace.h @@ -9,18 +9,11 @@ #include "atldef.h" -#if DBG // FIXME: We should use _DEBUG instead of DBG. CORE-17505 +#ifdef _DEBUG #include #include -extern "C" -{ -// FIXME: Enabling _DEBUG at top level causes assertion failures... CORE-17505 -int __cdecl _CrtDbgReport(int reportType, const char *filename, int linenumber, const char *moduleName, const char *format, ...); -int __cdecl _CrtDbgReportW(int reportType, const wchar_t *filename, int linenumber, const wchar_t *moduleName, const wchar_t *format, ...); -} - namespace ATL { @@ -267,10 +260,10 @@ AtlTrace(_In_z_ _Printf_format_string_ const X_CHAR *format, ...) } // namespace ATL -#endif // DBG +#endif // _DEBUG #ifndef ATLTRACE - #if DBG // FIXME: We should use _DEBUG instead of DBG. CORE-17505 + #ifdef _DEBUG #define ATLTRACE(format, ...) ATL::AtlTraceEx(__FILE__, __LINE__, format, ##__VA_ARGS__) #else #define ATLTRACE(format, ...) ((void)0) @@ -279,7 +272,7 @@ AtlTrace(_In_z_ _Printf_format_string_ const X_CHAR *format, ...) #define ATLTRACE2 ATLTRACE -#if DBG // FIXME: We should use _DEBUG instead of DBG. CORE-17505 +#ifdef _DEBUG #define ATLTRACENOTIMPL(funcname) do { \ ATLTRACE(atlTraceNotImpl, 0, #funcname " is not implemented.\n"); \ return E_NOTIMPL; \ diff --git a/sdk/lib/crt/misc/dbgrpt.cpp b/sdk/lib/crt/misc/dbgrpt.cpp index 131a918a2e2..51c55af9b4c 100644 --- a/sdk/lib/crt/misc/dbgrpt.cpp +++ b/sdk/lib/crt/misc/dbgrpt.cpp @@ -309,7 +309,14 @@ static int _CrtHandleDbgReport(int reportType, const char_t* szCompleteMessage, EXTERN_C -int __cdecl _CrtDbgReport(int reportType, const char *filename, int linenumber, const char *moduleName, const char *format, ...) +int __cdecl +_VCrtDbgReportA( + int reportType, + const char *filename, + int linenumber, + const char *moduleName, + const char *format, + va_list arglist) { char szFormatted[DBGRPT_MAX_BUFFER_SIZE+1] = {0}; // The user provided message char szCompleteMessage[(DBGRPT_MAX_BUFFER_SIZE+1)*2] = {0}; // The output for debug / file @@ -325,11 +332,7 @@ int __cdecl _CrtDbgReport(int reportType, const char *filename, int linenumber, if (format) { - va_list arglist; - va_start(arglist, format); int len = _vsnprintf(szFormatted, DBGRPT_MAX_BUFFER_SIZE - 2 - sizeof(DBGRPT_ASSERT_PREFIX_MESSAGE), format, arglist); - va_end(arglist); - if (len < 0) { strcpy(szFormatted, DBGRPT_STRING_TOO_LONG); @@ -361,7 +364,14 @@ int __cdecl _CrtDbgReport(int reportType, const char *filename, int linenumber, } EXTERN_C -int __cdecl _CrtDbgReportW(int reportType, const wchar_t *filename, int linenumber, const wchar_t *moduleName, const wchar_t *format, ...) +int __cdecl +_VCrtDbgReportW( + int reportType, + const wchar_t *filename, + int linenumber, + const wchar_t *moduleName, + const wchar_t *format, + va_list arglist) { wchar_t szFormatted[DBGRPT_MAX_BUFFER_SIZE+1] = {0}; // The user provided message wchar_t szCompleteMessage[(DBGRPT_MAX_BUFFER_SIZE+1)*2] = {0}; // The output for debug / file @@ -377,11 +387,7 @@ int __cdecl _CrtDbgReportW(int reportType, const wchar_t *filename, int linenumb if (format) { - va_list arglist; - va_start(arglist, format); int len = _vsnwprintf(szFormatted, DBGRPT_MAX_BUFFER_SIZE - 2 - sizeof(DBGRPT_ASSERT_PREFIX_MESSAGE), format, arglist); - va_end(arglist); - if (len < 0) { wcscpy(szFormatted, _CRT_WIDE(DBGRPT_STRING_TOO_LONG)); @@ -412,5 +418,68 @@ int __cdecl _CrtDbgReportW(int reportType, const wchar_t *filename, int linenumb return nResult; } +EXTERN_C +int __cdecl +_CrtDbgReportV( + int reportType, + const char *filename, + int linenumber, + const char *moduleName, + const char *format, + va_list arglist) +{ + return _VCrtDbgReportA(reportType, filename, linenumber, moduleName, format, arglist); +} + +EXTERN_C +int __cdecl +_CrtDbgReportWV( + int reportType, + const wchar_t *filename, + int linenumber, + const wchar_t *moduleName, + const wchar_t *format, + va_list arglist) +{ + return _VCrtDbgReportW(reportType, filename, linenumber, moduleName, format, arglist); +} + +EXTERN_C +int __cdecl +_CrtDbgReport( + int reportType, + const char *filename, + int linenumber, + const char *moduleName, + const char *format, + ...) +{ + va_list arglist; + int result; + + va_start(arglist, format); + result = _VCrtDbgReportA(reportType, filename, linenumber, moduleName, format, arglist); + va_end(arglist); + return result; +} + +EXTERN_C +int __cdecl +_CrtDbgReportW( + int reportType, + const wchar_t *filename, + int linenumber, + const wchar_t *moduleName, + const wchar_t *format, + ...) +{ + va_list arglist; + int result; + + va_start(arglist, format); + result = _VCrtDbgReportW(reportType, filename, linenumber, moduleName, format, arglist); + va_end(arglist); + return result; +} //#endif // _DEBUG