|
@@ -114,20 +114,20 @@ static void skip(int size)
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
-static unsigned int read4(void)
|
|
|
|
|
|
+static unsigned int read4(struct pevent *pevent)
|
|
{
|
|
{
|
|
unsigned int data;
|
|
unsigned int data;
|
|
|
|
|
|
read_or_die(&data, 4);
|
|
read_or_die(&data, 4);
|
|
- return __data2host4(perf_pevent, data);
|
|
|
|
|
|
+ return __data2host4(pevent, data);
|
|
}
|
|
}
|
|
|
|
|
|
-static unsigned long long read8(void)
|
|
|
|
|
|
+static unsigned long long read8(struct pevent *pevent)
|
|
{
|
|
{
|
|
unsigned long long data;
|
|
unsigned long long data;
|
|
|
|
|
|
read_or_die(&data, 8);
|
|
read_or_die(&data, 8);
|
|
- return __data2host8(perf_pevent, data);
|
|
|
|
|
|
+ return __data2host8(pevent, data);
|
|
}
|
|
}
|
|
|
|
|
|
static char *read_string(void)
|
|
static char *read_string(void)
|
|
@@ -168,12 +168,12 @@ static char *read_string(void)
|
|
return str;
|
|
return str;
|
|
}
|
|
}
|
|
|
|
|
|
-static void read_proc_kallsyms(void)
|
|
|
|
|
|
+static void read_proc_kallsyms(struct pevent *pevent)
|
|
{
|
|
{
|
|
unsigned int size;
|
|
unsigned int size;
|
|
char *buf;
|
|
char *buf;
|
|
|
|
|
|
- size = read4();
|
|
|
|
|
|
+ size = read4(pevent);
|
|
if (!size)
|
|
if (!size)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -181,29 +181,29 @@ static void read_proc_kallsyms(void)
|
|
read_or_die(buf, size);
|
|
read_or_die(buf, size);
|
|
buf[size] = '\0';
|
|
buf[size] = '\0';
|
|
|
|
|
|
- parse_proc_kallsyms(buf, size);
|
|
|
|
|
|
+ parse_proc_kallsyms(pevent, buf, size);
|
|
|
|
|
|
free(buf);
|
|
free(buf);
|
|
}
|
|
}
|
|
|
|
|
|
-static void read_ftrace_printk(void)
|
|
|
|
|
|
+static void read_ftrace_printk(struct pevent *pevent)
|
|
{
|
|
{
|
|
unsigned int size;
|
|
unsigned int size;
|
|
char *buf;
|
|
char *buf;
|
|
|
|
|
|
- size = read4();
|
|
|
|
|
|
+ size = read4(pevent);
|
|
if (!size)
|
|
if (!size)
|
|
return;
|
|
return;
|
|
|
|
|
|
buf = malloc_or_die(size);
|
|
buf = malloc_or_die(size);
|
|
read_or_die(buf, size);
|
|
read_or_die(buf, size);
|
|
|
|
|
|
- parse_ftrace_printk(buf, size);
|
|
|
|
|
|
+ parse_ftrace_printk(pevent, buf, size);
|
|
|
|
|
|
free(buf);
|
|
free(buf);
|
|
}
|
|
}
|
|
|
|
|
|
-static void read_header_files(void)
|
|
|
|
|
|
+static void read_header_files(struct pevent *pevent)
|
|
{
|
|
{
|
|
unsigned long long size;
|
|
unsigned long long size;
|
|
char *header_event;
|
|
char *header_event;
|
|
@@ -214,7 +214,7 @@ static void read_header_files(void)
|
|
if (memcmp(buf, "header_page", 12) != 0)
|
|
if (memcmp(buf, "header_page", 12) != 0)
|
|
die("did not read header page");
|
|
die("did not read header page");
|
|
|
|
|
|
- size = read8();
|
|
|
|
|
|
+ size = read8(pevent);
|
|
skip(size);
|
|
skip(size);
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -227,47 +227,48 @@ static void read_header_files(void)
|
|
if (memcmp(buf, "header_event", 13) != 0)
|
|
if (memcmp(buf, "header_event", 13) != 0)
|
|
die("did not read header event");
|
|
die("did not read header event");
|
|
|
|
|
|
- size = read8();
|
|
|
|
|
|
+ size = read8(pevent);
|
|
header_event = malloc_or_die(size);
|
|
header_event = malloc_or_die(size);
|
|
read_or_die(header_event, size);
|
|
read_or_die(header_event, size);
|
|
free(header_event);
|
|
free(header_event);
|
|
}
|
|
}
|
|
|
|
|
|
-static void read_ftrace_file(unsigned long long size)
|
|
|
|
|
|
+static void read_ftrace_file(struct pevent *pevent, unsigned long long size)
|
|
{
|
|
{
|
|
char *buf;
|
|
char *buf;
|
|
|
|
|
|
buf = malloc_or_die(size);
|
|
buf = malloc_or_die(size);
|
|
read_or_die(buf, size);
|
|
read_or_die(buf, size);
|
|
- parse_ftrace_file(buf, size);
|
|
|
|
|
|
+ parse_ftrace_file(pevent, buf, size);
|
|
free(buf);
|
|
free(buf);
|
|
}
|
|
}
|
|
|
|
|
|
-static void read_event_file(char *sys, unsigned long long size)
|
|
|
|
|
|
+static void read_event_file(struct pevent *pevent, char *sys,
|
|
|
|
+ unsigned long long size)
|
|
{
|
|
{
|
|
char *buf;
|
|
char *buf;
|
|
|
|
|
|
buf = malloc_or_die(size);
|
|
buf = malloc_or_die(size);
|
|
read_or_die(buf, size);
|
|
read_or_die(buf, size);
|
|
- parse_event_file(buf, size, sys);
|
|
|
|
|
|
+ parse_event_file(pevent, buf, size, sys);
|
|
free(buf);
|
|
free(buf);
|
|
}
|
|
}
|
|
|
|
|
|
-static void read_ftrace_files(void)
|
|
|
|
|
|
+static void read_ftrace_files(struct pevent *pevent)
|
|
{
|
|
{
|
|
unsigned long long size;
|
|
unsigned long long size;
|
|
int count;
|
|
int count;
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- count = read4();
|
|
|
|
|
|
+ count = read4(pevent);
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
for (i = 0; i < count; i++) {
|
|
- size = read8();
|
|
|
|
- read_ftrace_file(size);
|
|
|
|
|
|
+ size = read8(pevent);
|
|
|
|
+ read_ftrace_file(pevent, size);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-static void read_event_files(void)
|
|
|
|
|
|
+static void read_event_files(struct pevent *pevent)
|
|
{
|
|
{
|
|
unsigned long long size;
|
|
unsigned long long size;
|
|
char *sys;
|
|
char *sys;
|
|
@@ -275,15 +276,15 @@ static void read_event_files(void)
|
|
int count;
|
|
int count;
|
|
int i,x;
|
|
int i,x;
|
|
|
|
|
|
- systems = read4();
|
|
|
|
|
|
+ systems = read4(pevent);
|
|
|
|
|
|
for (i = 0; i < systems; i++) {
|
|
for (i = 0; i < systems; i++) {
|
|
sys = read_string();
|
|
sys = read_string();
|
|
|
|
|
|
- count = read4();
|
|
|
|
|
|
+ count = read4(pevent);
|
|
for (x=0; x < count; x++) {
|
|
for (x=0; x < count; x++) {
|
|
- size = read8();
|
|
|
|
- read_event_file(sys, size);
|
|
|
|
|
|
+ size = read8(pevent);
|
|
|
|
+ read_event_file(pevent, sys, size);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -377,7 +378,7 @@ static int calc_index(void *ptr, int cpu)
|
|
return (unsigned long)ptr - (unsigned long)cpu_data[cpu].page;
|
|
return (unsigned long)ptr - (unsigned long)cpu_data[cpu].page;
|
|
}
|
|
}
|
|
|
|
|
|
-struct pevent_record *trace_peek_data(int cpu)
|
|
|
|
|
|
+struct pevent_record *trace_peek_data(struct pevent *pevent, int cpu)
|
|
{
|
|
{
|
|
struct pevent_record *data;
|
|
struct pevent_record *data;
|
|
void *page = cpu_data[cpu].page;
|
|
void *page = cpu_data[cpu].page;
|
|
@@ -399,15 +400,15 @@ struct pevent_record *trace_peek_data(int cpu)
|
|
/* FIXME: handle header page */
|
|
/* FIXME: handle header page */
|
|
if (header_page_ts_size != 8)
|
|
if (header_page_ts_size != 8)
|
|
die("expected a long long type for timestamp");
|
|
die("expected a long long type for timestamp");
|
|
- cpu_data[cpu].timestamp = data2host8(perf_pevent, ptr);
|
|
|
|
|
|
+ cpu_data[cpu].timestamp = data2host8(pevent, ptr);
|
|
ptr += 8;
|
|
ptr += 8;
|
|
switch (header_page_size_size) {
|
|
switch (header_page_size_size) {
|
|
case 4:
|
|
case 4:
|
|
- cpu_data[cpu].page_size = data2host4(perf_pevent, ptr);
|
|
|
|
|
|
+ cpu_data[cpu].page_size = data2host4(pevent, ptr);
|
|
ptr += 4;
|
|
ptr += 4;
|
|
break;
|
|
break;
|
|
case 8:
|
|
case 8:
|
|
- cpu_data[cpu].page_size = data2host8(perf_pevent, ptr);
|
|
|
|
|
|
+ cpu_data[cpu].page_size = data2host8(pevent, ptr);
|
|
ptr += 8;
|
|
ptr += 8;
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -421,10 +422,10 @@ read_again:
|
|
|
|
|
|
if (idx >= cpu_data[cpu].page_size) {
|
|
if (idx >= cpu_data[cpu].page_size) {
|
|
get_next_page(cpu);
|
|
get_next_page(cpu);
|
|
- return trace_peek_data(cpu);
|
|
|
|
|
|
+ return trace_peek_data(pevent, cpu);
|
|
}
|
|
}
|
|
|
|
|
|
- type_len_ts = data2host4(perf_pevent, ptr);
|
|
|
|
|
|
+ type_len_ts = data2host4(pevent, ptr);
|
|
ptr += 4;
|
|
ptr += 4;
|
|
|
|
|
|
type_len = type_len4host(type_len_ts);
|
|
type_len = type_len4host(type_len_ts);
|
|
@@ -434,14 +435,14 @@ read_again:
|
|
case RINGBUF_TYPE_PADDING:
|
|
case RINGBUF_TYPE_PADDING:
|
|
if (!delta)
|
|
if (!delta)
|
|
die("error, hit unexpected end of page");
|
|
die("error, hit unexpected end of page");
|
|
- length = data2host4(perf_pevent, ptr);
|
|
|
|
|
|
+ length = data2host4(pevent, ptr);
|
|
ptr += 4;
|
|
ptr += 4;
|
|
length *= 4;
|
|
length *= 4;
|
|
ptr += length;
|
|
ptr += length;
|
|
goto read_again;
|
|
goto read_again;
|
|
|
|
|
|
case RINGBUF_TYPE_TIME_EXTEND:
|
|
case RINGBUF_TYPE_TIME_EXTEND:
|
|
- extend = data2host4(perf_pevent, ptr);
|
|
|
|
|
|
+ extend = data2host4(pevent, ptr);
|
|
ptr += 4;
|
|
ptr += 4;
|
|
extend <<= TS_SHIFT;
|
|
extend <<= TS_SHIFT;
|
|
extend += delta;
|
|
extend += delta;
|
|
@@ -452,7 +453,7 @@ read_again:
|
|
ptr += 12;
|
|
ptr += 12;
|
|
break;
|
|
break;
|
|
case 0:
|
|
case 0:
|
|
- length = data2host4(perf_pevent, ptr);
|
|
|
|
|
|
+ length = data2host4(pevent, ptr);
|
|
ptr += 4;
|
|
ptr += 4;
|
|
die("here! length=%d", length);
|
|
die("here! length=%d", length);
|
|
break;
|
|
break;
|
|
@@ -477,17 +478,17 @@ read_again:
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
-struct pevent_record *trace_read_data(int cpu)
|
|
|
|
|
|
+struct pevent_record *trace_read_data(struct pevent *pevent, int cpu)
|
|
{
|
|
{
|
|
struct pevent_record *data;
|
|
struct pevent_record *data;
|
|
|
|
|
|
- data = trace_peek_data(cpu);
|
|
|
|
|
|
+ data = trace_peek_data(pevent, cpu);
|
|
cpu_data[cpu].next = NULL;
|
|
cpu_data[cpu].next = NULL;
|
|
|
|
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
-ssize_t trace_report(int fd, bool __repipe)
|
|
|
|
|
|
+ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe)
|
|
{
|
|
{
|
|
char buf[BUFSIZ];
|
|
char buf[BUFSIZ];
|
|
char test[] = { 23, 8, 68 };
|
|
char test[] = { 23, 8, 68 };
|
|
@@ -519,30 +520,32 @@ ssize_t trace_report(int fd, bool __repipe)
|
|
file_bigendian = buf[0];
|
|
file_bigendian = buf[0];
|
|
host_bigendian = bigendian();
|
|
host_bigendian = bigendian();
|
|
|
|
|
|
- read_trace_init(file_bigendian, host_bigendian);
|
|
|
|
|
|
+ *ppevent = read_trace_init(file_bigendian, host_bigendian);
|
|
|
|
+ if (*ppevent == NULL)
|
|
|
|
+ die("read_trace_init failed");
|
|
|
|
|
|
read_or_die(buf, 1);
|
|
read_or_die(buf, 1);
|
|
long_size = buf[0];
|
|
long_size = buf[0];
|
|
|
|
|
|
- page_size = read4();
|
|
|
|
|
|
+ page_size = read4(*ppevent);
|
|
|
|
|
|
- read_header_files();
|
|
|
|
|
|
+ read_header_files(*ppevent);
|
|
|
|
|
|
- read_ftrace_files();
|
|
|
|
- read_event_files();
|
|
|
|
- read_proc_kallsyms();
|
|
|
|
- read_ftrace_printk();
|
|
|
|
|
|
+ read_ftrace_files(*ppevent);
|
|
|
|
+ read_event_files(*ppevent);
|
|
|
|
+ read_proc_kallsyms(*ppevent);
|
|
|
|
+ read_ftrace_printk(*ppevent);
|
|
|
|
|
|
size = calc_data_size - 1;
|
|
size = calc_data_size - 1;
|
|
calc_data_size = 0;
|
|
calc_data_size = 0;
|
|
repipe = false;
|
|
repipe = false;
|
|
|
|
|
|
if (show_funcs) {
|
|
if (show_funcs) {
|
|
- pevent_print_funcs(perf_pevent);
|
|
|
|
|
|
+ pevent_print_funcs(*ppevent);
|
|
return size;
|
|
return size;
|
|
}
|
|
}
|
|
if (show_printk) {
|
|
if (show_printk) {
|
|
- pevent_print_printk(perf_pevent);
|
|
|
|
|
|
+ pevent_print_printk(*ppevent);
|
|
return size;
|
|
return size;
|
|
}
|
|
}
|
|
|
|
|