From 97002d0ca0d06f7d26bd9810d4be49b60fe28a47 Mon Sep 17 00:00:00 2001 From: Kyle Farnung Date: Mon, 1 May 2017 17:35:50 -0700 Subject: [PATCH] inspector: fixing lambda call frames PR-URL: https://github.com/nodejs/node-chakracore/pull/230 Reviewed-By: Sandeep Agarwal Reviewed-By: Hitesh Kanwathirtha Call frames for a lambda function may not include a "this" object. In those cases we were omitting the "this" member, but that causes a validation failure and returns an empty call stack. --- deps/chakrashim/src/jsrtinspectorhelpers.cc | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/deps/chakrashim/src/jsrtinspectorhelpers.cc b/deps/chakrashim/src/jsrtinspectorhelpers.cc index 325a373b24f..1bf415f7880 100644 --- a/deps/chakrashim/src/jsrtinspectorhelpers.cc +++ b/deps/chakrashim/src/jsrtinspectorhelpers.cc @@ -480,26 +480,31 @@ namespace jsrt { "thisObject", &hasProperty)); - if (hasProperty) - { + JsValueRef thisObj = nullptr; + + if (hasProperty) { JsValueRef thisObject = nullptr; CHAKRA_VERIFY_NOERROR(InspectorHelpers::GetProperty(stackProperties, "thisObject", &thisObject)); - - JsValueRef thisObj = nullptr; WrapObject(thisObject, &thisObj); - CHAKRA_VERIFY_NOERROR(InspectorHelpers::SetProperty(wrappedObj, - "this", - thisObj)); + } else { + // The protocol requires a "this" member, so create an undefined object + // to return. + CHAKRA_VERIFY_NOERROR(JsCreateObject(&thisObj)); + CHAKRA_VERIFY_NOERROR(InspectorHelpers::SetStringProperty( + thisObj, "type", "undefined")); } + + CHAKRA_VERIFY_NOERROR(InspectorHelpers::SetProperty(wrappedObj, + "this", + thisObj)); CHAKRA_VERIFY_NOERROR(InspectorHelpers::HasProperty(stackProperties, "returnValue", &hasProperty)); - if (hasProperty) - { + if (hasProperty) { JsValueRef returnObj = nullptr; CHAKRA_VERIFY_NOERROR(InspectorHelpers::GetProperty(stackProperties, "returnValue",