コード例 #1
0
ファイル: commandlineparser.cpp プロジェクト: KDE/calligra
void CommandLineParser::handleActivateRequest(const QStringList &arguments, const QString &workingDirectory)
{
    m_commandLineParser.parse(arguments);

    handleCommandLine(QDir(workingDirectory));

    // terminate startup notification and activate the mainwindow
    KStartupInfo::setNewStartupId(m_mainwindow, KStartupInfo::startupId());
    KWindowSystem::forceActiveWindow(m_mainwindow->winId());

}
コード例 #2
0
ファイル: main.cpp プロジェクト: 0x90erator/binnavi
int main(int argc, const char* argv[]) {
  printStartMessage();

  std::string target;

  unsigned int port = 2222;
  bool verbose = false;
  bool vverbose = false;
  std::string lf = "";
  std::vector<const char*> commands;

  handleCommandLine(argc, argv, target, port, verbose, vverbose, lf, commands);

  unsigned int loglevel = LOG_ALWAYS;

  if (verbose) {
    loglevel = LOG_VERBOSE;
  } else if (vverbose) {
    loglevel = LOG_ALL;
  }

  initLogger(lf, loglevel);

  msglog->log(LOG_ALWAYS,
              "---------------------------------------------------------");
  msglog->log(LOG_ALWAYS, "Starting new Debugging session");
  msglog->log(LOG_ALWAYS, "Server Port %d", port);

  if (verbose) {
    msglog->log(LOG_ALWAYS, "Verbose mode: ON");
  }

  if (vverbose) {
    msglog->log(LOG_ALWAYS, "Very Verbose mode: ON");
  }

  if (lf != "") {
    msglog->log(LOG_ALWAYS, "Logging to file: %s", lf.c_str());
  }

  for (;;) {
    std::unique_ptr<DebugClient> debugClient;

    if (target == "") {
      msglog->log(LOG_ALWAYS,
                  "No target specified. Target will be chosen later.");

      debugClient = std::unique_ptr<DebugClient>(
          new DebugClient(new CONNECTION_POLICY(port), new SYSTEM_POLICY()));

    } else if (zylib::zycon::isPositiveNumber(target)) {
      msglog->log(LOG_ALWAYS, "Target PID: %s", target.c_str());

      unsigned int processId = zylib::zycon::parseString<unsigned int>(target);

      debugClient = std::unique_ptr<DebugClient>(
          new DebugClient(new CONNECTION_POLICY(port),
          new SYSTEM_POLICY(processId)));
    } else {
      msglog->log(LOG_ALWAYS, "Target executable: %s", target.c_str());

      if (!fexists(target.c_str())) {
        msglog->log(LOG_ALWAYS, "Error: Target executable '%s' does not exist",
                    target.c_str());

        return 1;
      }

      debugClient = std::unique_ptr<DebugClient>(new DebugClient(
          new CONNECTION_POLICY(port),
          new SYSTEM_POLICY(target.c_str(), commands)));
    }

    std::string arguments = "";

    if (commands.size() == 0) {
      arguments = "-";
    }

    for (std::vector<const char*>::iterator Iter = commands.begin();
        Iter != commands.end(); ++Iter) {
      arguments += *Iter;
      arguments += " ";
    }

    msglog->log(LOG_ALWAYS, "Commandline arguments: %s", arguments.c_str());

    msglog->log(LOG_ALWAYS,
                "---------------------------------------------------------");

    msglog->log(LOG_ALWAYS, "Waiting for connection from BinNavi...");

    unsigned int init = debugClient->initializeConnection();

    if (init) {
      msglog->log(LOG_ALWAYS,
                  "Error: Couldn't initialize connection (Code: %d)", init);
      return 1;
    }

    unsigned int connected = debugClient->waitForConnection();

    if (connected) {
      msglog->log(LOG_ALWAYS, "Error: Didn't receive a connection (Code %d)",
                  connected);
      return 1;
    }

    if (debugClient->getSystemPolicy()->hasTarget()) {
      // We do have a system policy at this point. That means that a target
      // process was
      // in some way selected.

      unsigned int attached = debugClient->attachToProcess();

      if (attached) {
        msglog->log(LOG_ALWAYS,
                    "Error: Couldn't attach to the target process (Code %d)",
                    attached);

        debugClient->closeConnection();

        target = "";

        continue;
      } else {
        // Once the debug client attached to the target for the first time, it
        // is necessary
        // to use the PID instead of the target path from now on to support
        // re-attach operations.
        target = zylib::zycon::toString(
            debugClient->getSystemPolicy()->getPID());
      }
    } else {
      debugClient->requestTarget();
    }

    unsigned int procp = debugClient->processPackets();

    if (procp) {
      msglog->log(LOG_ALWAYS,
                  "Error: Error during packet processing. (Code %d)", procp);
    }

    debugClient->closeConnection();
  }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: 0x90erator/binnavi
int main(int argc, const char* argv[]) {
  printStartMessage();

  if (EXPIRE_YEAR) {
    checkTrial();
  }

  std::vector < std::pair<std::string, std::string> > params =
      zylib::zyline::parseCommandLine(argc, argv);

  if (params.size() < 3) {
    std::cout << szUsage << std::endl;
    return 1;
  }

  std::string gdbhost;
  std::string targetCpu;
  unsigned int clientport = 2222;
  bool verbose = false;
  bool vverbose = false;
  bool testMode = false;
  std::string lf = "";

  handleCommandLine(params, gdbhost, targetCpu, clientport, verbose, vverbose,
                    testMode, lf);

  unsigned int loglevel = LOG_ALWAYS;

  if (verbose) {
    loglevel = LOG_VERBOSE;
  } else if (vverbose) {
    loglevel = LOG_ALL;
  }

  initLogger(lf, loglevel);

  msglog->log(LOG_ALWAYS,
              "---------------------------------------------------------");
  msglog->log(LOG_ALWAYS, "Starting new GDB client session");
  msglog->log(LOG_ALWAYS, "Location of the GDB server: %s", gdbhost.c_str());
  msglog->log(LOG_ALWAYS, "Target CPU: %s", targetCpu.c_str());
  msglog->log(LOG_ALWAYS, "Server Port %d", clientport);

  if (verbose) {
    msglog->log(LOG_ALWAYS, "Verbose mode: ON");
  }

  if (vverbose) {
    msglog->log(LOG_ALWAYS, "Very Verbose mode: ON");
  }

  if (testMode) {
    msglog->log(LOG_ALWAYS, "Test mode: ON");
  }

  if (lf != "") {
    msglog->log(LOG_ALWAYS, "Logging to file: %s", lf.c_str());
  }

  msglog->log(LOG_ALWAYS,
              "---------------------------------------------------------");

  // don't delete it after use, debugClient will do it
  GdbSystem* system = new SYSTEM_POLICY(123);

  std::unique_ptr<DebugClient> debugClient(
      new DebugClient(new CONNECTION_POLICY(clientport), system));

  msglog->log(LOG_ALWAYS, "Connecting to the GDB server ...");

  NaviError initResult = system->initTarget(gdbhost, targetCpu);

  if (initResult) {
    if (initResult == NaviErrors::INVALID_CONNECTION_STRING) {
      msglog->log(LOG_ALWAYS, "Error: Invalid connection string");
    } else if (initResult == NaviErrors::INVALID_CPU_STRING) {
      msglog->log(LOG_ALWAYS, "Error: Invalid CPU string");
    } else if (initResult == NaviErrors::COULDNT_CONNECT_TO_GDBSERVER) {
      msglog->log(LOG_ALWAYS, "Error: Couldn't connect to the gdbserver");
    } else {
      msglog->log(LOG_ALWAYS, "Error: Unexpected error (Code %d)", initResult);
    }

    return initResult;
  }

  msglog->log(LOG_ALWAYS, "Connection to the GDB server open...");

  if (testMode) {
    system->getCpu()->testRun();

    return 0;
  }

  do {
    msglog->log(LOG_VERBOSE, "Creating server for BinNavi to connect ...");

    unsigned int init = debugClient->initializeConnection();

    if (init) {
      msglog->log(LOG_ALWAYS, "Error: Couldn't create server (Code d)", init);
      return 1;
    }

    msglog->log(LOG_VERBOSE, "Waiting for BinNavi to connect ...");

    unsigned int connected = debugClient->waitForConnection();

    if (connected) {
      msglog->log(LOG_ALWAYS, "Error: Didn't receive a connection (Code %d)",
                  connected);
      return 1;
    }

    msglog->log(LOG_VERBOSE, "Attaching to the target process ...");

    unsigned int attached = debugClient->attachToProcess();

    if (attached) {
      msglog->log(LOG_ALWAYS,
                  "Error: Couldn't attach to the target process (Code %d)",
                  attached);
      return 1;
    }

    msglog->log(LOG_VERBOSE, "Processing communication packets ...");

    unsigned int procp = debugClient->processPackets();

    if (procp) {
      msglog->log(LOG_ALWAYS,
                  "Error: Error during packet processing. (Code %d)", procp);
    }

    msglog->log(LOG_VERBOSE, "Closing the connection to BinNavi ...");

    debugClient->closeConnection();
  } while (true);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: 0x90erator/binnavi
int main(int argc, const char* argv[]) {
  printStartMessage();

  std::string target;

  unsigned int port = 2222;
  bool verbose = false;
  bool vverbose = false;
  std::string lf = "";
  std::vector<const char*> commands;

  handleCommandLine(argc, argv, target, port, verbose, vverbose, lf, commands);

  unsigned int loglevel = LOG_ALWAYS;

  if (verbose) {
    loglevel = LOG_VERBOSE;
  } else if (vverbose) {
    loglevel = LOG_ALL;
  }

  initLogger(lf, loglevel);

  msglog->log(LOG_ALWAYS,
              "---------------------------------------------------------");
  msglog->log(LOG_ALWAYS, "Starting new Debugging session");
  msglog->log(LOG_ALWAYS, "Server Port %d", port);

  if (verbose) {
    msglog->log(LOG_ALWAYS, "Verbose mode: ON");
  }

  if (vverbose) {
    msglog->log(LOG_ALWAYS, "Very Verbose mode: ON");
  }

  if (lf != "") {
    msglog->log(LOG_ALWAYS, "Logging to file: %s", lf.c_str());
  }
  /*
   for (;;)
   {*/
  std::unique_ptr<DebugClient> debugClient;

  msglog->log(LOG_ALWAYS, "Target pipe: %s", target.c_str());

  debugClient = std::unique_ptr<DebugClient>(
      new DebugClient(new CONNECTION_POLICY(port),
                      new SYSTEM_POLICY(target.c_str())));

  msglog->log(LOG_ALWAYS,
              "---------------------------------------------------------");

  msglog->log(LOG_ALWAYS, "Waiting for connection from BinNavi...");

  unsigned int init = debugClient->initializeConnection();

  if (init) {
    msglog->log(LOG_ALWAYS, "Error: Couldn't initialize connection (Code: d)",
                init);
    return 1;
  }

  unsigned int connected = debugClient->waitForConnection();

  if (connected) {
    msglog->log(LOG_ALWAYS, "Error: Didn't receive a connection (Code %d)",
                connected);
    return 1;
  }

  if (debugClient->getSystemPolicy()->hasTarget()) {
    // We do have a system policy at this point. That means that a target
    // process was
    // in some way selected.

    unsigned int attached = debugClient->attachToProcess();

    if (attached) {
      msglog->log(LOG_ALWAYS,
                  "Error: Couldn't attach to the target process (Code %d)",
                  attached);

      debugClient->closeConnection();
      target = "";

      // continue;
    } else {
      // Once the debug client attached to the target for the first time, it is
      // necessary
      // to use the PID instead of the the taregt path from now on to support
      // re-attach operations.
      target = zylib::zycon::toString(debugClient->getSystemPolicy()->getPID());
    }
  } else {
    debugClient->requestTarget();
  }

  unsigned int procp = debugClient->processPackets();

  if (procp) {
    msglog->log(LOG_ALWAYS, "Error: Error during packet processing. (Code %d)",
                procp);
  }

  debugClient->closeConnection();
  //}
}