// wrapper for exit(), calling NAError_stub_for_breakpoints() first
void NAExit(Int32 status)
{
    NAAssertMutexLock(); // Serialize termination
    releaseRTSSemaphore();
  if (status)
    NAError_stub_for_breakpoints(); // LCOV_EXCL_LINE :dpm
  if (status != 0)
    {
#ifndef _DEBUG
  char *abortOnError = getenv("ABORT_ON_ERROR");
  if (abortOnError != NULL)
     abort();
  else
  if (IdentifyMyself::GetMyName() == I_AM_EMBEDDED_SQL_COMPILER)
     AssertException("", __FILE__, __LINE__).throwException();
   else
#endif
     abort();  // this will create core file on Linux
  }
  else
    // Calling my_mpi_fclose explicitly fixes the problem reported in bug 2243
    // for callers of NAExit(0) which is that registering it via the atexit
    // function does not guarantee that at process termination time
    // msg_mon_process_shutdown will be called before Seabed termination code
    // which requires msg_mon_process_shutdown to be called first.
    {
      my_mpi_fclose();
    }
   exit(status);
}
示例#2
0
void InstructionStack::assert(OperandStack & stack, std::string const & value, eOperandType type)
{
	IOperand const * op = Factory::getInstance().createOperand(type, value);
	IOperand const * res = *op - *stack.top();
	if (res->toString().compare("0"))
		throw AssertException(op->toString());
}
示例#3
0
文件: Instruction.cpp 项目: T4lus/AVM
void Instruction::Assert::execute() const
{
  Operand::IOperand *top;
  Operand::IOperand *actual;

  top = AbstractVM::getVM()->getStack()->getTopOperand();
  actual = this->op;
  if (top->toString() != actual->toString())
    throw AssertException("Assert with the value: " + actual->toString());
}
示例#4
0
int NAAssertMutexCreate()
{
  int rc;
  pthread_mutexattr_t attr;
  if (NAAssertMutexThreadCount++ == 0)
  {
  // The recursive attribute allows the mutex to be locked recursively
  // within a thread.  This avoids a hang if NAExit locks the mutex
  // and an exit handler subsequently asserts and calls
  // assert_botch_abend. At the present time, only the SeaMonster exit
  // handler can call assert_botch_abend, but other exit handlers
  // might be capable of calling it in the future.
    rc = pthread_mutexattr_init(&attr);
    if (rc)
    {
      if (IdentifyMyself::GetMyName() == I_AM_EMBEDDED_SQL_COMPILER)
        AssertException("", __FILE__, __LINE__).throwException();
      else
        abort();
    }
    rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
    if (rc)
    {    
      if (IdentifyMyself::GetMyName() == I_AM_EMBEDDED_SQL_COMPILER)
        AssertException("", __FILE__, __LINE__).throwException();
      else
        abort();
    }
    rc = pthread_mutex_init(&NAAssertMutex, &attr); // Create mutex on call from executor thread
    if (rc)
    {
      if (IdentifyMyself::GetMyName() == I_AM_EMBEDDED_SQL_COMPILER)
        AssertException("", __FILE__, __LINE__).throwException();
      else
        abort();
    }
    NAAssertMutexExTid = (int) syscall(__NR_gettid);
  }
  return NAAssertMutexThreadCount;
}
示例#5
0
int NAAssertMutexLock()
{
  int rc;
  rc = pthread_mutex_lock(&NAAssertMutex);
  if (rc)
  {
    if (IdentifyMyself::GetMyName() == I_AM_EMBEDDED_SQL_COMPILER)
      AssertException("", __FILE__, __LINE__).throwException();
    else
      abort();
  }
  return rc;
}
示例#6
0
		void AssertMessage(const char * text, const char * filename, int linenum, const char * format, ...)
		{
			// We only want to display the file name
			filename = clean_filename(filename);

			SCP_stringstream msgStream;
			msgStream << "Assert: \"" << text << "\"\n";
			msgStream << "File: " << filename << "\n";
			msgStream << "Line: " << linenum << "\n";
			
			if (format != nullptr)
			{
				SCP_string buffer;
				va_list args;

				va_start(args, format);
				vsprintf(buffer, format, args);
				va_end(args);

				msgStream << buffer << "\n";
				mprintf(("ASSERTION: \"%s\" at %s:%d\n %s\n", text, filename, linenum, buffer.c_str()));
			}
			else
			{
				// No additional message
				mprintf(("ASSERTION: \"%s\" at %s:%d\n", text, filename, linenum));
			}

			if (running_unittests) {
				throw AssertException(msgStream.str());
			}

			msgStream << "\n";
			msgStream << dump_stacktrace();

			SCP_string messageText = msgStream.str();
			set_clipboard_text(messageText.c_str());

			messageText = truncateLines(msgStream, Messagebox_lines);
			messageText += "\n[ This info is in the clipboard so you can paste it somewhere now ]\n";
			messageText += "\n\nUse Debug to break into Debugger, Exit will close the application.\n";

			Error(messageText.c_str());
		}
示例#7
0
UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults,
									 const TestDetails* testDetails,
									 char const* description,
									 char const* filename,
									 int lineNumber)
{
	if (AssertExpectedFlag() == false)
	{
		TestDetails assertDetails(testDetails->testName, testDetails->suiteName, filename, lineNumber);
		testResults->OnTestFailure(assertDetails, description);
	}

	ExpectAssert(false);

#ifndef UNITTEST_NO_EXCEPTIONS
	throw AssertException();
#else
	UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET();
#endif
}
示例#8
0
void	MemoryClass<D>::assert(const D &el) const
{
	if (data[cont_size - 1] != el)
		throw (AssertException());
}
示例#9
0
void assert_botch_abend( const char *f, Int32 l, const char * m, const char *c)
{
#ifndef __EID
  NAAssertMutexLock(); // Assure "termination synchronization"
  int pid = (int) getpid();

  // get thread id for SeaMonster reader thread or other future
  // executor threads
  int tid = (int) syscall(__NR_gettid);

  Lng32 *tidPtr = tid == pid ? NULL : (Lng32*)&tid;
  if (tid == NAAssertMutexExTid)
    releaseRTSSemaphore(); // Semaphore is released on by main executor thread
  // log the message to the event log
  SQLMXLoggingArea::logSQLMXAssertionFailureEvent(f, l, m, c, tidPtr); // Any executor thread can log a failure

  // Log the message to stderr. On Linux stderr is mapped to a file
  // under $MY_SQROOT/logs and our output will be prefixed with a
  // timestamp and process ID.
  cerr << "Executor assertion failure in file " << f
       << " on line " << l << '\n';
  cerr << "Message: " << m << endl << flush;

#ifdef _DEBUG
  // If debug code, log the message again to the terminal
  char timeString[40] = "";
  time_t tm = time(0);
  ctime_r(&tm, timeString);
  printf("*** EXECUTOR ASSERTION FAILURE\n");
  printf("*** Time: %s", timeString);
  printf("*** Process: %d\n", pid);
  if (tid != pid)
    printf("*** Thread ID: %d\n", tid);
  printf("*** File: %s\n", f);
  printf("*** Line: %d\n", (int) l);
  if (c)
    printf("*** Condition: %s\n", c);
  printf("*** Message: %s\n", m);
  fflush(stdout);
#endif // _DEBUG

  // Cleanup the shared segment since the registered atexit function
  // will not be called
  char *envvar;
  envvar = getenv("SQL_LOOP_ON_ASSERT");
  if (envvar && *envvar == '1')
  {
    while (*envvar == '1')
          sleep(10);
  }
#ifndef _DEBUG
  char *abortOnError = getenv("ABORT_ON_ERROR");
  NAString fileName(f);
  if (abortOnError != NULL)
     abort();
  else if(((int)fileName.index("/optimizer/")) > -1 )
  {
    //throw exception if ABORT is called from optimizer dir
    AssertException(m, f, l).throwException();
  }
  else
#endif
    abort();
#else
  assert_botch_in_eid(f, l, m);
#endif
}
示例#10
0
void ReportAssert(char const* description, char const* filename, int lineNumber) { throw AssertException(description, filename, lineNumber); }
示例#11
0
		void ReleaseWarning(const char* filename, int line, const char* format, ...)
		{
			Global_warning_count++;

			filename = clean_filename(filename);

			// output to the debug log before anything else (so that we have a complete record)

			SCP_string formatMessage;
			va_list args;
			va_start(args, format);
			vsprintf(formatMessage, format, args);
			va_end(args);


			SCP_string printfString = formatMessage;
			std::transform(printfString.begin(), printfString.end(), printfString.begin(), replaceNewline);

			mprintf(("WARNING: \"%s\" at %s:%d\n", printfString.c_str(), filename, line));

			// now go for the additional popup window, if we want it ...
			if (Cmdline_noninteractive) {
				return;
			}

			if (running_unittests) {
				throw AssertException(printfString);
			}

			SCP_stringstream boxMsgStream;
			boxMsgStream << "Warning: " << formatMessage << "\n";
			boxMsgStream << "File: " << filename << "\n";
			boxMsgStream << "Line: " << line << "\n";

			boxMsgStream << "\n";
			boxMsgStream << dump_stacktrace();

			set_clipboard_text(boxMsgStream.str().c_str());

			SCP_string boxMessage = truncateLines(boxMsgStream, Messagebox_lines);
			boxMessage += "\n[ This info is in the clipboard so you can paste it somewhere now ]\n";
			boxMessage += "\n\nUse Debug to break into Debugger\n";

			const SDL_MessageBoxButtonData buttons[] = {
				{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 2, "Exit" },
				{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 1, "Continue" },
				{ /* .flags, .buttonid, .text */        0, 0, "Debug" },
			};

			SDL_MessageBoxData boxData;
			memset(&boxData, 0, sizeof(boxData));

			boxData.buttons = buttons;
			boxData.numbuttons = 3;
			boxData.colorScheme = nullptr;
			boxData.flags = SDL_MESSAGEBOX_WARNING;
			boxData.message = boxMessage.c_str();
			boxData.title = "Warning!";
			boxData.window = os::getSDLMainWindow();

			gr_activate(0);

			int buttonId;
			if (SDL_ShowMessageBox(&boxData, &buttonId) < 0)
			{
				// Call failed
				exit(1);
			}

			switch (buttonId)
			{
			case 2:
				exit(1);

			case 0:
				Int3();
				break;

			default:
				break;
			}

			gr_activate(1);
		}
示例#12
0
文件: assert.hpp 项目: maydayzm/ftl
	inline void assert(bool value, const char* text = "(no description)") {
		if (!value)
			throw AssertException(text);
	}