From 078149c6505fa48fef244f7981849876d4e2d79a Mon Sep 17 00:00:00 2001 From: Kevin Cadieux Date: Thu, 5 Mar 2020 06:32:17 -0800 Subject: [PATCH] Avoid time inversion in the output trace by using the event itself when relogging a command line or environment variable. --- src/Views/BuildExplorerView.cpp | 40 ++++++++++++++++----------------- src/Views/BuildExplorerView.h | 10 ++++----- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Views/BuildExplorerView.cpp b/src/Views/BuildExplorerView.cpp index 27f1c31..2107852 100644 --- a/src/Views/BuildExplorerView.cpp +++ b/src/Views/BuildExplorerView.cpp @@ -94,31 +94,31 @@ void BuildExplorerView::OnCompilerEnvironmentVariable(const Compiler& cl, if (_wcsicmp(name, L"CL") == 0) { - ProcessStringProperty(relogSession, cl, "Env Var: CL", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: CL", envVar.Value()); return; } if (_wcsicmp(name, L"_CL_") == 0) { - ProcessStringProperty(relogSession, cl, "Env Var: _CL_", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: _CL_", envVar.Value()); return; } if (_wcsicmp(name, L"INCLUDE") == 0) { - ProcessStringProperty(relogSession, cl, "Env Var: INCLUDE", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: INCLUDE", envVar.Value()); return; } if (_wcsicmp(name, L"LIBPATH") == 0) { - ProcessStringProperty(relogSession, cl, "Env Var: LIBPATH", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: LIBPATH", envVar.Value()); return; } if (_wcsicmp(name, L"PATH") == 0) { - ProcessStringProperty(relogSession, cl, "Env Var: PATH", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: PATH", envVar.Value()); return; } } @@ -130,31 +130,31 @@ void BuildExplorerView::OnLinkerEnvironmentVariable(const Linker& link, if (_wcsicmp(name, L"LINK") == 0) { - ProcessStringProperty(relogSession, link, "Env Var: LINK", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: LINK", envVar.Value()); return; } if (_wcsicmp(name, L"_LINK_") == 0) { - ProcessStringProperty(relogSession, link, "Env Var: _LINK_", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: _LINK_", envVar.Value()); return; } if (_wcsicmp(name, L"LIB") == 0) { - ProcessStringProperty(relogSession, link, "Env Var: LIB", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: LIB", envVar.Value()); return; } if (_wcsicmp(name, L"PATH") == 0) { - ProcessStringProperty(relogSession, link, "Env Var: PATH", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: PATH", envVar.Value()); return; } if (_wcsicmp(name, L"TMP") == 0) { - ProcessStringProperty(relogSession, link, "Env Var: TMP", envVar.Value()); + ProcessStringProperty(relogSession, envVar, "Env Var: TMP", envVar.Value()); return; } } @@ -192,7 +192,7 @@ void BuildExplorerView::LogActivity(const void* relogSession, const Activity& a, template void BuildExplorerView::ProcessStringProperty(const void* relogSession, - const Invocation& invocation, const char* name, const TChar* value) + const Event& e, const char* name, const TChar* value) { size_t len = std::char_traits::length(value); @@ -205,33 +205,33 @@ void BuildExplorerView::ProcessStringProperty(const void* relogSession, memcpy(segment, value, COMMAND_LINE_SEGMENT_LEN * sizeof(TChar)); segment[COMMAND_LINE_SEGMENT_LEN] = 0; - LogStringPropertySegment(relogSession, invocation, name, segment); + LogStringPropertySegment(relogSession, e, name, segment); len -= COMMAND_LINE_SEGMENT_LEN; value += COMMAND_LINE_SEGMENT_LEN; } - LogStringPropertySegment(relogSession, invocation, name, value); + LogStringPropertySegment(relogSession, e, name, value); } void BuildExplorerView::LogStringPropertySegment(const void* relogSession, - const Invocation& invocation, const char* name, const char* value) + const Event& e, const char* name, const char* value) { - LogStringPropertySegment(relogSession, invocation, name, value, + LogStringPropertySegment(relogSession, e, name, value, &CppBuildInsightsBuildExplorerAnsiStringProperty); } void BuildExplorerView::LogStringPropertySegment(const void* relogSession, - const Invocation& invocation, const char* name, const wchar_t* value) + const Event& e, const char* name, const wchar_t* value) { - LogStringPropertySegment(relogSession, invocation, name, value, + LogStringPropertySegment(relogSession, e, name, value, &CppBuildInsightsBuildExplorerUnicodeStringProperty); } template void BuildExplorerView::LogStringPropertySegment(const void* relogSession, - const Invocation& invocation, const char* name, const TChar* value, + const Event& e, const char* name, const TChar* value, PCEVENT_DESCRIPTOR desc) { auto* context = contextBuilder_->GetContextData(); @@ -250,8 +250,8 @@ void BuildExplorerView::LogStringPropertySegment(const void* relogSession, ); InjectEvent(relogSession, &CppBuildInsightsGuid, desc, - invocation.ProcessId(), invocation.ThreadId(), invocation.ProcessorIndex(), - invocation.StartTimestamp(), p.GetData(), (unsigned long)p.Size()); + e.ProcessId(), e.ThreadId(), e.ProcessorIndex(), + e.Timestamp(), p.GetData(), (unsigned long)p.Size()); } } // namespace vcperf \ No newline at end of file diff --git a/src/Views/BuildExplorerView.h b/src/Views/BuildExplorerView.h index 40570c5..cfbb0e9 100644 --- a/src/Views/BuildExplorerView.h +++ b/src/Views/BuildExplorerView.h @@ -43,7 +43,7 @@ class BuildExplorerView : public BI::IRelogger void OnCommandLine(const A::Invocation& invocation, const SE::CommandLine& commandLine, const void* relogSession) { - ProcessStringProperty(relogSession, invocation, "CommandLine", commandLine.Value()); + ProcessStringProperty(relogSession, commandLine, "CommandLine", commandLine.Value()); } void OnCompilerEnvironmentVariable(const A::Compiler& cl, const SE::EnvironmentVariable& envVar, @@ -80,16 +80,16 @@ class BuildExplorerView : public BI::IRelogger template void ProcessStringProperty(const void* relogSession, - const A::Invocation& invocation, const char* name, const TChar* value); + const BI::Event& e, const char* name, const TChar* value); void LogStringPropertySegment(const void* relogSession, - const A::Invocation& invocation, const char* name, const char* value); + const BI::Event& e, const char* name, const char* value); void LogStringPropertySegment(const void* relogSession, - const A::Invocation& invocation, const char* name, const wchar_t* value); + const BI::Event& e, const char* name, const wchar_t* value); template - void LogStringPropertySegment(const void* relogSession, const A::Invocation& invocation, + void LogStringPropertySegment(const void* relogSession, const BI::Event& e, const char* name, const TChar* value, PCEVENT_DESCRIPTOR desc); std::wstring invocationInfoString_;