Hi Rodolph,

You may need a tool for C++ native function tracing. uftrace can help you 
with that.
https://github.com/namhyung/uftrace

It's basic output for V8 is just like below:

  1. Normal execution
$ ./out/x64.release/d8 fib-20.js fib(20) = 6765

  2. Tracing with uftrace for the same execution 
$ uftrace -t 40ms -F main ./out/x64.release/d8 fib-20.js
fib(20) = 6765 # DURATION TID FUNCTION [ 3452] | main() { [ 3452] | 
v8::Shell::Main() { [ 3452] | v8::V8::InitializeICUDefaultLocation() { [ 
3452] | v8::internal::InitializeICUDefaultLocation() { [ 3452] | 
v8::internal::InitializeICU() { 92.415 ms [ 3452] | fread(); 92.485 ms [ 
3452] | } /* v8::internal::InitializeICU */ 92.493 ms [ 3452] | } /* 
v8::internal::InitializeICUDefaultLocation */ 92.496 ms [ 3452] | } /* 
v8::V8::InitializeICUDefaultLocation */ [ 3452] | v8::Isolate::New() { [ 
3452] | v8::internal::Snapshot::Initialize() { [ 3452] | 
v8::internal::Isolate::Init() { 40.058 ms [ 3452] | 
v8::internal::Deserializer::Deserialize(); 45.748 ms [ 3452] | } /* 
v8::internal::Isolate::Init */ 45.772 ms [ 3452] | } /* 
v8::internal::Snapshot::Initialize */ 46.213 ms [ 3452] | } /* 
v8::Isolate::New */ [ 3452] | v8::Shell::RunMain() { [ 3452] | 
v8::Shell::CreateEvaluationContext() { [ 3452] | v8::Context::New() { [ 
3452] | v8::NewContext() { [ 3452] | v8::CreateEnvironment() { [ 3452] | 
v8::InvokeBootstrapper::Invoke() { [ 3452] | 
v8::internal::Bootstrapper::CreateEnvironment() { 57.126 ms [ 3452] | 
v8::internal::Genesis::Genesis(); 57.423 ms [ 3452] | } /* 
v8::internal::Bootstrapper::CreateEnvironment */ 57.424 ms [ 3452] | } /* 
v8::InvokeBootstrapper::Invoke */ 57.502 ms [ 3452] | } /* 
v8::CreateEnvironment */ 57.506 ms [ 3452] | } /* v8::NewContext */ 57.507 
ms [ 3452] | } /* v8::Context::New */ 60.977 ms [ 3452] | } /* 
v8::Shell::CreateEvaluationContext */ [ 3452] | v8::SourceGroup::Execute() 
{ [ 3452] | v8::Shell::ExecuteString() { [ 3452] | v8::Script::Run() { [ 
3452] | v8::internal::Execution::Call() { 44.009 ms [ 3452] | 
v8::internal::_GLOBAL__N_1::Invoke(); 44.011 ms [ 3452] | } /* 
v8::internal::Execution::Call */ 44.027 ms [ 3452] | } /* v8::Script::Run 
*/ 53.626 ms [ 3452] | } /* v8::Shell::ExecuteString */ 53.668 ms [ 3452] | 
} /* v8::SourceGroup::Execute */ 114.797 ms [ 3452] | } /* 
v8::Shell::RunMain */ 256.926 ms [ 3452] | } /* v8::Shell::Main */ 256.926 
ms [ 3452] | } /* main */

There's more description for V8 in the link below:
https://groups.google.com/d/msg/v8-dev/i16DdbPsxa0/KbIg_dshBgAJ

Hope this will be helpful to you.

Thanks,
Honggyu


On Friday, October 27, 2017 at 11:57:39 PM UTC+9, Rodolph Perfetta wrote:
>
> code for flags is usually gated by FLAG_xxx so look for FLAG_trace
>
> On Fri, 27 Oct 2017 at 09:22 <[email protected] <javascript:>> wrote:
>
>> Hi,
>>
>> *--trace *was a great hint. Thanks! Unfortunately *--trace* does not log 
>> 'native' methods as the example below shows (*concat *and *print *are 
>> not logged). Is there a way to modify the tracing algorithm to add the 
>> native methods? I could not find the C++ code responsible for teh tracing. 
>>
>> Code:
>> function foo(var0){
>>   bar(var0.concat(" World!"));
>> }
>>
>> function bar(var1){
>>   print(var1);
>> }
>>
>> foo("Hello");
>>
>> Output:
>>    1: ~+0(this=0x1407e1103521 <JSGlobal Object>) {
>>    2:  ~foo+0(this=0x1407e1103521 <JSGlobal Object>, 0x313b061a8b79 <
>> String[5]: Hello>) {
>>    3:   ~bar+0(this=0x1407e1103521 <JSGlobal Object>, 0x1407e110cd99 <
>> String[12]: Hello World!>) {
>> Hello World!
>>    3:   } -> 0x2169365022e1 <undefined>
>>    2:  } -> 0x2169365022e1 <undefined>
>>    1: } -> 0x2169365022e1 <undefined>
>>
>> Cheers,
>> Tobias
>>
>>
>>
>> Am Donnerstag, 26. Oktober 2017 16:24:21 UTC+2 schrieb Rodolph Perfetta:
>>
>>> What you are looking for sounds similar to the --trace flag, have you 
>>> tried it?
>>>
>>> On Thu, 26 Oct 2017 at 07:36 Tobias <[email protected]> wrote:
>>>
>> Hello,
>>>>
>>>>  
>>>>
>>>> I am fairly new to V8 and need some help or hints how to start on my 
>>>> problem.
>>>>
>>>>  
>>>>
>>>> I want to log all function calls of any given script (i.e. the Stack 
>>>> trace of the script – see the example below).
>>>>
>>>> Can you give me please a hint or advice where to start?
>>>>
>>>> I took a look at the “V8 Inspector 
>>>> <https://github.com/v8/v8/wiki/Debugging-over-the-V8-Inspector-API>” 
>>>> but I did not find a way to log the JavaScript function calls.
>>>>
>>>> The “StackTrace API <https://github.com/v8/v8/wiki/Stack-Trace-API>” 
>>>> seems to work but only for exceptions not all function calls.
>>>>
>>>>  
>>>>
>>>> Any help is appreciated!
>>>>
>>>>  
>>>>
>>>> Cheers,
>>>>
>>>> Tobias
>>>>
>>>>  
>>>>
>>>> *Example: *
>>>>
>>>> For the script
>>>> <script>
>>>>   var c = document.getElementById("myCanvas"); 
>>>>   var ctx = c.getContext("2d"); 
>>>>   ctx.font = "30px Arial"; 
>>>>   ctx.fillText("Hello World",10,50); 
>>>> </script>
>>>>
>>>>
>>>> I want something like:
>>>>
>>>> Script foo:
>>>>
>>>>   getElementById
>>>>
>>>>   getContext
>>>>
>>>>   fillText
>>>>
>>>> -- 
>>>> -- 
>>>> v8-dev mailing list
>>>>
>>> [email protected]
>>>
>>>
>>>> http://groups.google.com/group/v8-dev
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "v8-dev" group.
>>>>
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>
>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> -- 
>> -- 
>> v8-dev mailing list
>> [email protected] <javascript:>
>> http://groups.google.com/group/v8-dev
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "v8-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to