wspr-ncsu / visiblev8

A instrumented variant of the V8 JavaScript Engine
https://kapravelos.com/projects/vv8
BSD 3-Clause "New" or "Revised" License
151 stars 37 forks source link

Unsure about the setter offset #104

Open aswad546 opened 4 months ago

aswad546 commented 4 months ago

Hello,

I had a query about the offsets that visible v8 provides for specific APIs. Especially the offsets for setters (prefixed by s).

As an example I have the following code:

let attr1 = _MouseEvent.screenX_
let HTMLInputElement.value = attr1  // setter for API HTML Input Element.value
let a = HTMLInputElement.value  //getter example

The offset provided for the API HTMLInputElement.value will be a bit ahead in this case starting from the = sign instead of starting from v in HTMLInputElement.value. However in the case of getters (as in line 3) the offset correctly starts from v instead of someplace else.

I am wondering if you meant to show the offset of the value being set (hence the offset is at the equal to sign) and not the exact API itself?

Looking forward to your response! Thanks, Aswad

sohomdatta1 commented 4 months ago

I think this is a quirk of V8, the getter and setter offsets are pulled from the stack trace API inside V8.

The most probable cause for the discrepancy you are seeing is that our functions are hooking into V8 at a point where the runtime has only ingested till the = token in the setter's case whereas, for the getter's case, the runtime must ingest almost the whole line to predict what kind of operation is being performed.

aswad546 commented 4 months ago

Okay, thanks for your quick response, I guess I can fix this in the post-processor.

sohomdatta1 commented 4 months ago

Feel free to send us a patch if you figure out a reliable way to do this :)