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__)
24 #include "probes_manager.h"
26 #include "event_tmpl.h"
28 ///////////////////////////////////////////////////////////////////////////////////////////////////
30 #ifndef __DISABLE_RELAYFS
31 extern struct rchan* GetRelayChannel(void);
32 extern struct dentry* GetRelayDir(void);
33 #endif //__DISABLE_RELAYFS
35 extern int EnableMultipleBuffer(void);
36 extern int DisableMultipleBuffer(void);
37 extern int EnableContinuousRetrieval(void);
38 extern int DisableContinuousRetrieval(void);
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
42 extern unsigned int GetBufferSize(void);
43 extern int SetBufferSize(unsigned int nSize);
44 extern int ResetBuffer(void);
46 //extern spinlock_t buffer_spinlock;
48 ///////////////////////////////////////////////////////////////////////////////////////////////////
51 Functions "storage_init()" and "storage_down()" are for initialization and
52 shutdown respectively.
54 extern int storage_init (void);
55 extern void storage_down (void);
58 Function "pack_event_info()" saves information about event into buffer. It
59 is used in 'probes' to pack and save event data.
61 extern void pack_event_info (probe_id_t probe_id, record_type_t record_type, const char *fmt, ...);
64 Function "set_us_proc_inst()" saves instrumentation info for user space process.
66 extern int set_us_proc_inst_info (ioctl_inst_usr_space_proc_t * inst_info);
69 Function "release_us_proc_inst_info()" destroys instrumentation info for user space process.
71 extern void release_us_proc_inst_info (void);
74 Adds non-predefined kernel probe to the list.
76 extern int add_probe_to_list (unsigned long addr, kernel_probe_t ** pprobe);
79 Removes non-predefined kernel probe from the list.
81 extern int remove_probe_from_list (unsigned long addr);
84 Searches non-predefined kernel probe in the list.
86 extern kernel_probe_t *find_probe (unsigned long addr);
89 Copies event from user space to buffer and updates its pid/tid/cpu/time.
91 extern int put_us_event (char *data, unsigned long len);
96 extern int set_event_mask (int new_mask);
101 extern int get_event_mask (int *mask);
104 Sets predefined user space probes info.
106 extern int set_predef_uprobes (ioctl_predef_uprobes_info_t *data);
108 Gets predefined user space probes info length.
110 extern int get_predef_uprobes_size(int *size);
112 Gets predefined user space probes info.
114 extern int get_predef_uprobes(ioctl_predef_uprobes_info_t *data);
116 #ifdef MEMORY_CHECKER
117 extern void mec_remove_objects(void);
118 extern void *mec_find_in_object_range(void *addr, int *rz);
119 extern void mec_change_active_object(void *obj);
120 extern unsigned long pf_addr;
121 // maximum overflow/underflow size
122 // access into unallocated process space near active object,
123 // but within this gap will be treated as overflow/underflow
124 #define MEC_MAX_OVERFLOW_SIZE (1024)
127 // internal bookkeeping of storage
128 extern char *p_buffer;
130 // list of selected non-predefined kernel probes
131 extern struct hlist_head kernel_probes;
134 extern int event_mask;
140 struct jprobe jprobe;
141 struct kretprobe retprobe;
142 unsigned long offset;
148 struct jprobe jprobe;
150 struct list_head list;
158 signed char reg; // -1 - memory, 0..127 - register number
160 struct list_head list;
161 } us_proc_vtp_data_t;
163 typedef struct dentry *STRUCT_DENTRY_PTR;
168 STRUCT_DENTRY_PTR m_f_dentry;
172 us_proc_vtp_t *p_vtps;
179 STRUCT_DENTRY_PTR m_f_dentry;
181 unsigned unres_ips_count;
182 unsigned unres_vtps_count;
183 //kprobe_opcode_t *mapped_codelets;
185 us_proc_lib_t *p_libs;
189 /* cond data itself */
190 struct event_tmpl tmpl;
192 struct list_head list;
193 /* has been applied (for start and stop conditions) */
197 extern struct cond cond_list;
199 /* macros for testing flags */
200 #define ET_FIELD_CLR(flags, field) (flags &= ~field)
201 #define ET_FIELD_SET(flags, field) (flags |= field)
202 #define ET_FIELD_ISSET(flags, field) ((flags & field) != 0)
204 extern inst_us_proc_t us_proc_info;
207 #endif /* !defined(__STORAGE_H__) */