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@dc9c863768
Browse files Browse the repository at this point in the history
[MERGE #4636 @mrkmarron] TTD: Updates to support innerloop debugging (1.9) .

Merge pull request #4636 from mrkmarron:innerloop19

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
mrkmarron authored and chakrabot committed Feb 2, 2018
1 parent 023dc1b commit 31a5b2e
Show file tree
Hide file tree
Showing 21 changed files with 385 additions and 55 deletions.
2 changes: 2 additions & 0 deletions deps/chakrashim/core/bin/ChakraCore/ChakraCore.def
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ JsTTDPreExecuteSnapShotInterval
JsTTDMoveToTopLevelEvent
JsTTDReplayExecution

JsTTDDiagWriteLog

JsInitializeModuleRecord
JsParseModuleSource
JsModuleEvaluation
Expand Down
4 changes: 2 additions & 2 deletions deps/chakrashim/core/bin/ch/ChakraRtInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct JsAPIHooks
typedef JsErrorCode(WINAPI *JsrtCreateExternalArrayBuffer)(void *data, unsigned int byteLength, JsFinalizeCallback finalizeCallback, void *callbackState, JsValueRef *result);
typedef JsErrorCode(WINAPI *JsrtCreatePropertyId)(const char *name, size_t length, JsPropertyIdRef *propertyId);

typedef JsErrorCode(WINAPI *JsrtTTDCreateRecordRuntimePtr)(JsRuntimeAttributes attributes, size_t snapInterval, size_t snapHistoryLength, TTDOpenResourceStreamCallback openResourceStream, JsTTDWriteBytesToStreamCallback writeBytesToStream, JsTTDFlushAndCloseStreamCallback flushAndCloseStream, JsThreadServiceCallback threadService, JsRuntimeHandle *runtime);
typedef JsErrorCode(WINAPI *JsrtTTDCreateRecordRuntimePtr)(JsRuntimeAttributes attributes, bool enableDebugging, size_t snapInterval, size_t snapHistoryLength, TTDOpenResourceStreamCallback openResourceStream, JsTTDWriteBytesToStreamCallback writeBytesToStream, JsTTDFlushAndCloseStreamCallback flushAndCloseStream, JsThreadServiceCallback threadService, JsRuntimeHandle *runtime);
typedef JsErrorCode(WINAPI *JsrtTTDCreateReplayRuntimePtr)(JsRuntimeAttributes attributes, const char* infoUri, size_t infoUriCount, bool enableDebugging, TTDOpenResourceStreamCallback openResourceStream, JsTTDReadBytesFromStreamCallback readBytesFromStream, JsTTDFlushAndCloseStreamCallback flushAndCloseStream, JsThreadServiceCallback threadService, JsRuntimeHandle *runtime);
typedef JsErrorCode(WINAPI *JsrtTTDCreateContextPtr)(JsRuntimeHandle runtime, bool useRuntimeTTDMode, JsContextRef *newContext);
typedef JsErrorCode(WINAPI *JsrtTTDNotifyContextDestroyPtr)(JsContextRef context);
Expand Down Expand Up @@ -384,7 +384,7 @@ class ChakraRTInterface
static JsErrorCode WINAPI JsSetModuleHostInfo(JsModuleRecord requestModule, JsModuleHostInfoKind moduleHostInfo, void* hostInfo) { return HOOK_JS_API(SetModuleHostInfo(requestModule, moduleHostInfo, hostInfo)); }
static JsErrorCode WINAPI JsGetModuleHostInfo(JsModuleRecord requestModule, JsModuleHostInfoKind moduleHostInfo, void** hostInfo) { return HOOK_JS_API(GetModuleHostInfo(requestModule, moduleHostInfo, hostInfo)); }

static JsErrorCode WINAPI JsTTDCreateRecordRuntime(JsRuntimeAttributes attributes, size_t snapInterval, size_t snapHistoryLength, TTDOpenResourceStreamCallback openResourceStream, JsTTDWriteBytesToStreamCallback writeBytesToStream, JsTTDFlushAndCloseStreamCallback flushAndCloseStream, JsThreadServiceCallback threadService, JsRuntimeHandle *runtime) { return HOOK_JS_API(TTDCreateRecordRuntime(attributes, snapInterval, snapHistoryLength, openResourceStream, writeBytesToStream, flushAndCloseStream, threadService, runtime)); }
static JsErrorCode WINAPI JsTTDCreateRecordRuntime(JsRuntimeAttributes attributes, size_t snapInterval, size_t snapHistoryLength, TTDOpenResourceStreamCallback openResourceStream, JsTTDWriteBytesToStreamCallback writeBytesToStream, JsTTDFlushAndCloseStreamCallback flushAndCloseStream, JsThreadServiceCallback threadService, JsRuntimeHandle *runtime) { return HOOK_JS_API(TTDCreateRecordRuntime(attributes, false, snapInterval, snapHistoryLength, openResourceStream, writeBytesToStream, flushAndCloseStream, threadService, runtime)); }
static JsErrorCode WINAPI JsTTDCreateReplayRuntime(JsRuntimeAttributes attributes, const char* infoUri, size_t infoUriCount, TTDOpenResourceStreamCallback openResourceStream, JsTTDReadBytesFromStreamCallback readBytesFromStream, JsTTDFlushAndCloseStreamCallback flushAndCloseStream, JsThreadServiceCallback threadService, JsRuntimeHandle *runtime) { return HOOK_JS_API(TTDCreateReplayRuntime(attributes, infoUri, infoUriCount, false, openResourceStream, readBytesFromStream, flushAndCloseStream, threadService, runtime)); }
static JsErrorCode WINAPI JsTTDCreateContext(JsRuntimeHandle runtime, bool useRuntimeTTDMode, JsContextRef *newContext) { return HOOK_JS_API(TTDCreateContext(runtime, useRuntimeTTDMode, newContext)); }
static JsErrorCode WINAPI JsTTDNotifyContextDestroy(JsContextRef context) { return HOOK_JS_API(TTDNotifyContextDestroy(context)); }
Expand Down
15 changes: 15 additions & 0 deletions deps/chakrashim/core/lib/Jsrt/ChakraDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ typedef unsigned __int32 uint32_t;
/// Creates a new runtime in Record Mode.
/// </summary>
/// <param name="attributes">The attributes of the runtime to be created.</param>
/// <param name="enableDebugging">A flag to enable debugging during record.</param>
/// <param name="snapInterval">The interval to wait between snapshots (measured in millis).</param>
/// <param name="snapHistoryLength">The amount of history to maintain before discarding -- measured in number of snapshots and controls how far back in time a trace can be reversed.</param>
/// <param name="openResourceStream">The <c>TTDOpenResourceStreamCallback</c> function for generating a JsTTDStreamHandle to read/write serialized data.</param>
Expand All @@ -726,6 +727,7 @@ typedef unsigned __int32 uint32_t;
CHAKRA_API
JsTTDCreateRecordRuntime(
_In_ JsRuntimeAttributes attributes,
_In_ bool enableDebugging,
_In_ size_t snapInterval,
_In_ size_t snapHistoryLength,
_In_ TTDOpenResourceStreamCallback openResourceStream,
Expand Down Expand Up @@ -1012,4 +1014,17 @@ typedef unsigned __int32 uint32_t;
_Inout_ JsTTDMoveMode* moveMode,
_Out_ int64_t* rootEventTime);

/// <summary>
/// TTD API -- may change in future versions:
/// A way for the debugger to programatically write a trace when it is at a breakpoint.
/// </summary>
/// <param name="uri">The URI that the log should be written into.</param>
/// <param name="uriLength">The length of the uri array that the host passed in for storing log info.</param>
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns>
CHAKRA_API
JsTTDDiagWriteLog(
_In_reads_(uriLength) const char* uri,
_In_ size_t uriLength
);

#endif // _CHAKRADEBUG_H_
9 changes: 2 additions & 7 deletions deps/chakrashim/core/lib/Jsrt/Jsrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,6 @@ JsErrorCode CreateRuntimeCore(_In_ JsRuntimeAttributes attributes,
return JsErrorInvalidArgument; //A runtime can only be in 1 mode
}

if(isDebug && !isReplay)
{
return JsErrorInvalidArgument; //A debug runtime also needs to be in runtime mode (and we are going to be strict about it)
}

if(isReplay && optTTUri == nullptr)
{
return JsErrorInvalidArgument; //We must have a location to store data into
Expand Down Expand Up @@ -3960,7 +3955,7 @@ CHAKRA_API JsRunSerializedScriptWithCallback(_In_ JsSerializedScriptLoadSourceCa

/////////////////////

CHAKRA_API JsTTDCreateRecordRuntime(_In_ JsRuntimeAttributes attributes, _In_ size_t snapInterval, _In_ size_t snapHistoryLength,
CHAKRA_API JsTTDCreateRecordRuntime(_In_ JsRuntimeAttributes attributes, _In_ bool enableDebugging, _In_ size_t snapInterval, _In_ size_t snapHistoryLength,
_In_ TTDOpenResourceStreamCallback openResourceStream, _In_ JsTTDWriteBytesToStreamCallback writeBytesToStream, _In_ JsTTDFlushAndCloseStreamCallback flushAndCloseStream,
_In_opt_ JsThreadServiceCallback threadService, _Out_ JsRuntimeHandle *runtime)
{
Expand All @@ -3972,7 +3967,7 @@ CHAKRA_API JsTTDCreateRecordRuntime(_In_ JsRuntimeAttributes attributes, _In_ si
return JsErrorInvalidArgument;
}

return CreateRuntimeCore(attributes, nullptr, 0, true, false, false, (uint32)snapInterval, (uint32)snapHistoryLength,
return CreateRuntimeCore(attributes, nullptr, 0, true, false, enableDebugging, (uint32)snapInterval, (uint32)snapHistoryLength,
openResourceStream, nullptr, writeBytesToStream, flushAndCloseStream,
threadService, runtime);
#endif
Expand Down
25 changes: 24 additions & 1 deletion deps/chakrashim/core/lib/Jsrt/JsrtDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ CHAKRA_API JsDiagSetStepType(
}
else if (stepType == JsDiagStepTypeStepOut)
{
jsrtDebugManager->SetResumeType(BREAKRESUMEACTION_STEP_OUT);
jsrtDebugManager->SetResumeType(BREAKRESUMEACTION_STEP_OUT);
}
else if (stepType == JsDiagStepTypeStepOver)
{
Expand Down Expand Up @@ -531,6 +531,29 @@ CHAKRA_API JsDiagSetStepType(
#endif
}

CHAKRA_API JsTTDDiagWriteLog(_In_reads_(uriLength) const char* uri, _In_ size_t uriLength)
{
#if !ENABLE_TTD
return JsErrorCategoryUsage;
#else
return ContextAPIWrapper_NoRecord<true>([&](Js::ScriptContext * scriptContext) -> JsErrorCode {

JsrtContext *currentContext = JsrtContext::GetCurrent();
JsrtRuntime* runtime = currentContext->GetRuntime();

VALIDATE_RUNTIME_IS_AT_BREAK(runtime);

JsrtDebugManager* jsrtDebugManager = runtime->GetJsrtDebugManager();

TTD::TTDebuggerSourceLocation cloc;
jsrtDebugManager->GetThreadContext()->TTDExecutionInfo->GetTimeAndPositionForDebugger(cloc);
jsrtDebugManager->GetThreadContext()->TTDLog->InnerLoopEmitLog(cloc, uri, uriLength);

return JsNoError;
});
#endif
}

CHAKRA_API JsDiagGetFunctionPosition(
_In_ JsValueRef function,
_Out_ JsValueRef *functionPosition)
Expand Down
4 changes: 3 additions & 1 deletion deps/chakrashim/core/lib/Runtime/Base/ScriptContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ namespace Js
, TTDShouldPerformRecordOrReplayAction(false)
, TTDShouldPerformRecordAction(false)
, TTDShouldPerformReplayAction(false)
, TTDShouldPerformDebuggerAction(false)
, TTDShouldPerformRecordOrReplayDebuggerAction(false)
, TTDShouldPerformRecordDebuggerAction(false)
, TTDShouldPerformReplayDebuggerAction(false)
, TTDShouldSuppressGetterInvocationForDebuggerEvaluation(false)
#endif
#ifdef REJIT_STATS
Expand Down
13 changes: 11 additions & 2 deletions deps/chakrashim/core/lib/Runtime/Base/ScriptContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,10 @@ namespace Js
bool TTDShouldPerformRecordAction;
bool TTDShouldPerformReplayAction;

bool TTDShouldPerformDebuggerAction;
bool TTDShouldPerformRecordOrReplayDebuggerAction;
bool TTDShouldPerformRecordDebuggerAction;
bool TTDShouldPerformReplayDebuggerAction;

bool TTDShouldSuppressGetterInvocationForDebuggerEvaluation;

//Check if the TTD system has been activated (and record/replay may or may not be enabled)
Expand All @@ -1166,7 +1169,13 @@ namespace Js
bool ShouldPerformReplayAction() const { return this->TTDShouldPerformReplayAction; }

//Use this to check specifically if we are in debugging mode AND this code is being run on behalf of the user application
bool ShouldPerformDebuggerAction() const { return this->TTDShouldPerformDebuggerAction; }
bool ShouldPerformRecordOrReplayDebuggerAction() const { return this->TTDShouldPerformRecordOrReplayDebuggerAction; }

//Use this to check specifically if we are in debugging record mode AND this code is being run on behalf of the user application
bool ShouldPerformRecordDebuggerAction() const { return this->TTDShouldPerformRecordDebuggerAction; }

//Use this to check specifically if we are in debugging replay mode AND this code is being run on behalf of the user application
bool ShouldPerformReplayDebuggerAction() const { return this->TTDShouldPerformReplayDebuggerAction; }

//A special check to see if we are debugging and want to suppress the execution of getters (which may be triggered by displaying values in the debugger)
bool ShouldSuppressGetterInvocationForDebuggerEvaluation() const { return this->TTDShouldSuppressGetterInvocationForDebuggerEvaluation; }
Expand Down
12 changes: 10 additions & 2 deletions deps/chakrashim/core/lib/Runtime/Base/ThreadContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@ void ThreadContext::InitHostFunctionsAndTTData(bool record, bool replay, bool de
{
TTDAssert(optTTUri == nullptr, "No URI is needed in record mode (the host explicitly provides it when writing.");

this->TTDLog->InitForTTDRecord();
this->TTDLog->InitForTTDRecord(debug);
}
else
{
Expand All @@ -2064,7 +2064,15 @@ void ThreadContext::InitHostFunctionsAndTTData(bool record, bool replay, bool de
{
#endif

this->TTDExecutionInfo = HeapNew(TTD::ExecutionInfoManager);
TTD::TTInnerLoopLastStatementInfo lsi;
TTD::TTDebuggerSourceLocation dsl;
this->TTDLog->LoadLastSourceLineInfo(lsi, dsl);

this->TTDExecutionInfo = HeapNew(TTD::ExecutionInfoManager, lsi);
if(dsl.HasValue())
{
this->TTDExecutionInfo->SetPendingTTDToTarget(dsl);
}

#if !ENABLE_TTD_DIAGNOSTICS_TRACING
}
Expand Down
6 changes: 2 additions & 4 deletions deps/chakrashim/core/lib/Runtime/Debug/DiagObjectModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1904,9 +1904,8 @@ namespace Js
Var objValue = nullptr;

#if ENABLE_TTD
bool suppressGetterForTTDebug = requestContext->GetThreadContext()->IsRuntimeInTTDMode() && requestContext->GetThreadContext()->TTDLog->ShouldDoGetterInvocationSupression();
TTD::TTModeStackAutoPopper suppressModeAutoPopper(requestContext->GetThreadContext()->TTDLog);
if(suppressGetterForTTDebug)
if(requestContext->GetThreadContext()->IsRuntimeInTTDMode())
{
suppressModeAutoPopper.PushModeAndSetToAutoPop(TTD::TTDMode::DebuggerSuppressGetter);
}
Expand Down Expand Up @@ -2258,9 +2257,8 @@ namespace Js
BOOL retValue = FALSE;

#if ENABLE_TTD
bool suppressGetterForTTDebug = scriptContext->GetThreadContext()->IsRuntimeInTTDMode() && scriptContext->GetThreadContext()->TTDLog->ShouldDoGetterInvocationSupression();
TTD::TTModeStackAutoPopper suppressModeAutoPopper(scriptContext->GetThreadContext()->TTDLog);
if(suppressGetterForTTDebug)
if(scriptContext->GetThreadContext()->IsRuntimeInTTDMode())
{
suppressModeAutoPopper.PushModeAndSetToAutoPop(TTD::TTDMode::DebuggerSuppressGetter);
}
Expand Down
8 changes: 4 additions & 4 deletions deps/chakrashim/core/lib/Runtime/Debug/TTActionEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ namespace TTD
}
END_JS_RUNTIME_CALL(ctx);

if(ctx->ShouldPerformDebuggerAction())
if(ctx->ShouldPerformReplayDebuggerAction())
{
ctx->GetThreadContext()->TTDExecutionInfo->ProcessScriptLoad(ctx, cpAction->BodyCtrId, fb, utf8SourceInfo, &se);
}
Expand Down Expand Up @@ -1160,7 +1160,7 @@ namespace TTD
{
TTDAssert(NSLogEvents::EventCompletesWithException(evt), "Why did we get a different exception");

if(executeContext->GetActiveScriptContext()->ShouldPerformDebuggerAction())
if(executeContext->GetActiveScriptContext()->ShouldPerformReplayDebuggerAction())
{
//convert to uncaught debugger exception for host
TTDebuggerSourceLocation lastLocation;
Expand All @@ -1184,7 +1184,7 @@ namespace TTD
{
TTDAssert(NSLogEvents::EventCompletesWithException(evt), "Why did we get a different exception");

if(executeContext->GetActiveScriptContext()->ShouldPerformDebuggerAction())
if(executeContext->GetActiveScriptContext()->ShouldPerformReplayDebuggerAction())
{
//convert to uncaught debugger exception for host
TTDebuggerSourceLocation lastLocation;
Expand All @@ -1200,7 +1200,7 @@ namespace TTD
}
catch(...)
{
if(executeContext->GetActiveScriptContext()->ShouldPerformDebuggerAction())
if(executeContext->GetActiveScriptContext()->ShouldPerformReplayDebuggerAction())
{
TTDebuggerSourceLocation lastLocation;
threadContext->TTDExecutionInfo->GetLastExecutedTimeAndPositionForDebugger(lastLocation);
Expand Down
Loading

0 comments on commit 31a5b2e

Please sign in to comment.