"Fossies" - the Fresh Open Source Software Archive 
Member "FunctionCheck-3.2.0/src/include/fc_com.h" (26 May 2012, 5172 Bytes) of package /linux/privat/old/FunctionCheck-3.2.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /*
2 * FunctionCheck profiler
3 * (C) Copyright 2000-2012 Yannick Perret
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /** fc_com.h: manage coms between profiled program and the manager **/
20
21 #ifndef __fc_com_h_
22 #define __fc_com_h_
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <unistd.h>
27 #include <time.h>
28 #include <sys/time.h>
29 #include <sys/types.h>
30 #include <unistd.h>
31
32 /** flag to indicate if the lib is compiled with threads **/
33 extern int fc_allow_thread_hard;
34
35 /** basic structures **/
36
37 /* enter in a function */
38 typedef struct {
39 void *from, *to; /* call-site, fnc */
40 unsigned long long time;
41 } FC_CEnter;
42
43 /* exit from a function */
44 typedef struct {
45 void *from, *to; /* call-site, fnc */
46 unsigned long long time;
47 } FC_CExit;
48
49 /* malloc action */
50 typedef struct {
51 void *ptr, *where; /* returned pointer and action place */
52 unsigned int size; /* size of the block */
53 } FC_CMalloc;
54
55 /* free action */
56 typedef struct {
57 void *ptr, *where; /* pointer and action place */
58 } FC_CFree;
59
60 /* memalign action */
61 typedef struct {
62 void *ptr, *where; /* returned pointer and action place */
63 unsigned int size, align; /* size of the block and requested alignment */
64 } FC_CMemalign;
65
66 /* realloc action */
67 typedef struct {
68 void *ptr, *old, *where; /* returned pointer, initial pointer and action place */
69 unsigned int size; /* new size */
70 } FC_CRealloc;
71
72 /* quit action */
73 typedef struct {
74 unsigned long long time; /* time of the quit action */
75 } FC_CQuit;
76
77 /* dlopen action */
78 typedef struct {
79 void *handle; /* returned handle */
80 int flag; /* given flag */
81 char name[32]; /* object name */
82 } FC_CDlopen;
83
84 /* dlclose action */
85 typedef struct {
86 void *handle; /* handle to close */
87 } FC_CDlclose;
88
89 /* dlsym action */
90 typedef struct {
91 void *handle, *fnc; /* handle and function pointer returned */
92 char name[32]; /* function name */
93 } FC_CDlsym;
94
95 /* parent information */
96 typedef struct {
97 int parent; /* parent of the concerned process */
98 } FC_CParent;
99
100 /* fork information */
101 typedef struct {
102 int child; /* the created child */
103 unsigned long long time;
104 } FC_CFork;
105
106 /* thread creation */
107 typedef struct {
108 int thread; /* the thread_id of the create thread */
109 unsigned long long time;
110 } FC_CThread;
111
112 /* time event */
113 typedef struct {
114 unsigned int time;
115 } FC_CTime;
116
117 /** definition of types of messages **/
118 #define FC_TYPE_NDEF 255
119 #define FC_TYPE_FIRST 0
120 #define FC_TYPE_ENTER 1
121 #define FC_TYPE_EXIT 2
122 #define FC_TYPE_MALLOC 3
123 #define FC_TYPE_FREE 4
124 #define FC_TYPE_MEMALIGN 5
125 #define FC_TYPE_REALLOC 6
126 #define FC_TYPE_QUIT 7
127 #define FC_TYPE_DLOPEN 8
128 #define FC_TYPE_DLCLOSE 9
129 #define FC_TYPE_DLSYM 10
130 #define FC_TYPE_PARENT 11
131 #define FC_TYPE_FORK 12
132 #define FC_TYPE_THREAD 13
133 #define FC_TYPE_TIME 14
134 #define FC_TYPE_MAX (FC_TYPE_TIME+1)
135
136 /** sizes of each type **/
137 extern unsigned int fc_type_sizes[];
138
139 /** structure for initialisation **/
140 typedef struct {
141 int function_size;
142 int stack_size;
143 int graph_size;
144 int buffer_size;
145 int memory_size;
146 int use_pid;
147 int mode;
148 unsigned long long start_time;
149 int first_pid;
150 int verbose;
151 int debug;
152 int memory;
153 int time_mode;
154 char dump_name[128];
155 char dump_path[128];
156 int follow; /* true if a list of dynamic lib follows */
157 /* not finished */
158 } FC_INIT;
159
160 /** structure for dynamic libraries **/
161 typedef struct {
162 void *addr;
163 char name[128];
164 } FC_LDYN;
165
166 /** functions **/
167
168 /* init the communication process */
169 int fc_com_init(int mode, int buffer_size, unsigned int *shmid);
170
171 /* start fcmanager */
172 int fc_com_start_manager(unsigned int shmid);
173
174 /* write init message */
175 int fc_com_write_init(FC_INIT *init);
176
177 /* write init message */
178 int fc_com_write_lib(FC_LDYN *ldyn);
179
180 /* functions */
181 void fc_com_enter(void *f, void *s);
182 void fc_com_exit(void *f, void *s);
183 void fc_com_malloc(void *ptr, unsigned int size, void *where);
184 void fc_com_free(void *ptr, void *where);
185 void fc_com_realloc(void *ptr, void *inc, unsigned int size, void *where);
186 void fc_com_memalign(void *ptr, unsigned int align, unsigned int size, void *where);
187 void fc_com_dlopen(void *ptr, const char *filename, int flag);
188 void fc_com_dlclose(void *handle);
189 void fc_com_dlsym(void *ptr, void *handle, char *symbol);
190 void fc_com_fork(int pid);
191 void fc_com_thread(int tid);
192 void fc_com_parent(int pid);
193 void fc_com_quit(void);
194
195 /* stop the communication process */
196 int fc_com_fini(unsigned int shmid);
197
198 #endif /* __fc_com_h_ */