Skip to content

Commit

Permalink
Avoid time inversion in the output trace by using the event itself wh…
Browse files Browse the repository at this point in the history
…en relogging a command line or environment variable.
  • Loading branch information
kevcadieux committed Mar 5, 2020
1 parent b3c5722 commit 078149c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
40 changes: 20 additions & 20 deletions src/Views/BuildExplorerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -192,7 +192,7 @@ void BuildExplorerView::LogActivity(const void* relogSession, const Activity& a,

template <typename TChar>
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<TChar>::length(value);

Expand All @@ -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 <typename TChar>
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();
Expand All @@ -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
10 changes: 5 additions & 5 deletions src/Views/BuildExplorerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -80,16 +80,16 @@ class BuildExplorerView : public BI::IRelogger

template <typename TChar>
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 <typename TChar>
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_;
Expand Down

0 comments on commit 078149c

Please sign in to comment.