How to use trace marker in ftrace
in order to record user events? I use the following, but the compiler cannot define WR_ONLY
:
static int trace_fd = -1;
void trace_write(const char *fmt, ...)
{
va_list ap;
char buf[256];
int n;
if (trace_fd < 0)
return;
va_start(ap, fmt);
n = vsnprintf(buf, 256, fmt, ap);
va_end(ap);
write(trace_fd, buf, n);
}
[...]
trace_fd = open("trace_marker", WR_ONLY);
And later, using the trace_write()
function to record into the ftrace
buffer.
trace_write("record this event\n")
The compiler error:
error: C++ requires a type specifier for all declarations
trace_fd = open("trace_marker", WR_ONLY);