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

inspector: enable TimeTravel support #244

Merged
merged 2 commits into from
May 17, 2017
Merged

inspector: enable TimeTravel support #244

merged 2 commits into from
May 17, 2017

Conversation

kfarnung
Copy link
Contributor

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

chakrashim, inspector

@kfarnung
Copy link
Contributor Author

kfarnung commented May 15, 2017

CI: https://ci.nodejs.org/job/chakracore-test-pull-request/33/ - PASSED

Edit: With the way we currently handle node tests in node-chakracore, the test passes will always end with "UNSTABLE" status. For the purposes of CI we consider that to be a passing run.

@kfarnung
Copy link
Contributor Author

kfarnung commented May 15, 2017

Resolves #228

src/node.cc Outdated
// Start debug agent when argv has --debug
if (debug_enabled)
if (debug_options.debugger_enabled() || debug_options.inspector_enabled())
Copy link
Member

Choose a reason for hiding this comment

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

debug_options.debugger_enabled() [](start = 6, length = 32)

This is no longer present in upstream. See if you can get rid of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did we take that change yet or is the hope that I just eliminate it now in preparation for that change?

Copy link
Member

Choose a reason for hiding this comment

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

I am planning to do it in a day or 2. So yeah, consider it as prep work.


In reply to: 116625440 [](ancestors = 116625440)

@@ -28,7 +31,9 @@ bool V8InspectorSession::canDispatchMethod(const StringView& method) {
stringViewStartsWith(method,
protocol::Console::Metainfo::commandPrefix) ||
stringViewStartsWith(method,
protocol::Schema::Metainfo::commandPrefix);
protocol::Schema::Metainfo::commandPrefix) ||
stringViewStartsWith(method,
Copy link
Member

Choose a reason for hiding this comment

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

stringViewStartsWith [](start = 9, length = 20)

not too familiar with this code, but does this have to be inside TTT if-condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it and decided not to mess with the dispatcher dynamically. The TTD dispatcher will be wired up, but any attempts to use it will return an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we already have code under ENABLE_TTD_NODE might be good to have all this under same


In reply to: 116629150 [](ancestors = 116629150)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are currently no usages of ENABLE_TTD_NODE anywhere in chakrashim. I even see one instance where it's present, but commented out, so I suspect it's not possible.

m_timeTravelAgent = wrapUnique(new V8TimeTravelAgentImpl(
this, this, agentState(protocol::TimeTravel::Metainfo::domainName)));
protocol::TimeTravel::Dispatcher::wire(&m_dispatcher,
m_timeTravelAgent.get());
Copy link
Member

Choose a reason for hiding this comment

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

same here. Should they be only if TTT is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it and decided not to mess with the dispatcher dynamically. The TTD dispatcher will be wired up, but any attempts to use it will return an error.

m_debugger->reverse();
}

void V8DebuggerAgentImpl::stepBack(ErrorString* errorString) {
Copy link
Member

Choose a reason for hiding this comment

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

stepBack [](start = 26, length = 8)

should we add unit test or open an issue to add later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's already the list in #227.

@kfarnung
Copy link
Contributor Author

@agarwal-sandeep Can you take a look when you have a few minutes?

@@ -91,7 +91,7 @@ class V8_EXPORT Debug {
static Local<Context> GetDebugContext(Isolate* isolate);

static void EnableDebug();
static void EnableInspector();
static void EnableInspector(bool enableReplayDebug = false);
Copy link
Contributor

Choose a reason for hiding this comment

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

EnableInspector [](start = 14, length = 15)

This function is not in deps/v8/include/v8-debug.h generally we keep V8 header same between v8 and chakrashim. Is this specific to chakrashim?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I could see there was no EnableDebug function defined either, so I didn't worry about it. The calls to both functions were gated behind CHAKRACORE conditions.

https://github.com/nodejs/node-chakracore/search?utf8=%E2%9C%93&q=enabledebug&type=

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to remember that it was present when I implemented debugger support. If not I am fine with adding new function.

Copy link
Contributor Author

@kfarnung kfarnung May 16, 2017

Choose a reason for hiding this comment

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

If it was present, it no longer is. Looking at the usage, I suspect we added it as a workaround.

EDIT: Seems like it was added in 99d6392 as part of the debugger enablement work.

@@ -171,7 +175,14 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
using DebugServerBreakpointToBreakpointIdAndSourceMap =
protocol::HashMap<String16, std::pair<String16, BreakpointSource>>;

enum DebuggerStep { NoStep = 0, StepInto, StepOver, StepOut };
enum DebuggerStep {
Copy link
Contributor

Choose a reason for hiding this comment

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

DebuggerStep [](start = 7, length = 12)

Good to keep this in same order as JsDiagStepType

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 streams don't ever cross currently, but I've updated it.

#include "src/inspector/v8-inspector-session-impl.h"
#include "src/inspector/v8-debugger-agent-impl.h"

#include "src/jsrtinspector.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove extra empty lines


bool V8TimeTravelAgentImpl::checkEnabled(ErrorString* errorString) {
if (enabled()) {
return true;
Copy link
Contributor

@agarwal-sandeep agarwal-sandeep May 16, 2017

Choose a reason for hiding this comment

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

return true; [](start = 4, length = 12)

Initialize errorString to nullptr for this case? Same for reverse and stepBack functions

Copy link
Contributor Author

@kfarnung kfarnung May 16, 2017

Choose a reason for hiding this comment

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

The pattern elsewhere is to only touch the variable in cases where there's an error. This was consistent with the state of the V8 code at the time it was forked.

@agarwal-sandeep
Copy link
Contributor

Beside some general changes the code looks good to me. Please incorporate feedback and merge if CI is clean.

@kfarnung kfarnung force-pushed the ttd branch 2 times, most recently from 90d839e to 828656c Compare May 16, 2017 19:26
If the debugger attempts to set a breakpoint that gets resolved to an
existing breakpoint, then when we go to clear the same breakpoint will
be removed twice. On the second removal the API returns
JsErrorInvalidArgument which is a no-op for this function.

PR-URL: nodejs#244
Reviewed-By: Kunal Pathak <Kunal.Pathak@microsoft.com>
Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
* Added the TimeTravel domain and wired it up
* Debuggers can now detect time travel mode by looking at the
  available domains.

PR-URL: nodejs#244
Reviewed-By: Kunal Pathak <Kunal.Pathak@microsoft.com>
Reviewed-By: Sandeep Agarwal <saagarwa@microsoft.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants