Пример #1
0
void assertion(const bool expression, const std::string& file, unsigned int line, const std::string& message)
{
    if (!expression)
    {
        auto slashPos = file.find_last_of("/\\");

        std::string newStr = "File: " + file.substr(slashPos == std::string::npos ? 0 : slashPos + 1);
        newStr += "\nLine: " + std::to_string(line);
        newStr += "\n\n" + message;

#if defined(JOP_OS_WINDOWS)

        MessageBoxA(GetDesktopWindow(), newStr.c_str(), "Assertion failed!", MB_ICONERROR | MB_OK | MB_SETFOREGROUND);

#elif defined(JOP_OS_ANDROID)

        __android_log_assert(0, "jopnal", newStr.c_str());

#endif

#if defined(JOP_DEBUG_MODE) && defined(JOP_COMPILER_MSVC)
        // An assertion failed. There's a break here so you can traverse the call stack
        DebugBreak();
#endif

        std::exit(EXIT_FAILURE);
    }
}
Пример #2
0
PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln)
{
    PR_LogPrint("Assertion failure: %s, at %s:%d\n", s, file, ln);
    fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln);
    fflush(stderr);
#ifdef WIN32
    DebugBreak();
#elif defined(XP_OS2)
    asm("int $3");
#elif defined(ANDROID)
    __android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n",
                         s, file, ln);
#endif
    abort();
}
Пример #3
0
__sighandler_t bsd_signal(int s, __sighandler_t f)
{
 if (bsd_signal_func == 0)
 {
   // For now (up to Android 7.0) this is always available 
   bsd_signal_func = (bsd_signal_func_t) dlsym(RTLD_DEFAULT, "bsd_signal");

   if (bsd_signal_func == 0)
   {
     // You may try dlsym(RTLD_DEFAULT, "signal") or dlsym(RTLD_NEXT, "signal") here
     // Make sure you add a comment here in StackOverflow
     // if you find a device that doesn't have "bsd_signal" in its libc.so!!!

     __android_log_assert("", "bsd_signal_wrapper", "bsd_signal symbol not found!");
   }
 }

 return bsd_signal_func(s, f);
}
Пример #4
0
	void __assert2(const char *file, int line, const char *func,
					const char *expr) {
		__android_log_assert(expr, android_log_tag,
								"Assertion failure: '%s' in %s:%d (%s)",
								 expr, file, line, func);
	}