[v8-users] Re: Debugging wrapped C++ object

2018-05-21 Thread Anoop R. S.
Hi,
I read around a bit and did some changes. 
Instead of using an *ObjectTemplate *directly, for wrapping the C++ object, 
I created a *FunctionTemplate *first, used *SetClassName()* and then called 
*InstanceTemplate()* to create an *ObjectTemplate *from it. All handlers 
were set on this *ObjectTemplate*. Now  the name is getting displayed for 
the returned object. :)
However, there is a catch. When I set the callback 
*SetCallAsFunctionHandler()* on the *ObjectTemplate*, it stops working and 
starts showing up as *f anonymous()*. I need this because I want to further 
call the object as a function. 
ibon, can you please check if *SetCallAsFunctionHandler()* is set for your 
*ObjectTemplate*?

regards,
Anoop R. S.

On Tuesday, 22 May 2018 10:03:11 UTC+5:30, Anoop R. S. wrote:
>
> Thank you for your reply, ibon.
> I am using *FunctionTemplate *to expose the keyword '*Point*'. So, it 
> will call the function registered with the *FunctionTemplate*. In that 
> function, I am using *ObjectTemplate* to wrap the C++ object and return. 
> For the *ObjectTemplate*, I am setting the handlers. (
> *v8::NamedPropertyHandlerConfiguration* and 
> *v8::IndexedPropertyHandlerConfiguration*)
> I tried using *SetClassName()* on the *FunctionTemplate*. That worked in 
> a different way. Now, when I do mouse over on '*Point*', it is displaying 
> the string I am populating.
>
>
> 
>
> Where as, if *SetClassName()* is not called, it is displayed as 
> anonymous. 
>
>
> 
>
> My aim is to change the value being displayed for the variable p, to which 
> I am returning an *ObjectTemplate*. 
> Or, is it that I can use a *FunctionTemplate* to return? In that case, 
> how can I set the handlers? 
> I used the source 
> *https://github.com/v8/v8/blob/master/samples/process.cc* 
>  as a guide. 
>
> Maybe I am not doing it properly here. The Embedder's guide says:
>
>> Each function template has an associated object template. This is used to 
>> configure objects created with this function as their constructor.
>
> But it seems I am using an unrelated *ObjectTemplate* to wrap C++ object. 
> Please correct me if I am wrong. I am inferring that you are using the 
> associated *ObjectTemplate *of the of the *FunctionTemplate *to wrap the 
> C++ object. 
> Also, from *v8.h:*
>
> /** 
> * Set the class name of the FunctionTemplate. This is used for 
> * printing objects created with the function created from the 
> * FunctionTemplate as its constructor. 
> */ 
> void SetClassName(Local name);
> This also leads me to believe that I am not using the *ObjectTemplate *as 
> intended. 
>
> regards,
> Anoop R. S.
>  
> On Monday, 21 May 2018 14:03:25 UTC+5:30, ibon wrote:
>>
>> Have you tried setting the class name in the FunctionTemplate ?
>>
>> interface_template->SetClassName( v8::String )
>>
>> This names my objects as expected. I also get [object MyObject] instead 
>> of [object Object] when calling Object's prototype toString.
>> You also might want to name the prototype by setting the GetToStringTag 
>> symbol in the prototype object template.
>>
>>
>> El lunes, 21 de mayo de 2018, 6:40:45 (UTC+2), Anoop R. S. escribió:
>>>
>>> Hi All,
>>> I noticed another behaviour. If the callback *SetCallAsFunctionHandler() 
>>> *is implemented for the ObjectTemplate, the value of the object is 
>>> displayed as *f anonymous() *as shown below. 
>>>
>>>
>>> 
>>>
>>> it seems to be overriding the callbacks 
>>> *NamedPropertyHandlerConfiguration* and 
>>> *IndexedPropertyHandlerConfiguration 
>>> *(with respect to how it is displayed only). 
>>>
>>> Is there any way to override this behaviour? 
>>>
>>> I tried tracking where it is getting populated as *function, *but ended 
>>> up in *CALL_GENERATED_CODE* called in *Invoke()* in *execution.cc*
>>>
>>>
>>> regards,
>>> Anoop R. S.
>>>
>>> On Tuesday, 8 May 2018 10:05:12 UTC+5:30, Anoop R. S. wrote:

 Hi All,
 I am trying out a debugger prototype using the remote debugger 
 protocol. 
 Going by the standard example in Embedder's Guide:
 C++ class:
 -
 class Point {
  public:
   Point(int x, int y) : x_(x), y_(y) { }
   int x_, y_;
 }

 Usage in JavaScript:
 ---
 var p = Point(1,2);

 Has anyone tried debugging a wrapped C++ object that is being returned 
 to Javascript? Is it possible? 

 regards,
 Anoop R. S.

>>>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this me

Re: [v8-users] Tracing V8 using Intel PIN

2018-05-21 Thread Ben Noordhuis
On Fri, May 18, 2018 at 9:56 PM,   wrote:
> Hello everyone,
>
> My colleagues and I are working on a dynamic analysis project and we were
> hoping to be able to instrument V8. I was wondering if anyone has had
> experience in trying to obtain execution traces from V8 using Pin. Currently
> we have been unable to actually record any traces (even with the -execv
> flag, which allows Pin to follow forks/clone). I've been trying to trace
> both the V8 shell and d8 with external javascript files, but the resulting
> traces from Pin are empty (even though the javascript files are executed and
> I get the output I am expecting). If anyone has any suggestions or previous
> experiences for why V8 doesn't get traced by Pin, I'd love to hear them!
>
> Thank you for your time and patience!

I expect it's because V8 is a just-in-time compiler, it generates
machine code on the fly.  Intel VTune is another instrumenting tool
that doesn't work without custom hooks, see src/third_party/vtune.

-- 
-- 
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.


[v8-users] Re: Debugging wrapped C++ object

2018-05-21 Thread Anoop R. S.
Thank you for your reply, ibon.
I am using *FunctionTemplate *to expose the keyword '*Point*'. So, it will 
call the function registered with the *FunctionTemplate*. In that function, 
I am using *ObjectTemplate* to wrap the C++ object and return. For the 
*ObjectTemplate*, I am setting the handlers. (
*v8::NamedPropertyHandlerConfiguration* and 
*v8::IndexedPropertyHandlerConfiguration*)
I tried using *SetClassName()* on the *FunctionTemplate*. That worked in a 
different way. Now, when I do mouse over on '*Point*', it is displaying the 
string I am populating.



Where as, if *SetClassName()* is not called, it is displayed as anonymous. 



My aim is to change the value being displayed for the variable p, to which 
I am returning an *ObjectTemplate*. 
Or, is it that I can use a *FunctionTemplate* to return? In that case, how 
can I set the handlers? 
I used the source *https://github.com/v8/v8/blob/master/samples/process.cc* 
 as a guide. 

Maybe I am not doing it properly here. The Embedder's guide says:

> Each function template has an associated object template. This is used to 
> configure objects created with this function as their constructor.

But it seems I am using an unrelated *ObjectTemplate* to wrap C++ object. 
Please correct me if I am wrong. I am inferring that you are using the 
associated *ObjectTemplate *of the of the *FunctionTemplate *to wrap the 
C++ object. 
Also, from *v8.h:*

/** 
* Set the class name of the FunctionTemplate. This is used for 
* printing objects created with the function created from the 
* FunctionTemplate as its constructor. 
*/ 
void SetClassName(Local name);
This also leads me to believe that I am not using the *ObjectTemplate *as 
intended. 

regards,
Anoop R. S.
 
On Monday, 21 May 2018 14:03:25 UTC+5:30, ibon wrote:
>
> Have you tried setting the class name in the FunctionTemplate ?
>
> interface_template->SetClassName( v8::String )
>
> This names my objects as expected. I also get [object MyObject] instead of 
> [object Object] when calling Object's prototype toString.
> You also might want to name the prototype by setting the GetToStringTag 
> symbol in the prototype object template.
>
>
> El lunes, 21 de mayo de 2018, 6:40:45 (UTC+2), Anoop R. S. escribió:
>>
>> Hi All,
>> I noticed another behaviour. If the callback *SetCallAsFunctionHandler() 
>> *is implemented for the ObjectTemplate, the value of the object is 
>> displayed as *f anonymous() *as shown below. 
>>
>>
>> 
>>
>> it seems to be overriding the callbacks 
>> *NamedPropertyHandlerConfiguration* and *IndexedPropertyHandlerConfiguration 
>> *(with respect to how it is displayed only). 
>>
>> Is there any way to override this behaviour? 
>>
>> I tried tracking where it is getting populated as *function, *but ended 
>> up in *CALL_GENERATED_CODE* called in *Invoke()* in *execution.cc*
>>
>>
>> regards,
>> Anoop R. S.
>>
>> On Tuesday, 8 May 2018 10:05:12 UTC+5:30, Anoop R. S. wrote:
>>>
>>> Hi All,
>>> I am trying out a debugger prototype using the remote debugger protocol. 
>>> Going by the standard example in Embedder's Guide:
>>> C++ class:
>>> -
>>> class Point {
>>>  public:
>>>   Point(int x, int y) : x_(x), y_(y) { }
>>>   int x_, y_;
>>> }
>>>
>>> Usage in JavaScript:
>>> ---
>>> var p = Point(1,2);
>>>
>>> Has anyone tried debugging a wrapped C++ object that is being returned 
>>> to Javascript? Is it possible? 
>>>
>>> regards,
>>> Anoop R. S.
>>>
>>

-- 
-- 
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] How Date.now() function value is returned (Is it from kernel of v8 engine has its own implementation)

2018-05-21 Thread Abhishek Kanike
Sorry JaKob

On Mon, May 21, 2018, 6:51 PM Abhishek Kanike 
wrote:

> Cool.. I see it. Thanks a lot Jacob.
>
> On Mon, May 21, 2018, 5:40 PM Jakob Kummerow 
> wrote:
>
>> The time always has to be retrieved from the kernel. V8's implementation
>> is in base::OS::TimeCurrentMillis, implemented in
>> src/base/platform/platform-{win32,posix}.cc.
>>
>> On Mon, May 21, 2018 at 3:22 PM Abhishek Kanike <
>> kai.dranzer32...@gmail.com> wrote:
>>
>>> Hi,
>>> I want to know how the date.now() function is called in javascript (or
>>> how it returns the value). I believe that javascript uses date.now() by
>>> system call. I want to in chrome source code how it is being set.
>>> This is useful for one of the performance benchmark that I am working on.
>>> Can someone please guide me to know how this happens in v8 engine.
>>>
>>> Thanks in advance.
>>>
>>> Regards,
>>> K Abhishek
>>>
>>> --
>>> --
>>> 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.
>>>
>> --
>> --
>> 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.
>>
>

-- 
-- 
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] How Date.now() function value is returned (Is it from kernel of v8 engine has its own implementation)

2018-05-21 Thread Abhishek Kanike
Cool.. I see it. Thanks a lot Jacob.

On Mon, May 21, 2018, 5:40 PM Jakob Kummerow  wrote:

> The time always has to be retrieved from the kernel. V8's implementation
> is in base::OS::TimeCurrentMillis, implemented in
> src/base/platform/platform-{win32,posix}.cc.
>
> On Mon, May 21, 2018 at 3:22 PM Abhishek Kanike <
> kai.dranzer32...@gmail.com> wrote:
>
>> Hi,
>> I want to know how the date.now() function is called in javascript (or
>> how it returns the value). I believe that javascript uses date.now() by
>> system call. I want to in chrome source code how it is being set.
>> This is useful for one of the performance benchmark that I am working on.
>> Can someone please guide me to know how this happens in v8 engine.
>>
>> Thanks in advance.
>>
>> Regards,
>> K Abhishek
>>
>> --
>> --
>> 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.
>>
> --
> --
> 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.
>

-- 
-- 
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] How Date.now() function value is returned (Is it from kernel of v8 engine has its own implementation)

2018-05-21 Thread Jakob Kummerow
The time always has to be retrieved from the kernel. V8's implementation is
in base::OS::TimeCurrentMillis, implemented in
src/base/platform/platform-{win32,posix}.cc.

On Mon, May 21, 2018 at 3:22 PM Abhishek Kanike 
wrote:

> Hi,
> I want to know how the date.now() function is called in javascript (or how
> it returns the value). I believe that javascript uses date.now() by system
> call. I want to in chrome source code how it is being set.
> This is useful for one of the performance benchmark that I am working on.
> Can someone please guide me to know how this happens in v8 engine.
>
> Thanks in advance.
>
> Regards,
> K Abhishek
>
> --
> --
> 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.
>

-- 
-- 
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.


[v8-users] How Date.now() function value is returned (Is it from kernel of v8 engine has its own implementation)

2018-05-21 Thread Abhishek Kanike
Hi,
I want to know how the date.now() function is called in javascript (or how 
it returns the value). I believe that javascript uses date.now() by system 
call. I want to in chrome source code how it is being set. 
This is useful for one of the performance benchmark that I am working on.
Can someone please guide me to know how this happens in v8 engine.

Thanks in advance.

Regards,
K Abhishek

-- 
-- 
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.


[v8-users] Re: Debugging wrapped C++ object

2018-05-21 Thread ibon
Have you tried setting the class name in the FunctionTemplate ?

interface_template->SetClassName( v8::String )

This names my objects as expected. I also get [object MyObject] instead of 
[object Object] when calling Object's prototype toString.
You also might want to name the prototype by setting the GetToStringTag 
symbol in the prototype object template.


El lunes, 21 de mayo de 2018, 6:40:45 (UTC+2), Anoop R. S. escribió:
>
> Hi All,
> I noticed another behaviour. If the callback *SetCallAsFunctionHandler() *is 
> implemented for the ObjectTemplate, the value of the object is displayed as 
> *f 
> anonymous() *as shown below. 
>
>
> 
>
> it seems to be overriding the callbacks 
> *NamedPropertyHandlerConfiguration* and *IndexedPropertyHandlerConfiguration 
> *(with respect to how it is displayed only). 
>
> Is there any way to override this behaviour? 
>
> I tried tracking where it is getting populated as *function, *but ended 
> up in *CALL_GENERATED_CODE* called in *Invoke()* in *execution.cc*
>
>
> regards,
> Anoop R. S.
>
> On Tuesday, 8 May 2018 10:05:12 UTC+5:30, Anoop R. S. wrote:
>>
>> Hi All,
>> I am trying out a debugger prototype using the remote debugger protocol. 
>> Going by the standard example in Embedder's Guide:
>> C++ class:
>> -
>> class Point {
>>  public:
>>   Point(int x, int y) : x_(x), y_(y) { }
>>   int x_, y_;
>> }
>>
>> Usage in JavaScript:
>> ---
>> var p = Point(1,2);
>>
>> Has anyone tried debugging a wrapped C++ object that is being returned to 
>> Javascript? Is it possible? 
>>
>> regards,
>> Anoop R. S.
>>
>

-- 
-- 
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.