// make sure that a valid file is set, at least dummy with empty name void CachegrindLoader::ensureFile() { if (currentFile) return; currentFile = _data->file(_emptyString); currentPartFile = currentFile->partFile(_part); }
// Note: Callgrind sometimes gives different IDs for same file // (when references to same source file come from different ELF objects) TraceFile* CachegrindLoader::compressedFile(const QString& name) { if ((name[0] != '(') || !name[1].isDigit()) return _data->file(checkUnknown(name)); // compressed format using _fileVector int p = name.indexOf(')'); if (p<2) { error(QStringLiteral("Invalid compressed file ('%1')").arg(name)); return 0; } int index = name.midRef(1, p-1).toUInt(); TraceFile* f = 0; p++; while((name.length()>p) && name.at(p).isSpace()) p++; if (name.length()>p) { if (_fileVector.size() <= index) { int newSize = index * 2; #if TRACE_LOADER qDebug() << " CachegrindLoader::fileVector enlarged to " << newSize; #endif _fileVector.resize(newSize); } QString realName = checkUnknown(name.mid(p)); f = (TraceFile*) _fileVector.at(index); if (f && (f->name() != realName)) { error(QStringLiteral("Redefinition of compressed file index %1 (was '%2') to %3") .arg(index).arg(f->name()).arg(realName)); } f = _data->file(realName); _fileVector.replace(index, f); } else { if ((_fileVector.size() <= index) || ( (f=(TraceFile*)_fileVector.at(index)) == 0)) { error(QStringLiteral("Undefined compressed file index %1").arg(index)); return 0; } } return f; }
void CachegrindLoader::setCalledFile(const QString& name) { currentCalledFile = compressedFile(name); if (!currentCalledFile) { error(QStringLiteral("Invalid specification of called file, setting to unknown")); currentCalledFile = _data->file(_emptyString); } currentCalledPartFile = currentCalledFile->partFile(_part); }
void CachegrindLoader::setFile(const QString& name) { currentFile = compressedFile(name); if (!currentFile) { error(QString("Invalid file specification, setting to unknown")); currentFile = _data->file(_emptyString); } currentPartFile = currentFile->partFile(_part); currentLine = 0; currentPartLine = 0; }