You could manually patch all existing functions (which will work for
anything that is configurable):

let original = String.prototype.indexOf;
String.prototype.indexOf = function() {
    console.log("indexOf");
    return original.apply(this, arguments);
}


On Wed, Dec 6, 2017 at 11:07 AM <[email protected]> wrote:

> Thanks for your replay. Could you give me some advice what I have to do to
> trace *intrinsic functions (e.g., toString())*
>  or browser specific API function calls (e.g., *document.getElementById()*
> )?
>
> Cheers,
> Tobias
>
>
> Am Mittwoch, 6. Dezember 2017 10:55:04 UTC+1 schrieb Ross McIlroy:
>
>> Hi Tobias,
>>
>> Native functions aren't compiled to bytecode (since they are C++ not
>> JavaScript), so don't run through the code-path you describe in the
>> BytecodeGenerator.
>>
>> Cheers,
>> Ross
>>
>>
>> On 5 December 2017 at 11:02, <[email protected]> wrote:
>>
>>> Hi,
>>> I found the trace flag (in the bytecode generator class
>>> <https://chromium.googlesource.com/v8/v8/+/refs/heads/roll/src/interpreter/bytecode-generator.cc>).
>>> To me it seems that the class - if tracing is enabled- calls the *EnterTrace
>>> *function from the <http://goog_1387160106> <http://goog_1387160106>runtime
>>> environment (Line 825
>>> <https://github.com/v8/v8/blob/master/src/runtime/runtime-test.cc>).
>>> But somehow these functions are not used to log native functions and I do
>>> not know why.
>>>
>>>
>>>
>>> Freitag, 27. Oktober 2017 16:57:39 UTC+2 schrieb Rodolph Perfetta:
>>>>
>>>> code for flags is usually gated by FLAG_xxx so look for FLAG_trace
>>>>
>>>> On Fri, 27 Oct 2017 at 09:22 <[email protected]> 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]
>>>>> 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]
>>> 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]
> 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.
>
-- 
Camillo Bruni |  Software Engineer, V8 |  Google Germany GmbH |  Erika-Mann
Str. 33, 80636 München
Registergericht und -nummer: Hamburg, HRB 86891 | Sitz der Gesellschaft:
Hamburg | Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

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