示例#1
0
//++
// Details: MI's application start point of execution. The application runs in
// two modes.
//          An LLDB native driver mode where it acts no different from the LLDB
//          driver.
//          The other mode is the MI when it finds on the command line
//          the --interpreter option. Command line argument --help on its own
//          will give
//          help for the LLDB driver. If entered with --interpreter then
//          application
//          help will provided.
// Type:    Method.
// Args:    argc    - (R) An integer that contains the count of arguments that
// follow in
//                        argv. The argc parameter is always greater than or
//                        equal to 1.
//          argv    - (R) An array of null-terminated strings representing
//          command-line
//                        arguments entered by the user of the program. By
//                        convention,
//                        argv[0] is the command with which the program is
//                        invoked.
// Return:  int -  0 =   Normal exit, program success.
//                >0    = Program success with status i.e. Control-C signal
//                status
//                <0    = Program failed.
//              -1      = Program failed reason not specified here, see MI log
//              file.
//              -1000   = Program failed did not initialize successfully.
// Throws:  None.
//--
int main(int argc, char const *argv[]) {
#if MICONFIG_DEBUG_SHOW_ATTACH_DBG_DLG
  CMIUtilDebug::WaitForDbgAttachInfinteLoop();
#endif // MICONFIG_DEBUG_SHOW_ATTACH_DBG_DLG

  llvm::StringRef ToolName = argv[0];
  llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
  llvm::PrettyStackTraceProgram X(argc, argv);

  // *** Order is important here ***
  bool bOk = DriverSystemInit();
  if (!bOk) {
    DriverSystemShutdown(bOk);
    return -1000;
  }

  // CODETAG_IOR_SIGNALS
  signal(SIGINT, sigint_handler);

  bool bExiting = false;
  CMIDriverMgr &rDriverMgr = CMIDriverMgr::Instance();
  bOk = bOk && rDriverMgr.ParseArgs(argc, argv, bExiting);
  if (bOk && !bExiting)
    bOk = rDriverMgr.DriverParseArgs(argc, argv, stdout, bExiting);
  if (bOk && !bExiting)
    bOk = rDriverMgr.DriverMainLoop();

  // Logger and other resources shutdown now
  DriverSystemShutdown(bOk);

  const int appResult = bOk ? 0 : -1;

  return appResult;
}
示例#2
0
//++
//------------------------------------------------------------------------------------
// Details: MI's application start point of execution. The application runs in
// two modes.
//          An LLDB native driver mode where it acts no different from the LLDB
//          driver.
//          The other mode is the MI when it finds on the command line
//          the --interpreter option. Command line argument --help on its own
//          will give
//          help for the LLDB driver. If entered with --interpreter then
//          application
//          help will provided.
// Type:    Method.
// Args:    argc    - (R) An integer that contains the count of arguments that
// follow in
//                        argv. The argc parameter is always greater than or
//                        equal to 1.
//          argv    - (R) An array of null-terminated strings representing
//          command-line
//                        arguments entered by the user of the program. By
//                        convention,
//                        argv[0] is the command with which the program is
//                        invoked.
// Return:  int -  0 =   Normal exit, program success.
//                >0    = Program success with status i.e. Control-C signal
//                status
//                <0    = Program failed.
//              -1      = Program failed reason not specified here, see MI log
//              file.
//              -1000   = Program failed did not initialize successfully.
// Throws:  None.
//--
int main(int argc, char const *argv[]) {
#if MICONFIG_DEBUG_SHOW_ATTACH_DBG_DLG
#ifdef _WIN32
  CMIUtilDebug::ShowDlgWaitForDbgAttach();
#else
  CMIUtilDebug::WaitForDbgAttachInfinteLoop();
#endif //  _WIN32
#endif // MICONFIG_DEBUG_SHOW_ATTACH_DBG_DLG

  // *** Order is important here ***
  bool bOk = DriverSystemInit();
  if (!bOk) {
    DriverSystemShutdown(bOk);
    return -1000;
  }

  // CODETAG_IOR_SIGNALS
  signal(SIGINT, sigint_handler);

  bool bExiting = false;
  CMIDriverMgr &rDriverMgr = CMIDriverMgr::Instance();
  bOk = bOk && rDriverMgr.ParseArgs(argc, argv, bExiting);
  if (bOk && !bExiting)
    bOk = rDriverMgr.DriverParseArgs(argc, argv, stdout, bExiting);
  if (bOk && !bExiting)
    bOk = rDriverMgr.DriverMainLoop();

  // Logger and other resources shutdown now
  DriverSystemShutdown(bOk);

  const int appResult = bOk ? 0 : -1;

  return appResult;
}