2009-09-21 12:02:48 +02:00
|
|
|
#ifndef __PERF_RECORD_H
|
|
|
|
|
#define __PERF_RECORD_H
|
2009-09-24 18:02:18 +02:00
|
|
|
|
2009-12-27 21:37:00 -02:00
|
|
|
#include <limits.h>
|
2011-12-02 11:06:37 -02:00
|
|
|
#include <stdio.h>
|
2009-12-27 21:37:00 -02:00
|
|
|
|
2009-08-12 10:19:53 +02:00
|
|
|
#include "../perf.h"
|
2009-12-27 21:37:00 -02:00
|
|
|
#include "map.h"
|
2009-08-12 10:19:53 +02:00
|
|
|
|
2009-08-13 11:47:55 +02:00
|
|
|
/*
|
|
|
|
|
* PERF_SAMPLE_IP | PERF_SAMPLE_TID | *
|
|
|
|
|
*/
|
2009-08-12 10:19:53 +02:00
|
|
|
struct ip_event {
|
|
|
|
|
struct perf_event_header header;
|
|
|
|
|
u64 ip;
|
|
|
|
|
u32 pid, tid;
|
|
|
|
|
unsigned char __more_data[];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct mmap_event {
|
|
|
|
|
struct perf_event_header header;
|
|
|
|
|
u32 pid, tid;
|
|
|
|
|
u64 start;
|
|
|
|
|
u64 len;
|
|
|
|
|
u64 pgoff;
|
|
|
|
|
char filename[PATH_MAX];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct comm_event {
|
|
|
|
|
struct perf_event_header header;
|
|
|
|
|
u32 pid, tid;
|
|
|
|
|
char comm[16];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct fork_event {
|
|
|
|
|
struct perf_event_header header;
|
|
|
|
|
u32 pid, ppid;
|
|
|
|
|
u32 tid, ptid;
|
2009-09-12 07:52:47 +02:00
|
|
|
u64 time;
|
2009-08-12 10:19:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct lost_event {
|
|
|
|
|
struct perf_event_header header;
|
|
|
|
|
u64 id;
|
|
|
|
|
u64 lost;
|
|
|
|
|
};
|
|
|
|
|
|
2009-08-13 11:47:55 +02:00
|
|
|
/*
|
|
|
|
|
* PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
|
|
|
|
|
*/
|
2009-08-12 10:19:53 +02:00
|
|
|
struct read_event {
|
|
|
|
|
struct perf_event_header header;
|
2009-09-16 13:45:00 +02:00
|
|
|
u32 pid, tid;
|
2009-08-12 10:19:53 +02:00
|
|
|
u64 value;
|
|
|
|
|
u64 time_enabled;
|
|
|
|
|
u64 time_running;
|
|
|
|
|
u64 id;
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-21 19:33:04 +02:00
|
|
|
|
|
|
|
|
#define PERF_SAMPLE_MASK \
|
|
|
|
|
(PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
|
|
|
|
|
PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \
|
|
|
|
|
PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \
|
|
|
|
|
PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
|
|
|
|
|
|
2009-12-06 20:08:24 +09:00
|
|
|
struct sample_event {
|
2009-09-12 07:53:00 +02:00
|
|
|
struct perf_event_header header;
|
|
|
|
|
u64 array[];
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-29 13:02:00 -02:00
|
|
|
struct perf_sample {
|
2009-12-06 20:08:24 +09:00
|
|
|
u64 ip;
|
|
|
|
|
u32 pid, tid;
|
|
|
|
|
u64 time;
|
|
|
|
|
u64 addr;
|
|
|
|
|
u64 id;
|
|
|
|
|
u64 stream_id;
|
|
|
|
|
u64 period;
|
2010-04-05 12:53:45 -03:00
|
|
|
u32 cpu;
|
2009-12-06 20:08:24 +09:00
|
|
|
u32 raw_size;
|
|
|
|
|
void *raw_data;
|
2010-04-05 12:53:45 -03:00
|
|
|
struct ip_callchain *callchain;
|
2012-02-09 23:21:01 +01:00
|
|
|
struct branch_stack *branch_stack;
|
2009-12-06 20:08:24 +09:00
|
|
|
};
|
|
|
|
|
|
2009-11-04 18:50:43 -02:00
|
|
|
#define BUILD_ID_SIZE 20
|
|
|
|
|
|
|
|
|
|
struct build_id_event {
|
|
|
|
|
struct perf_event_header header;
|
2010-04-19 13:32:50 +08:00
|
|
|
pid_t pid;
|
2009-11-04 18:50:43 -02:00
|
|
|
u8 build_id[ALIGN(BUILD_ID_SIZE, sizeof(u64))];
|
|
|
|
|
char filename[];
|
|
|
|
|
};
|
2009-09-12 07:53:00 +02:00
|
|
|
|
2010-05-02 22:05:29 +02:00
|
|
|
enum perf_user_event_type { /* above any possible kernel type */
|
2010-12-07 12:48:47 +00:00
|
|
|
PERF_RECORD_USER_TYPE_START = 64,
|
2010-04-01 23:59:19 -05:00
|
|
|
PERF_RECORD_HEADER_ATTR = 64,
|
2010-04-01 23:59:20 -05:00
|
|
|
PERF_RECORD_HEADER_EVENT_TYPE = 65,
|
2010-04-01 23:59:21 -05:00
|
|
|
PERF_RECORD_HEADER_TRACING_DATA = 66,
|
2010-04-01 23:59:22 -05:00
|
|
|
PERF_RECORD_HEADER_BUILD_ID = 67,
|
2010-05-02 22:05:29 +02:00
|
|
|
PERF_RECORD_FINISHED_ROUND = 68,
|
2010-04-01 23:59:19 -05:00
|
|
|
PERF_RECORD_HEADER_MAX
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct attr_event {
|
|
|
|
|
struct perf_event_header header;
|
|
|
|
|
struct perf_event_attr attr;
|
|
|
|
|
u64 id[];
|
2010-04-01 23:59:15 -05:00
|
|
|
};
|
|
|
|
|
|
2010-04-01 23:59:20 -05:00
|
|
|
#define MAX_EVENT_NAME 64
|
|
|
|
|
|
|
|
|
|
struct perf_trace_event_type {
|
|
|
|
|
u64 event_id;
|
|
|
|
|
char name[MAX_EVENT_NAME];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct event_type_event {
|
|
|
|
|
struct perf_event_header header;
|
|
|
|
|
struct perf_trace_event_type event_type;
|
|
|
|
|
};
|
|
|
|
|
|
2010-04-01 23:59:21 -05:00
|
|
|
struct tracing_data_event {
|
|
|
|
|
struct perf_event_header header;
|
|
|
|
|
u32 size;
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-29 14:01:45 -02:00
|
|
|
union perf_event {
|
2009-08-12 10:19:53 +02:00
|
|
|
struct perf_event_header header;
|
|
|
|
|
struct ip_event ip;
|
|
|
|
|
struct mmap_event mmap;
|
|
|
|
|
struct comm_event comm;
|
|
|
|
|
struct fork_event fork;
|
|
|
|
|
struct lost_event lost;
|
|
|
|
|
struct read_event read;
|
2009-09-12 07:53:00 +02:00
|
|
|
struct sample_event sample;
|
2010-04-01 23:59:19 -05:00
|
|
|
struct attr_event attr;
|
2010-04-01 23:59:20 -05:00
|
|
|
struct event_type_event event_type;
|
2010-04-01 23:59:21 -05:00
|
|
|
struct tracing_data_event tracing_data;
|
2010-04-01 23:59:22 -05:00
|
|
|
struct build_id_event build_id;
|
2011-01-29 14:01:45 -02:00
|
|
|
};
|
2009-08-12 11:07:25 +02:00
|
|
|
|
2011-01-29 14:01:45 -02:00
|
|
|
void perf_event__print_totals(void);
|
2009-11-27 16:29:22 -02:00
|
|
|
|
2011-11-28 08:30:20 -02:00
|
|
|
struct perf_tool;
|
2011-02-10 12:52:47 -02:00
|
|
|
struct thread_map;
|
2009-12-13 19:50:29 -02:00
|
|
|
|
2011-11-28 08:30:20 -02:00
|
|
|
typedef int (*perf_event__handler_t)(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
union perf_event *event,
|
2011-01-29 14:01:45 -02:00
|
|
|
struct perf_sample *sample,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine);
|
2010-01-07 19:59:40 -02:00
|
|
|
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__synthesize_thread_map(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
struct thread_map *threads,
|
2011-02-11 11:45:54 -02:00
|
|
|
perf_event__handler_t process,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine);
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__synthesize_threads(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
perf_event__handler_t process,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine);
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
perf_event__handler_t process,
|
2011-01-29 14:01:45 -02:00
|
|
|
struct machine *machine,
|
|
|
|
|
const char *symbol_name);
|
|
|
|
|
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__synthesize_modules(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
perf_event__handler_t process,
|
2011-01-29 14:01:45 -02:00
|
|
|
struct machine *machine);
|
|
|
|
|
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__process_comm(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
union perf_event *event,
|
|
|
|
|
struct perf_sample *sample,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine);
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__process_lost(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
union perf_event *event,
|
|
|
|
|
struct perf_sample *sample,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine);
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__process_mmap(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
union perf_event *event,
|
|
|
|
|
struct perf_sample *sample,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine);
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__process_task(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
union perf_event *event,
|
|
|
|
|
struct perf_sample *sample,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine);
|
2011-11-28 08:30:20 -02:00
|
|
|
int perf_event__process(struct perf_tool *tool,
|
2011-11-25 08:19:45 -02:00
|
|
|
union perf_event *event,
|
|
|
|
|
struct perf_sample *sample,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine);
|
2009-11-27 16:29:22 -02:00
|
|
|
|
2009-11-27 16:29:23 -02:00
|
|
|
struct addr_location;
|
2011-01-29 14:01:45 -02:00
|
|
|
int perf_event__preprocess_sample(const union perf_event *self,
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine *machine,
|
2011-01-29 14:01:45 -02:00
|
|
|
struct addr_location *al,
|
|
|
|
|
struct perf_sample *sample,
|
|
|
|
|
symbol_filter_t filter);
|
2009-11-27 16:29:23 -02:00
|
|
|
|
2011-01-29 14:01:45 -02:00
|
|
|
const char *perf_event__name(unsigned int id);
|
2010-05-14 10:36:42 -03:00
|
|
|
|
2011-01-29 14:01:45 -02:00
|
|
|
int perf_event__parse_sample(const union perf_event *event, u64 type,
|
2011-05-21 19:33:04 +02:00
|
|
|
int sample_size, bool sample_id_all,
|
2011-09-06 09:12:26 -06:00
|
|
|
struct perf_sample *sample, bool swapped);
|
2011-11-28 12:03:31 +03:00
|
|
|
int perf_event__synthesize_sample(union perf_event *event, u64 type,
|
|
|
|
|
const struct perf_sample *sample,
|
|
|
|
|
bool swapped);
|
2011-01-21 13:46:41 -02:00
|
|
|
|
2011-12-02 11:06:37 -02:00
|
|
|
size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp);
|
|
|
|
|
size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp);
|
|
|
|
|
size_t perf_event__fprintf_task(union perf_event *event, FILE *fp);
|
|
|
|
|
size_t perf_event__fprintf(union perf_event *event, FILE *fp);
|
|
|
|
|
|
2009-09-24 18:02:18 +02:00
|
|
|
#endif /* __PERF_RECORD_H */
|