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;
|
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;
|
2009-12-13 19:50:28 -02:00
|
|
|
struct rb_root threads;
|
2010-06-17 08:37:44 -03:00
|
|
|
struct list_head dead_threads;
|
2009-12-13 19:50:28 -02:00
|
|
|
struct thread *last_match;
|
2010-05-09 19:57:08 -03:00
|
|
|
struct machine host_machine;
|
2010-04-27 21:17:50 -03:00
|
|
|
struct rb_root machines;
|
2010-05-10 13:04:11 -03:00
|
|
|
struct rb_root hists_tree;
|
|
|
|
|
/*
|
|
|
|
|
* FIXME: should point to the first entry in hists_tree and
|
|
|
|
|
* be a hists instance. Right now its only 'report'
|
|
|
|
|
* that is using ->hists_tree while all the rest use
|
|
|
|
|
* ->hists.
|
|
|
|
|
*/
|
|
|
|
|
struct hists hists;
|
2009-12-14 14:23:00 -02:00
|
|
|
u64 sample_type;
|
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;
|
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;
|
2009-12-11 21:24:02 -02:00
|
|
|
char filename[0];
|
|
|
|
|
};
|
|
|
|
|
|
2010-05-03 15:14:33 +02:00
|
|
|
struct perf_event_ops;
|
|
|
|
|
|
2010-12-02 14:10:21 -02:00
|
|
|
typedef int (*event_op)(event_t *self, struct sample_data *sample,
|
|
|
|
|
struct perf_session *session);
|
|
|
|
|
typedef int (*event_synth_op)(event_t *self, struct perf_session *session);
|
2010-05-03 15:14:33 +02:00
|
|
|
typedef int (*event_op2)(event_t *self, struct perf_session *session,
|
|
|
|
|
struct perf_event_ops *ops);
|
2009-12-13 19:50:25 -02:00
|
|
|
|
|
|
|
|
struct perf_event_ops {
|
2010-05-03 15:14:33 +02:00
|
|
|
event_op sample,
|
|
|
|
|
mmap,
|
|
|
|
|
comm,
|
|
|
|
|
fork,
|
|
|
|
|
exit,
|
|
|
|
|
lost,
|
|
|
|
|
read,
|
|
|
|
|
throttle,
|
2010-12-02 14:10:21 -02:00
|
|
|
unthrottle;
|
|
|
|
|
event_synth_op attr,
|
2010-05-03 15:14:33 +02:00
|
|
|
event_type,
|
|
|
|
|
tracing_data,
|
|
|
|
|
build_id;
|
|
|
|
|
event_op2 finished_round;
|
|
|
|
|
bool ordered_samples;
|
2009-12-13 19:50:25 -02:00
|
|
|
};
|
|
|
|
|
|
2010-05-01 01:41:20 -05:00
|
|
|
struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe);
|
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,
|
|
|
|
|
struct perf_event_ops *ops);
|
2009-12-13 19:50:25 -02:00
|
|
|
int perf_session__process_events(struct perf_session *self,
|
2009-12-13 19:50:27 -02:00
|
|
|
struct perf_event_ops *event_ops);
|
2009-12-13 19:50:25 -02:00
|
|
|
|
2010-03-24 16:40:18 -03:00
|
|
|
struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
|
|
|
|
|
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-04-19 13:32:50 +08:00
|
|
|
int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
|
2010-01-05 16:50:31 -02:00
|
|
|
const char *symbol_name,
|
|
|
|
|
u64 addr);
|
|
|
|
|
|
2010-01-14 12:23:10 -02:00
|
|
|
void mem_bswap_64(void *src, int byte_size);
|
|
|
|
|
|
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
|
|
|
int do_read(int fd, void *buf, size_t size);
|
|
|
|
|
void perf_session__update_sample_type(struct perf_session *self);
|
2010-12-02 14:10:21 -02:00
|
|
|
void perf_session__set_sample_type(struct perf_session *session, u64 type);
|
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,
|
|
|
|
|
machine__process_t process)
|
|
|
|
|
{
|
2010-05-09 19:57:08 -03:00
|
|
|
process(&self->host_machine, self);
|
2010-04-27 21:17:50 -03:00
|
|
|
return machines__process(&self->machines, process, self);
|
|
|
|
|
}
|
2010-04-27 21:22:44 -03:00
|
|
|
|
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
|
|
|
|
|
|
|
|
static inline
|
|
|
|
|
size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp)
|
|
|
|
|
{
|
|
|
|
|
return hists__fprintf_nr_events(&self->hists, fp);
|
|
|
|
|
}
|
2009-12-11 21:24:02 -02:00
|
|
|
#endif /* __PERF_SESSION_H */
|