예제 #1
0
 void testDetectProcess()
 {
   ProbeABIDetector detector;
   QVERIFY(!detector.qtCoreForProcess(QCoreApplication::applicationPid()).isEmpty());
   const ProbeABI abi = detector.abiForProcess(QCoreApplication::applicationPid());
   QCOMPARE(abi.id(), QStringLiteral(GAMMARAY_PROBE_ABI));
 }
예제 #2
0
    void testToString()
    {
        QFETCH(QString, id);
        QFETCH(int, majorVersion);
        QFETCH(int, minorVersion);
        QFETCH(bool, isDebug);
        QFETCH(QString, arch);
        QFETCH(QString, compiler);
        QFETCH(QString, compilerVersion);

        ProbeABI abi;
        abi.setQtVersion(majorVersion, minorVersion);
        abi.setIsDebug(isDebug);
        abi.setArchitecture(arch);
        abi.setCompiler(compiler);
        abi.setCompilerVersion(compilerVersion);

        QCOMPARE(abi.id(), id);
    }
예제 #3
0
int main(int argc, char **argv)
{
  QCoreApplication::setOrganizationName(QStringLiteral("KDAB"));
  QCoreApplication::setOrganizationDomain(QStringLiteral("kdab.com"));
  QCoreApplication::setApplicationName(QStringLiteral("GammaRay"));

  installSignalHandler();

  QStringList args;
  args.reserve(argc);
  for (int i = 1; i < argc; ++i) {
    args.push_back(QString::fromLocal8Bit(argv[i]));
  }
#ifdef HAVE_QT_WIDGETS
  QApplication app(argc, argv); // for style inspector
#else
  QCoreApplication app(argc, argv);
#endif
  Paths::setRelativeRootPath(GAMMARAY_INVERSE_BIN_DIR);

  QStringList builtInArgs = QStringList() << QStringLiteral("-style")
                                          << QStringLiteral("-stylesheet")
                                          << QStringLiteral("-graphicssystem");

  LaunchOptions options;
  while (!args.isEmpty() && args.first().startsWith('-')) {
    const QString arg = args.takeFirst();
    if ((arg == QLatin1String("-i") || arg == QLatin1String("--injector")) && !args.isEmpty()) {
      options.setInjectorType(args.takeFirst());
      continue;
    }
    if ((arg == QLatin1String("-p") || arg == QLatin1String("--pid")) && !args.isEmpty()) {
      options.setPid( args.takeFirst().toInt() );
      continue;
    }
    if (arg == QLatin1String("-h") || arg == QLatin1String("--help")) {
      usage(argv[0]);
      return 0;
    }
    if (arg == QLatin1String("-v") || arg == QLatin1String("--version")) {
      out << "GammaRay version " << GAMMARAY_VERSION_STRING << endl;
      out << "Copyright (C) 2010-2016 Klaralvdalens Datakonsult AB, "
          << "a KDAB Group company, [email protected]" << endl;
      return 0;
    }
    if (arg == QLatin1String("--inprocess")) {
      options.setUiMode(LaunchOptions::InProcessUi);
    }
    if (arg == QLatin1String("--inject-only")) {
      options.setUiMode(LaunchOptions::NoUi);
    }
    if (arg == QLatin1String("--listen") && !args.isEmpty()) {
      options.setProbeSetting(QStringLiteral("ServerAddress"), urlFromUserInput(args.takeFirst()).toString());
    }
    if ( arg == QLatin1String("--no-listen")) {
      options.setProbeSetting(QStringLiteral("RemoteAccessEnabled"), false);
      options.setUiMode(LaunchOptions::InProcessUi);
    }
    if ( arg == QLatin1String("--list-probes")) {
      foreach( const ProbeABI &abi, ProbeFinder::listProbeABIs())
        out << abi.id() << " (" << abi.displayString() << ")" << endl;
      return 0;
    }
    if ( arg == QLatin1String("--probe") && !args.isEmpty()) {
      const ProbeABI abi = ProbeABI::fromString(args.takeFirst());
      if (!abi.isValid()) {
        out << "Invalid probe ABI specified, see --list-probes for valid ones." << endl;
        return 1;
      }
      if (ProbeFinder::findProbe(QStringLiteral(GAMMARAY_PROBE_BASENAME), abi).isEmpty()) {
        out << abi.id() << "is not a known probe, see --list-probes." << endl;
        return 1;
      }
      options.setProbeABI(abi);
    }
    if ( arg == QLatin1String("--connect") && !args.isEmpty()) {
      const QUrl url = urlFromUserInput(args.takeFirst());
      ClientLauncher client;
      client.launch(url);
      client.waitForFinished();
      return 0;
    }

    // debug/test options
    if (arg == QLatin1String("-filtertest")) {
      qputenv("GAMMARAY_TEST_FILTER", "1");
    }
    if (arg == QLatin1String("-unittest")) {
      qputenv("GAMMARAY_UNITTEST", "1");
    }
    if (arg == QLatin1String("-modeltest")) {
      qputenv("GAMMARAY_MODELTEST", "1");
    }
    // built-in arguments of QApp, could be meant for us if we are showing the launcher window
    foreach (const QString &builtInArg, builtInArgs) {
      if (arg == builtInArg && !args.isEmpty()) {
        args.takeFirst();
      }
    }
  }
예제 #4
0
파일: main.cpp 프로젝트: giucam/GammaRay
int main(int argc, char **argv)
{
    QCoreApplication::setOrganizationName(QStringLiteral("KDAB"));
    QCoreApplication::setOrganizationDomain(QStringLiteral("kdab.com"));
    QCoreApplication::setApplicationName(QStringLiteral("GammaRay"));

    installSignalHandler();

    QStringList args;
    args.reserve(argc);
    for (int i = 1; i < argc; ++i)
        args.push_back(QString::fromLocal8Bit(argv[i]));

#ifndef GAMMARAY_CORE_ONLY_LAUNCHER
    QApplication app(argc, argv); // for style inspector
#else
    QCoreApplication app(argc, argv);
#endif
    Paths::setRelativeRootPath(GAMMARAY_INVERSE_BIN_DIR);

    QStringList builtInArgs = QStringList() << QStringLiteral("-style")
                                            << QStringLiteral("-stylesheet")
                                            << QStringLiteral("-graphicssystem");

    LaunchOptions options;
    while (!args.isEmpty() && args.first().startsWith('-')) {
        const QString arg = args.takeFirst();
        if ((arg == QLatin1String("-i") || arg == QLatin1String("--injector")) && !args.isEmpty()) {
            options.setInjectorType(args.takeFirst());
            continue;
        }
        if ((arg == QLatin1String("-o") || arg == QLatin1String("--injector-override"))
            && !args.isEmpty()) {
            options.setInjectorTypeExecutableOverride(args.takeFirst());
            continue;
        }
        if ((arg == QLatin1String("-p") || arg == QLatin1String("--pid")) && !args.isEmpty()) {
            options.setPid(args.takeFirst().toInt());
            continue;
        }
        if (arg == QLatin1String("-h") || arg == QLatin1String("--help")) {
            usage(argv[0]);
            return 0;
        }
        if (arg == QLatin1String("-v") || arg == QLatin1String("--version")) {
            out << "GammaRay version " << GAMMARAY_VERSION_STRING << endl;
            out << "Copyright (C) 2010-2016 Klaralvdalens Datakonsult AB, "
                << "a KDAB Group company, [email protected]" << endl;
            out << "Protocol version " << Protocol::version() << endl;
            out << "Broadcast version " << Protocol::broadcastFormatVersion() << endl;
            return 0;
        }
        if (arg == QLatin1String("--inprocess"))
            options.setUiMode(LaunchOptions::InProcessUi);
        if (arg == QLatin1String("--inject-only"))
            options.setUiMode(LaunchOptions::NoUi);
        if (arg == QLatin1String("--listen") && !args.isEmpty())
            options.setProbeSetting(QStringLiteral("ServerAddress"),
                                    urlFromUserInput(args.takeFirst()).toString());
        if (arg == QLatin1String("--no-listen")) {
            options.setProbeSetting(QStringLiteral("RemoteAccessEnabled"), false);
            options.setUiMode(LaunchOptions::InProcessUi);
        }
        if (arg == QLatin1String("--list-probes")) {
            foreach (const ProbeABI &abi, ProbeFinder::listProbeABIs())
                out << abi.id() << " (" << abi.displayString() << ")" << endl;
            return 0;
        }
        if (arg == QLatin1String("--probe") && !args.isEmpty()) {
            const ProbeABI abi = ProbeABI::fromString(args.takeFirst());
            if (!abi.isValid()) {
                out << "Invalid probe ABI specified, see --list-probes for valid ones." << endl;
                return 1;
            }
            if (ProbeFinder::findProbe(abi).isEmpty()) {
                out << abi.id() << "is not a known probe, see --list-probes." << endl;
                return 1;
            }
            options.setProbeABI(abi);
        }
        if (arg == QLatin1String("--connect") && !args.isEmpty()) {
            const QUrl url = urlFromUserInput(args.takeFirst());
            ClientLauncher client;
            client.launch(url);
            client.waitForFinished();
            return 0;
        }
        if (arg == QLatin1String("--self-test")) {
            SelfTest selfTest;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
            QObject::connect(&selfTest, &SelfTest::information, [](const QString &msg) {
                out << msg << endl;
            });
            QObject::connect(&selfTest, &SelfTest::error, [](const QString &msg) {
                err << "Error: " << msg << endl;
            });
#endif
            if (args.isEmpty() || args.first().startsWith('-'))
                return selfTest.checkEverything() ? 0 : 1;
            const auto injectorType = args.takeFirst();
            return selfTest.checkInjector(injectorType) ? 0 : 1;
        }

        // debug/test options
        if (arg == QLatin1String("-filtertest"))
            qputenv("GAMMARAY_TEST_FILTER", "1");
        if (arg == QLatin1String("-unittest"))
            qputenv("GAMMARAY_UNITTEST", "1");
        // built-in arguments of QApp, could be meant for us if we are showing the launcher window
        foreach (const QString &builtInArg, builtInArgs) {
            if (arg == builtInArg && !args.isEmpty())
                args.takeFirst();
        }
    }