Commit d89bd9ff authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Add file name to qtc.clangbackend.jobs output

This helps to overview debug output in case several files are involved.

Change-Id: I12ee23bd7cec4cd344746ef1323afb3f0ab54d4b
Reviewed-by: Marco Bubke's avatarMarco Bubke <marco.bubke@qt.io>
parent e0bbb0a0
......@@ -35,6 +35,8 @@
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
namespace ClangBackEnd {
class DocumentProcessorData
......@@ -47,7 +49,7 @@ public:
ClangCodeModelClientInterface &client)
: document(document)
, documents(documents)
, jobs(documents, unsavedFiles, projects, client)
, jobs(documents, unsavedFiles, projects, client, QFileInfo(document.filePath()).fileName())
, supportiveTranslationUnitInitializer(document, jobs)
{
const auto isDocumentClosedChecker = [this](const Utf8String &filePath,
......
......@@ -33,6 +33,7 @@
#include <functional>
Q_DECLARE_LOGGING_CATEGORY(jobsLog);
#define qCDebugJobs() qCDebug(jobsLog) << "[" << m_logTag << "]"
namespace ClangBackEnd {
......
......@@ -35,9 +35,10 @@
namespace ClangBackEnd {
JobQueue::JobQueue(Documents &documents, ProjectParts &projectParts)
JobQueue::JobQueue(Documents &documents, ProjectParts &projectParts, const Utf8String &logTag)
: m_documents(documents)
, m_projectParts(projectParts)
, m_logTag(logTag)
{
}
......@@ -45,11 +46,11 @@ bool JobQueue::add(const JobRequest &job)
{
QString notAddableReason;
if (isJobRequestAddable(job, notAddableReason)) {
qCDebug(jobsLog) << "Adding" << job;
qCDebugJobs() << "Adding" << job;
m_queue.append(job);
return true;
} else {
qCDebug(jobsLog) << "Not adding" << job << notAddableReason;
qCDebugJobs() << "Not adding" << job << notAddableReason;
cancelJobRequest(job);
return false;
}
......@@ -77,7 +78,7 @@ void JobQueue::removeExpiredRequests()
try {
QString expirationReason;
if (isJobRequestExpired(jobRequest, expirationReason)) {
qCDebug(jobsLog) << "Expired:" << jobRequest << expirationReason;
qCDebugJobs() << "Expired:" << jobRequest << expirationReason;
cancelJobRequest(jobRequest);
} else {
cleanedRequests.append(jobRequest);
......@@ -207,28 +208,28 @@ void JobQueue::cancelJobRequest(const JobRequest &jobRequest)
m_cancelJobRequest(jobRequest);
}
static bool areRunConditionsMet(const JobRequest &request, const Document &document)
bool JobQueue::areRunConditionsMet(const JobRequest &request, const Document &document) const
{
using Condition = JobRequest::RunCondition;
const JobRequest::RunConditions conditions = request.runConditions;
if (conditions.testFlag(Condition::DocumentSuspended) && !document.isSuspended()) {
qCDebug(jobsLog) << "Not choosing due to unsuspended document:" << request;
qCDebugJobs() << "Not choosing due to unsuspended document:" << request;
return false;
}
if (conditions.testFlag(Condition::DocumentUnsuspended) && document.isSuspended()) {
qCDebug(jobsLog) << "Not choosing due to suspended document:" << request;
qCDebugJobs() << "Not choosing due to suspended document:" << request;
return false;
}
if (conditions.testFlag(Condition::DocumentVisible) && !document.isVisibleInEditor()) {
qCDebug(jobsLog) << "Not choosing due to invisble document:" << request;
qCDebugJobs() << "Not choosing due to invisble document:" << request;
return false;
}
if (conditions.testFlag(Condition::DocumentNotVisible) && document.isVisibleInEditor()) {
qCDebug(jobsLog) << "Not choosing due to visble document:" << request;
qCDebugJobs() << "Not choosing due to visble document:" << request;
return false;
}
......@@ -236,12 +237,12 @@ static bool areRunConditionsMet(const JobRequest &request, const Document &docum
if (document.isDirty()) {
// TODO: If the document is dirty due to a project update,
// references are processes later than ideal.
qCDebug(jobsLog) << "Not choosing due to dirty document:" << request;
qCDebugJobs() << "Not choosing due to dirty document:" << request;
return false;
}
if (request.documentRevision != document.documentRevision()) {
qCDebug(jobsLog) << "Not choosing due to revision mismatch:" << request;
qCDebugJobs() << "Not choosing due to revision mismatch:" << request;
return false;
}
}
......
......@@ -37,7 +37,7 @@ class Documents;
class JobQueue
{
public:
JobQueue(Documents &documents, ProjectParts &projects);
JobQueue(Documents &documents, ProjectParts &projects, const Utf8String &logTag = Utf8String());
bool add(const JobRequest &job);
......@@ -61,6 +61,7 @@ public: // for tests
void prioritizeRequests();
private:
bool areRunConditionsMet(const JobRequest &request, const Document &document) const;
void cancelJobRequest(const JobRequest &jobRequest);
bool isJobRunningForTranslationUnit(const Utf8String &translationUnitId);
bool isJobRunningForJobRequest(const JobRequest &jobRequest);
......@@ -72,6 +73,7 @@ private:
private:
Documents &m_documents;
ProjectParts &m_projectParts;
Utf8String m_logTag;
IsJobRunningForTranslationUnitHandler m_isJobRunningForTranslationUnitHandler;
IsJobRunningForJobRequestHandler m_isJobRunningForJobRequestHandler;
......
......@@ -41,12 +41,14 @@ namespace ClangBackEnd {
Jobs::Jobs(Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projectParts,
ClangCodeModelClientInterface &client)
ClangCodeModelClientInterface &client,
const Utf8String &logTag)
: m_documents(documents)
, m_unsavedFiles(unsavedFiles)
, m_projectParts(projectParts)
, m_client(client)
, m_queue(documents, projectParts)
, m_logTag(logTag)
, m_queue(documents, projectParts, logTag)
{
m_queue.setIsJobRunningForTranslationUnitHandler([this](const Utf8String &translationUnitId) {
return isJobRunningForTranslationUnit(translationUnitId);
......@@ -132,7 +134,7 @@ bool Jobs::runJob(const JobRequest &jobRequest)
asyncJob->setContext(context);
if (const IAsyncJob::AsyncPrepareResult prepareResult = asyncJob->prepareAsyncRun()) {
qCDebug(jobsLog) << "Running" << jobRequest
qCDebugJobs() << "Running" << jobRequest
<< "with TranslationUnit" << prepareResult.translationUnitId;
asyncJob->setFinishedHandler([this](IAsyncJob *asyncJob){ onJobFinished(asyncJob); });
......@@ -142,7 +144,7 @@ bool Jobs::runJob(const JobRequest &jobRequest)
m_running.insert(asyncJob, runningJob);
return true;
} else {
qCDebug(jobsLog) << "Preparation failed for " << jobRequest;
qCDebugJobs() << "Preparation failed for " << jobRequest;
delete asyncJob;
}
......@@ -151,7 +153,7 @@ bool Jobs::runJob(const JobRequest &jobRequest)
void Jobs::onJobFinished(IAsyncJob *asyncJob)
{
qCDebug(jobsLog) << "Finishing" << asyncJob->context().jobRequest;
qCDebugJobs() << "Finishing" << asyncJob->context().jobRequest;
if (m_jobFinishedCallback) {
const RunningJob runningJob = m_running.value(asyncJob);
......
......@@ -56,7 +56,8 @@ public:
Jobs(Documents &documents,
UnsavedFiles &unsavedFiles,
ProjectParts &projects,
ClangCodeModelClientInterface &client);
ClangCodeModelClientInterface &client,
const Utf8String &logTag = Utf8String());
~Jobs();
JobRequest createJobRequest(const Document &document, JobRequest::Type type,
......@@ -90,6 +91,7 @@ private:
UnsavedFiles &m_unsavedFiles;
ProjectParts &m_projectParts;
ClangCodeModelClientInterface &m_client;
Utf8String m_logTag;
JobQueue m_queue;
RunningJobs m_running;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment