Skip to content

Conversation

@obastemur
Copy link
Collaborator

@obastemur obastemur commented Nov 18, 2016

In addition to Debugger support, this PR also brings the required base for compiling code with script profiler.

Fixes #2058

@obastemur
Copy link
Collaborator Author

/cc @agarwal-sandeep

function Script1Func3() { scriptFunc3(); } \
function setFunc2(func) { scriptFunc2 = func; } \
function setFunc3(func) { scriptFunc3 = func; }",
"samethread", "Script1.js");
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Script1.js" [](start = 16, length = 12)

Why remove this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When file name is given, LoadScript is trying to find the full path on xplat and that fails

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then we should fix WScriptJsrt::LoadScript?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not necessarily. The comment there says; // No fileName provided (WScript.LoadScript()), use dummy "script.js" IMHO the intention there is clean. This particular script file doesn't do that

Copy link
Collaborator

Choose a reason for hiding this comment

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

In debugging it makes a difference as when giving the source we will give Unknown script, you can try that by using debugger annotation dumpSourceList().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Make sense however, for this particular test, it doesn't make any difference. Opening a GH issue to track this instead.

#if defined(ENABLE_SCRIPT_PROFILING)
if (attach)
{
this->RegisterDebugThunk();
Copy link
Collaborator

Choose a reason for hiding this comment

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

RegisterDebugThunk [](start = 18, length = 18)

We use ProfileThunk under debugger and its set in this function, if we are not calling this where are we setting the thunk?

<default>
<compile-flags>-debuglaunch -dbgbaseline:JsDiagGetFunctionPosition.js.dbg.baseline</compile-flags>
<files>JsDiagGetFunctionPosition.js</files>
<!-- xplat-todo: enable back [not supported] -->
Copy link
Collaborator

Choose a reason for hiding this comment

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

not supported [](start = 36, length = 13)

Why? JsDiagGetFunctionPosition doesn't seems to have any xplat specific code? and it is used in node-chakracore debugging which seems to be working fine on xplat.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why? JsDiagGetFunctionPosition doesn't seems to have any xplat specific code? and it is used in node-chakracore debugging which seems to be working fine on xplat.

@agarwal-sandeep Intl is not enabled on xplat.

@obastemur
Copy link
Collaborator Author

@agarwal-sandeep ping

#define DefaultDeferredParsingThunk Js::JavascriptFunction::DeferredParsingThunk
#ifdef ENABLE_SCRIPT_PROFILING
#if defined(ENABLE_SCRIPT_PROFILING) || defined(ENABLE_SCRIPT_DEBUGGING)
#define ProfileDeferredParsingThunk Js::ScriptContext::ProfileModeDeferredParsingThunk
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we use ProfileDeferredParsingThunk in debugging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, the method itself doesn't receive any call but I've fixed it's impl. for xplat instead of adding even more ifdef checks etc.

#endif
{
return true;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whole if should be under #ifdef _WN32, we don't want to retrun true without setting sourceName. and in JsRT there is no sourceName support.

__finally
#endif
{
threadContext->GetDebugManager()->GetDebuggingFlags()->SetIsBuiltInWrapperPresent(isOrigWrapperPresent);
Copy link
Collaborator

Choose a reason for hiding this comment

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

threadContext->GetDebugManager()->GetDebuggingFlags()->SetIsBuiltInWrapperPresent(isOrigWrapperPresent); [](start = 24, length = 104)

How will this work with DISABLE_SEH?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@agarwal-sandeep We don't have SEH on xplat. Can you please explain more?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean if we don't have try finally and CallFunction throws how will we make sure SetIsBuiltInWrapperPresent is restored?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If it throws something that requires SEH in place, we can't restore on xplat.

Choose a reason for hiding this comment

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

Please change these __try/__finally to use TryFinally function https://github.com/Microsoft/ChakraCore/blob/master/lib/Common/CommonPal.h#L603.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jianchun That PAL interface is subject to be removal. No libunwind / seh etc..

Choose a reason for hiding this comment

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

@obastemur The TryFinally function I mentioned has nothing to do with libunwind / seh, and why "subject to removal"?

Choose a reason for hiding this comment

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

@obastemur This was the TryFinally comment not addressed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nevermind; I was referring to something totally unrelated and this one is update to one we have in CommonPAL

@agarwal-sandeep
Copy link
Collaborator

Have we run crawler and exprgen with this change? We should do private testing before checking in this change.

@obastemur
Copy link
Collaborator Author

Have we run crawler and exprgen with this change? We should do private testing before checking in this change.

@agarwal-sandeep I tried not to change anything for non xplat. Could you please point out the places might affect Windows?

@agarwal-sandeep
Copy link
Collaborator

I understand the sentiment that we haven't touched the code for windows but testing a change before it goes in doesn't harm. plus we have a single click test system at http://onecirro/ where you just provide a private and it does the rest.

import os

def print_usage():
print "usage: jstoc.py <js file path> <variable name>"
Copy link
Collaborator

Choose a reason for hiding this comment

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

usage: jstoc.py [](start = 11, length = 15)

Output some more help message about what this script does?

#ifdef _WIN32
// dep: TIME_ZONE_INFORMATION, DaylightTimeHelper, Windows.Globalization
#define ENABLE_GLOBALIZATION
// dep: IDebugDocumentContext
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this comment together with ENABLE_SCRIPT_DEBUGGING?

@obastemur
Copy link
Collaborator Author

Also tested with full project. Test/Debug ..

@Oceanswave
Copy link
Contributor

ping

@obastemur obastemur force-pushed the debug branch 3 times, most recently from 5ac66cf to c933dc4 Compare December 21, 2016 09:45
@obastemur
Copy link
Collaborator Author

@agarwal-sandeep I got the Crawler result and looks like that one is also good.

@obastemur
Copy link
Collaborator Author

ping @jianchun @agarwal-sandeep

JavascriptMethod origEntryPoint = function->GetFunctionInfo()->GetOriginalEntryPoint();

__try
__TRY_FINALLY_BEGIN // SEH is not guaranteed, see the implementation
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add the test case for returnValue to DebuggerCommon

function foo1() {
return 1;
}
function foo2() {
return 2;
}
function foo() {
var x = 1; /bp:resume('step_over');resume('step_over');locals()/
return foo1() + foo2();
}
foo();
WScript.Attach(foo);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@agarwal-sandeep thanks for the test case, added under the DebuggerCommon. Testing on CI now, lets see how Windows testing is going to react to my baseline file line-endings

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@agarwal-sandeep checked other tests we have and saw returnedvaluetests1 is actually doing the same. No reason to introduce this extra test ?

@obastemur obastemur force-pushed the debug branch 2 times, most recently from 356fa3e to 0113657 Compare December 21, 2016 23:28
JavascriptMethod origEntryPoint = function->GetFunctionInfo()->GetOriginalEntryPoint();

__try
__TRY_FINALLY_BEGIN // SEH is not guaranteed, see the implementation

Choose a reason for hiding this comment

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

__TRY_FINALLY_BEGIN // SEH is not guaranteed, see the implementation [](start = 8, length = 68)

I wonder if I misunderstand something. Does this code need sth. special from SEH? Why do you mention SEH and try to keep __try/__finally on Windows?

Copy link
Collaborator Author

@obastemur obastemur Dec 21, 2016

Choose a reason for hiding this comment

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

@jianchun I also didn't observe any SEH specific code after reading to code again.

2 things I've been trying to to with this PR; 1) do not update any Windows specific code unless it is a bug etc. 2) generally update TRY/FINALLY code to macro.

The second one was out of the scope and we hadn't reach to a consensus there. Updating this implementation very close to original while adding a notice. In case, in the future, if someone expects this part of the code handling SEH, the comment above should be enough to keep the intentions away. In the meantime, adding a macro for future use.

Choose a reason for hiding this comment

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

OK, no more issues from me. I haven't reviewed other part, assuming @agarwal-sandeep did.

@obastemur obastemur force-pushed the debug branch 4 times, most recently from d2e0406 to e321447 Compare December 22, 2016 12:07
In addition to Debugger support, this PR also brings the required base for compiling code with script profiler.
@agarwal-sandeep
Copy link
Collaborator

@obastemur @jianchun I have reviewed debugger specific changes and they look good to me

@obastemur
Copy link
Collaborator Author

@agarwal-sandeep @jianchun @ThomsonTan Thanks for the reviews.

@Oceanswave Thanks for opening the issue and follow ups!

@chakrabot chakrabot merged commit 649f3d2 into chakra-core:master Dec 23, 2016
chakrabot pushed a commit that referenced this pull request Dec 23, 2016
Merge pull request #2056 from obastemur:debug

In addition to Debugger support, this PR also brings the required base for compiling code with script profiler.

Fixes #2058
@Oceanswave
Copy link
Contributor

@obastemur thank you for the hard work and sticking through. Greatly appreciate the effort.

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.

7 participants