2009-12-11 21:24:02 -02:00
|
|
|
#ifndef __PERF_SESSION_H
|
|
|
|
|
#define __PERF_SESSION_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-04-24 00:04:12 +02:00
|
|
|
struct list_head samples_head;
|
|
|
|
|
struct sample_queue *last_inserted;
|
|
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
|
|
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;
|
2009-12-14 15:06:01 -02:00
|
|
|
struct events_stats events_stats;
|
2010-03-05 12:51:07 -03:00
|
|
|
struct rb_root stats_by_id;
|
2009-12-14 15:06:01 -02:00
|
|
|
unsigned long event_total[PERF_RECORD_MAX];
|
2009-12-27 21:37:03 -02:00
|
|
|
unsigned long unknown_events;
|
2009-12-14 13:10:39 -02:00
|
|
|
struct rb_root 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;
|
|
|
|
|
|
2009-12-13 19:50:25 -02:00
|
|
|
typedef int (*event_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,
|
|
|
|
|
unthrottle,
|
|
|
|
|
attr,
|
|
|
|
|
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-03-11 20:12:44 -03:00
|
|
|
#ifdef NO_NEWT_SUPPORT
|
2010-03-26 21:16:22 -03:00
|
|
|
static inline int perf_session__browse_hists(struct rb_root *hists __used,
|
|
|
|
|
u64 nr_hists __used,
|
2010-03-11 20:12:44 -03:00
|
|
|
u64 session_total __used,
|
2010-04-03 11:54:35 -03:00
|
|
|
const char *helpline __used,
|
|
|
|
|
const char *input_name __used)
|
2010-03-26 21:16:22 -03:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-03-11 20:12:44 -03:00
|
|
|
#else
|
2010-03-26 21:16:22 -03:00
|
|
|
int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
|
2010-04-03 11:54:35 -03:00
|
|
|
u64 session_total, const char *helpline,
|
|
|
|
|
const char *input_name);
|
2010-03-11 20:12:44 -03:00
|
|
|
#endif
|
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
|
|
|
|
|
|
|
|
static inline
|
|
|
|
|
size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
|
|
|
|
|
bool with_hits)
|
|
|
|
|
{
|
|
|
|
|
return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits);
|
|
|
|
|
}
|
2009-12-11 21:24:02 -02:00
|
|
|
#endif /* __PERF_SESSION_H */
|