Skip to content

Instantly share code, notes, and snippets.

@emersion
Created March 18, 2021 17:03
Show Gist options
  • Save emersion/498948b2c2beb599bafdc60ae9952809 to your computer and use it in GitHub Desktop.
Save emersion/498948b2c2beb599bafdc60ae9952809 to your computer and use it in GitHub Desktop.
static void tracef(const char *fmt, ...)
{
static int first = 1;
static FILE *trace_file = NULL;
if (first) {
trace_file = fopen("/sys/kernel/tracing/trace_marker", "w");
first = 0;
}
if (trace_file) {
va_list args;
va_start(args, fmt);
vfprintf(trace_file, fmt, args);
va_end(args);
fprintf(trace_file, "\n");
fflush(trace_file);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment