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
10 *
11 * Modified by Maynard Johnson <maynardj@us.ibm.com>
12 * These modifications are:
13 * (C) Copyright IBM Corporation 2007
14 */
15
16#ifndef OPD_TRANS_H
17#define OPD_TRANS_H
18
19#include "opd_cookie.h"
20#include "op_types.h"
21
22#include <stdint.h>
23
24struct 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;
56	uint64_t embedded_offset;
57	void * ext;
58};
59
60typedef void (*handler_t)(struct transient *);
61extern handler_t handlers[];
62
63uint64_t pop_buffer_value(struct transient * trans);
64int enough_remaining(struct transient * trans, size_t size);
65static inline void update_trans_last(struct transient * trans)
66{
67	trans->last = trans->current;
68	trans->last_anon = trans->anon;
69	trans->last_pc = trans->pc;
70}
71
72extern size_t kernel_pointer_size;
73static inline int is_escape_code(uint64_t code)
74{
75	return kernel_pointer_size == 4 ? code == ~0LU : code == ~0LLU;
76}
77
78void opd_process_samples(char const * buffer, size_t count);
79
80/** used when we need to clear data that's been freed */
81void clear_trans_last(struct transient * trans);
82
83/** used when we need to clear data that's been freed */
84void clear_trans_current(struct transient * trans);
85
86#endif /* OPD_TRANS_H */
87