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);
69 void dbi_find_and_set_handler_for_probe(kernel_probe_t *p);
72 Searches non-predefined kernel probe in the list.
74 extern kernel_probe_t *find_probe (unsigned long addr);
77 Copies event from user space to buffer and updates its pid/tid/cpu/time.
79 extern int put_us_event (char *data, unsigned long len);
84 extern int set_event_mask (int new_mask);
89 extern int get_event_mask (int *mask);
92 Sets predefined user space probes info.
94 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
96 Gets predefined user space probes info length.
98 extern int get_predef_uprobes_size(int *size);
100 Gets predefined user space probes info.
102 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
105 // internal bookkeeping of storage
106 extern char *p_buffer;
108 // list of selected non-predefined kernel probes
109 extern struct hlist_head kernel_probes;
111 // multiple handlers stuff
112 /*struct dbi_modules_handlers {
113 struct list_head modules_handlers;
117 struct dbi_modules_handlers_info {
118 struct module *dbi_module;
119 struct handler_map *dbi_handlers;
121 struct list_head dbi_list_head;
124 extern int dbi_register_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
125 extern int dbi_unregister_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);
126 //unsigned long get_dbi_modules_handlers(void);*/
129 extern int event_mask;
131 // process pid to instrument
132 extern unsigned int inst_pid;
136 struct list_head list;
139 struct jprobe jprobe;
140 struct kretprobe retprobe;
141 unsigned long offset;
142 unsigned long got_addr;
144 unsigned flag_retprobe:1;
151 struct jprobe jprobe;
153 struct list_head list;
161 signed char reg; // -1 - memory, 0..127 - register number
163 struct list_head list;
164 } us_proc_vtp_data_t;
170 unsigned real_func_addr;
177 struct dentry *m_f_dentry;
181 us_proc_vtp_t *p_vtps;
184 us_proc_plt_t *p_plt;
185 unsigned long vma_start;
186 unsigned long vma_end;
194 struct dentry *m_f_dentry;
196 unsigned unres_ips_count;
197 unsigned unres_vtps_count;
198 //kprobe_opcode_t *mapped_codelets;
201 us_proc_lib_t *p_libs;
204 struct sspt_procs *pp;
210 unsigned int inst_type;
222 dex_proc_ip_t *p_ips;
228 /* cond data itself */
229 struct event_tmpl tmpl;
231 struct list_head list;
232 /* has been applied (for start and stop conditions) */
236 extern struct cond cond_list;
238 /* macros for testing flags */
239 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
240 #define ET_FIELD_SET(flags, field) (flags |= field)
241 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
243 extern inst_us_proc_t us_proc_info;
244 extern inst_dex_proc_t dex_proc_info;
246 #endif /* !defined(__STORAGE_H__) */