예제 #1
0
        static int Main(string[] aArguments)
        {
            int error = CACmdLineException.KErrNone;

            //
            using (FSLog log = new FSLog(true))
            {
                try
                {
                    FSUtilities.ClearTempPath();
                    //
                    CACommandLineUI commandLineUi = new CACommandLineUI(aArguments, log);
                    error = commandLineUi.Run();
                    //
                    if (error != CACmdLineException.KErrNone)
                    {
                        SymbianUtils.SymDebug.SymDebugger.Break();
                    }
                }
                catch (Exception e)
                {
                    log.TraceAlways("CrashAnalyserServerExe.Main() - EXCEPTION: " + e.Message);
                    log.TraceAlways("CrashAnalyserServerExe.Main() - STACK:     " + e.StackTrace);
                    SymbianUtils.SymDebug.SymDebugger.Break();
                    error = -1;
                }
                //
                if (error != 0)
                {
                    log.TraceAlways("CA completed with error: " + error);
                }
            }
            //
            return(error);
        }
예제 #2
0
        static int Main(string[] aArgs)
        {
            int error = HeapAnalyser.Exceptions.HAUIException.KErrCommandLineNone;

            //
            try
            {
                // Enable visual styles if supported
                if (OSFeature.Feature.IsPresent(OSFeature.Themes))
                {
                    Application.EnableVisualStyles();
                    Application.DoEvents();
                }

                FSUtilities.ClearTempPath();

                HAUIManager uiManager = new HAUIManager(aArgs);
                error = uiManager.Run();
            }
            catch (Exception exception)
            {
                SymExceptionDialog dialog = new SymExceptionDialog();
                dialog.Exception = exception;
                dialog.ShowDialog();
            }
            //
            return(error);
        }
        public CISinkSerializationParameters(Version aUIVersion, string aUICommandLineArguments)
        {
            iUIVersion = aUIVersion;
            iUICommandLineArguments = aUICommandLineArguments;
            //
            string tempPath = FSUtilities.MakeTempPath();

            OutputDirectory = new DirectoryInfo(tempPath);
            //
            PrepareDefaultExtensions();
        }
예제 #4
0
        public bool IsLoaded(CodeSegDefinition aDefinition)
        {
            // In ROM, variation might mean that the file name
            // doesn't match the definition name from the actual run-time code
            // segments loaded by a process...
            //
            // If we don't find a file name match, but we do find an address match
            // then we'll treat it as "good enough"
            bool   activated    = false;
            string searchingFor = aDefinition.ImageFileName.ToLower();
            string searchingForWithoutExtension = FSUtilities.StripAllExtensions(searchingFor);

            // Try to promote a symbol
            foreach (SymbolsForBinary file in iActivatedSymbols)
            {
                string entryName = System.IO.Path.GetFileName(file.HostBinaryFileName).ToLower();
                if (entryName == searchingFor)
                {
                    activated = true;
                    break;
                }
                else if (file.AddressRangeStart == aDefinition.AddressStart && file.AddressRangeEnd == aDefinition.AddressEnd)
                {
                    // E.g: ROM.symbol says:         "From    \epoc32\release\armv5\urel\xxx.22.dll"
                    //      runtime code seg says:   "xxx.dll"
                    // We must use the base address instead...

                    activated = true;
                    break;
                }
                else
                {
                    // Try a fuzzy match
                    string entryNameWithoutExtension = FSUtilities.StripAllExtensions(entryName);
                    if (entryNameWithoutExtension.Contains(searchingForWithoutExtension))
                    {
                        // Also make sure the base addresses are the same
                        if (file.AddressRangeStart == aDefinition.AddressStart)
                        {
                            // Fuzzy match
                            activated = true;
                            break;
                        }
                    }
                }
            }

            return(activated);
        }
예제 #5
0
 static void Main()
 {
     // Create UI manager which will act as application context
     try
     {
         FSUtilities.ClearTempPath();
         CAGraphicalUIManager uiManager = new CAGraphicalUIManager();
         uiManager.Run();
     }
     catch (Exception exception)
     {
         SymExceptionDialog dialog = new SymExceptionDialog();
         dialog.Exception = exception;
         dialog.ShowDialog();
     }
 }
        static int Main(string[] aArguments)
        {
            int error = 0;

            //
            using (FSLog log = new FSLog(true))
            {
                try
                {
                    FSUtilities.ClearTempPath();
                    //
                    CACommandLineUI commandLineUi = new CACommandLineUI(aArguments, log);
                    error = commandLineUi.Run();
                    //
                    if (error != CrashAnalyserEngine.Plugins.CAPlugin.KErrCommandLineNone)
                    {
                        SymbianUtils.SymDebug.SymDebugger.Break();
                    }
                }
                catch (Exception e)
                {
                    log.TraceAlways("CrashAnalyserConsole.Main() - EXCEPTION: " + e.Message);
                    log.TraceAlways("CrashAnalyserConsole.Main() - STACK:     " + e.StackTrace);
                    SymbianUtils.SymDebug.SymDebugger.Break();
                    error = -1;
                }
                //
                if (error != 0)
                {
                    log.TraceAlways("CA completed with error: " + error);
                }
            }

            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Console.Write("PRESS ANY KEY");
                System.Console.ReadKey();
            }
            //
            return(error);
        }
예제 #7
0
        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");
        }
예제 #8
0
        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);
        }