static void process_sched_switch(struct pevent *pevent, struct pevent_record *record) { unsigned long long val; const char *comm; int pid; int ret; comm = (char *)(record->data + sched_switch_prev_field->offset); ret = pevent_read_number_field(sched_switch_prev_pid_field, record->data, &val); if (ret < 0) die("no prev_pid field in sched_switch?"); pid = val; pevent_register_comm(pevent, comm, pid); comm = (char *)(record->data + sched_switch_next_field->offset); ret = pevent_read_number_field(sched_switch_next_pid_field, record->data, &val); if (ret < 0) die("no next_pid field in sched_switch?"); pid = val; pevent_register_comm(pevent, comm, pid); }
void parse_saved_cmdline(struct pevent *pevent, char *file, unsigned int size __maybe_unused) { char *comm; char *line; char *next = NULL; int pid; line = strtok_r(file, "\n", &next); while (line) { sscanf(line, "%d %ms", &pid, &comm); pevent_register_comm(pevent, comm, pid); free(comm); line = strtok_r(NULL, "\n", &next); } }
void parse_cmdlines(struct pevent *pevent, char *file, int size __maybe_unused) { char *comm; char *line; char *next = NULL; int pid; line = strtok_r(file, "\n", &next); while (line) { sscanf(line, "%d %as", &pid, (float *)(void *)&comm); /* workaround gcc warning */ pevent_register_comm(pevent, comm, pid); free(comm); line = strtok_r(NULL, "\n", &next); } }
static void write_and_save_comm(struct format_field *field, struct pevent_record *record, struct trace_seq *s, int pid) { const char *comm; int len; comm = (char *)(record->data + field->offset); len = s->len; trace_seq_printf(s, "%.*s", field->size, comm); /* make sure the comm has a \0 at the end. */ trace_seq_terminate(s); comm = &s->buffer[len]; /* Help out the comm to ids. This will handle dups */ pevent_register_comm(field->event->pevent, comm, pid); }
void print_event(struct pevent *pevent, int cpu, void *data, int size, unsigned long long nsecs, char *comm) { struct pevent_record record; struct trace_seq s; int pid; pevent->latency_format = latency_format; record.ts = nsecs; record.cpu = cpu; record.size = size; record.data = data; pid = pevent_data_pid(pevent, &record); if (!pevent_pid_is_registered(pevent, pid)) pevent_register_comm(pevent, comm, pid); trace_seq_init(&s); pevent_print_event(pevent, &s, &record); trace_seq_do_printf(&s); printf("\n"); }
static void process_sched_wakeup(struct pevent *pevent, struct pevent_record *record, int type) { unsigned long long val; const char *comm; int pid; int ret; if (type == sched_wakeup_type) { comm = (char *)(record->data + sched_wakeup_comm_field->offset); ret = pevent_read_number_field(sched_wakeup_pid_field, record->data, &val); if (ret < 0) die("no pid field in sched_wakeup?"); } else { comm = (char *)(record->data + sched_wakeup_new_comm_field->offset); ret = pevent_read_number_field(sched_wakeup_new_pid_field, record->data, &val); if (ret < 0) die("no pid field in sched_wakeup_new?"); } pid = val; pevent_register_comm(pevent, comm, pid); }