private void ParseInputs() { Trace("[HA Cmd] ParseInputs() - START "); Trace(string.Empty); Trace("[HA Cmd] command line: " + System.Environment.CommandLine); Trace("[HA Cmd] command wd: " + System.Environment.CurrentDirectory); Trace("[HA Cmd] proc count: " + System.Environment.ProcessorCount); Trace("[HA Cmd] sysdir: " + System.Environment.SystemDirectory); Trace("[HA Cmd] version: " + System.Environment.Version.ToString()); Trace(string.Empty); // We expect to see an "-input" parameter string inputFileName = ExtractCommandLineInputParameter(Args); // If no file was found then inputFileName will be an empty string. if (string.IsNullOrEmpty(inputFileName)) { throw new HAUIException("Input file parameter missing", HAUIException.KErrCommandLineArgumentsMissing); } else if (!FSUtilities.Exists(inputFileName)) { throw new HAUIException("Input file not found", HAUIException.KErrCommandLineArgumentsFileNotFound); } else { Trace("[HA Cmd] ParseInputs() - start read inputs"); iInputs.Read(inputFileName); Trace("[HA Cmd] ParseInputs() - inputs read successfully"); // Validate the inputs are correct. if (string.IsNullOrEmpty(iInputs.ThreadName)) { throw new HAUIException("The specified thread name is invalid", HAUIException.KErrCommandLineAnalysisThreadNameInvalid); } else { // Validate input data int sourceCount = iInputs.SourceFiles.Count; switch (base.Engine.OperationType) { case HeapWizardEngine.TOperationType.EOperationTypeAnalyseAndView: if (iInputs.SourceFiles.Count != 1 && iInputs.SourceFiles[0].IsFile) { Trace("[HA Cmd] ParseInputs() - viewer - missing source file!"); throw new HAUIException("Source file not specified", HAUIException.KErrCommandLineSourceFileNotFound); } break; case HeapWizardEngine.TOperationType.EOperationTypeCompareHeapDumps: if (iInputs.SourceFiles.Count != 2 && iInputs.SourceFiles[0].IsFile && iInputs.SourceFiles[1].IsFile) { Trace("[HA Cmd] ParseInputs() - comparison - missing source files!"); throw new HAUIException("Source files not specified", HAUIException.KErrCommandLineSourceFileNotFound); } break; } // Validate output (where needed) if (base.Engine.OperationType == HeapWizardEngine.TOperationType.EOperationTypeCompareHeapDumps) { bool outputSet = iInputs.OutputFile != null; if (!outputSet) { throw new HAUIException("Output file not specified", HAUIException.KErrCommandLineAnalysisOutputInvalid); } } } } Trace("[HA Cmd] ParseInputs() - END"); }
public int RunCommandLineOperations() { UITrace("[CA Cmd] START "); UITrace(string.Empty); UITrace("[CA Cmd] command line: " + System.Environment.CommandLine); UITrace("[CA Cmd] command wd: " + System.Environment.CurrentDirectory); UITrace("[CA Cmd] proc count: " + System.Environment.ProcessorCount); UITrace("[CA Cmd] sysdir: " + System.Environment.SystemDirectory); UITrace("[CA Cmd] version: " + System.Environment.Version.ToString()); UITrace(string.Empty); int error = CAPlugin.KErrCommandLineNone; // try { // We expect to see an "-input" parameter string inputFileName = ExtractCommandLineInputParameter(CommandLineArguments); bool generateReport = CheckForReportParameter(CommandLineArguments); iProgressReporter.Enabled = CheckForProgressParameter(CommandLineArguments); iProgressReporter.Detailed = CheckForProgressDetailedParameter(CommandLineArguments); // If no file was found then inputFileName will be an empty string. if (string.IsNullOrEmpty(inputFileName)) { throw new CACmdLineException("Input file parameter missing", CAPlugin.KErrCommandLinePluginArgumentsMissing); } else if (!FSUtilities.Exists(inputFileName)) { throw new CACmdLineException("Input file not found", CAPlugin.KErrCommandLinePluginArgumentsFileNotFound); } else { // Switch off UI output at the debug engine level iEngine.DebugEngine.UiMode = TDbgUiMode.EUiDisabled; // Reading the input file will throw an exception upon error. // This is caught below and mapped onto an error code. There's nothing // else we can do in this situation. ReadInputFile(inputFileName); // At this point we have enough information to identify the exact total // number of progress reporting steps that will follow during the // rest of the processing operation. CalculateNumberOfOperationSteps(); // Next, attempt to prime the crash engine with every source we // identified from the input specification. The goal is to // create all the needed Crash Item Source objects for each input file. // Any inputs which we don't support will not have an associated source and // will be flagged accordingly within the CACmdLineFileSource object. TryToPrimeSources(); // Now link the input files with crash source objects AssociateInputFilesWithCrashItemSources(); // Next, prime the debug engine will all the debug meta-data inputs. // Again, individual error messages will be associated with each meta-data // input. // // We don't need to do this for summary operations if (iInputs.SinkParameters.DetailLevel != CISinkSerializationParameters.TDetailLevel.ESummary) { TryToPrimeDbgEngine(); } // Next we print out progress steps for skipped files, because those // files are count to total steps. PrintOutSkippepFiles(); // Next, we invoke the crash engine to process all the crash item sources we // created during the prime step. Exceptions are caught and associated // messages & diagnostics are created at the input-file level. TryToIdentifyCrashes(); // Next, we start the output phase. Any 'valid' crash containers are serialized // to xml. Any input files which could not be processed have 'dummy' containers // created for them, and these are also serialised to 'failed' XML files. // If the XML Sink plugin is unavailable, then we cannot create any XML output. // In this situation, we throw an exception which is caught below. TryToCreateXmlOutput(); // Finally, we want to create the XML manifest/report data, which we'll emit // via standard output. if (generateReport) { CreateAndEmitXmlReport(); } } } catch (CACmdLineException cmdLineException) { error = cmdLineException.ErrorCode; // UITrace("[CA Cmd] " + cmdLineException.Message + " " + cmdLineException.StackTrace); } catch (Exception generalException) { error = CAPlugin.KErrCommandLineGeneral; // UITrace("[CA Cmd] " + generalException.Message + " " + generalException.StackTrace); } UITrace("[CA Cmd] - operation complete: " + error); return(error); }