diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-19 22:48:53 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-19 22:48:53 -0400 |
commit | 522493257f03b9a9021ac6b18a2c15c0af581b32 (patch) | |
tree | 3f066511631946919c703c4598b75f1364122f0e /litmus | |
parent | 0acc5e8a1d7caa74f644ac92cab2d958cf508d6e (diff) |
Refactor Feather-Trace
- move platform dependent bits into arch/
- provide a default implementation (used for sparc64)
Diffstat (limited to 'litmus')
-rw-r--r-- | litmus/ft_event.c | 103 | ||||
-rw-r--r-- | litmus/trace.c | 2 |
2 files changed, 22 insertions, 83 deletions
diff --git a/litmus/ft_event.c b/litmus/ft_event.c index b1d80c52d7..6084b6d6b3 100644 --- a/litmus/ft_event.c +++ b/litmus/ft_event.c | |||
@@ -2,103 +2,42 @@ | |||
2 | 2 | ||
3 | #include <litmus/feather_trace.h> | 3 | #include <litmus/feather_trace.h> |
4 | 4 | ||
5 | /* the feather trace management functions assume | 5 | #ifndef __ARCH_HAS_FEATHER_TRACE |
6 | * exclusive access to the event table | 6 | /* provide dummy implementation */ |
7 | */ | ||
8 | 7 | ||
9 | 8 | int ft_events[MAX_EVENTS]; | |
10 | #define BYTE_JUMP 0xeb | ||
11 | #define BYTE_JUMP_LEN 0x02 | ||
12 | |||
13 | /* for each event, there is an entry in the event table */ | ||
14 | struct trace_event { | ||
15 | long id; | ||
16 | long count; | ||
17 | long start_addr; | ||
18 | long end_addr; | ||
19 | }; | ||
20 | |||
21 | extern struct trace_event __start___event_table[]; | ||
22 | extern struct trace_event __stop___event_table[]; | ||
23 | 9 | ||
24 | int ft_enable_event(unsigned long id) | 10 | int ft_enable_event(unsigned long id) |
25 | { | 11 | { |
26 | struct trace_event* te = __start___event_table; | 12 | if (id < MAX_EVENTS) { |
27 | int count = 0; | 13 | ft_events[id]++; |
28 | char* delta; | 14 | return 1; |
29 | unsigned char* instr; | 15 | } else |
30 | 16 | return 0; | |
31 | while (te < __stop___event_table) { | ||
32 | if (te->id == id && ++te->count == 1) { | ||
33 | instr = (unsigned char*) te->start_addr; | ||
34 | /* make sure we don't clobber something wrong */ | ||
35 | if (*instr == BYTE_JUMP) { | ||
36 | delta = (((unsigned char*) te->start_addr) + 1); | ||
37 | *delta = 0; | ||
38 | } | ||
39 | } | ||
40 | if (te->id == id) | ||
41 | count++; | ||
42 | te++; | ||
43 | } | ||
44 | return count; | ||
45 | } | 17 | } |
46 | 18 | ||
47 | int ft_disable_event(unsigned long id) | 19 | int ft_disable_event(unsigned long id) |
48 | { | 20 | { |
49 | struct trace_event* te = __start___event_table; | 21 | if (id < MAX_EVENTS && ft_events[id]) { |
50 | int count = 0; | 22 | ft_events[id]--; |
51 | char* delta; | 23 | return 1; |
52 | unsigned char* instr; | 24 | } else |
53 | 25 | return 0; | |
54 | while (te < __stop___event_table) { | ||
55 | if (te->id == id && --te->count == 0) { | ||
56 | instr = (unsigned char*) te->start_addr; | ||
57 | if (*instr == BYTE_JUMP) { | ||
58 | delta = (((unsigned char*) te->start_addr) + 1); | ||
59 | *delta = te->end_addr - te->start_addr - | ||
60 | BYTE_JUMP_LEN; | ||
61 | } | ||
62 | } | ||
63 | if (te->id == id) | ||
64 | count++; | ||
65 | te++; | ||
66 | } | ||
67 | return count; | ||
68 | } | 26 | } |
69 | 27 | ||
70 | int ft_disable_all_events(void) | 28 | int ft_disable_all_events(void) |
71 | { | 29 | { |
72 | struct trace_event* te = __start___event_table; | 30 | int i; |
73 | int count = 0; | 31 | |
74 | char* delta; | 32 | for (i = 0; i < MAX_EVENTS; i++) |
75 | unsigned char* instr; | 33 | ft_events[i] = 0; |
76 | 34 | ||
77 | while (te < __stop___event_table) { | 35 | return MAX_EVENTS; |
78 | if (te->count) { | ||
79 | instr = (unsigned char*) te->start_addr; | ||
80 | if (*instr == BYTE_JUMP) { | ||
81 | delta = (((unsigned char*) te->start_addr) | ||
82 | + 1); | ||
83 | *delta = te->end_addr - te->start_addr - | ||
84 | BYTE_JUMP_LEN; | ||
85 | te->count = 0; | ||
86 | count++; | ||
87 | } | ||
88 | } | ||
89 | te++; | ||
90 | } | ||
91 | return count; | ||
92 | } | 36 | } |
93 | 37 | ||
94 | int ft_is_event_enabled(unsigned long id) | 38 | int ft_is_event_enabled(unsigned long id) |
95 | { | 39 | { |
96 | struct trace_event* te = __start___event_table; | 40 | return id < MAX_EVENTS && ft_events[id]; |
97 | |||
98 | while (te < __stop___event_table) { | ||
99 | if (te->id == id) | ||
100 | return te->count; | ||
101 | te++; | ||
102 | } | ||
103 | return 0; | ||
104 | } | 41 | } |
42 | |||
43 | #endif | ||
diff --git a/litmus/trace.c b/litmus/trace.c index 489e23e8a6..28cfa5b072 100644 --- a/litmus/trace.c +++ b/litmus/trace.c | |||
@@ -21,7 +21,7 @@ feather_callback void save_timestamp(unsigned long event) | |||
21 | struct timestamp *ts; | 21 | struct timestamp *ts; |
22 | if (ft_buffer_start_write(trace_ts_buf, (void**) &ts)) { | 22 | if (ft_buffer_start_write(trace_ts_buf, (void**) &ts)) { |
23 | ts->event = event; | 23 | ts->event = event; |
24 | ts->timestamp = ft_read_tsc(); | 24 | ts->timestamp = ft_timestamp(); |
25 | ts->seq_no = seq_no; | 25 | ts->seq_no = seq_no; |
26 | ts->cpu = raw_smp_processor_id(); | 26 | ts->cpu = raw_smp_processor_id(); |
27 | ft_buffer_finish_write(trace_ts_buf, ts); | 27 | ft_buffer_finish_write(trace_ts_buf, ts); |