| Index: src/debug/debug-evaluate.cc
|
| diff --git a/src/debug/debug-evaluate.cc b/src/debug/debug-evaluate.cc
|
| index 9d0d38446e0a6cd27ec9bca7e614544c4026b30b..b04952f2c573ed438f44e12ee48349f5516e2d59 100644
|
| --- a/src/debug/debug-evaluate.cc
|
| +++ b/src/debug/debug-evaluate.cc
|
| @@ -77,7 +77,9 @@ MaybeHandle<Object> DebugEvaluate::Local(Isolate* isolate,
|
| MaybeHandle<Object> maybe_result = Evaluate(
|
| isolate, context_builder.outer_info(),
|
| context_builder.innermost_context(), context_extension, receiver, source);
|
| - if (!maybe_result.is_null()) context_builder.UpdateValues();
|
| + if (!maybe_result.is_null() && !FLAG_debug_eval_readonly_locals) {
|
| + context_builder.UpdateValues();
|
| + }
|
| return maybe_result;
|
| }
|
|
|
| @@ -309,7 +311,7 @@ void DebugEvaluate::ContextBuilder::MaterializeArgumentsObject(
|
|
|
|
|
| MaybeHandle<Object> DebugEvaluate::ContextBuilder::LoadFromContext(
|
| - Handle<Context> context, Handle<String> name) {
|
| + Handle<Context> context, Handle<String> name, bool* global) {
|
| static const ContextLookupFlags flags = FOLLOW_CONTEXT_CHAIN;
|
| int index;
|
| PropertyAttributes attributes;
|
| @@ -320,9 +322,13 @@ MaybeHandle<Object> DebugEvaluate::ContextBuilder::LoadFromContext(
|
| Handle<Object> value;
|
| if (index != Context::kNotFound) { // Found on context.
|
| Handle<Context> context = Handle<Context>::cast(holder);
|
| + // Do not shadow variables on the script context.
|
| + *global = context->IsScriptContext();
|
| return Handle<Object>(context->get(index), isolate_);
|
| } else { // Found on object.
|
| Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder);
|
| + // Do not shadow properties on the global object.
|
| + *global = object->IsJSGlobalObject();
|
| return JSReceiver::GetDataProperty(object, name);
|
| }
|
| }
|
| @@ -333,7 +339,13 @@ void DebugEvaluate::ContextBuilder::MaterializeContextChain(
|
| for (const Handle<String>& name : non_locals_) {
|
| HandleScope scope(isolate_);
|
| Handle<Object> value;
|
| - if (!LoadFromContext(context, name).ToHandle(&value)) continue;
|
| + bool global;
|
| + if (!LoadFromContext(context, name, &global).ToHandle(&value) || global) {
|
| + // If resolving the variable fails, skip it. If it resolves to a global
|
| + // variable, skip it as well since it's not read-only and can be resolved
|
| + // within debug-evaluate.
|
| + continue;
|
| + }
|
| JSObject::SetOwnPropertyIgnoreAttributes(target, name, value, NONE).Check();
|
| }
|
| }
|
| @@ -381,7 +393,8 @@ Handle<Context> DebugEvaluate::ContextBuilder::MaterializeReceiver(
|
| Handle<Object> receiver = isolate_->factory()->undefined_value();
|
| Handle<String> this_string = isolate_->factory()->this_string();
|
| if (this_is_non_local) {
|
| - LoadFromContext(lookup_context, this_string).ToHandle(&receiver);
|
| + bool global;
|
| + LoadFromContext(lookup_context, this_string, &global).ToHandle(&receiver);
|
| } else if (local_function->shared()->scope_info()->HasReceiver()) {
|
| receiver = handle(frame_->receiver(), isolate_);
|
| }
|
|
|