MemSpecs MemSpecParser::parse() { // Check the kernel source path QDir kernelSrc(_kernelSrcDir); if (! (kernelSrc.exists() && kernelSrc.exists("Makefile")) ) memSpecParserError(QString("Directory \"%1\" does not seem to be a kernel source or header tree.").arg(kernelSrc.absolutePath())); if (! kernelSrc.exists(".config") ) memSpecParserError(QString("Kernel source in \"%1\" does not seem to be configured properly.").arg(kernelSrc.absolutePath())); // Check the System.map file if (!QFile::exists(_systemMapFile)) memSpecParserError(QString("The file \"%1\" does not exist.").arg(_systemMapFile)); MemSpecs specs; specs.created = QDateTime::currentDateTime(); // Determine configured system architecture parseKernelConfig(&specs); // Process the System.map file first to get potentially value for // _vmallocEarlyreserve parseSystemMap(&specs); // Process the kernel source tree setupBuildDir(); buildHelperProg(specs); parseHelperProg(&specs); return specs; }
std::string GPU::getKernelSrc(const std::string& kernelPath) { std::ifstream kernelFile(kernelPath); if(!kernelFile.is_open()) { throw std::runtime_error("Failed to open the kernel file."); } kernelFile.seekg(0, std::ios::end); size_t fileSize = kernelFile.tellg(); std::string kernelSrc(fileSize, ' '); kernelFile.seekg(0); kernelFile.read(&kernelSrc[0], fileSize); return kernelSrc; }