示例#1
0
bool EditFiles::checkDebugger()
    {
    bool ok = false;

    NameValueFile projFile(Project::getProjectFilePath());
    OovStatus status = projFile.readFile();
    if(!status.ok())
        {
        OovString str = "Unable to get project file to get debugger: ";
        str += Project::getProjectFilePath();
        status.report(ET_Error, str);
        }
    getDebugger().setDebuggerFilePath(projFile.getValue(OptToolDebuggerPath));
    getDebugger().setDebuggee(mEditOptions.getValue(OptEditDebuggee));
    getDebugger().setDebuggeeArgs(mEditOptions.getValue(OptEditDebuggeeArgs));
    getDebugger().setWorkingDir(mEditOptions.getValue(OptEditDebuggerWorkingDir));
//Gui::messageBox("Debugging is not recommended. It is very unstable.");
    std::string debugger = getDebugger().getDebuggerFilePath();
    std::string debuggee = getDebugger().getDebuggeeFilePath();
    if(debugger.length() > 0)
        {
        if(debuggee.length() > 0)
            {
// The debugger could be on the path.
//          if(fileExists(debugger))
                {
                if(FileIsFileOnDisk(debuggee, status))
                    {
                    ok = true;
                    }
                else
                    {
                    Gui::messageBox("Component to debug in Edit/Preferences does not exist");
                    }
                if(status.needReport())
                    {
                    status.report(ET_Error, "Unable to check debuggee status");
                    }
                }
//          else
//                {
//                Gui::messageBox("Debugger in Oovaide Analysis/Settings does not exist");
//                }
            }
        else
            {
            Gui::messageBox("Component to debug must be set in Edit/Preferences");
            }
        }
    else
        {
        Gui::messageBox("Debugger tool path must be set in Oovaide Analysis/Settings");
        }
    return ok;
    }
示例#2
0
static bool makeCoverageComponentTypesFile(OovStringRef const srcFn, OovStringRef const dstFn)
    {
    ComponentTypesFile file;
    OovStatus status = file.readTypesOnly(srcFn);
    if(status.ok())
        {
        // Define a static library that contains the code that stores
        // the coverage counts that is compiled into exectuables.
        static OovStringRef const covLibName = Project::getCovLibName();
        CompoundValue names = file.getComponentNames();
        if(names.find(covLibName) == CompoundValue::npos)
            {
            names.push_back(covLibName);
            file.setComponentNames(names.getAsString());
            file.setComponentType(covLibName,
                    ComponentTypesFile::getShortComponentTypeName(
                            ComponentTypesFile::CT_StaticLib));
            }
        status = file.writeTypesOnly(dstFn);
        }
    if(status.needReport())
        {
        OovString err = "Unable to make component types file ";
        err += srcFn;
        status.report(ET_Error, err);
        }
    return status.ok();
    }
示例#3
0
void ComponentGraph::updateGraph(const ComponentDrawOptions &options)
    {
    ComponentTypesFile compFile;
    OovStatus status = compFile.read();
    if(status.ok())
        {
        mNodes.clear();
        for(auto const &name : compFile.getComponentNames())
            {
            ComponentTypesFile::eCompTypes ct = compFile.getComponentType(name);
            if(ct != ComponentTypesFile::CT_Unknown)
                {
                mNodes.push_back(ComponentNode(name,
                        ComponentNode::CNT_Component, ct));
                }
            }
        BuildPackages buildPkgs(true);
        std::vector<Package> packages = buildPkgs.getPackages();
        for(auto const &pkg : packages)
            {
            mNodes.push_back(ComponentNode(pkg.getPkgName(),
                    ComponentNode::CNT_ExternalPackage));
            }
        updateConnections(compFile, options);
        }
    if(status.needReport())
        {
        status.report(ET_Error, "Unable to update component graph");
        }
    }
示例#4
0
void CoverageCountsReader::read(OovStringRef const fn)
    {
    File file;
    OovStatus status = file.open(fn, "r");
    mInstrCounts.clear();
    if(status.ok())
        {
        char buf[100];
        int lineCounter = 0;
        while(file.getString(buf, sizeof(buf), status))
            {
            lineCounter++;
            int val;
            if(sscanf(buf, "%d", &val) == 1)
                {
                if(lineCounter == 1)
                    {
                    mNumInstrumentedLines = val;
                    }
                else
                    {
                    mInstrCounts.push_back(val);
                    }
                }
            }
        }
    if(status.needReport())
        {
        status.report(ET_Error, "Unable to read coverage counts");
        }
    }
void BuildSettingsDialog::saveScreen()
    {
    saveFromScreen(mLastCompName);
    OovStatus status = mComponentFile.writeFile();
    if(status.needReport())
        {
        status.report(ET_Error, "Unable to save build settings");
        }
    }
示例#6
0
/// Copy a single source file and make a comment that contains the hit count
/// for each instrumented line.
static void updateCovSourceCounts(OovStringRef const relSrcFn,
        std::vector<int> &counts)
    {
    FilePath srcFn(Project::getCoverageSourceDirectory(), FP_Dir);
    srcFn.appendFile(relSrcFn);
    FilePath dstFn(Project::getCoverageProjectDirectory(), FP_Dir);
    dstFn.appendFile(relSrcFn);
    File srcFile;
    OovStatus status = srcFile.open(srcFn, "r");
    if(status.ok())
        {
        status = FileEnsurePathExists(dstFn);
        if(status.ok())
            {
            File dstFile;
            status = dstFile.open(dstFn, "w");
            if(status.ok())
                {
                char buf[1000];
                size_t instrCount = 0;
                while(srcFile.getString(buf, sizeof(buf), status))
                    {
                    if(strstr(buf, "COV_IN("))
                        {
                        if(instrCount < counts.size())
                            {
                            OovString countStr = "    // ";
                            countStr.appendInt(counts[instrCount]);
                            OovString newStr = buf;
                            size_t pos = newStr.find('\n');
                            newStr.insert(pos, countStr);
                            if(newStr.length() < sizeof(buf)-1)
                                {
                                strcpy(buf, newStr.getStr());
                                }
                            }
                        instrCount++;
                        }
                    status = dstFile.putString(buf);
                    if(!status.ok())
                        {
                        break;
                        }
                    }
                }
            }
        }
    if(status.needReport())
        {
        OovString err = "Unable to transfer coverage ";
        err += srcFn;
        err += " ";
        err += dstFn;
        status.report(ET_Error, err);
        }
    }
示例#7
0
void CoverageHeader::write(SharedFile &outDefFile, OovStringRef const /*srcFn*/,
        int numInstrLines)
    {
    std::string fnDef = getFileDefine();
    mInstrDefineMap[fnDef] = numInstrLines;

    int totalCount = 0;
    for(auto const &defItem : mInstrDefineMap)
        {
        totalCount += defItem.second;
        }

    if(outDefFile.isOpen())
        {
        OovString buf;
        static char const *lines[] =
            {
            "// Automatically generated file by OovCovInstr\n",
            "// This file should not normally be edited manually.\n",
            "#define COV_IN(fileIndex, instrIndex) gCoverage[fileIndex+instrIndex]++;\n",
            };
        for(size_t i=0; i<sizeof(lines)/sizeof(lines[0]); i++)
            {
            buf += lines[i];
            }
        buf += "#define COV_TOTAL_INSTRS ";
        buf.appendInt(totalCount);
        buf += "\n";
        buf += "extern unsigned short gCoverage[COV_TOTAL_INSTRS];\n";

        int coverageCount = 0;
        for(auto const &defItem : mInstrDefineMap)
            {
            OovString def = "#define ";
            def += defItem.first;
            def += " ";
            def.appendInt(coverageCount);
            coverageCount += defItem.second;
            def += " // ";
            def.appendInt(defItem.second);
            def += "\n";
            buf += def;
            }
        outDefFile.truncate();
        OovStatus status = outDefFile.seekBegin();
        if(status.ok())
            {
            status = outDefFile.write(&buf[0], static_cast<int>(buf.size()));
            }
        if(status.needReport())
            {
            status.report(ET_Error, "Unable to write coverage source");
            }
        }
    }
示例#8
0
OovStatusReturn ComponentTypesFile::writeFile()
    {
    OovStatus status = mCompTypesFile.writeFile();
    if(status.needReport())
        {
        OovString str = "Unable to write component types file: ";
        str += mCompTypesFile.getFilename();
        status.report(ET_Error, str);
        }
    if(status.ok())
        {
        status = mCompSourceListFile.writeFile();
        if(status.needReport())
            {
            OovString str = "Unable to write source list file: ";
            str += mCompSourceListFile.getFilename();
            status.report(ET_Error, str);
            }
        }
    return status;
    }
示例#9
0
FilePath Project::getOutputDir()
    {
    FilePath fp(Project::getProjectDirectory(), FP_Dir);
    fp.appendDir("output");
    OovStatus status = FileEnsurePathExists(fp);
    if(status.needReport())
        {
        OovString err = "Unable to create directory ";
        err += fp;
        status.report(ET_Error, fp);
        }
    return fp;
    }
示例#10
0
void EditOptions::saveScreenSize(int width, int height)
    {
    if(getFilename().length() > 0)
        {
        setScreenCoord("ScreenWidth", width);
        setScreenCoord("ScreenHeight", height);
        OovStatus status = writeFile();
        if(status.needReport())
            {
            status.report(ET_Error, "Unable to write edit options");
            }
        }
    }
示例#11
0
bool makeCoverageStats()
    {
    bool success = false;
    SharedFile covHeaderFile;
    OovString covHeaderFn = CoverageHeaderReader::getFn(
            Project::getCoverageSourceDirectory());
    eOpenStatus stat = covHeaderFile.open(covHeaderFn, M_ReadShared, OE_Binary);
    if(stat == OS_Opened)
        {
        CoverageHeaderReader covHeaderReader;
        OovStatus status = covHeaderReader.read(covHeaderFile);
        if(status.needReport())
            {
            status.report(ET_Error, "Unable to read coverage header");
            }
        int headerInstrLines = covHeaderReader.getNumInstrumentedLines();
        if(headerInstrLines > 0)
            {
            success = true;
            FilePath covCountsFn(Project::getCoverageProjectDirectory(), FP_Dir);
            covCountsFn.appendDir("out-Debug");
            static char const covCountsFnStr[] = "OovCoverageCounts.txt";
            covCountsFn.appendFile(covCountsFnStr);
            CoverageCountsReader covCounts;
            covCounts.read(covCountsFn);
            int covInstrLines = covCounts.getNumInstrumentedLines();
            if(headerInstrLines == covInstrLines)
                {
                makeCoverageStats(covHeaderReader, covCounts);
                updateCovSourceCounts(covHeaderReader, covCounts);
                }
            else
                {
                fprintf(stderr, "Number of OovCoverage.h lines %d don't match %s lines %d\n",
                        headerInstrLines, covCountsFnStr, covInstrLines);
                }
            }
        else
            {
            fprintf(stderr, "No lines are instrumented in %s\n", covHeaderFn.getStr());
            }
        }
    else
        {
        fprintf(stderr, "Unable to open file %s\n", covHeaderFn.getStr());
        }
    return success;
    }
示例#12
0
void Editor::findInFiles(char const * const srchStr, char const * const path,
        bool caseSensitive, bool sourceOnly, GtkTextView *view)
    {
    FindFiles findFiles(srchStr, caseSensitive, sourceOnly, view);
    OovStatus status = findFiles.recurseDirs(path);
    if(status.needReport())
        {
        OovString err = "Unable to search path ";
        err += path;
        status.report(ET_Error, err);
        }
    OovString matchStr = "Found ";
    matchStr.appendInt(findFiles.getNumMatches());
    matchStr += " matches";
    Gui::appendText(view, matchStr);
    }
示例#13
0
OovStringRef const Project::getSrcRootDirectory()
    {
    if(sSourceRootDirectory.length() == 0)
        {
        NameValueFile file(getProjectFilePath());
        OovStatus status = file.readFile();
        if(status.needReport())
            {
            OovString str = "Unable to read project file to get source: ";
            str += getProjectFilePath();
            status.report(ET_Error, str);
            }
        sSourceRootDirectory = file.getValue(OptSourceRootDir);
        }
    return sSourceRootDirectory;
    }
示例#14
0
eDupReturn createDuplicatesFile(/*OovStringRef const projDir,*/ std::string &outFn)
    {
    eDupReturn ret = DR_NoDupFilesFound;
    DuplicateOptions options;
    std::vector<DuplicateLineInfo> dupLineInfo;
    if(getDuplicateLineInfo(options, dupLineInfo))
        {
        FilePath outPath(Project::getProjectDirectory(), FP_Dir);
        outPath.appendDir(DupsDir);
        outPath.appendFile("Dups.txt");
        File outFile;
        OovStatus status = outFile.open(outPath, "w");
        if(status.ok())
            {
            outFn = outPath;
            for(auto const &lineInfo : dupLineInfo)
                {
                OovString str = "lines ";
                str.appendInt(lineInfo.mTotalDupLines);
                str += "  :  ";
                str += lineInfo.mFile1;
                str += " ";
                str.appendInt(lineInfo.mFile1StartLine);
                str += "  :  ";
                str += lineInfo.mFile2;
                str += " ";
                str.appendInt(lineInfo.mFile2StartLine);
                str += "\n";
                status = outFile.putString(str);
                if(!status.ok())
                    {
                    break;
                    }
                }
            ret = DR_Success;
            }
        else
            {
            ret = DR_UnableToCreateDirectory;
            }
        if(status.needReport())
            {
            status.report(ET_Error, "Unable to write to duplicates file");
            }
        }
    return ret;
    }
示例#15
0
/// Make a stats file that contains the percentage of instrumented
/// lines that have been executed for each source file.
static void makeCoverageStats(CoverageHeaderReader const &covHeader,
        CoverageCountsReader const &covCounts)
    {
    FilePath statFn(Project::getCoverageProjectDirectory(), FP_Dir);
    statFn.appendFile("oovCovStats.txt");
    File statFile;
    OovStatus status = statFile.open(statFn, "w");
    if(status.ok())
        {
        size_t countIndex = 0;
        std::vector<int> const &counts = covCounts.getCounts();
        for(auto const &mapItem : covHeader.getMap())
            {
            int count = mapItem.second;
            int hits = 0;
            for(int i=0; i<count; i++)
                {
                if(countIndex < counts.size())
                    {
                    if(counts[countIndex++])
                        {
                        hits++;
                        }
                    }
                }
            int percent = 0;
            if(count > 0)
                {
                percent = (hits * 100) / count;
                }
            else
                {
                percent = 100;
                }
            OovString covFn = makeOrigCovFn(mapItem.first);
            fprintf(statFile.getFp(), "%s %d\n", covFn.getStr(), percent);
            }
        }
    if(status.needReport())
        {
        OovString err = "Unable to open file ";
        err += statFn;
        status.report(ET_Error, err);
        }
    }
示例#16
0
void CoverageHeader::update(OovStringRef const outDefFn, OovStringRef const srcFn,
        int numInstrLines)
    {
    SharedFile outDefFile;
    eOpenStatus stat = outDefFile.open(outDefFn, M_ReadWriteExclusive, OE_Binary);
    if(stat == OS_Opened)
        {
        OovStatus status = read(outDefFile);
        if(status.ok())
            {
            write(outDefFile, srcFn, numInstrLines);
            }
        if(status.needReport())
            {
            status.report(ET_Error, "Unable to update coverage file");
            }
        }
    }
示例#17
0
static bool makeCoverageProjectFile(OovStringRef const srcFn, OovStringRef const dstFn,
        OovStringRef const covSrcDir)
    {
    NameValueFile file(srcFn);
    OovStatus status = file.readFile();
    if(status.ok())
        {
        file.setFilename(dstFn);
        file.setNameValue(OptSourceRootDir, covSrcDir);
        status = file.writeFile();
        }
    if(status.needReport())
        {
        OovString err = "Unable to make project file ";
        err += srcFn;
        status.report(ET_Error, err);
        }
    return status.ok();
    }
示例#18
0
void BuildSettingsDialog::enterScreen()
{
    ScannedComponentInfo scannedCompInfo;
    OovStatus status = scannedCompInfo.readScannedInfo();
    if(status.ok())
    {
        GtkComboBoxText *typeBox = GTK_COMBO_BOX_TEXT(Builder::getBuilder()->getWidget(
                                       "ComponentTypeComboboxtext"));
        Gui::clear(typeBox);
        Gui::setSelected(GTK_COMBO_BOX(typeBox), -1);
        Gui::appendText(typeBox, ComponentTypesFile::getLongComponentTypeName(
                            CT_Unknown));
        Gui::appendText(typeBox, ComponentTypesFile::getLongComponentTypeName(
                            CT_StaticLib));
        Gui::appendText(typeBox, ComponentTypesFile::getLongComponentTypeName(
                            CT_SharedLib));
        Gui::appendText(typeBox, ComponentTypesFile::getLongComponentTypeName(
                            CT_Program));
        Gui::appendText(typeBox, ComponentTypesFile::getLongComponentTypeName(
                            CT_JavaJarLib));
        Gui::appendText(typeBox, ComponentTypesFile::getLongComponentTypeName(
                            CT_JavaJarProg));

        mComponentTree.clear();
        for(auto const &name : scannedCompInfo.getComponentNames())
        {
            if(mLastCompName.length() == 0)
            {
                mLastCompName = name;
            }
            mComponentTree.appendText(getParent(name),
                                      ComponentTypesFile::getComponentChildName(name));
        }
    }
    if(status.needReport())
    {
        status.report(ET_Error, "Unable to read component settings file");
    }
    GuiTreePath path("0");
    gtk_tree_view_set_cursor(mComponentTree.getTreeView(), path.getPath(),
                             nullptr, false);
}
示例#19
0
void ComponentGraph::removeNode(const ComponentNode &node,
        const ComponentDrawOptions &options)
    {
    for(size_t i=0; i<mNodes.size(); i++)
        {
        if(&node == &mNodes[i])
            {
            mNodes.erase(mNodes.begin() + i);
            break;
            }
        }
    ComponentTypesFile compFile;
    OovStatus status = compFile.read();
    if(status.needReport())
        {
        status.report(ET_Error, "Unable to read components file to update connections");
        }
    if(status.ok())
        {
        updateConnections(compFile, options);
        }
    mModified = true;
    }
示例#20
0
bool EditOptions::getScreenSize(int &width, int &height)
    {
    bool gotPos = false;
    OovStatus status = readFile();
    if(status.ok())
        {
        int tempWidth;
        if(getScreenCoord("ScreenWidth", tempWidth))
            {
            int tempHeight;
            if(getScreenCoord("ScreenHeight", tempHeight))
                {
                width = tempWidth;
                height = tempHeight;
                gotPos = true;
                }
            }
        }
    else
        {
        status.report(ET_Info, "Unable to get screen size");
        }
    return gotPos;
    }
示例#21
0
void EditFiles::viewFile(OovStringRef const fn, int lineNum)
    {
    FilePath fp;

    fp.getAbsolutePath(fn, FP_File);
    auto iter = std::find_if(mFileViews.begin(), mFileViews.end(),
        [fp](std::unique_ptr<ScrolledFileView> const &fv) -> bool
        { return fv->mFilename.comparePaths(fp) == 0; });
    if(iter == mFileViews.end())
        {
        GtkNotebook *book = nullptr;
        if(putInMainWindow(fn))
            book = mSourceBook;
        else
            book = mHeaderBook;
        if(book)
            {
            GtkWidget *scrolled = gtk_scrolled_window_new(nullptr, nullptr);
            GtkWidget *editView = gtk_text_view_new();

            /// @todo - use make_unique when supported.
            ScrolledFileView *scrolledView = new ScrolledFileView(mDebugger);
            scrolledView->mFileView.init(GTK_TEXT_VIEW(editView), this);
            OovStatus status = scrolledView->mFileView.openTextFile(fp);
            if(status.needReport())
                {
                OovString err = "Unable to open file ";
                err += fp;
                status.report(ET_Error, err);
                }
            scrolledView->mScrolled = GTK_SCROLLED_WINDOW(scrolled);
            scrolledView->mFilename = fp;

            gtk_container_add(GTK_CONTAINER(scrolled), editView);
            Gui::appendPage(book, scrolled,
                    newTabLabel(fp.getName(), scrolledView->getViewTopParent()));
            gtk_widget_show_all(scrolled);
            scrolledView->mLeftMargin.setupMargin(GTK_TEXT_VIEW(editView));

            // Set up the windows to draw the line numbers in the left margin.
            // GTK has changed, and different setups are required for different
            // versions of GTK.
            // This is not allowed for a text view
            //          gtk_widget_set_app_paintable(editView, true);
#if(USE_DRAW_LAYER)
            overrideDrawLayer(editView);
            // If the left window is not created, errors display, "Attempt to
            // convert text buffer coordinates to coordinates for a nonexistent
            // buffer or private child window of GtkTextView". So create a
            // window that is only one pixel wide, and draw the line numbers
            // on the main text view window.
            gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(editView),
                    GTK_TEXT_WINDOW_LEFT, 1);
            gtk_text_view_set_left_margin(GTK_TEXT_VIEW(editView),
                    scrolledView->mLeftMargin.getMarginWidth());
#else
            // The margin is drawn on the border window.
            gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(editView),
                    GTK_TEXT_WINDOW_LEFT, scrolledView->mLeftMargin.getMarginWidth());
            g_signal_connect(editView, "draw", G_CALLBACK(onTextViewDraw), scrolledView);
#endif

            g_signal_connect(editView, "focus_in_event",
                    G_CALLBACK(on_EditFiles_focus_in_event), NULL);
            g_signal_connect(editView, "key_press_event",
                    G_CALLBACK(on_EditFiles_key_press_event), NULL);
            g_signal_connect(editView, "button_press_event",
                    G_CALLBACK(on_EditFiles_button_press_event), NULL);
            mFileViews.push_back(std::unique_ptr<ScrolledFileView>(scrolledView));
#if(DBG_EDITF)
        sDbgFile.printflush("viewFile count %d, line %d\n", mFileViews.size(), lineNum);
#endif
            iter = mFileViews.end()-1;
            }
        }
    GtkNotebook *notebook = (*iter)->getBook();
    if(notebook)
        {
        int pageIndex = getPageNumber(notebook, (*iter)->getTextView());
        Gui::setCurrentPage(notebook, pageIndex);
        // focus is set after the screen is displayed by onIdle
//      gtk_widget_grab_focus(GTK_WIDGET((*iter).getTextView()));
#if(DBG_EDITF)
        sDbgFile.printflush("viewFile %d\n", pageIndex);
#endif
        if(lineNum > 1)
            {
            (*iter)->mDesiredLine = lineNum;
            }
        }
    }
示例#22
0
/*
class OovMonitorWriter
        {
        public:
                OovMonitorWriter():
                        mFp(0)
                        {}
                ~OovMonitorWriter()
                        {
                        fclose(mFp);
                        }
                void append(int fileIndex, int instrIndex)
                        {
                        if(!mFp)
                                {
                                mFp = fopen("OovMonitor.txt", "a");
                                }
                                {
//                              std::lock_guard<std::mutex> writeMutexLock(mWriteMutex);
                                std::stringstream id;
                                id << std::this_thread::get_id();
                                fprintf(mFp, "%s %d %d\n", id.str().c_str(), fileIndex, instrIndex);
                                fflush(mFp);
                                }
                        }

        private:
                FILE *mFp;
//              std::mutex mWriteMutex;
        };

OovMonitorWriter sOovMonitor;

void OovMonitor(int fileIndex, int instrIndex)
        {
        sOovMonitor.append(fileIndex, instrIndex);
        }
*/
void CppInstr::updateCoverageSource(OovStringRef const /*fn*/, OovStringRef const covDir)
    {
    FilePath outFn(covDir, FP_Dir);
    outFn.appendDir("covLib");
    OovStatus status = FileEnsurePathExists(outFn);
    if(status.ok())
        {
        outFn.appendFile("OovCoverage.cpp");

            if(!FileIsFileOnDisk(outFn, status))
            {
            File file;
            status = file.open(outFn, "w");

                static char const *lines[] = {
                "// Automatically generated file by OovCovInstr\n",
                "// This appends coverage data to either a new or existing file,\n"
                "// although the number of instrumented lines in the project must match.\n"
                "// This file must be compiled and linked into the project.\n",
                "#include <stdio.h>\n",
                "#include \"OovCoverage.h\"\n",
                "\n",
                "unsigned short gCoverage[COV_TOTAL_INSTRS];\n",
                "\n",
                "class cCoverageOutput\n",
                "  {\n",
                "  public:\n",
                "  cCoverageOutput()\n",
                "    {\n",
                "    // Initialize because some compilers may not initialize statics (TI)\n",
                "    for(int i=0; i<COV_TOTAL_INSTRS; i++)\n",
                "      gCoverage[i] = 0;\n",
                "    }\n",
                "  ~cCoverageOutput()\n",
                "    {\n",
                "      update();\n",
                "    }\n",
                "  void update()\n",
                "    {\n",
                "    read();\n",
                "    write();\n",
                "    }\n",
                "\n",
                "  private:\n",
                "  int getFirstIntFromLine(FILE *fp)\n",
                "    {\n",
                "   char buf[80];\n",
                "   fgets(buf, sizeof(buf), fp);\n",
                "   unsigned int tempInt = 0;\n",
                "           sscanf(buf, \"%u\", &tempInt);\n",
                "   return tempInt;\n",
                "    }\n",
                "  void read()\n",
                "    {\n",
                "    FILE *fp = fopen(\"OovCoverageCounts.txt\", \"r\");\n",
                "    if(fp)\n",
                "      {\n",
                "      int numInstrs = getFirstIntFromLine(fp);\n",
                "      if(numInstrs == COV_TOTAL_INSTRS)\n",
                "        {\n",
                "        for(int i=0; i<COV_TOTAL_INSTRS; i++)\n",
                "          {\n",
                "          gCoverage[i] += getFirstIntFromLine(fp);\n",
                "          }\n",
                "        }\n",
                "      fclose(fp);\n",
                "      }\n",
                "    }\n",
                "  void write()\n",
                "    {\n",
                "    FILE *fp = fopen(\"OovCoverageCounts.txt\", \"w\");\n",
                "    if(fp)\n",
                "      {\n",
                "      fprintf(fp, \"%d   # Number of instrumented lines\\n\", COV_TOTAL_INSTRS);\n",
                "      for(int i=0; i<COV_TOTAL_INSTRS; i++)\n",
                "        {\n",
                "        fprintf(fp, \"%u\", gCoverage[i]);\n",
                "        gCoverage[i] = 0;\n",
                "        fprintf(fp, \"\\n\");\n",
                "        }\n",
                "      fclose(fp);\n",
                "      }\n",
                "    }\n",
                "  };\n",
                "\n",
                "cCoverageOutput coverageOutput;\n"
                "\n",
                "void updateCoverage()\n",
                "  { coverageOutput.update(); }\n"

                };
            for(size_t i=0; i<sizeof(lines)/sizeof(lines[0]) && status.ok(); i++)
                {
                status = file.putString(lines[i]);
                if(!status.ok())
                    {
                    break;
                    }
                }
            }
        }
    if(!status.ok())
        {
        OovString err = "Unable to update coverage source ";
        err += outFn;
        status.report(ET_Error, err);
        }
    }