Haiyang-Sun / nodeprof.js

Instrumentation framework for Node.js compliant to ECMAScript 2020 based on GraalVM.
Apache License 2.0
53 stars 22 forks source link

how to record all write operations of a Node.js program #73

Closed tao2years closed 4 years ago

tao2years commented 4 years ago

As a newer, I wonder how can I record all operation write of a Node.js program. E.g x = 3

Haiyang-Sun commented 4 years ago

Hi,

You can include the write callback in your analysis, such as:

    this.write = function(iid, name, val){
        console.log('write', J$.iidToLocation(iid), name, typeof(val));
    }

We have a test analysis including the write callback: https://github.com/Haiyang-Sun/nodeprof.js/blob/master/src/ch.usi.inf.nodeprof/js/analysis/rw/analysis.js

Haiyang-Sun commented 4 years ago

You need to build nodeprof first, and then you can try this analysis with the following cmd in the nodeprof directory:

mx jalangi --analysis src/ch.usi.inf.nodeprof/js/analysis/rw/analysis.js YOURTEST.js

Or in the docker image release, you can run your test by replacing the example analysis with your analysis code: ./bin/node --experimental-options --nodeprof ./nodeprof/nodeprof.js --analysis ./nodeprof/examples/example.js ./nodeprof/tests/helloworld.js

tao2years commented 4 years ago

Thanks! I will have a try!