1 ////////////////////////////////////////////////////////////////////////////////////
6 // This file is C source for SWAP.
9 // AUTHOR: L.Komkov, S.Dianov, A.Gerenkov
10 // COMPANY NAME: Samsung Research Center in Moscow
11 // DEPT NAME: Advanced Software Group
12 // CREATED: 2008.02.15
14 // REVISION DATE: 2008.12.03
16 ////////////////////////////////////////////////////////////////////////////////////
18 #if !defined(__STORAGE_H__)
21 #include <linux/mount.h>
22 #include <linux/module.h>
23 #include <linux/list.h>
24 #include <linux/spinlock.h>
28 #include "probes_manager.h"
30 #include "event_tmpl.h"
31 #include "error_storage.h"
33 extern int EnableContinuousRetrieval(void);
34 extern int DisableContinuousRetrieval(void);
36 ///////////////////////////////////////////////////////////////////////////////////////////////////
38 extern unsigned int GetBufferSize(void);
39 extern int SetBufferSize(unsigned int nSize);
40 extern int ResetBuffer(void);
42 extern int SetPid(unsigned int pid);
44 //extern spinlock_t buffer_spinlock;
46 ///////////////////////////////////////////////////////////////////////////////////////////////////
49 Functions "storage_init()" and "storage_down()" are for initialization and
50 shutdown respectively.
52 extern int storage_init (void);
53 extern void storage_down (void);
56 Function "pack_event_info()" saves information about event into buffer. It
57 is used in 'probes' to pack and save event data.
59 extern void pack_task_event_info (struct task_struct *task, probe_id_t probe_id,
60 record_type_t record_type, const char *fmt, ...);
61 #define pack_event_info(probe_id, record_type, fmt, ...) \
62 pack_task_event_info(current, probe_id, record_type, fmt, __VA_ARGS__)
64 /* Set most links from us_proc_info to data in the bundle */
65 int link_bundle(void);
66 /* Undo the actions of link_bundle() */
67 void unlink_bundle(void);
70 Adds non-predefined kernel probe to the list.
72 extern int add_probe_to_list (unsigned long addr, kernel_probe_t ** pprobe);
75 Removes non-predefined kernel probe from the list.
77 extern int remove_probe_from_list (unsigned long addr);
80 Searches non-predefined kernel probe in the list.
82 extern kernel_probe_t *find_probe (unsigned long addr);
85 Copies event from user space to buffer and updates its pid/tid/cpu/time.
87 extern int put_us_event (char *data, unsigned long len);
92 extern int set_event_mask (int new_mask);
97 extern int get_event_mask (int *mask);
100 Sets predefined user space probes info.
102 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
104 Gets predefined user space probes info length.
106 extern int get_predef_uprobes_size(int *size);
108 Gets predefined user space probes info.
110 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
113 // internal bookkeeping of storage
114 extern char *p_buffer;
116 // list of selected non-predefined kernel probes
117 extern struct hlist_head kernel_probes;
119 // multiple handlers stuff
120 /*struct dbi_modules_handlers {
121 struct list_head modules_handlers;
125 struct dbi_modules_handlers_info {
126 struct module *dbi_module;
127 struct handler_map *dbi_handlers;
129 struct list_head dbi_list_head;
132 extern int dbi_register_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
133 extern int dbi_unregister_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
134 //unsigned long get_dbi_modules_handlers(void);*/
137 extern int event_mask;
139 // process pid to instrument
140 extern unsigned int inst_pid;
144 struct list_head list;
147 struct jprobe jprobe;
148 struct kretprobe retprobe;
149 unsigned long offset;
150 unsigned long got_addr;
152 unsigned flag_retprobe:1;
159 struct jprobe jprobe;
161 struct list_head list;
169 signed char reg; // -1 - memory, 0..127 - register number
171 struct list_head list;
172 } us_proc_vtp_data_t;
178 unsigned real_func_addr;
185 struct dentry *m_f_dentry;
189 us_proc_vtp_t *p_vtps;
192 us_proc_plt_t *p_plt;
193 unsigned long vma_start;
194 unsigned long vma_end;
202 struct dentry *m_f_dentry;
204 unsigned unres_ips_count;
205 unsigned unres_vtps_count;
206 //kprobe_opcode_t *mapped_codelets;
209 us_proc_lib_t *p_libs;
212 struct sspt_procs *pp;
218 unsigned int inst_type;
230 dex_proc_ip_t *p_ips;
236 /* cond data itself */
237 struct event_tmpl tmpl;
239 struct list_head list;
240 /* has been applied (for start and stop conditions) */
244 extern struct cond cond_list;
246 /* macros for testing flags */
247 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
248 #define ET_FIELD_SET(flags, field) (flags |= field)
249 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
251 extern inst_us_proc_t us_proc_info;
252 extern inst_dex_proc_t dex_proc_info;
254 #endif /* !defined(__STORAGE_H__) */