Re: [v8-users] Re: Debugging wrapped C++ object
On Thu, May 10, 2018 at 11:18 AM, Anoop R. S.wrote: > Thank you for the reply, Ben. >> >> Instead of v8::IndexedPropertyHandlerConfiguration, you may >> want to use v8::NamedPropertyHandlerConfiguration. > > I am already using it. What I noticed is that, when I run the code without > devtools debugging, only the callback GenericNamedPropertyGetterCallback, > (of NamedPropertyHandlerConfiguration) is invoked. > IndexedPropertyHandlerConfiguration callbacks are not called even though > they are implemented. But when I run the code through the debugger, I can > see the IndexedPropertyHandlerConfiguration callback is called and whatever > I am populating inside it, is visible in the debugger. After that, > GenericNamedPropertyGetterCallback, (of NamedPropertyHandlerConfiguration) > is called, for resolving the names which I am putting into the array in > GenericNamedPropertyGetterCallback implementation. Just to make sure we're on the same page: IndexedPropertyHandlerConfiguration is for number-as-key operations, i.e., obj[42]; obj.x and obj['x'] on the other hand are named property operations. What the debugger does is (mostly) equivalent to `Object.keys(obj)` and `Object.getOwnPropertyNames(obj)`, operations that include enumerable element indices _and_ enumerable named properties in their output. That's why you observe your IndexedPropertyEnumeratorCallback getting invoked. It's asked to list the object's enumerable element indices. Interceptor callbacks need to conform to some fairly strict semantics (that isn't always explained well in v8.h), otherwise you can get unintuitive behavior. If unsure, take a look at test/cctest/test-api-interceptors.cc. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Re: Debugging wrapped C++ object
Thank you for the reply, Ben. > Instead of v8::IndexedPropertyHandlerConfiguration, you may > want to use v8::NamedPropertyHandlerConfiguration. > I am already using it. What I noticed is that, when I run the code without devtools debugging, only the callback *GenericNamedPropertyGetterCallback, (*of *NamedPropertyHandlerConfiguration**) *is invoked. *IndexedPropertyHandlerConfiguration *callbacks are not called even though they are implemented. But when I run the code through the debugger, I can see the *IndexedPropertyHandlerConfiguration *callback is called and whatever I am populating inside it, is visible in the debugger. After that, *GenericNamedPropertyGetterCallback, (*of *NamedPropertyHandlerConfiguration**) *is called, for resolving the names which I am putting into the array in *GenericNamedPropertyGetterCallback *implementation. Based on this behaviour, I would assume that *evaluateOnCallFrame *(similar behaviour is shown by the message *Runtime.getProperties* also, which I think fetches the variable values for the overlay display) treats the variable as an indexed property. regards, Anoop R. S. On Thursday, 10 May 2018 13:10:03 UTC+5:30, Ben Noordhuis wrote: > > On Thu, May 10, 2018 at 8:42 AM, Anoop R. S.> wrote: > > Ok. I figured out that if v8::IndexedPropertyHandlerConfiguration is > set, > > and IndexedPropertyEnumeratorCallback is implemented, I can configure > what > > is displayed on mouse over action (Debugger.evaluateOnCallFrame is > passed > > from devtools on doing that operation.) > > > > The implementation is provided below. > > void IndexedPropertyEnumeratorCallbackFunction( > > const v8::PropertyCallbackInfo& p_callbackInfo) > > { > > v8::Local IndexArray = > > v8::Array::New(p_callbackInfo.GetIsolate(), 2); > > IndexArray->Set( > > v8::Integer::New(p_callbackInfo.GetIsolate(), 0), > > v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"x")); > > IndexArray->Set( > > v8::Integer::New(p_callbackInfo.GetIsolate(), 1), > > v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"y")); > > p_callbackInfo.GetReturnValue().Set(IndexArray); > > } > > > > From reading the embedder's guide, my understanding is that > >> > >> indexed property interceptors - called when accessing indexed > properties. > >> An example of this, in a browser environment, is > document.forms.elements[0]. > > > > > > Why is it called on evaluateOnCallFrame action? Also, I tried with other > > callback s of v8::IndexedPropertyHandlerConfiguration, but they are not > > called. Can I know why? Also, since the signature of callback is as > below : > > > > void (*IndexedPropertyEnumeratorCallback)( const > > PropertyCallbackInfo& info); > > > > I can set only arrays into the result and nothing else. > > I am not an expert in v8, hence these questions. Please let me know > about > > it/ point me to some documentation regarding this. > > > > regards, > > Anoop R. S. > > IndexedPropertyEnumeratorCallback - is called for Object.keys()-like > operations; i.e., to list the enumerable properties of the object but > not non-enumerable or prototype properties. The 'Indexed' refers to > the fact that it's intended for numeric keys, i.e., array-like > objects. Instead of v8::IndexedPropertyHandlerConfiguration, you may > want to use v8::NamedPropertyHandlerConfiguration. > > evaluateOnCallFrame - V8 cannot know whether your callback has any > side effects (it could create objects, call into JS code, etc.), hence > it evaluates it as if it were a snippet of regular JS code. Newer > versions of V8 let you register callbacks with kHasNoSideEffect but as > far as I know that has no effect (hah!) on whether or not > evaluateOnCallFrame is used. Maybe in the future. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Re: Debugging wrapped C++ object
Thank you for the reply, Ben. > Instead of v8::IndexedPropertyHandlerConfiguration, you may > want to use v8::NamedPropertyHandlerConfiguration. > I am already using it. What I noticed is that, when I run the code without devtools debugging, only the callback *GenericNamedPropertyGetterCallback, (*of *NamedPropertyHandlerConfiguration**) *is invoked. *IndexedPropertyHandlerConfiguration *callbacks are not called even though they are implemented. But when I run the code through the debugger, I can see the *IndexedPropertyHandlerConfiguration *callback is called and whatever I am populating inside it, is visible in the debugger. After that, *GenericNamedPropertyGetterCallback, (*of *NamedPropertyHandlerConfiguration**) *is called, for resolving the names which I am putting into the array in *GenericNamedPropertyGetterCallback *implementation. Based on this behaviour, I would assume that *evaluateOnCallFrame *(similar behaviour is shown by the message *Runtime.getProperties* also, which I think fetches the variable values for the overlay display) treats the variable as an indexed property. regards, Anoop R. S. On Thursday, 10 May 2018 13:10:03 UTC+5:30, Ben Noordhuis wrote: > > On Thu, May 10, 2018 at 8:42 AM, Anoop R. S.> wrote: > > Ok. I figured out that if v8::IndexedPropertyHandlerConfiguration is > set, > > and IndexedPropertyEnumeratorCallback is implemented, I can configure > what > > is displayed on mouse over action (Debugger.evaluateOnCallFrame is > passed > > from devtools on doing that operation.) > > > > The implementation is provided below. > > void IndexedPropertyEnumeratorCallbackFunction( > > const v8::PropertyCallbackInfo& p_callbackInfo) > > { > > v8::Local IndexArray = > > v8::Array::New(p_callbackInfo.GetIsolate(), 2); > > IndexArray->Set( > > v8::Integer::New(p_callbackInfo.GetIsolate(), 0), > > v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"x")); > > IndexArray->Set( > > v8::Integer::New(p_callbackInfo.GetIsolate(), 1), > > v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"y")); > > p_callbackInfo.GetReturnValue().Set(IndexArray); > > } > > > > From reading the embedder's guide, my understanding is that > >> > >> indexed property interceptors - called when accessing indexed > properties. > >> An example of this, in a browser environment, is > document.forms.elements[0]. > > > > > > Why is it called on evaluateOnCallFrame action? Also, I tried with other > > callback s of v8::IndexedPropertyHandlerConfiguration, but they are not > > called. Can I know why? Also, since the signature of callback is as > below : > > > > void (*IndexedPropertyEnumeratorCallback)( const > > PropertyCallbackInfo& info); > > > > I can set only arrays into the result and nothing else. > > I am not an expert in v8, hence these questions. Please let me know > about > > it/ point me to some documentation regarding this. > > > > regards, > > Anoop R. S. > > IndexedPropertyEnumeratorCallback - is called for Object.keys()-like > operations; i.e., to list the enumerable properties of the object but > not non-enumerable or prototype properties. The 'Indexed' refers to > the fact that it's intended for numeric keys, i.e., array-like > objects. Instead of v8::IndexedPropertyHandlerConfiguration, you may > want to use v8::NamedPropertyHandlerConfiguration. > > evaluateOnCallFrame - V8 cannot know whether your callback has any > side effects (it could create objects, call into JS code, etc.), hence > it evaluates it as if it were a snippet of regular JS code. Newer > versions of V8 let you register callbacks with kHasNoSideEffect but as > far as I know that has no effect (hah!) on whether or not > evaluateOnCallFrame is used. Maybe in the future. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Re: Debugging wrapped C++ object
Thank you for the reply, Ben. > Instead of v8::IndexedPropertyHandlerConfiguration, you may > want to use v8::NamedPropertyHandlerConfiguration. > I am already using it. What I noticed is that, when I run the code without devtools debugging, only the callback *GenericNamedPropertyGetterCallback *is invoked. *IndexedPropertyHandlerConfiguration *callbacks are not called even though they are implemented. But when I run the code through the debugger, I can see the *IndexedPropertyHandlerConfiguration *callback is called and whatever I am populating inside it, is visible in the debugger. Based on the behaviour, I would assume that *evaluateOnCallFrame (*similar behaviour is shown by the message *Runtime.getProperties* also, which I think fetches the variable values for the overlay display*) *treats the variable as an indexed property. On Thursday, 10 May 2018 13:10:03 UTC+5:30, Ben Noordhuis wrote: > > On Thu, May 10, 2018 at 8:42 AM, Anoop R. S.> wrote: > > Ok. I figured out that if v8::IndexedPropertyHandlerConfiguration is > set, > > and IndexedPropertyEnumeratorCallback is implemented, I can configure > what > > is displayed on mouse over action (Debugger.evaluateOnCallFrame is > passed > > from devtools on doing that operation.) > > > > The implementation is provided below. > > void IndexedPropertyEnumeratorCallbackFunction( > > const v8::PropertyCallbackInfo& p_callbackInfo) > > { > > v8::Local IndexArray = > > v8::Array::New(p_callbackInfo.GetIsolate(), 2); > > IndexArray->Set( > > v8::Integer::New(p_callbackInfo.GetIsolate(), 0), > > v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"x")); > > IndexArray->Set( > > v8::Integer::New(p_callbackInfo.GetIsolate(), 1), > > v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"y")); > > p_callbackInfo.GetReturnValue().Set(IndexArray); > > } > > > > From reading the embedder's guide, my understanding is that > >> > >> indexed property interceptors - called when accessing indexed > properties. > >> An example of this, in a browser environment, is > document.forms.elements[0]. > > > > > > Why is it called on evaluateOnCallFrame action? Also, I tried with other > > callback s of v8::IndexedPropertyHandlerConfiguration, but they are not > > called. Can I know why? Also, since the signature of callback is as > below : > > > > void (*IndexedPropertyEnumeratorCallback)( const > > PropertyCallbackInfo& info); > > > > I can set only arrays into the result and nothing else. > > I am not an expert in v8, hence these questions. Please let me know > about > > it/ point me to some documentation regarding this. > > > > regards, > > Anoop R. S. > > IndexedPropertyEnumeratorCallback - is called for Object.keys()-like > operations; i.e., to list the enumerable properties of the object but > not non-enumerable or prototype properties. The 'Indexed' refers to > the fact that it's intended for numeric keys, i.e., array-like > objects. Instead of v8::IndexedPropertyHandlerConfiguration, you may > want to use v8::NamedPropertyHandlerConfiguration. > > evaluateOnCallFrame - V8 cannot know whether your callback has any > side effects (it could create objects, call into JS code, etc.), hence > it evaluates it as if it were a snippet of regular JS code. Newer > versions of V8 let you register callbacks with kHasNoSideEffect but as > far as I know that has no effect (hah!) on whether or not > evaluateOnCallFrame is used. Maybe in the future. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] Re: Debugging wrapped C++ object
On Thu, May 10, 2018 at 8:42 AM, Anoop R. S.wrote: > Ok. I figured out that if v8::IndexedPropertyHandlerConfiguration is set, > and IndexedPropertyEnumeratorCallback is implemented, I can configure what > is displayed on mouse over action (Debugger.evaluateOnCallFrame is passed > from devtools on doing that operation.) > > The implementation is provided below. > void IndexedPropertyEnumeratorCallbackFunction( > const v8::PropertyCallbackInfo& p_callbackInfo) > { > v8::Local IndexArray = > v8::Array::New(p_callbackInfo.GetIsolate(), 2); > IndexArray->Set( > v8::Integer::New(p_callbackInfo.GetIsolate(), 0), > v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"x")); > IndexArray->Set( > v8::Integer::New(p_callbackInfo.GetIsolate(), 1), > v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"y")); > p_callbackInfo.GetReturnValue().Set(IndexArray); > } > > From reading the embedder's guide, my understanding is that >> >> indexed property interceptors - called when accessing indexed properties. >> An example of this, in a browser environment, is document.forms.elements[0]. > > > Why is it called on evaluateOnCallFrame action? Also, I tried with other > callback s of v8::IndexedPropertyHandlerConfiguration, but they are not > called. Can I know why? Also, since the signature of callback is as below : > > void (*IndexedPropertyEnumeratorCallback)( const > PropertyCallbackInfo& info); > > I can set only arrays into the result and nothing else. > I am not an expert in v8, hence these questions. Please let me know about > it/ point me to some documentation regarding this. > > regards, > Anoop R. S. IndexedPropertyEnumeratorCallback - is called for Object.keys()-like operations; i.e., to list the enumerable properties of the object but not non-enumerable or prototype properties. The 'Indexed' refers to the fact that it's intended for numeric keys, i.e., array-like objects. Instead of v8::IndexedPropertyHandlerConfiguration, you may want to use v8::NamedPropertyHandlerConfiguration. evaluateOnCallFrame - V8 cannot know whether your callback has any side effects (it could create objects, call into JS code, etc.), hence it evaluates it as if it were a snippet of regular JS code. Newer versions of V8 let you register callbacks with kHasNoSideEffect but as far as I know that has no effect (hah!) on whether or not evaluateOnCallFrame is used. Maybe in the future. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.