Example #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;
    }
Example #2
0
OovString const Project::getBinDirectory()
    {
    static OovString path;
    if(path.length() == 0)
        {
        OovStatus status(true, SC_File);
#ifdef __linux__
        char buf[300];
        ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf));
        if(len >= 0)
            {
            buf[len] = '\0';
            path = buf;
            size_t pos = path.rfind('/');
            if(pos == std::string::npos)
                {
                pos = path.rfind('\\');
                }
            if(pos != std::string::npos)
                {
                path.resize(pos+1);
                }
            }
/*
        if(FileIsFileOnDisk("./oovaide", status))
            {
            path = "./";
            }
        else if(FileIsFileOnDisk("/usr/local/bin/oovaide", status))
            {
            path = "/usr/local/bin/";
            }
*/
        else
            {
            path = "/usr/bin";
            }
#else
        if(FileIsFileOnDisk("./oovaide.exe", status))
            {
            path = "./";
            }
        else
            {
            path = FilePathGetDrivePath(sArgv0);
            }
#endif
        if(status.needReport())
            {
            status.report(ET_Error, "Unable to get bin directory");
            }
        }
    return path;
    }
Example #3
0
/// The package file is only copied if it doesn't exist or is old.  If it was
/// always copied, then the date would be updated which would cause a full
/// rebuild of all analysis and build files.
static bool copyPackageFileIfNeeded(OovStringRef const srcFn, OovStringRef const dstFn)
    {
    OovStatus status(true, SC_File);
    if(FileStat::isOutputOld(dstFn, srcFn, status))
        {
        File srcFile;
        status = srcFile.open(srcFn, "r");
        if(status.ok())
            {
            if(FileIsFileOnDisk(srcFn, status))
                {
                if(srcFile.isOpen())
                    {
                    status = FileEnsurePathExists(dstFn);
                    if(status.ok())
                        {
                        File dstFile;
                        status = dstFile.open(dstFn, "w");
                        if(status.ok())
                            {
                            char buf[10000];
                            while(srcFile.getString(buf, sizeof(buf), status))
                                {
                                status = dstFile.putString(buf);
                                if(!status.ok())
                                    {
                                    break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        if(status.needReport())
            {
            OovString err = "Unable to copy package file ";
            err += srcFn;
            status.report(ET_Error, err);
            }
        }
    return status.ok();
    }
Example #4
0
void OptionsDefaults::setDefaultOptions()
{
    CompoundValue baseArgs;
    CompoundValue extraCppDocArgs;
    CompoundValue extraCppRlsArgs;
    CompoundValue extraCppDbgArgs;

    baseArgs.addArg("-c");
    bool useCLangBuild = false;
#ifdef __linux__
//    baseArgs.addArg("-ER/usr/include/gtk-3.0");
//    baseArgs.addArg("-ER/usr/lib/x86_64-linux-gnu/glib-2.0/include");
    OovStatus status(true, SC_File);
    if(FileIsFileOnDisk("/usr/bin/clang++", status))
        useCLangBuild = true;
    if(status.needReport())
    {
        status.reported();
    }
#else
    std::string path = getenv("PATH");
    if(path.find("LLVM") != std::string::npos)
    {
        useCLangBuild = true;
    }
    /*
        // On Windows, GTK includes gmodule, glib, etc., so no reason to get mingw.
        bool success = addExternalReference(path, "gtk", baseArgs);
        if(!success)
            {
            addExternalReference(path, "mingw", baseArgs);
            }
        addExternalReference(path, "qt", baseArgs);
    */
#endif
    // The GNU compiler cannot have these, but the clang compiler requires them.
    // CLang 3.2 does not work on Windows well, so GNU is used on Windows for
    // building, but CLang is used for XMI parsing.
    // These are important for xmi parsing to show template relations
    if(useCLangBuild)
    {
        addCLangArgs(baseArgs);
    }
    else
    {
        addCLangArgs(extraCppDocArgs);
        extraCppDbgArgs.addArg("-std=c++0x");
        extraCppRlsArgs.addArg("-std=c++0x");
    }
    extraCppDbgArgs.addArg("-O0");
    extraCppDbgArgs.addArg("-g3");

    extraCppRlsArgs.addArg("-O3");

#ifdef __linux__
    mProject.setNameValue(OptToolDebuggerPath, "/usr/bin/gdb");
#else
    // This works without setting the full path.
    // The path could be /MinGW/bin, or could be /Program Files/mingw-builds/...
    mProject.setNameValue(OptToolDebuggerPath, "gdb.exe");
#endif

    setBuildConfigurationPaths(mProject, BuildConfigAnalysis,
                               extraCppDocArgs.getAsString(), useCLangBuild);
    setBuildConfigurationPaths(mProject, BuildConfigDebug,
                               extraCppDbgArgs.getAsString(), useCLangBuild);
    setBuildConfigurationPaths(mProject, BuildConfigRelease,
                               extraCppRlsArgs.getAsString(), useCLangBuild);

    mProject.setNameValue(OptBaseArgs, baseArgs.getAsString());
}
Example #5
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);
        }
    }
Example #6
0
bool NameValueFile::isFilePresent(OovStatus &status)
    {
    return FileIsFileOnDisk(mFilename, status);
    }