2009-12-11 21:24:02 -02:00
|
|
|
#ifndef __PERF_SESSION_H
|
|
|
|
|
#define __PERF_SESSION_H
|
|
|
|
|
|
2010-05-10 13:04:11 -03:00
|
|
|
#include "hist.h"
|
2009-12-13 19:50:25 -02:00
|
|
|
#include "event.h"
|
2009-12-11 21:24:02 -02:00
|
|
|
#include "header.h"
|
2010-02-03 16:52:00 -02:00
|
|
|
#include "symbol.h"
|
2009-12-13 19:50:29 -02:00
|
|
|
#include "thread.h"
|
2009-12-13 19:50:28 -02:00
|
|
|
#include <linux/rbtree.h>
|
2009-12-14 15:06:01 -02:00
|
|
|
#include "../../../include/linux/perf_event.h"
|
2009-12-13 19:50:28 -02:00
|
|
|
|
2010-04-24 00:04:12 +02:00
|
|
|
struct sample_queue;
|
2009-12-14 14:22:59 -02:00
|
|
|
struct ip_callchain;
|
2009-12-13 19:50:28 -02:00
|
|
|
struct thread;
|
2009-12-11 21:24:02 -02:00
|
|
|
|
2010-04-24 00:04:12 +02:00
|
|
|
struct ordered_samples {
|
|
|
|
|
u64 last_flush;
|
2010-05-03 15:14:33 +02:00
|
|
|
u64 next_flush;
|
|
|
|
|
u64 max_timestamp;
|
2010-11-30 17:49:33 +00:00
|
|
|
struct list_head samples;
|
2010-11-30 17:49:53 +00:00
|
|
|
struct list_head sample_cache;
|
2010-11-30 17:49:55 +00:00
|
|
|
struct list_head to_free;
|
|
|
|
|
struct sample_queue *sample_buffer;
|
2010-11-30 17:49:33 +00:00
|
|
|
struct sample_queue *last_sample;
|
2010-11-30 17:49:55 +00:00
|
|
|
int sample_buffer_idx;
|
2011-10-29 12:41:45 -02:00
|
|
|
unsigned int nr_samples;
|
2010-04-24 00:04:12 +02:00
|
|
|
};
|
|
|
|
|
|
2009-12-11 21:24:02 -02:00
|
|
|
struct perf_session {
|
|
|
|
|
struct perf_header header;
|
|
|
|
|
unsigned long size;
|
2009-12-13 19:50:27 -02:00
|
|
|
unsigned long mmap_window;
|
2010-05-09 19:57:08 -03:00
|
|
|
struct machine host_machine;
|
2010-04-27 21:17:50 -03:00
|
|
|
struct rb_root machines;
|
2011-03-05 21:40:06 -03:00
|
|
|
struct perf_evlist *evlist;
|
2010-05-10 13:04:11 -03:00
|
|
|
/*
|
2011-03-05 21:40:06 -03:00
|
|
|
* FIXME: Need to split this up further, we need global
|
|
|
|
|
* stats + per event stats. 'perf diff' also needs
|
|
|
|
|
* to properly support multiple events in a single
|
|
|
|
|
* perf.data file.
|
2010-05-10 13:04:11 -03:00
|
|
|
*/
|
|
|
|
|
struct hists hists;
|
2009-12-14 14:23:00 -02:00
|
|
|
u64 sample_type;
|
2011-05-21 19:33:04 +02:00
|
|
|
int sample_size;
|
2009-12-11 21:24:02 -02:00
|
|
|
int fd;
|
2010-04-01 23:59:15 -05:00
|
|
|
bool fd_pipe;
|
2010-05-01 01:41:20 -05:00
|
|
|
bool repipe;
|
2010-12-02 10:25:28 -02:00
|
|
|
bool sample_id_all;
|
|
|
|
|
u16 id_hdr_size;
|
2009-12-13 19:50:27 -02:00
|
|
|
int cwdlen;
|
|
|
|
|
char *cwd;
|
2010-04-24 00:04:12 +02:00
|
|
|
struct ordered_samples ordered_samples;
|
2011-12-07 10:02:52 +01:00
|
|
|
char filename[1];
|
2009-12-11 21:24:02 -02:00
|
|
|
};
|
|
|
|
|
|
2011-11-28 08:30:20 -02:00
|
|
|
struct perf_tool;
|
2009-12-13 19:50:25 -02:00
|
|
|
|
2010-12-10 14:09:16 +11:00
|
|
|
struct perf_session *perf_session__new(const char *filename, int mode,
|
|
|
|
|
bool force, bool repipe,
|
2011-11-28 08:30:20 -02:00
|
|
|
struct perf_tool *tool);
|
2009-12-11 21:24:02 -02:00
|
|
|
void perf_session__delete(struct perf_session *self);
|
|
|
|
|
|
2010-01-14 12:23:10 -02:00
|
|
|
void perf_event_header__bswap(struct perf_event_header *self);
|
|
|
|
|
|
2010-02-03 16:52:05 -02:00
|
|
|
int __perf_session__process_events(struct perf_session *self,
|
|
|
|
|
u64 data_offset, u64 data_size, u64 size,
|
2011-11-28 08:30:20 -02:00
|
|
|
struct perf_tool *tool);
|
2009-12-13 19:50:25 -02:00
|
|
|
int perf_session__process_events(struct perf_session *self,
|
2011-11-28 08:30:20 -02:00
|
|
|
struct perf_tool *tool);
|
2009-12-13 19:50:25 -02:00
|
|
|
|
2011-11-11 23:10:26 -02:00
|
|
|
int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel,
|
2011-01-14 04:51:58 +01:00
|
|
|
struct thread *thread,
|
|
|
|
|
struct ip_callchain *chain,
|
|
|
|
|
struct symbol **parent);
|
2009-12-14 14:22:59 -02:00
|
|
|
|
2009-12-27 21:37:02 -02:00
|
|
|
bool perf_session__has_traces(struct perf_session *self, const char *msg);
|
2009-12-27 21:37:01 -02:00
|
|
|
|
2010-01-14 12:23:10 -02:00
|
|
|
void mem_bswap_64(void *src, int byte_size);
|
2011-07-15 12:34:09 -06:00
|
|
|
void perf_event__attr_swap(struct perf_event_attr *attr);
|
2010-01-14 12:23:10 -02:00
|
|
|
|
2010-04-19 13:32:50 +08:00
|
|
|
int perf_session__create_kernel_maps(struct perf_session *self);
|
2010-03-11 20:12:44 -03:00
|
|
|
|
2010-04-01 23:59:15 -05:00
|
|
|
void perf_session__update_sample_type(struct perf_session *self);
|
2010-06-17 08:37:44 -03:00
|
|
|
void perf_session__remove_thread(struct perf_session *self, struct thread *th);
|
2010-04-01 23:59:15 -05:00
|
|
|
|
2010-04-27 21:17:50 -03:00
|
|
|
static inline
|
|
|
|
|
struct machine *perf_session__find_host_machine(struct perf_session *self)
|
|
|
|
|
{
|
2010-05-09 19:57:08 -03:00
|
|
|
return &self->host_machine;
|
2010-04-27 21:17:50 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline
|
|
|
|
|
struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
|
|
|
|
|
{
|
2010-05-09 19:57:08 -03:00
|
|
|
if (pid == HOST_KERNEL_ID)
|
|
|
|
|
return &self->host_machine;
|
2010-04-27 21:17:50 -03:00
|
|
|
return machines__find(&self->machines, pid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline
|
|
|
|
|
struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid)
|
|
|
|
|
{
|
2010-05-09 19:57:08 -03:00
|
|
|
if (pid == HOST_KERNEL_ID)
|
|
|
|
|
return &self->host_machine;
|
2010-04-27 21:17:50 -03:00
|
|
|
return machines__findnew(&self->machines, pid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline
|
|
|
|
|
void perf_session__process_machines(struct perf_session *self,
|
2011-11-28 08:30:20 -02:00
|
|
|
struct perf_tool *tool,
|
2010-04-27 21:17:50 -03:00
|
|
|
machine__process_t process)
|
|
|
|
|
{
|
2011-11-28 08:30:20 -02:00
|
|
|
process(&self->host_machine, tool);
|
|
|
|
|
return machines__process(&self->machines, process, tool);
|
2010-04-27 21:17:50 -03:00
|
|
|
}
|
2010-04-27 21:22:44 -03:00
|
|
|
|
2011-11-28 07:56:39 -02:00
|
|
|
struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
|
|
|
|
|
size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
|
|
|
|
|
|
2010-05-09 19:57:08 -03:00
|
|
|
size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp);
|
2010-04-27 21:22:44 -03:00
|
|
|
|
2010-05-19 13:41:23 -03:00
|
|
|
size_t perf_session__fprintf_dsos_buildid(struct perf_session *self,
|
|
|
|
|
FILE *fp, bool with_hits);
|
2010-05-14 10:36:42 -03:00
|
|
|
|
2011-03-05 21:40:06 -03:00
|
|
|
size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
|
2011-01-21 13:46:41 -02:00
|
|
|
|
|
|
|
|
static inline int perf_session__parse_sample(struct perf_session *session,
|
2011-01-29 14:01:45 -02:00
|
|
|
const union perf_event *event,
|
2011-01-29 13:02:00 -02:00
|
|
|
struct perf_sample *sample)
|
2011-01-21 13:46:41 -02:00
|
|
|
{
|
2011-01-29 14:01:45 -02:00
|
|
|
return perf_event__parse_sample(event, session->sample_type,
|
2011-05-21 19:33:04 +02:00
|
|
|
session->sample_size,
|
2011-09-06 09:12:26 -06:00
|
|
|
session->sample_id_all, sample,
|
|
|
|
|
session->header.needs_swap);
|
2011-01-21 13:46:41 -02:00
|
|
|
}
|
|
|
|
|
|
2011-11-28 12:03:31 +03:00
|
|
|
static inline int perf_session__synthesize_sample(struct perf_session *session,
|
|
|
|
|
union perf_event *event,
|
|
|
|
|
const struct perf_sample *sample)
|
|
|
|
|
{
|
|
|
|
|
return perf_event__synthesize_sample(event, session->sample_type,
|
|
|
|
|
sample, session->header.needs_swap);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 21:54:20 -06:00
|
|
|
struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
|
|
|
|
|
unsigned int type);
|
|
|
|
|
|
2011-11-28 07:56:39 -02:00
|
|
|
void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
|
|
|
|
|
struct machine *machine, struct perf_evsel *evsel,
|
2012-01-30 13:43:15 +09:00
|
|
|
int print_sym, int print_dso, int print_symoffset);
|
2011-03-09 22:23:27 -07:00
|
|
|
|
2011-07-04 21:57:50 +10:00
|
|
|
int perf_session__cpu_bitmap(struct perf_session *session,
|
|
|
|
|
const char *cpu_list, unsigned long *cpu_bitmap);
|
|
|
|
|
|
2011-09-30 15:40:40 +02:00
|
|
|
void perf_session__fprintf_info(struct perf_session *s, FILE *fp, bool full);
|
2009-12-11 21:24:02 -02:00
|
|
|
#endif /* __PERF_SESSION_H */
|