Skip to content

Conversation

@mrkmarron
Copy link
Contributor

Fixes around trace write for innerloop debugging scenarios.

{
NSLogEvents::TTDInnerLoopLogWriteEventLogEntry* evt = nullptr;
this->RecordGetInitializedEvent<NSLogEvents::TTDInnerLoopLogWriteEventLogEntry, NSLogEvents::EventKind::TTDInnerLoopLogWriteTag>(&evt);
byte buff[TTD_EVENT_PLUS_DATA_SIZE(NSLogEvents::TTDInnerLoopLogWriteEventLogEntry)];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not clear why you're allocating a byte[] and then casting to EventLogEntry, instead of just allocating an EventLogEntry on stack. Latter would be more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log layout is a packed setup where we expect the event payload data to immediately follow the event header. To ensure this layout is done correctly here we do the byte[] + manual casts instead of relying on the compiler to do contiguous layout on the stack. I'll add a comment here + ref to the other relevant code.

return ContextAPIWrapper_NoRecord<true>([&](Js::ScriptContext * scriptContext) -> JsErrorCode {
if (!scriptContext->GetThreadContext()->IsRuntimeInTTDMode() || !scriptContext->GetThreadContext()->TTDLog->CanWriteInnerLoopTrace())
{
return JsErrorDiagUnableToPerformAction;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are callers of this method expecting such an error code & do they need to do anything special to account for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the caller just ignores the return code. However, the lack of an error code here is not inline with the form of the other API's so I wanted to get it added for cleanliness when I was adding the check code.

bool CanWriteInnerLoopTrace() const;
bool SuppressDiagnosticTracesDuringInnerLoop() const;

void EmitLog(const char* emitUri, size_t emitUriLength, NSLogEvents::EventLogEntry* optInnerLoopEvent=nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing around equals

}
#endif
}
if (optInnerLoopEvent != nullptr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline before if to make the separation more clear

this->EmitLog(emitUri, emitUriLength, entry);
}

bool EventLog::CanWriteInnerLoopTrace() const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More pedantry than anything else but is the idea now that inner loop = record mode?

}
if (optInnerLoopEvent != nullptr)
{
NSLogEvents::EventLogEntry_Emit(optInnerLoopEvent, this->m_eventListVTable, &writer, this->m_threadContext, NSTokens::Separator::BigSpaceSeparator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this event supposed to signify?

@mrkmarron
Copy link
Contributor Author

@dotnet-bot test OSX static_osx_osx_debug please
@dotnet-bot test OSX static_osx_osx_test please

@chakrabot chakrabot merged commit 4b79e6e into chakra-core:release/1.9 Apr 2, 2018
chakrabot pushed a commit that referenced this pull request Apr 2, 2018
Merge pull request #4913 from mrkmarron:innerloopfixes

Fixes around trace write for innerloop debugging scenarios.
chakrabot pushed a commit that referenced this pull request Apr 2, 2018
…management.

Merge pull request #4913 from mrkmarron:innerloopfixes

Fixes around trace write for innerloop debugging scenarios.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants