MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / findTracepointId

Function findTracepointId

src/perfEvents_linux.cpp:94–103  ·  view source on GitHub ↗

Get perf_event_attr.config numeric value of the given tracepoint name by reading /sys/kernel/tracing/events/ /id (since 4.1) or /sys/kernel/debug/tracing/events/ /id (before 4.1)

Source from the content-addressed store, hash-verified

92// by reading /sys/kernel/tracing/events/<name>/id (since 4.1)
93// or /sys/kernel/debug/tracing/events/<name>/id (before 4.1)
94static int findTracepointId(const char* dir, const char* name) {
95 char buf[256];
96 if ((size_t)snprintf(buf, sizeof(buf), "/sys/kernel/%s/events/%s/id", dir, name) >= sizeof(buf)) {
97 return 0;
98 }
99
100 *strchr(buf, ':') = '/'; // make path from event name
101
102 return fetchInt(buf);
103}
104
105// Get perf_event_attr.type for the given event source
106// by reading /sys/bus/event_source/devices/<name>/type

Callers 1

forNameMethod · 0.85

Calls 1

fetchIntFunction · 0.85

Tested by

no test coverage detected