aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-29 14:16:35 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-29 14:16:35 -0500
commitc40b62e42e901e46c1722104dbeaa17ac0b591a5 (patch)
tree08dde432c7c974c5dc50829157994e5635135712
parentff8ebb0ecd19766c9a8d72cd17e622156f7ca723 (diff)
parent2b0090a023316912f7d242a861aec50145919fae (diff)
Merge branch 'trace-cmd' into trace-view
-rw-r--r--.gitignore4
-rw-r--r--ctracecmd.i20
-rw-r--r--list.h47
-rw-r--r--parse-events.h13
-rw-r--r--trace-cmd.h5
-rw-r--r--trace-input.c284
-rw-r--r--trace-util.c11
-rw-r--r--tracecmd.py15
8 files changed, 254 insertions, 145 deletions
diff --git a/.gitignore b/.gitignore
index 964dbdf..af130c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,7 @@ trace-cmd
4*.a 4*.a
5trace.dat 5trace.dat
6*~ 6*~
7kernelshark
8trace-graph
9trace-view
10
diff --git a/ctracecmd.i b/ctracecmd.i
index 20a681c..a9d3ca5 100644
--- a/ctracecmd.i
+++ b/ctracecmd.i
@@ -6,19 +6,21 @@
6#include "trace-cmd.h" 6#include "trace-cmd.h"
7%} 7%}
8 8
9/* typemaps must come before the implementation of wrapped functions */ 9%typemap(out) unsigned long long {
10extern int pevent_read_number_field_32(struct format_field *f, void *data, 10$result = PyLong_FromUnsignedLongLong((unsigned long long) $1);
11 unsigned long *OUTPUT, unsigned long *OUTPUT); 11}
12 12
13%inline %{ 13%inline %{
14int pevent_read_number_field_32(struct format_field *f, void *data, unsigned long *hi, unsigned long *lo) 14PyObject *pevent_read_number_field_py(struct format_field *f, void *data)
15{ 15{
16 unsigned long long val64; 16 unsigned long long val;
17 int ret; 17 int ret;
18 ret = pevent_read_number_field(f, data, &val64); 18
19 *hi = (unsigned long)(val64>>32); 19 ret = pevent_read_number_field(f, data, &val);
20 *lo = (unsigned long)((val64<<32)>>32); 20 if (ret)
21 return ret; 21 Py_RETURN_NONE;
22 else
23 return PyLong_FromUnsignedLongLong(val);
22} 24}
23%} 25%}
24 26
diff --git a/list.h b/list.h
new file mode 100644
index 0000000..1ddac26
--- /dev/null
+++ b/list.h
@@ -0,0 +1,47 @@
1#ifndef __LIST_H
2#define __LIST_H
3
4#define offset_of(type, field) (long)(&((type *)0)->field)
5#define container_of(p, type, field) (type *)((long)p - offset_of(type, field))
6
7struct list_head {
8 struct list_head *next;
9 struct list_head *prev;
10};
11
12static inline void list_head_init(struct list_head *list)
13{
14 list->next = list;
15 list->prev = list;
16}
17
18static inline void list_add(struct list_head *p, struct list_head *head)
19{
20 struct list_head *next = head->next;
21
22 p->prev = head;
23 p->next = next;
24 next->prev = p;
25 head->next = p;
26}
27
28static inline void list_del(struct list_head *p)
29{
30 struct list_head *next = p->next;
31 struct list_head *prev = p->prev;
32
33 next->prev = prev;
34 prev->next = next;
35}
36
37static inline int list_empty(struct list_head *list)
38{
39 return list->next == list;
40}
41
42#define list_for_each_entry(p, list, type, field) \
43 for (p = container_of((list)->next, type, field); \
44 &(p)->field != list; \
45 p = container_of((p)->field.next, type, field))
46
47#endif /* __LIST_H */
diff --git a/parse-events.h b/parse-events.h
index 92f174e..bfbba5c 100644
--- a/parse-events.h
+++ b/parse-events.h
@@ -15,12 +15,13 @@
15#endif 15#endif
16 16
17struct record { 17struct record {
18 unsigned long long ts; 18 unsigned long long ts;
19 unsigned long long offset; 19 unsigned long long offset;
20 int record_size; /* size of binary record */ 20 int record_size; /* size of binary record */
21 int size; /* size of data */ 21 int size; /* size of data */
22 void *data; 22 void *data;
23 int cpu; 23 int cpu;
24 void *private;
24}; 25};
25 26
26/* 27/*
diff --git a/trace-cmd.h b/trace-cmd.h
index f6141f4..d0b5c92 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -22,10 +22,7 @@ enum {
22#define TS_SHIFT 27 22#define TS_SHIFT 27
23#endif 23#endif
24 24
25static inline void free_record(struct record *record) 25void free_record(struct record *record);
26{
27 free(record);
28}
29 26
30struct tracecmd_input; 27struct tracecmd_input;
31struct tracecmd_output; 28struct tracecmd_output;
diff --git a/trace-input.c b/trace-input.c
index 0bb750c..431c580 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -17,10 +17,19 @@
17#include <errno.h> 17#include <errno.h>
18 18
19#include "trace-cmd.h" 19#include "trace-cmd.h"
20#include "list.h"
20 21
21/* for debugging read instead of mmap */ 22/* for debugging read instead of mmap */
22static int force_read = 0; 23static int force_read = 0;
23 24
25struct page {
26 struct list_head list;
27 off64_t offset;
28 struct tracecmd_input *handle;
29 void *map;
30 int ref_count;
31};
32
24struct cpu_data { 33struct cpu_data {
25 /* the first two never change */ 34 /* the first two never change */
26 unsigned long long file_offset; 35 unsigned long long file_offset;
@@ -28,28 +37,27 @@ struct cpu_data {
28 unsigned long long offset; 37 unsigned long long offset;
29 unsigned long long size; 38 unsigned long long size;
30 unsigned long long timestamp; 39 unsigned long long timestamp;
40 struct list_head pages;
31 struct record *next; 41 struct record *next;
32 char *page; 42 struct page *page;
33 void *read_page;
34 int cpu; 43 int cpu;
35 int index; 44 int index;
36 int page_size; 45 int page_size;
37}; 46};
38 47
39struct tracecmd_input { 48struct tracecmd_input {
40 struct pevent *pevent; 49 struct pevent *pevent;
41 int fd; 50 int fd;
42 int long_size; 51 int long_size;
43 int page_size; 52 int page_size;
44 int read_page; 53 int read_page;
45 int cpus; 54 int cpus;
46 struct cpu_data *cpu_data; 55 struct cpu_data *cpu_data;
47 56
48 /* file information */ 57 /* file information */
49 size_t header_files_start; 58 size_t header_files_start;
50 size_t ftrace_files_start; 59 size_t ftrace_files_start;
51 size_t event_files_start; 60 size_t event_files_start;
52
53}; 61};
54 62
55__thread struct tracecmd_input *tracecmd_curr_thread_handle; 63__thread struct tracecmd_input *tracecmd_curr_thread_handle;
@@ -109,7 +117,7 @@ static char *read_string(struct tracecmd_input *handle)
109 } 117 }
110 if (i < r) 118 if (i < r)
111 break; 119 break;
112 120
113 if (str) { 121 if (str) {
114 size += BUFSIZ; 122 size += BUFSIZ;
115 str = realloc(str, size); 123 str = realloc(str, size);
@@ -121,7 +129,7 @@ static char *read_string(struct tracecmd_input *handle)
121 str = malloc(size); 129 str = malloc(size);
122 if (!str) 130 if (!str)
123 return NULL; 131 return NULL;
124 memcpy(str, buf, size); 132 memcpy(str, buf, size);
125 } 133 }
126 } 134 }
127 135
@@ -504,7 +512,97 @@ static unsigned int read_type_len_ts(s