示例#1
0
            public void Log(string msg, bool error)
            {
                if (!String.IsNullOrEmpty(msg))
                {
                    // Don't bother to add it if it's in the list of ignorable warnings
                    if (_warningsToSuppress != null)
                    {
                        foreach (string ignorableWarning in _warningsToSuppress)
                        {
                            if (msg.StartsWith(ignorableWarning + ":"))
                            {
                                return;
                            }
                        }
                    }

                    if (error)
                    {
                        _logger.Complain(msg);
                    }
                    else
                    {
                        _logger.Say(msg);
                    }
                }
            }
示例#2
0
        public override bool Execute()
        {
            String targetBinary = binaryFile.FullName;
            String targetPdb    = System.IO.Path.ChangeExtension(binaryFile.FullName, "pdb");

            String backupBinary = Path.Combine(originalsDirectory.FullName, binaryFile.Name);
            String backupPdb    = System.IO.Path.ChangeExtension(backupBinary, "pdb");

            try
            {
                // Move the originals into the new directory (it was created earlier, in setting the required property)
                if (File.Exists(backupBinary))
                {
                    File.Delete(backupBinary);
                }
                File.Move(targetBinary, backupBinary);

                if (File.Exists(backupPdb))
                {
                    File.Delete(backupPdb);
                }
                File.Move(targetPdb, backupPdb);

                // Run BBCover to create instrumented versions in the original location

                // handle the required args
                String bbcoverCmd = String.Format("/i \"{0}\" /o \"{1}\" /opdb \"{2}\" /customVer {3}", backupBinary, targetBinary, targetPdb, BuildID);

                // append the optional args
                if (Verbose)
                {
                    bbcoverCmd += " /verbose";
                }
                if (IgnoreAsm)
                {
                    bbcoverCmd += " /ignoreAsm";
                }
                if (NoHookUnload)
                {
                    bbcoverCmd += " /noHookUnload";
                }
                if (OmitFixupRecords)
                {
                    bbcoverCmd += " /pdbNoFixups";
                }
                if (OptimizeArcProbes)
                {
                    bbcoverCmd += " /probeOpt";
                }
                if (RelationalOperatorCoverage)
                {
                    bbcoverCmd += " /relop";
                }
                if (Rereadable)
                {
                    bbcoverCmd += " /rereadable";
                }
                if (SessionSpaceBinary)
                {
                    bbcoverCmd += " /tsGlobal";
                }

                if (!String.IsNullOrEmpty(DatabaseInfo))
                {
                    bbcoverCmd += String.Format(" /db \"{0}\"", DatabaseInfo);
                }
                if (!String.IsNullOrEmpty(EntryFunction))
                {
                    bbcoverCmd += " /entryName " + EntryFunction;
                }
                if (!String.IsNullOrEmpty(BbtfCmdFile))
                {
                    bbcoverCmd += String.Format(" /cmd \"{0}\"", BbtfCmdFile);
                }
                if (!String.IsNullOrEmpty(UnloadFunction))
                {
                    bbcoverCmd += " /unload " + UnloadFunction;
                }

                switch (InstrumentationMode)
                {
                case InstrumentationModeKind.Default:
                    break;

                case InstrumentationModeKind.KernelMode:
                    bbcoverCmd += " /kernelmode";
                    break;

                case InstrumentationModeKind.UserMode:
                    bbcoverCmd += " /usermode";
                    break;

                case InstrumentationModeKind.NoImportDLLMode:
                    bbcoverCmd += " /noimportdll";
                    break;
                }

                switch (RegistrationHook)
                {
                case RegistrationHookLocaleKind.Default:
                    break;

                case RegistrationHookLocaleKind.None:
                    bbcoverCmd += " /AutoRegister none";
                    break;

                case RegistrationHookLocaleKind.Entry:
                    bbcoverCmd += " /AutoRegister entry";
                    break;

                case RegistrationHookLocaleKind.Exports:
                    bbcoverCmd += " /AutoRegister exports";
                    break;

                case RegistrationHookLocaleKind.Internal:
                    bbcoverCmd += " /AutoRegister internal";
                    break;
                }

                // TODO: support multiple /DontInstrument and /DontInstrumentSrc ranges

                return(this.ExecuteCmd(bbcoverCmd));
            }
            catch (Exception e)
            {
                _logger.Complain(e);

                return(false);
            }
        }