bool IndexerJob::visit(int build) { if (!mUnits.at(build).second) { abort(); return false; } clang_getInclusions(mUnits.at(build).second, IndexerJob::inclusionVisitor, this); if (isAborted()) return false; clang_visitChildren(clang_getTranslationUnitCursor(mUnits.at(build).second), IndexerJob::indexVisitor, this); if (isAborted()) return false; if (testLog(VerboseDebug)) { VerboseVisitorUserData u = { 0, "<VerboseVisitor " + mClangLines.at(build) + ">\n", this }; clang_visitChildren(clang_getTranslationUnitCursor(mUnits.at(build).second), IndexerJob::verboseVisitor, &u); u.out += "</VerboseVisitor " + mClangLines.at(build) + ">"; if (getenv("RTAGS_INDEXERJOB_DUMP_TO_FILE")) { char buf[1024]; snprintf(buf, sizeof(buf), "/tmp/%s.log", mSourceInformation.sourceFile.fileName()); FILE *f = fopen(buf, "w"); assert(f); fwrite(u.out.constData(), 1, u.out.size(), f); fclose(f); } else { logDirect(VerboseDebug, u.out); } } return !isAborted(); }
void IndexerJob::sendDiagnostics(const List<String> &diagnostics) { for (Set<uint32_t>::const_iterator it = mVisitedFiles.begin(); it != mVisitedFiles.end(); ++it) log(CompilationError, "file: %s", Location::path(*it).constData()); for (int i=0; i<diagnostics.size(); ++i) logDirect(CompilationError, diagnostics.at(i)); }
void Log::log(LogLevel level, const char *file, int line, const QString &msg) { const QStringList msgLines = msg.split('\n'); for (const QString &msgLine : msgLines) { logDirect(level, file, line, msgLine); } flush(); }
static void log(LogLevel level, const char *format, va_list v) { if (!testLog(level)) return; va_list v2; va_copy(v2, v); enum { Size = 16384 }; StackBuffer<Size> buf(Size); int n = vsnprintf(buf, Size, format, v); if (n == -1) { va_end(v2); return; } if (n >= Size) { buf.resize(n + 2); n = vsnprintf(buf, n + 1, format, v2); } logDirect(level, buf, n); va_end(v2); }
bool ClangIndexer::visit() { if (!mClangUnit || !mSource.fileId) { return false; } StopWatch watch; clang_visitChildren(clang_getTranslationUnitCursor(mClangUnit), ClangIndexer::indexVisitor, this); for (Hash<uint32_t, bool>::const_iterator it = mData->visited.begin(); it != mData->visited.end(); ++it) { mData->dependencies[it->first].insert(mSource.fileId); addFileSymbol(it->first); } mVisitDuration = watch.elapsed(); if (testLog(VerboseDebug)) { VerboseVisitorUserData u = { 0, "<VerboseVisitor " + mClangLine + ">\n", this }; clang_visitChildren(clang_getTranslationUnitCursor(mClangUnit), ClangIndexer::verboseVisitor, &u); u.out += "</VerboseVisitor " + mClangLine + ">"; if (getenv("RTAGS_INDEXERJOB_DUMP_TO_FILE")) { char buf[1024]; snprintf(buf, sizeof(buf), "/tmp/%s.log", Location::path(mSource.fileId).fileName()); FILE *f = fopen(buf, "w"); assert(f); fwrite(u.out.constData(), 1, u.out.size(), f); fclose(f); } else { logDirect(VerboseDebug, u.out); } } return true; }