blob: ab4e816099c0402cd3793c9c542cd5091a690d3d [file] [log] [blame]
Upstreamcc2ee171970-01-12 13:46:40 +00001/**
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
Ben Cheng2b16b5f2008-10-23 16:07:43 -070010 *
11 * Modified by Maynard Johnson <maynardj@us.ibm.com>
12 * These modifications are:
13 * (C) Copyright IBM Corporation 2007
Upstreamcc2ee171970-01-12 13:46:40 +000014 */
15
16#ifndef OPD_TRANS_H
17#define OPD_TRANS_H
18
19#include "opd_cookie.h"
20#include "op_types.h"
21
Ben Cheng2b16b5f2008-10-23 16:07:43 -070022#include <stdint.h>
23
Upstreamcc2ee171970-01-12 13:46:40 +000024struct sfile;
25struct anon_mapping;
26
27enum 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 */
39struct 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;
Ben Cheng2b16b5f2008-10-23 16:07:43 -070056 uint64_t embedded_offset;
Upstreamcc2ee171970-01-12 13:46:40 +000057};
58
Ben Cheng2b16b5f2008-10-23 16:07:43 -070059typedef void (*handler_t)(struct transient *);
60extern handler_t handlers[];
61
62uint64_t pop_buffer_value(struct transient * trans);
63int enough_remaining(struct transient * trans, size_t size);
64static 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
71extern size_t kernel_pointer_size;
72static inline int is_escape_code(uint64_t code)
73{
74 return kernel_pointer_size == 4 ? code == ~0LU : code == ~0LLU;
75}
76
Upstreamcc2ee171970-01-12 13:46:40 +000077void opd_process_samples(char const * buffer, size_t count);
78
79/** used when we need to clear data that's been freed */
80void clear_trans_last(struct transient * trans);
81
82/** used when we need to clear data that's been freed */
83void clear_trans_current(struct transient * trans);
84
85#endif /* OPD_TRANS_H */