Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report script loads from eval when debugging #3391

Merged
merged 1 commit into from
Jul 25, 2017

Conversation

kfarnung
Copy link
Contributor

Added code to report the load of scripts on eval in order to support
stepping into the eval code.

JsrtDebugUtils::AddFileNameOrScriptTypeToObject(eventDataObject, utf8SourceInfo);
JsrtDebugUtils::AddLineCountToObject(eventDataObject, utf8SourceInfo);
JsrtDebugUtils::AddPropertyToObject(eventDataObject, JsrtDebugPropertyId::sourceLength, utf8SourceInfo->GetCchLength(), utf8SourceInfo->GetScriptContext());

Copy link
Contributor

Choose a reason for hiding this comment

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

I see this operations in order and also appear on the other functions in this file. Could you refactor to one and call in the other functions as well?

@@ -60,11 +60,14 @@ namespace Js

HostDebugContext * GetHostDebugContext() const { return hostDebugContext; }

bool GetIsReparsingSource() { return this->isReparsingSource; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

use const

@@ -141,6 +142,23 @@ namespace Js

HRESULT DebugContext::RundownSourcesAndReparse(bool shouldPerformSourceRundown, bool shouldReparseFunctions)
{
struct AutoRestore
Copy link
Collaborator

Choose a reason for hiding this comment

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

AutoRestore [](start = 15, length = 11)

Rename to AutoRestoreIsReparsingSource

AutoRestore(DebugContext* debugContext)
:debugContext(debugContext)
{
this->debugContext->isReparsingSource = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this->debugContext->isReparsingSource = true; [](start = 15, length = 46)

We should restrict this to only when shouldReparseFunctions is true. Not needed during PerformSourceRundown

{
JsrtDebugEventObject debugEventObject(scriptContext);
Js::DynamicObject* eventDataObject = debugEventObject.GetEventDataObject();
JsrtDebugUtils::AddSourceMetadataToObject(eventDataObject, utf8SourceInfo);
Copy link
Collaborator

Choose a reason for hiding this comment

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

AddSourceMetadataToObject [](start = 28, length = 25)

When ever we use AddSourceMetadataToObject we also add Scriptid. Move the HasDebugDocument check and AddScriptIdToObject inside AddSourceMetadataToObject

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the case here, but not elsewhere in the file. That's why I kept is separate.

@@ -154,6 +154,21 @@ HRESULT JsrtDebugManager::DbgRegisterFunction(Js::ScriptContext* scriptContext,
{
utf8SourceInfo->SetDebugDocument(debugDocument);
}

if (this->debugEventCallback != nullptr && !scriptContext->GetDebugContext()->GetIsReparsingSource())
Copy link
Collaborator

Choose a reason for hiding this comment

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

!scriptContext->GetDebugContext()->GetIsReparsingSource()) [](start = 51, length = 58)

Add a comment here explaining why this check

@@ -154,6 +154,18 @@ HRESULT JsrtDebugManager::DbgRegisterFunction(Js::ScriptContext* scriptContext,
{
utf8SourceInfo->SetDebugDocument(debugDocument);
}

// Only raise an event in the case where we have a registered callback and we are not
// currently in the middle of a source reparse (e.g. attaching/detaching).
Copy link
Collaborator

Choose a reason for hiding this comment

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

middle of a source reparse (e.g. attaching/detaching). [](start = 28, length = 54)

Please explain why we are adding isParsingSource check, will help somebody understand the code/logic when we are not around.

@agarwal-sandeep
Copy link
Collaborator

:shipit:

* Added code to report the load of scripts on eval in order to support
  stepping into the eval code.
* Added protections to prevent re-entrancy when reparsing scripts
* Updated debugger test baselines
@chakrabot chakrabot merged commit 1c2d259 into chakra-core:release/1.7 Jul 25, 2017
chakrabot pushed a commit that referenced this pull request Jul 25, 2017
Merge pull request #3391 from kfarnung:evaldebug

* Added code to report the load of scripts on eval in order to support
  stepping into the eval code.
* Added protections to prevent re-entrancy when reparsing scripts
* Updated debugger test baselines
chakrabot pushed a commit that referenced this pull request Jul 25, 2017
…en debugging

Merge pull request #3391 from kfarnung:evaldebug

* Added code to report the load of scripts on eval in order to support
  stepping into the eval code.
* Added protections to prevent re-entrancy when reparsing scripts
* Updated debugger test baselines
@kfarnung kfarnung deleted the evaldebug branch July 25, 2017 19:11
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.

5 participants