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

Commit dc759ca

Browse files
mrkmarronjackhorton
authored andcommitted
Add support for innerloop Time-Travel Debugging
1 parent 0dc4db5 commit dc759ca

14 files changed

+63
-28
lines changed

deps/chakrashim/include/v8-debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class V8_EXPORT Debug {
8686
static void ProcessDebugMessages(Isolate* isolate) {}
8787
static Local<Context> GetDebugContext(Isolate* isolate);
8888

89-
static void EnableInspector(bool enableReplayDebug = false);
89+
static void EnableInspector(bool enableTTDebug = false);
9090

9191
static void SetLiveEditEnabled(Isolate* isolate, bool enable);
9292
};

deps/chakrashim/src/inspector/js_protocol.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,13 @@
782782
"domain": "TimeTravel",
783783
"description": "TimeTravel domain exposes JavaScript time travel capabilities. It allows stepping backwards through execution.",
784784
"commands": [
785+
{
786+
"name": "writeTTDLog",
787+
"parameters": [
788+
{ "name": "uri", "type": "string", "description": "Location to write time-travel log." }
789+
],
790+
"description": "Write a TTD log to the given location"
791+
},
785792
{
786793
"name": "stepBack",
787794
"description": "Steps backwards to the previous statement."

deps/chakrashim/src/inspector/v8-debugger-agent-impl.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,11 @@ void V8DebuggerAgentImpl::reverse(ErrorString* errorString) {
668668
m_debugger->reverse();
669669
}
670670

671+
void V8DebuggerAgentImpl::writeTTDLog(ErrorString* errorString, const String16& uri) {
672+
if (!assertPaused(errorString)) return;
673+
m_debugger->writeTTDLog(uri);
674+
}
675+
671676
void V8DebuggerAgentImpl::stepBack(ErrorString* errorString) {
672677
if (!assertPaused(errorString)) return;
673678
m_scheduledDebuggerStep = StepBack;

deps/chakrashim/src/inspector/v8-debugger-agent-impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
111111
positions) override;
112112

113113
// Time travel implementations
114+
void writeTTDLog(ErrorString*, const String16&);
114115
void reverse(ErrorString*);
115116
void stepBack(ErrorString*);
116117

deps/chakrashim/src/inspector/v8-debugger.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ void V8Debugger::clearStepping() {
249249
JsDiagSetStepType(JsDiagStepTypeContinue);
250250
}
251251

252+
void V8Debugger::writeTTDLog(const String16& uri) {
253+
DCHECK(isPaused());
254+
auto sval = uri.utf8();
255+
JsTTDDiagWriteLog(sval.c_str(), sval.length());
256+
}
257+
252258
void V8Debugger::reverse() {
253259
DCHECK(isPaused());
254260
JsDiagSetStepType(JsDiagStepTypeReverseContinue);

deps/chakrashim/src/inspector/v8-debugger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class V8Debugger {
5959
void clearStepping();
6060

6161
// Time travel
62+
void writeTTDLog(const String16& uri);
6263
void reverse();
6364
void stepBack();
6465

deps/chakrashim/src/inspector/v8-timetravel-agent-impl.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ bool V8TimeTravelAgentImpl::checkEnabled(ErrorString* errorString) {
2828
}
2929

3030
bool V8TimeTravelAgentImpl::enabled() {
31-
return jsrt::Inspector::IsReplayDebugEnabled();
31+
return jsrt::Inspector::IsTTDebugEnabled();
32+
}
33+
34+
void V8TimeTravelAgentImpl::writeTTDLog(ErrorString* errorString, const String16& uri) {
35+
if(!checkEnabled(errorString)) {
36+
return;
37+
}
38+
39+
m_session->debuggerAgent()->writeTTDLog(errorString, uri);
3240
}
3341

3442
void V8TimeTravelAgentImpl::reverse(ErrorString* errorString) {

deps/chakrashim/src/inspector/v8-timetravel-agent-impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class V8TimeTravelAgentImpl : public protocol::TimeTravel::Backend {
2626
~V8TimeTravelAgentImpl() override;
2727

2828
// Part of the protocol.
29+
void writeTTDLog(ErrorString*, const String16&) override;
2930
void reverse(ErrorString*) override;
3031
void stepBack(ErrorString*) override;
3132

deps/chakrashim/src/jsrtinspector.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
namespace v8 {
2828
extern THREAD_LOCAL bool g_EnableInspector;
29-
extern THREAD_LOCAL bool g_EnableReplayDebug;
29+
extern THREAD_LOCAL bool g_EnableTTDebug;
3030
}
3131

3232
namespace jsrt {
@@ -160,8 +160,8 @@ bool Inspector::IsInspectorEnabled() {
160160
return v8::g_EnableInspector;
161161
}
162162

163-
bool Inspector::IsReplayDebugEnabled() {
164-
return v8::g_EnableReplayDebug;
163+
bool Inspector::IsTTDebugEnabled() {
164+
return v8::g_EnableTTDebug;
165165
}
166166

167167
void Inspector::StartDebugging(JsRuntimeHandle runtime) {

deps/chakrashim/src/jsrtinspector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class InspectorBreakQueue;
3030
class Inspector {
3131
public:
3232
static bool IsInspectorEnabled();
33-
static bool IsReplayDebugEnabled();
33+
static bool IsTTDebugEnabled();
3434
static void StartDebugging(JsRuntimeHandle runtime);
3535
static void RequestAsyncBreak(JsRuntimeHandle runtime,
3636
v8::InterruptCallback callback,

0 commit comments

Comments
 (0)