1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
////////////////////////////////////////////////////////////////////////////////////
//
// FILE: storage.h
//
// DESCRIPTION:
// This file is C source for SWAP.
//
// SEE ALSO: storage.c
// AUTHOR: L.Komkov, S.Dianov, A.Gerenkov
// COMPANY NAME: Samsung Research Center in Moscow
// DEPT NAME: Advanced Software Group
// CREATED: 2008.02.15
// VERSION: 1.0
// REVISION DATE: 2008.12.03
//
////////////////////////////////////////////////////////////////////////////////////
#if !defined(__STORAGE_H__)
#define __STORAGE_H__
#include <linux/mount.h>
#include <linux/module.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include "picl.h"
#include "ec_ioctl.h"
#include "ec_probe.h"
#include "probes_manager.h"
#include "probes.h"
#include "event_tmpl.h"
#include "error_storage.h"
extern int EnableContinuousRetrieval(void);
extern int DisableContinuousRetrieval(void);
///////////////////////////////////////////////////////////////////////////////////////////////////
extern unsigned int GetBufferSize(void);
extern int SetBufferSize(unsigned int nSize);
extern int ResetBuffer(void);
extern int SetPid(unsigned int pid);
//extern spinlock_t buffer_spinlock;
///////////////////////////////////////////////////////////////////////////////////////////////////
/*
Functions "storage_init()" and "storage_down()" are for initialization and
shutdown respectively.
*/
extern int storage_init (void);
extern void storage_down (void);
/*
Function "pack_event_info()" saves information about event into buffer. It
is used in 'probes' to pack and save event data.
*/
extern void pack_task_event_info (struct task_struct *task, probe_id_t probe_id,
record_type_t record_type, const char *fmt, ...);
#define pack_event_info(probe_id, record_type, fmt, ...) \
pack_task_event_info(current, probe_id, record_type, fmt, __VA_ARGS__)
/* Set most links from us_proc_info to data in the bundle */
int link_bundle(void);
/* Undo the actions of link_bundle() */
void unlink_bundle(void);
void dbi_find_and_set_handler_for_probe(unsigned long addr,
unsigned long *pre_entry,
unsigned long *jp_handler,
unsigned long *rp_handler);
/*
Copies event from user space to buffer and updates its pid/tid/cpu/time.
*/
extern int put_us_event (char *data, unsigned long len);
/*
Sets event mask.
*/
extern int set_event_mask (int new_mask);
/*
Gets event mask.
*/
extern int get_event_mask (int *mask);
/*
Sets predefined user space probes info.
*/
extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
/*
Gets predefined user space probes info length.
*/
extern int get_predef_uprobes_size(int *size);
/*
Gets predefined user space probes info.
*/
extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
// internal bookkeeping of storage
extern char *p_buffer;
// multiple handlers stuff
/*struct dbi_modules_handlers {
struct list_head modules_handlers;
spinlock_t lock;
};
struct dbi_modules_handlers_info {
struct module *dbi_module;
struct handler_map *dbi_handlers;
int dbi_nr_handlers;
struct list_head dbi_list_head;
};
extern int dbi_register_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
extern int dbi_unregister_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
//unsigned long get_dbi_modules_handlers(void);*/
// event mask
extern int event_mask;
// process pid to instrument
extern unsigned int inst_pid;
typedef struct
{
struct list_head list;
char *name;
int installed;
struct jprobe jprobe;
struct kretprobe retprobe;
unsigned long offset;
unsigned long got_addr;
unsigned flag_retprobe:1;
unsigned flag_got:1;
} us_proc_ip_t;
typedef struct
{
int installed;
struct jprobe jprobe;
unsigned long addr;
struct list_head list;
} us_proc_vtp_t;
typedef struct
{
char *name;
char type;
unsigned long size;
signed char reg; // -1 - memory, 0..127 - register number
long off;
struct list_head list;
} us_proc_vtp_data_t;
typedef struct
{
unsigned func_addr;
unsigned got_addr;
unsigned real_func_addr;
} us_proc_plt_t;
typedef struct
{
char *path;
char *path_dyn;
struct dentry *m_f_dentry;
unsigned ips_count;
us_proc_ip_t *p_ips;
unsigned vtps_count;
us_proc_vtp_t *p_vtps;
int loaded;
unsigned plt_count;
us_proc_plt_t *p_plt;
unsigned long vma_start;
unsigned long vma_end;
unsigned vma_flag;
} us_proc_lib_t;
typedef struct
{
char *path;
struct dentry *m_f_dentry;
pid_t tgid;
unsigned unres_ips_count;
unsigned unres_vtps_count;
//kprobe_opcode_t *mapped_codelets;
int is_plt;
unsigned libs_count;
us_proc_lib_t *p_libs;
// new_dpf
struct sspt_proc *pp;
} inst_us_proc_t;
typedef struct
{
unsigned int addr;
unsigned int inst_type;
char *name;
char *class_name;
char *method_name;
char *prototype;
}dex_proc_ip_t;
typedef struct
{
char *path;
unsigned ips_count;
dex_proc_ip_t *p_ips;
}inst_dex_proc_t;
struct cond {
/* cond data itself */
struct event_tmpl tmpl;
/* linked list */
struct list_head list;
/* has been applied (for start and stop conditions) */
int applied;
};
extern struct cond cond_list;
/* macros for testing flags */
#define ET_FIELD_CLR(flags, field) (flags &= ~field)
#define ET_FIELD_SET(flags, field) (flags |= field)
#define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
extern inst_us_proc_t us_proc_info;
extern inst_dex_proc_t dex_proc_info;
#endif /* !defined(__STORAGE_H__) */
|