Upstream | cc2ee17 | 1970-01-12 13:46:40 +0000 | [diff] [blame] | 1 | /** |
| 2 | * @file daemon/opd_trans.h |
| 3 | * Processing the sample buffer |
| 4 | * |
| 5 | * @remark Copyright 2002 OProfile authors |
| 6 | * @remark Read the file COPYING |
| 7 | * |
| 8 | * @author John Levon |
| 9 | * @author Philippe Elie |
The Android Open Source Project | 7984f7a | 2008-12-17 18:04:47 -0800 | [diff] [blame] | 10 | * |
| 11 | * Modified by Maynard Johnson <maynardj@us.ibm.com> |
| 12 | * These modifications are: |
| 13 | * (C) Copyright IBM Corporation 2007 |
Upstream | cc2ee17 | 1970-01-12 13:46:40 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef OPD_TRANS_H |
| 17 | #define OPD_TRANS_H |
| 18 | |
| 19 | #include "opd_cookie.h" |
| 20 | #include "op_types.h" |
| 21 | |
The Android Open Source Project | 7984f7a | 2008-12-17 18:04:47 -0800 | [diff] [blame] | 22 | #include <stdint.h> |
| 23 | |
Upstream | cc2ee17 | 1970-01-12 13:46:40 +0000 | [diff] [blame] | 24 | struct sfile; |
| 25 | struct anon_mapping; |
| 26 | |
| 27 | enum tracing_type { |
| 28 | TRACING_OFF, |
| 29 | TRACING_START, |
| 30 | TRACING_ON |
| 31 | }; |
| 32 | |
| 33 | /** |
| 34 | * Transient values used for parsing the event buffer. |
| 35 | * Note that these are reset for each buffer read, but |
| 36 | * that should be ok as in the kernel, cpu_buffer_reset() |
| 37 | * ensures that a correct context starts off the buffer. |
| 38 | */ |
| 39 | struct transient { |
| 40 | char const * buffer; |
| 41 | size_t remaining; |
| 42 | enum tracing_type tracing; |
| 43 | struct sfile * current; |
| 44 | struct sfile * last; |
| 45 | struct anon_mapping * anon; |
| 46 | struct anon_mapping * last_anon; |
| 47 | cookie_t cookie; |
| 48 | cookie_t app_cookie; |
| 49 | vma_t pc; |
| 50 | vma_t last_pc; |
| 51 | unsigned long event; |
| 52 | int in_kernel; |
| 53 | unsigned long cpu; |
| 54 | pid_t tid; |
| 55 | pid_t tgid; |
The Android Open Source Project | 7984f7a | 2008-12-17 18:04:47 -0800 | [diff] [blame] | 56 | uint64_t embedded_offset; |
Upstream | cc2ee17 | 1970-01-12 13:46:40 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
The Android Open Source Project | 7984f7a | 2008-12-17 18:04:47 -0800 | [diff] [blame] | 59 | typedef void (*handler_t)(struct transient *); |
| 60 | extern handler_t handlers[]; |
| 61 | |
| 62 | uint64_t pop_buffer_value(struct transient * trans); |
| 63 | int enough_remaining(struct transient * trans, size_t size); |
| 64 | static inline void update_trans_last(struct transient * trans) |
| 65 | { |
| 66 | trans->last = trans->current; |
| 67 | trans->last_anon = trans->anon; |
| 68 | trans->last_pc = trans->pc; |
| 69 | } |
| 70 | |
| 71 | extern size_t kernel_pointer_size; |
| 72 | static inline int is_escape_code(uint64_t code) |
| 73 | { |
| 74 | return kernel_pointer_size == 4 ? code == ~0LU : code == ~0LLU; |
| 75 | } |
| 76 | |
Upstream | cc2ee17 | 1970-01-12 13:46:40 +0000 | [diff] [blame] | 77 | void opd_process_samples(char const * buffer, size_t count); |
| 78 | |
| 79 | /** used when we need to clear data that's been freed */ |
| 80 | void clear_trans_last(struct transient * trans); |
| 81 | |
| 82 | /** used when we need to clear data that's been freed */ |
| 83 | void clear_trans_current(struct transient * trans); |
| 84 | |
| 85 | #endif /* OPD_TRANS_H */ |