void DoAssert(const wchar_t * Message, const wchar_t * Filename, uintptr_t LineNumber) { if (IsTracing) { DoTrace(Filename, L"assert", LineNumber, Message); } _wassert(Message, Filename, (unsigned int)LineNumber); }
void geAssertDefault( void *exp, void *file, unsigned line ) { #ifdef _DEBUG #if _MSC_VER > 1200 _wassert(exp, file, line); #else _assert(exp, file, line); #endif #endif }
void deAssertFail (const char* reason, const char* file, int line) { #if defined(DE_ASSERT_FAILURE_CALLBACK) if (g_assertFailureCallback != DE_NULL) { /* Remove callback in case of the callback causes further asserts. */ deAssertFailureCallbackFunc callback = g_assertFailureCallback; deSetAssertFailureCallback(DE_NULL); callback(reason, file, line); } #endif #if (((DE_OS == DE_OS_WIN32) || (DE_OS == DE_OS_WINCE)) && (DE_COMPILER == DE_COMPILER_MSC)) { wchar_t wreason[1024]; wchar_t wfile[128]; int num; int i; /* MessageBox(reason, "Assertion failed", MB_OK); */ num = deMin32((int)strlen(reason), DE_LENGTH_OF_ARRAY(wreason)-1); for (i = 0; i < num; i++) wreason[i] = reason[i]; wreason[i] = 0; num = deMin32((int)strlen(file), DE_LENGTH_OF_ARRAY(wfile)-1); for (i = 0; i < num; i++) wfile[i] = file[i]; wfile[i] = 0; # if (DE_OS == DE_OS_WIN32) _wassert(wreason, wfile, line); # else /* WINCE */ assert(wreason); # endif } #elif ((DE_OS == DE_OS_WIN32) && (DE_COMPILER == DE_COMPILER_CLANG)) _assert(reason, file, line); #elif (DE_OS == DE_OS_UNIX) __assert_fail(reason, file, (unsigned int)line, "Unknown function"); #elif (DE_OS == DE_OS_SYMBIAN) __assert("Unknown function", file, line, reason); #elif (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_IOS) fprintf(stderr, "Assertion '%s' failed at %s:%d\n", reason, file, line); raise(SIGTRAP); abort(); #elif (DE_OS == DE_OS_ANDROID) __android_log_print(ANDROID_LOG_ERROR, "delibs", "Assertion '%s' failed at %s:%d", reason, file, line); __assert(file, line, reason); #else # error Implement assertion function on your platform. #endif }
void WIN32_OP_D_FAIL(const wchar_t * _Message, const wchar_t *_File, unsigned _Line) { const DWORD code = GetLastError(); pfc::array_t<wchar_t> msgFormatted; msgFormatted.set_size(pfc::strlen_t(_Message) + 64); wsprintfW(msgFormatted.get_ptr(), L"%s (code: %u)", _Message, code); if (IsDebuggerPresent()) { OutputDebugString(TEXT("WIN32_OP_D() failure:\n")); OutputDebugString(msgFormatted.get_ptr()); OutputDebugString(TEXT("\n")); pfc::crash(); } _wassert(msgFormatted.get_ptr(),_File,_Line); }
void msvc_assert(const wchar_t* msg, const wchar_t* expr, const wchar_t* file, unsigned line) { if (IsDebuggerPresent()) { wchar_t buffer[1024]; if (msg) { wsprintf(buffer, L"Assertion failed: %s: %s, file %s, line %d\n", msg, expr, file, line); } else { wsprintf(buffer, L"Assertion failed: %s, file %s, line %d\n", expr, file, line); } OutputDebugStringW(buffer); __debugbreak(); } else { _wassert(expr, file, line); } }
void assertFailed(const char *file, unsigned line, const char *expression, const std::string &message) { auto stackTrace = platform::captureStackTrace(); auto trace = platform::formatStackTrace(stackTrace); platform::freeStackTrace(stackTrace); fmt::MemoryWriter out; out << "Assertion failed:\n"; out << "Expression: " << expression << "\n"; out << "File: " << file << "\n"; out << "Line: " << line << "\n"; if (!message.empty()) { out << "Message: " << message << "\n"; } if (trace.size()) { out << "Stacktrace:\n" << trace << "\n"; } if (gLog) { gLog->critical("{}", out.str()); } std::cerr << out.str() << std::endl; #ifdef PLATFORM_WINDOWS std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; auto wmsg = converter.from_bytes(message); if (IsDebuggerPresent()) { OutputDebugStringW(converter.from_bytes(out.c_str()).c_str()); } else { auto expr = converter.from_bytes(expression); if (!wmsg.empty()) { expr += L"\nMessage: "; expr += wmsg; } _wassert(expr.c_str(), converter.from_bytes(file).c_str(), line); } #endif }
void DL_Debug::Debug::AssertMessage(const char *aFileName, int aLine, const char *aFunctionName, const wchar_t *aString) { myDebugFile << "\nFilename: " << aFileName << "\n" << "Line: " << aLine << "\n" << "Function: " << aFunctionName << "\n" << "Message: " << aString << "\n"; StackWalker st; st.ShowCallstack(); std::wstringstream ss; ss << aFileName; myDebugFile.flush(); _wassert(aString, ss.str().c_str(), aLine); }
void Debug::AssertMessage(const char* aFileName, int aLine, const char* aFunctionName, const char* aString) { time_t t = time(0); // get current system time; struct tm timeinfo; localtime_s(&timeinfo, &t); myDebugFile << timeinfo.tm_hour << ":" << timeinfo.tm_min << ":" << timeinfo.tm_sec << " error" << std::endl; myDebugFile << " Error: " << aString << " in function " << aFunctionName << " line " << aLine << " in file " << aFileName << std::endl; myDebugFile.flush(); StackWalker aStackWalker; aStackWalker.ShowCallstack(); size_t* a(NULL); wchar_t tmpFileName[256]; mbstowcs_s(a, tmpFileName, aFileName, 256); wchar_t tmpString[256]; mbstowcs_s(a, tmpString, aString, 256); _wassert(tmpString, tmpFileName, aLine); }