Skip to content

[trace] How to add a trace point? #91

Closed
@hhellyer

Description

(My apologies if this is the wrong place to ask, I know the trace work is still ongoing but I was trying it out and hit an issue so it seemed best to raise it here. @ofrobots - you might be the right person to ask!)

I was looking at how the v8 trace mechanism is intended to be used from Node.js by trying to add a simple trace point to Start() in node.cc and running node --trace-events-enabled helloworld.js

The trace point I added was just to show node had started with:

TRACE_EVENT_INSTANT0("node", "node::Start", TRACE_EVENT_SCOPE_PROCESS);

This produced a lot of trace points for v8 but the new trace point was missing. I ran with node --trace-events-enabled --trace-event-categories node helloworld.js and got no output at all.

After a bit of investigation I found that when node reached the v8::platform::DefaultPlatform class it was calling a version of AddTraceEvent that had not been overridden from the base v8::platform::Platform class and had an empty implementation. Implementing that call (by copying the implemented version of AddTraceEvent) caused my trace point to start appearing.

I’m trying to understand if I did something wrong by just calling TRACE_EVENT_INSTANT0 and if so what I should have done or if there’s a missing piece of code in v8 that the Node.js trace implementation is going to require. (I think the v8 trace points take the other path using the other version of AddTraceEvent.)

I’ve put my demonstration code up on a branch if anyone has a chance to look:
nodejs/node@master...hhellyer:trace_bug

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions