Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
deps: update ChakraCore to chakra-core/ChakraCore@8e52453b89
Browse files Browse the repository at this point in the history
[MERGE #4913 @mrkmarron] TTD: Fixes for innerloop trace management.

Merge pull request #4913 from mrkmarron:innerloopfixes

Fixes around trace write for innerloop debugging scenarios.

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
mrkmarron authored and chakrabot committed Apr 3, 2018
1 parent fd3229c commit 96ed842
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
4 changes: 4 additions & 0 deletions deps/chakrashim/core/lib/Jsrt/JsrtDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,10 @@ CHAKRA_API JsTTDDiagWriteLog(_In_reads_(uriLength) const char* uri, _In_ size_t
return JsErrorCategoryUsage;
#else
return ContextAPIWrapper_NoRecord<true>([&](Js::ScriptContext * scriptContext) -> JsErrorCode {
if (!scriptContext->GetThreadContext()->IsRuntimeInTTDMode() || !scriptContext->GetThreadContext()->TTDLog->CanWriteInnerLoopTrace())
{
return JsErrorDiagUnableToPerformAction;
}

JsrtContext *currentContext = JsrtContext::GetCurrent();
JsrtRuntime* runtime = currentContext->GetRuntime();
Expand Down
36 changes: 31 additions & 5 deletions deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2526,8 +2526,14 @@ namespace TTD

void EventLog::InnerLoopEmitLog(const TTDebuggerSourceLocation& writeLocation, const char* emitUri, size_t emitUriLength)
{
NSLogEvents::TTDInnerLoopLogWriteEventLogEntry* evt = nullptr;
this->RecordGetInitializedEvent<NSLogEvents::TTDInnerLoopLogWriteEventLogEntry, NSLogEvents::EventKind::TTDInnerLoopLogWriteTag>(&evt);
//Events are slab allocated with header immediately followed by payload -- we need to replicate this layout here so we allocate an array and explicitly layout.
//See definition of GetNextAvailableEntry and GetInlineEventDataAs for more detail.
byte buff[TTD_EVENT_PLUS_DATA_SIZE(NSLogEvents::TTDInnerLoopLogWriteEventLogEntry)];

NSLogEvents::EventLogEntry* entry = reinterpret_cast<NSLogEvents::EventLogEntry*>(buff);
NSLogEvents::EventLogEntry_Initialize<NSLogEvents::EventKind::TTDInnerLoopLogWriteTag>(entry, this->m_eventTimeCtr);

NSLogEvents::TTDInnerLoopLogWriteEventLogEntry* evt = NSLogEvents::GetInlineEventDataAs<NSLogEvents::TTDInnerLoopLogWriteEventLogEntry, NSLogEvents::EventKind::TTDInnerLoopLogWriteTag>(entry);

evt->SourceScriptLogId = writeLocation.GetScriptLogTagId();
evt->EventTime = writeLocation.GetRootEventTime();
Expand All @@ -2541,10 +2547,23 @@ namespace TTD
evt->Line = writeLocation.GetSourceLine();
evt->Column = writeLocation.GetSourceColumn();

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

void EventLog::EmitLog(const char* emitUri, size_t emitUriLength)
bool EventLog::CanWriteInnerLoopTrace() const
{
bool isInnerLoop = (this->m_currentMode & (TTDMode::RecordDebuggerMode)) == TTDMode::RecordDebuggerMode;
bool isEnabled = (this->m_currentMode & (TTDMode::CurrentlyEnabled)) == TTDMode::CurrentlyEnabled;

return isInnerLoop & isEnabled;
}

bool EventLog::SuppressDiagnosticTracesDuringInnerLoop() const
{
return (this->m_currentMode & (TTDMode::DebuggerAttachedMode)) == TTDMode::DebuggerAttachedMode;
}

void EventLog::EmitLog(const char* emitUri, size_t emitUriLength, NSLogEvents::EventLogEntry* optInnerLoopEvent)
{
#if ENABLE_BASIC_TRACE || ENABLE_FULL_BC_TRACE
this->m_threadContext->TTDExecutionInfo->GetTraceLogger()->ForceFlush();
Expand Down Expand Up @@ -2604,7 +2623,7 @@ namespace TTD
writer.WriteUInt64(NSTokens::Key::usedMemory, usedSpace, NSTokens::Separator::CommaSeparator);
writer.WriteUInt64(NSTokens::Key::reservedMemory, reservedSpace, NSTokens::Separator::CommaSeparator);

uint32 ecount = this->m_eventList.Count();
uint32 ecount = this->m_eventList.Count() + (optInnerLoopEvent != nullptr ? 1 : 0);
writer.WriteLengthValue(ecount, NSTokens::Separator::CommaAndBigSpaceSeparator);

#if ENABLE_TTD_INTERNAL_DIAGNOSTICS
Expand Down Expand Up @@ -2677,6 +2696,13 @@ namespace TTD
}
#endif
}

if (optInnerLoopEvent != nullptr)
{
//Emit the special event that indicates we want to break at the end of the log (with a known breakpoint time)
NSLogEvents::EventLogEntry_Emit(optInnerLoopEvent, this->m_eventListVTable, &writer, this->m_threadContext, NSTokens::Separator::BigSpaceSeparator);
}

writer.AdjustIndent(-1);
writer.WriteSequenceEnd(NSTokens::Separator::BigSpaceSeparator);

Expand Down
5 changes: 4 additions & 1 deletion deps/chakrashim/core/lib/Runtime/Debug/TTEventLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,10 @@ namespace TTD

void InnerLoopEmitLog(const TTDebuggerSourceLocation& writeLocation, const char* emitUri, size_t emitUriLength);

void EmitLog(const char* emitUri, size_t emitUriLength);
bool CanWriteInnerLoopTrace() const;
bool SuppressDiagnosticTracesDuringInnerLoop() const;

void EmitLog(const char* emitUri, size_t emitUriLength, NSLogEvents::EventLogEntry* optInnerLoopEvent = nullptr);
void ParseLogInto(TTDataIOInfo& iofp, const char* parseUri, size_t parseUriLength);
};

Expand Down
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Runtime/Library/GlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,7 @@ namespace Js
PROBE_STACK(function->GetScriptContext(), Js::Constants::MinStackDefault);
ARGUMENTS(args, callInfo);

if(function->GetScriptContext()->ShouldPerformRecordOrReplayAction())
if(function->GetScriptContext()->ShouldPerformRecordOrReplayAction() && !function->GetScriptContext()->GetThreadContext()->TTDLog->SuppressDiagnosticTracesDuringInnerLoop())
{
return function->GetScriptContext()->GetLibrary()->GetTrue();
}
Expand Down

0 comments on commit 96ed842

Please sign in to comment.