trace_start(const char *json)
{
trace_file = json;
- cc_log("Starting tracing: %s", json);
MTR_META_PROCESS_NAME(MYNAME);
trace_id = (void *) ((long) getpid());
MTR_START("program", "ccache", trace_id);
static void
trace_stop(void *context)
{
- const char *json = (const char *) context;
- if (str_eq(json, "")) {
- json = format("%s%s", output_obj, ".ccache-trace");
- }
- cc_log("Stopping tracing: %s", json);
+ (void) context;
+ const char *json = format("%s%s", output_obj, ".ccache-trace");
MTR_FINISH("program", "ccache", trace_id);
mtr_flush();
mtr_shutdown();
- if (!str_eq(trace_file, json)) {
- move_file(trace_file, json, 0);
- }
+ move_file(trace_file, json, 0);
}
static const char *
tracefile = format("%s/trace.%d.json", tmpdir(), (int)getpid());
trace_init(tracefile);
-#else
- cc_log("Error: tracing is not enabled!");
#endif
}
umask(conf->umask);
}
-#ifdef MTR_ENABLED
if (tracefile != NULL) {
+#ifdef MTR_ENABLED
trace_start(tracefile);
- exitfn_add(trace_stop, tracefile);
- }
+ exitfn_add(trace_stop, NULL);
+#else
+ cc_log("Error: tracing is not enabled!");
#endif
+ }
}
// Reset the global state. Used by the test suite.