static int st_write_event_mapping(void) { uint64_t type = TRACE_RECORD_TYPE_MAPPING; TraceEventIter iter; TraceEvent *ev; trace_event_iter_init(&iter, NULL); while ((ev = trace_event_iter_next(&iter)) != NULL) { uint64_t id = trace_event_get_id(ev); const char *name = trace_event_get_name(ev); uint32_t len = strlen(name); if (fwrite(&type, sizeof(type), 1, trace_fp) != 1 || fwrite(&id, sizeof(id), 1, trace_fp) != 1 || fwrite(&len, sizeof(len), 1, trace_fp) != 1 || fwrite(name, len, 1, trace_fp) != 1) { return -1; } } return 0; }
void trace_event_set_state_dynamic(TraceEvent *ev, bool state) { TraceEventID id; bool state_pre; assert(trace_event_get_state_static(ev)); id = trace_event_get_id(ev); /* * We ignore the "vcpu" property here, since there's no target code. Then * dstate can only be 1 or 0. */ state_pre = trace_events_dstate[id]; if (state_pre != state) { if (state) { trace_events_enabled_count++; trace_events_dstate[id] = 1; } else { trace_events_enabled_count--; trace_events_dstate[id] = 0; } } }
TraceEvent *trace_event_pattern(const char *pat, TraceEvent *ev) { assert(pat != NULL); TraceEventID i; if (ev == NULL) { i = -1; } else { i = trace_event_get_id(ev); } i++; while (i < trace_event_count()) { TraceEvent *res = trace_event_id(i); if (pattern_glob(pat, trace_event_get_name(res))) { return res; } i++; } return NULL; }