Exemple #1
0
static void unlock_mutex(pthread_mutex_t *l)
{
	int ret;

	if ((ret = pthread_mutex_unlock(l)) != 0) {
		fprintf(stderr, "pthread_mutex_unlock returned:%d %s", ret, strerror(ret));
		dump_stacktrace();
		exit(1);
	}
}
Exemple #2
0
static void static_unlock(void)
{
	int ret;

	if ((ret = pthread_mutex_unlock(&static_mutex)) != 0) {
		ERROR("pthread_mutex_unlock returned:%d %s", ret, strerror(ret));
		dump_stacktrace();
		exit(1);
	}
}
Exemple #3
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());
		}
Exemple #4
0
NORETURN void panic(const char *fmt, ...)
{
   static bool first_printk_ok;

   uptr rc;
   va_list args;
   task_info *curr;

   disable_interrupts_forced(); /* No interrupts: we're in a panic state */

   if (__in_panic) {

      /* Ouch, nested panic! */

      if (first_printk_ok)
         printk("FATAL: got panic while in panic state. Halt.\n");

      goto end;
   }

   __in_panic = true;

   disable_fpu_features();
   panic_save_current_state();
   curr = get_curr_task();

   if (term_is_initialized(get_curr_term())) {

      if (get_curr_tty() != NULL)
         tty_setup_for_panic(get_curr_tty());

   } else {

      init_console();
   }

   /* Hopefully, we can print something on screen */

   printk("*********************************"
          " KERNEL PANIC "
          "********************************\n");

   /*
    * Register the fact that the first printk() succeeded: in case of panic
    * in panic, at least we know that we can show something on the screen.
    */

   first_printk_ok = true;

   va_start(args, fmt);

   /* print the arguments in a fault-safe way */
   rc = fault_resumable_call(ALL_FAULTS_MASK, vprintk, 2, fmt, args);

   if (rc != 0) {
      printk("[panic] Got fault %d while trying to print "
             "the panic message.", get_fault_num(rc));
   }

   va_end(args);
   printk("\n");

   panic_print_task_info(curr);
   panic_dump_nested_interrupts();

   if (PANIC_SHOW_REGS)
      dump_regs(&panic_state_regs);

   if (PANIC_SHOW_STACKTRACE)
      dump_stacktrace();

   if (DEBUG_QEMU_EXIT_ON_PANIC)
      debug_qemu_turn_off_machine();

end:
   /* Halt the CPU forever */
   while (true) { halt(); }
}
Exemple #5
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);
		}
Exemple #6
0
		void Error(const char* text)
		{
			mprintf(("\n%s\n", text));

			if (Cmdline_noninteractive) {
				abort();
				return;
			}

			if (running_unittests) {
				throw ErrorException(text);
			}

			SCP_stringstream messageStream;
			messageStream << text << "\n";
			messageStream << dump_stacktrace();

			SCP_string fullText = messageStream.str();
			set_clipboard_text(fullText.c_str());

			fullText = truncateLines(messageStream, Messagebox_lines);

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

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

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

			boxData.buttons = buttons;
			boxData.numbuttons = 2;
			boxData.colorScheme = nullptr;
			boxData.flags = SDL_MESSAGEBOX_ERROR;
			boxData.message = text;
			boxData.title = "Error!";
			boxData.window = os::getSDLMainWindow();

			gr_activate(0);

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

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

			default:
				Int3();
				break;
			}
			gr_activate(1);
		}