void GdbAttachEngine::runEngine()
{
    QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
    const qint64 pid = runParameters().attachPID;
    runCommand({"attach " + QByteArray::number(pid), NoFlags,
                [this](const DebuggerResponse &r) { handleAttach(r); }});
    showStatusMessage(tr("Attached to process %1.").arg(inferiorPid()));
}
Example #2
0
void GdbAttachEngine::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    const qint64 pid = startParameters().attachPID;
    postCommand("attach " + QByteArray::number(pid), NoFlags,
                [this](const DebuggerResponse &r) { handleAttach(r); });
    // Task 254674 does not want to remove them
    //qq->breakHandler()->removeAllBreakpoints();
}
Example #3
0
int main(int iargc, char *argv[])
{                                       /* despite different conventions */
   unsigned argc = (unsigned) iargc;   /* make argc consistently unsigned */
   unsigned int i;
   signed int j;
   char *logfilename = NULL;
   int allTestsPassed = TRUE;
   int retval;
   char *mutatee_name = NULL;
   unsigned int label_count = 0;
   int print_labels = FALSE;
   FILE* f;

#if defined(os_bgq_test)
   MPI_Init(&iargc, &argv);
#endif

   gargc = argc;
   gargv = argv;

   initOutputDriver();

   /* Extract the name of the mutatee binary from argv[0] */
   /* Find the last '/' in argv[0]; we want everything after that */
   mutatee_name = strrchr(argv[0], '/');
   if (!mutatee_name) {
      /* argv[0] contains just the filename for the executable */
      mutatee_name = argv[0];
      setExecutableName(argv[0]);
   } else {
      mutatee_name += 1; /* Skip past the '/' */
      setExecutableName(mutatee_name);
   }

   for (j=0; j < max_tests; j++) {
      runTest[j] = FALSE;
   }

   /* Parse command line arguments */
   for (i=1; i < argc; i++) {

      if (!strcmp(argv[i], "-verbose")) {
         debugPrint = 1;
      } else if (!strcmp(argv[i], "-log")) {
         /* Read the log file name so we can set it up later */
         if ((i + 1) >= argc) {
            output->log(STDERR, "Missing log file name\n");
            exit(-1);
         }
         i += 1;
         logfilename = argv[i];
      } else if (!strcmp(argv[i], "-attach")) {
         useAttach = TRUE;
#if !defined(os_windows_test)
         if (++i >= argc) {
            output->log(STDERR, "attach usage\n");
            output->log(STDERR, "%s\n", USAGE);
            exit(-1);
         }
         pfd = atoi(argv[i]);
#endif
      } else if (!strcmp(argv[i], "-customattach")) {
         custom_attach = 1;
      } else if (!strcmp(argv[i], "-delayedattach")) {

		  delayed_attach = 1;
      } else if (!strcmp(argv[i], "-run")) {
         int j;
         for ( j = i+1; j < argc; j++ )
         {
            if ( argv[j][0] == '-' )
            {
               // end of test list
               break;
            }
            else
            {
               setRunTest(argv[j]);
            }
         }
         i = j - 1;
      } else if (!strcmp(argv[i], "-label")) {
         if (i + 1 >= argc) {
            output->log(STDERR, "-label must be followed by a label string\n");
            exit(-1);
         }
         i += 1;
         setLabel(argv[i]);
         label_count += 1;
      } else if (!strcmp(argv[i], "-print-labels")) {
         print_labels = TRUE;
      } else if (!strcmp(argv[i], "-humanlog")) {
         if (i + 1 >= argc) {
            output->log(STDERR, "-humanlog must be followed by a file name or '-'\n");
            exit(-1);
         }
         i += 1;
         setHumanLog(argv[i]);
      } else if (!strcmp(argv[i], "-runall")) {
         for (j = 0; j < max_tests; j++) {
            runTest[j] = TRUE;
         }
      } else if (!strcmp(argv[i], "-dboutput")) {
         /* Set up database output */
         initDatabaseOutputDriver();
      } else if (!strcmp(argv[i], "-resumelog")) {
         i += 1;
         resumelog_name = argv[i];
      } else if (!strcmp(argv[i], "-uniqueid")) {
         i += 1;
         unique_id = atoi(argv[i]);
      } else if (!strcmp(argv[i], "-signal_file")) {
         i += 1;
         f = fopen(argv[i], "w");
         fclose(f);
      } else if (!strcmp(argv[i], "-signal_fd")) {
         signal_fd = atoi(argv[++i]);
         if (!signal_fd) {
            fprintf(stderr, "Invalid signal_fd value %s\n", argv[i]);
            exit(-1);
         }
      } else {
         /* Let's just ignore unrecognized parameters.  They might be
          * important to a specific test.
          */
      }
   }
	//fprintf(stderr, "parsed command line args\n");

   if ((logfilename != NULL) && (strcmp(logfilename, "-") != 0)) {
      /* Set up the log file */
      redirectStream(LOGINFO, logfilename);
      redirectStream(LOGERR, logfilename);
      outlog = fopen(logfilename, "a");
      if (NULL == outlog) {
         output->log(STDERR, "Error opening log file %s\n", logfilename);
         exit(-1);
      }
      errlog = outlog;
   } else {
      outlog = stdout;
      errlog = stderr;
   }
   if ((argc==1) || debugPrint)
      logstatus("Mutatee %s [%s]:\"%s\"\n", argv[0],
                mutateeCplusplus ? "C++" : "C", Builder_id);
   if (argc==1) {
		fprintf(stderr, "no tests specified, exiting\n");
	   exit(0);
   }

   /* see if we should wait for the attach */
   if (useAttach && !custom_attach) {
      if (!delayed_attach)
         handleAttach();
   } else {
      setUseAttach(FALSE);
   }

   /* 
    * Run the tests and keep track of return values in case of test failure
    */
   for (i = 0; i < (unsigned) max_tests; i++) {

	   if (runTest[i]) {

         log_testrun(mutatee_funcs[i].testname);

         if (print_labels && (mutatee_funcs[i].testlabel != NULL)) {
            logstatus("%s\n", mutatee_funcs[i].testlabel);
         }

         output->setTestName(mutatee_funcs[i].testname);
	
		 mutatee_funcs[i].func();
	
		 log_testresult(passedTest[i]);
    
         if (!passedTest[i]) {
            allTestsPassed = FALSE;
         }
      }

      flushOutputLog();
      flushErrorLog();
   }
	
   if (allTestsPassed) {
      logstatus("All tests passed.\n");
      retval = 0;
   } else {
#if 0
	   unsigned int i;
	   for (i = 0; i < max_tests; ++i)
	   {
		   if (runTest[i])
			   logstatus("%s[%d]: %s: %s \n",  __FILE__, __LINE__, 
					   mutatee_funcs[i].testlabel == NULL ? "bad_label" : mutatee_funcs[i].testlabel, passedTest[i] ? "PASSED" : "FAILED");
	   }
	   logstatus("\n");
#endif
      retval = -1;
   }

   /* Clean up after ourselves */
   if ((outlog != NULL) && (outlog != stdout)) {
      fclose(outlog);
   }
   //logstatus("Mutatee exiting\n");
   exit( retval);
}