1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
30 // create() and others are defined in fcntl.h.
31 // Our 'create' should not have the __nonnull attribute
37 #include "collector.h"
38 #include "gp-experiment.h"
39 #include "data_pckts.h"
42 /* TprintfT(<level>,...) definitions. Adjust per module as needed */
43 #define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings
44 #define DBG_LTT 0 // for interposition on GLIBC functions
45 #define DBG_LT1 1 // for configuration details, warnings
49 /* define the packet that will be written out */
50 typedef struct IOTrace_packet
51 { /* IO tracing packet */
53 IOTrace_type iotype
; /* IO type */
54 int32_t fd
; /* file descriptor */
55 Size_type nbyte
; /* number of bytes */
56 hrtime_t requested
; /* time of IO requested */
57 int32_t ofd
; /* original file descriptor */
58 FileSystem_type fstype
; /* file system type */
59 char fname
; /* file name */
62 typedef long long offset_t
;
64 static int open_experiment (const char *);
65 static int start_data_collection (void);
66 static int stop_data_collection (void);
67 static int close_experiment (void);
68 static int detach_experiment (void);
69 static int init_io_intf ();
71 static ModuleInterface module_interface
={
72 SP_IOTRACE_FILE
, /* description */
73 NULL
, /* initInterface */
74 open_experiment
, /* openExperiment */
75 start_data_collection
, /* startDataCollection */
76 stop_data_collection
, /* stopDataCollection */
77 close_experiment
, /* closeExperiment */
78 detach_experiment
/* detachExperiment (fork child) */
81 static CollectorInterface
*collector_interface
= NULL
;
82 static struct Heap
*io_heap
= NULL
;
83 static int io_mode
= 0;
84 static CollectorModule io_hndl
= COLLECTOR_MODULE_ERR
;
85 static unsigned io_key
= COLLECTOR_TSD_INVALID_KEY
;
87 #define CHCK_REENTRANCE(x) (!io_mode || ((x) = collector_interface->getKey( io_key )) == NULL || (*(x) != 0))
88 #define RECHCK_REENTRANCE(x) (!io_mode || ((x) = collector_interface->getKey( io_key )) == NULL || (*(x) == 0))
89 #define PUSH_REENTRANCE(x) ((*(x))++)
90 #define POP_REENTRANCE(x) ((*(x))--)
92 #define CALL_REAL(x) (__real_##x)
93 #define NULL_PTR(x) (__real_##x == NULL)
95 #define gethrtime collector_interface->getHiResTime
98 #define Tprintf(...) if (collector_interface) collector_interface->writeDebugInfo( 0, __VA_ARGS__ )
99 #define TprintfT(...) if (collector_interface) collector_interface->writeDebugInfo( 1, __VA_ARGS__ )
102 #define TprintfT(...)
105 /* interposition function handles */
106 static int (*__real_open
)(const char *path
, int oflag
, ...) = NULL
;
107 static int (*__real_fcntl
)(int fildes
, int cmd
, ...) = NULL
;
108 static int (*__real_openat
)(int fildes
, const char *path
, int oflag
, ...) = NULL
;
109 static int (*__real_close
)(int fildes
) = NULL
;
110 static FILE *(*__real_fopen
)(const char *filename
, const char *mode
) = NULL
;
111 static int (*__real_fclose
)(FILE *stream
) = NULL
;
112 static int (*__real_dup
)(int fildes
) = NULL
;
113 static int (*__real_dup2
)(int fildes
, int fildes2
) = NULL
;
114 static int (*__real_pipe
)(int fildes
[2]) = NULL
;
115 static int (*__real_socket
)(int domain
, int type
, int protocol
) = NULL
;
116 static int (*__real_mkstemp
)(char *template) = NULL
;
117 static int (*__real_mkstemps
)(char *template, int slen
) = NULL
;
118 static int (*__real_creat
)(const char *path
, mode_t mode
) = NULL
;
119 static FILE *(*__real_fdopen
)(int fildes
, const char *mode
) = NULL
;
120 static ssize_t (*__real_read
)(int fildes
, void *buf
, size_t nbyte
) = NULL
;
121 static ssize_t (*__real_write
)(int fildes
, const void *buf
, size_t nbyte
) = NULL
;
122 static ssize_t (*__real_readv
)(int fildes
, const struct iovec
*iov
, int iovcnt
) = NULL
;
123 static ssize_t (*__real_writev
)(int fildes
, const struct iovec
*iov
, int iovcnt
) = NULL
;
124 static size_t (*__real_fread
)(void *ptr
, size_t size
, size_t nitems
, FILE *stream
) = NULL
;
125 static size_t (*__real_fwrite
)(const void *ptr
, size_t size
, size_t nitems
, FILE *stream
) = NULL
;
126 static ssize_t (*__real_pread
)(int fildes
, void *buf
, size_t nbyte
, off_t offset
) = NULL
;
127 static ssize_t (*__real_pwrite
)(int fildes
, const void *buf
, size_t nbyte
, off_t offset
) = NULL
;
128 static ssize_t (*__real_pwrite64
)(int fildes
, const void *buf
, size_t nbyte
, off64_t offset
) = NULL
;
129 static char *(*__real_fgets
)(char *s
, int n
, FILE *stream
) = NULL
;
130 static int (*__real_fputs
)(const char *s
, FILE *stream
) = NULL
;
131 static int (*__real_fputc
)(int c
, FILE *stream
) = NULL
;
132 static int (*__real_fprintf
)(FILE *stream
, const char *format
, ...) = NULL
;
133 static int (*__real_vfprintf
)(FILE *stream
, const char *format
, va_list ap
) = NULL
;
134 static off_t (*__real_lseek
)(int fildes
, off_t offset
, int whence
) = NULL
;
135 static offset_t (*__real_llseek
)(int fildes
, offset_t offset
, int whence
) = NULL
;
136 static int (*__real_chmod
)(const char *path
, mode_t mode
) = NULL
;
137 static int (*__real_access
)(const char *path
, int amode
) = NULL
;
138 static int (*__real_rename
)(const char *old
, const char *new) = NULL
;
139 static int (*__real_mkdir
)(const char *path
, mode_t mode
) = NULL
;
140 static int (*__real_getdents
)(int fildes
, struct dirent
*buf
, size_t nbyte
) = NULL
;
141 static int (*__real_unlink
)(const char *path
) = NULL
;
142 static int (*__real_fseek
)(FILE *stream
, long offset
, int whence
) = NULL
;
143 static void (*__real_rewind
)(FILE *stream
) = NULL
;
144 static long (*__real_ftell
)(FILE *stream
) = NULL
;
145 static int (*__real_fgetpos
)(FILE *stream
, fpos_t *pos
) = NULL
;
146 static int (*__real_fsetpos
)(FILE *stream
, const fpos_t *pos
) = NULL
;
147 static int (*__real_fsync
)(int fildes
) = NULL
;
148 static struct dirent
*(*__real_readdir
)(DIR *dirp
) = NULL
;
149 static int (*__real_flock
)(int fd
, int operation
) = NULL
;
150 static int (*__real_lockf
)(int fildes
, int function
, off_t size
) = NULL
;
151 static int (*__real_fflush
)(FILE *stream
) = NULL
;
154 static int (*__real_open64
)(const char *path
, int oflag
, ...) = NULL
;
155 static int (*__real_creat64
)(const char *path
, mode_t mode
) = NULL
;
156 static int (*__real_fgetpos64
)(FILE *stream
, fpos64_t
*pos
) = NULL
;
157 static int (*__real_fsetpos64
)(FILE *stream
, const fpos64_t
*pos
) = NULL
;
160 static FILE *(*__real_fopen_2_1
)(const char *filename
, const char *mode
) = NULL
;
161 static int (*__real_fclose_2_1
)(FILE *stream
) = NULL
;
162 static FILE *(*__real_fdopen_2_1
)(int fildes
, const char *mode
) = NULL
;
163 static int (*__real_fgetpos_2_2
)(FILE *stream
, fpos_t *pos
) = NULL
;
164 static int (*__real_fsetpos_2_2
)(FILE *stream
, const fpos_t *pos
) = NULL
;
165 static int (*__real_fgetpos64_2_2
)(FILE *stream
, fpos64_t
*pos
) = NULL
;
166 static int (*__real_fsetpos64_2_2
)(FILE *stream
, const fpos64_t
*pos
) = NULL
;
167 static int (*__real_open64_2_2
)(const char *path
, int oflag
, ...) = NULL
;
168 static ssize_t (*__real_pread_2_2
)(int fildes
, void *buf
, size_t nbyte
, off_t offset
) = NULL
;
169 static ssize_t (*__real_pwrite_2_2
)(int fildes
, const void *buf
, size_t nbyte
, off_t offset
) = NULL
;
170 static ssize_t (*__real_pwrite64_2_2
)(int fildes
, const void *buf
, size_t nbyte
, off64_t offset
) = NULL
;
171 static FILE *(*__real_fopen_2_0
)(const char *filename
, const char *mode
) = NULL
;
172 static int (*__real_fclose_2_0
)(FILE *stream
) = NULL
;
173 static FILE *(*__real_fdopen_2_0
)(int fildes
, const char *mode
) = NULL
;
174 static int (*__real_fgetpos_2_0
)(FILE *stream
, fpos_t *pos
) = NULL
;
175 static int (*__real_fsetpos_2_0
)(FILE *stream
, const fpos_t *pos
) = NULL
;
176 static int (*__real_fgetpos64_2_1
)(FILE *stream
, fpos64_t
*pos
) = NULL
;
177 static int (*__real_fsetpos64_2_1
)(FILE *stream
, const fpos64_t
*pos
) = NULL
;
178 static int (*__real_open64_2_1
)(const char *path
, int oflag
, ...) = NULL
;
179 static ssize_t (*__real_pread_2_1
)(int fildes
, void *buf
, size_t nbyte
, off_t offset
) = NULL
;
180 static ssize_t (*__real_pwrite_2_1
)(int fildes
, const void *buf
, size_t nbyte
, off_t offset
) = NULL
;
181 static ssize_t (*__real_pwrite64_2_1
)(int fildes
, const void *buf
, size_t nbyte
, off64_t offset
) = NULL
;
183 #endif /* WSIZE(32) */
186 collector_align_pktsize (int sz
)
193 pktSize
= (sz
/ 8) + 1;
200 collector_memset (void *s
, int c
, size_t n
)
202 unsigned char *s1
= s
;
204 *s1
++ = (unsigned char) c
;
208 collector_strlen (const char *s
)
213 while (s
[++len
] != '\0')
219 collector_strncpy (char *dst
, const char *src
, size_t dstsize
)
222 for (i
= 0; i
< dstsize
; i
++)
232 collector_strchr (const char *s
, int c
)
243 static FileSystem_type
244 collector_fstype (const char *path
)
246 return UNKNOWNFS_TYPE
;
250 __collector_module_init (CollectorInterface
*_collector_interface
)
252 if (_collector_interface
== NULL
)
254 collector_interface
= _collector_interface
;
255 Tprintf (0, "iotrace: __collector_module_init\n");
256 io_hndl
= collector_interface
->registerModule (&module_interface
);
257 /* Initialize next module */
258 ModuleInitFunc next_init
= (ModuleInitFunc
) dlsym (RTLD_NEXT
, "__collector_module_init");
259 if (next_init
!= NULL
)
260 next_init (_collector_interface
);
265 open_experiment (const char *exp
)
267 if (collector_interface
== NULL
)
269 Tprintf (0, "iotrace: collector_interface is null.\n");
270 return COL_ERROR_IOINIT
;
272 if (io_hndl
== COLLECTOR_MODULE_ERR
)
274 Tprintf (0, "iotrace: handle create failed.\n");
275 collector_interface
->writeLog ("<event kind=\"%s\" id=\"%d\">data handle not created</event>\n",
276 SP_JCMD_CERROR
, COL_ERROR_IOINIT
);
277 return COL_ERROR_IOINIT
;
279 TprintfT (0, "iotrace: open_experiment %s\n", exp
);
280 if (NULL_PTR (fopen
))
284 io_heap
= collector_interface
->newHeap ();
287 Tprintf (0, "iotrace: new heap failed.\n");
288 collector_interface
->writeLog ("<event kind=\"%s\" id=\"%d\">new iotrace heap not created</event>\n",
289 SP_JCMD_CERROR
, COL_ERROR_IOINIT
);
290 return COL_ERROR_IOINIT
;
294 const char *params
= collector_interface
->getParams ();
297 if ((params
[0] == 'i') && (params
[1] == ':'))
302 params
= collector_strchr (params
, ';');
306 if (params
== NULL
) /* IO data collection not specified */
307 return COL_ERROR_IOINIT
;
309 io_key
= collector_interface
->createKey (sizeof ( int), NULL
, NULL
);
310 if (io_key
== (unsigned) - 1)
312 Tprintf (0, "iotrace: TSD key create failed.\n");
313 collector_interface
->writeLog ("<event kind=\"%s\" id=\"%d\">TSD key not created</event>\n",
314 SP_JCMD_CERROR
, COL_ERROR_IOINIT
);
315 return COL_ERROR_IOINIT
;
318 collector_interface
->writeLog ("<profile name=\"%s\">\n", SP_JCMD_IOTRACE
);
319 collector_interface
->writeLog (" <profdata fname=\"%s\"/>\n",
320 module_interface
.description
);
321 /* Record IOTrace_packet description */
322 IOTrace_packet
*pp
= NULL
;
323 collector_interface
->writeLog (" <profpckt kind=\"%d\" uname=\"IO tracing data\">\n", IOTRACE_PCKT
);
324 collector_interface
->writeLog (" <field name=\"LWPID\" uname=\"Lightweight process id\" offset=\"%d\" type=\"%s\"/>\n",
325 &pp
->comm
.lwp_id
, sizeof (pp
->comm
.lwp_id
) == 4 ? "INT32" : "INT64");
326 collector_interface
->writeLog (" <field name=\"THRID\" uname=\"Thread number\" offset=\"%d\" type=\"%s\"/>\n",
327 &pp
->comm
.thr_id
, sizeof (pp
->comm
.thr_id
) == 4 ? "INT32" : "INT64");
328 collector_interface
->writeLog (" <field name=\"CPUID\" uname=\"CPU id\" offset=\"%d\" type=\"%s\"/>\n",
329 &pp
->comm
.cpu_id
, sizeof (pp
->comm
.cpu_id
) == 4 ? "INT32" : "INT64");
330 collector_interface
->writeLog (" <field name=\"TSTAMP\" uname=\"High resolution timestamp\" offset=\"%d\" type=\"%s\"/>\n",
331 &pp
->comm
.tstamp
, sizeof (pp
->comm
.tstamp
) == 4 ? "INT32" : "INT64");
332 collector_interface
->writeLog (" <field name=\"FRINFO\" offset=\"%d\" type=\"%s\"/>\n",
333 &pp
->comm
.frinfo
, sizeof (pp
->comm
.frinfo
) == 4 ? "INT32" : "INT64");
334 collector_interface
->writeLog (" <field name=\"IOTYPE\" uname=\"IO trace function type\" offset=\"%d\" type=\"%s\"/>\n",
335 &pp
->iotype
, sizeof (pp
->iotype
) == 4 ? "INT32" : "INT64");
336 collector_interface
->writeLog (" <field name=\"IOFD\" uname=\"File descriptor\" offset=\"%d\" type=\"%s\"/>\n",
337 &pp
->fd
, sizeof (pp
->fd
) == 4 ? "INT32" : "INT64");
338 collector_interface
->writeLog (" <field name=\"IONBYTE\" uname=\"Number of bytes\" offset=\"%d\" type=\"%s\"/>\n",
339 &pp
->nbyte
, sizeof (pp
->nbyte
) == 4 ? "INT32" : "INT64");
340 collector_interface
->writeLog (" <field name=\"IORQST\" uname=\"Time of IO requested\" offset=\"%d\" type=\"%s\"/>\n",
341 &pp
->requested
, sizeof (pp
->requested
) == 4 ? "INT32" : "INT64");
342 collector_interface
->writeLog (" <field name=\"IOOFD\" uname=\"Original file descriptor\" offset=\"%d\" type=\"%s\"/>\n",
343 &pp
->ofd
, sizeof (pp
->ofd
) == 4 ? "INT32" : "INT64");
344 collector_interface
->writeLog (" <field name=\"IOFSTYPE\" uname=\"File system type\" offset=\"%d\" type=\"%s\"/>\n",
345 &pp
->fstype
, sizeof (pp
->fstype
) == 4 ? "INT32" : "INT64");
346 collector_interface
->writeLog (" <field name=\"IOFNAME\" uname=\"File name\" offset=\"%d\" type=\"%s\"/>\n",
347 &pp
->fname
, "STRING");
348 collector_interface
->writeLog (" </profpckt>\n");
349 collector_interface
->writeLog ("</profile>\n");
350 return COL_ERROR_NONE
;
354 start_data_collection (void)
357 Tprintf (0, "iotrace: start_data_collection\n");
362 stop_data_collection (void)
365 Tprintf (0, "iotrace: stop_data_collection\n");
370 close_experiment (void)
373 io_key
= COLLECTOR_TSD_INVALID_KEY
;
376 collector_interface
->deleteHeap (io_heap
);
379 Tprintf (0, "iotrace: close_experiment\n");
384 detach_experiment (void)
386 /* fork child. Clean up state but don't write to experiment */
388 io_key
= COLLECTOR_TSD_INVALID_KEY
;
391 collector_interface
->deleteHeap (io_heap
);
394 Tprintf (0, "iotrace: detach_experiment\n");
403 /* if we detect recursion/reentrance, SEGV so we can get a stack */
404 static int init_io_intf_started
;
405 static int init_io_intf_finished
;
406 init_io_intf_started
++;
407 if (!init_io_intf_finished
&& init_io_intf_started
>= 3)
409 /* pull the plug if recursion occurs... */
413 /* lookup fprint to print fatal error message */
414 void *ptr
= dlsym (RTLD_NEXT
, "fprintf");
416 __real_fprintf
= (int (*)(FILE*, const char*, ...)) ptr
;
422 #define SYS_FOPEN_X_VERSION "GLIBC_2.1"
423 #define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
424 #define SYS_FGETPOS64_X_VERSION "GLIBC_2.2"
425 #define SYS_OPEN64_X_VERSION "GLIBC_2.2"
426 #define SYS_PREAD_X_VERSION "GLIBC_2.2"
427 #define SYS_PWRITE_X_VERSION "GLIBC_2.2"
428 #define SYS_PWRITE64_X_VERSION "GLIBC_2.2"
429 #else /* WSIZE(64) */
430 #define SYS_FOPEN_X_VERSION "GLIBC_2.2.5"
431 #define SYS_FGETPOS_X_VERSION "GLIBC_2.2.5"
435 #define SYS_FOPEN_X_VERSION "GLIBC_2.1"
436 #define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
437 #else /* WSIZE(64) */
438 #define SYS_FOPEN_X_VERSION "GLIBC_2.2"
439 #define SYS_FGETPOS_X_VERSION "GLIBC_2.2"
442 #define SYS_FOPEN_X_VERSION "GLIBC_2.17"
443 #define SYS_FGETPOS_X_VERSION "GLIBC_2.17"
448 __real_fopen
= (FILE * (*)(const char*, const char*))dlvsym (dlflag
, "fopen", SYS_FOPEN_X_VERSION
);
449 if (__real_fopen
== NULL
)
451 /* We are probably dlopened after libc,
452 * try to search in the previously loaded objects
454 __real_fopen
= (FILE * (*)(const char*, const char*))dlvsym (RTLD_DEFAULT
, "fopen", SYS_FOPEN_X_VERSION
);
455 if (__real_fopen
!= NULL
)
457 Tprintf (0, "iotrace: WARNING: init_io_intf() using RTLD_DEFAULT for Linux io routines\n");
458 dlflag
= RTLD_DEFAULT
;
462 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fopen\n");
463 rc
= COL_ERROR_IOINIT
;
467 __real_fclose
= (int (*)(FILE*))dlvsym (dlflag
, "fclose", SYS_FOPEN_X_VERSION
);
468 if (__real_fclose
== NULL
)
470 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fclose\n");
471 rc
= COL_ERROR_IOINIT
;
474 __real_fdopen
= (FILE * (*)(int, const char*))dlvsym (dlflag
, "fdopen", SYS_FOPEN_X_VERSION
);
475 if (__real_fdopen
== NULL
)
477 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fdopen\n");
478 rc
= COL_ERROR_IOINIT
;
481 __real_fgetpos
= (int (*)(FILE*, fpos_t*))dlvsym (dlflag
, "fgetpos", SYS_FGETPOS_X_VERSION
);
482 if (__real_fgetpos
== NULL
)
484 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fgetpos\n");
485 rc
= COL_ERROR_IOINIT
;
488 __real_fsetpos
= (int (*)(FILE*, const fpos_t*))dlvsym (dlflag
, "fsetpos", SYS_FGETPOS_X_VERSION
);
489 if (__real_fsetpos
== NULL
)
491 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fsetpos\n");
492 rc
= COL_ERROR_IOINIT
;
497 __real_fopen_2_1
= __real_fopen
;
498 __real_fclose_2_1
= __real_fclose
;
499 __real_fdopen_2_1
= __real_fdopen
;
500 __real_fgetpos_2_2
= __real_fgetpos
;
501 __real_fsetpos_2_2
= __real_fsetpos
;
503 __real_fopen_2_0
= (FILE * (*)(const char*, const char*))dlvsym (dlflag
, "fopen", "GLIBC_2.0");
504 if (__real_fopen_2_0
== NULL
)
506 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fopen_2_0\n");
507 rc
= COL_ERROR_IOINIT
;
510 __real_fclose_2_0
= (int (*)(FILE*))dlvsym (dlflag
, "fclose", "GLIBC_2.0");
511 if (__real_fclose_2_0
== NULL
)
513 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fclose_2_0\n");
514 rc
= COL_ERROR_IOINIT
;
517 __real_fdopen_2_0
= (FILE * (*)(int, const char*))dlvsym (dlflag
, "fdopen", "GLIBC_2.0");
518 if (__real_fdopen_2_0
== NULL
)
520 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fdopen_2_0\n");
521 rc
= COL_ERROR_IOINIT
;
524 __real_fgetpos_2_0
= (int (*)(FILE*, fpos_t*))dlvsym (dlflag
, "fgetpos", "GLIBC_2.0");
525 if (__real_fgetpos_2_0
== NULL
)
527 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fgetpos_2_0\n");
528 rc
= COL_ERROR_IOINIT
;
531 __real_fsetpos_2_0
= (int (*)(FILE*, const fpos_t*))dlvsym (dlflag
, "fsetpos", "GLIBC_2.0");
532 if (__real_fsetpos_2_0
== NULL
)
534 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fsetpos_2_0\n");
535 rc
= COL_ERROR_IOINIT
;
538 __real_fgetpos64_2_1
= (int (*)(FILE*, fpos64_t
*))dlvsym (dlflag
, "fgetpos64", "GLIBC_2.1");
539 if (__real_fgetpos64_2_1
== NULL
)
541 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fgetpos64_2_1\n");
542 rc
= COL_ERROR_IOINIT
;
545 __real_fsetpos64_2_1
= (int (*)(FILE*, const fpos64_t
*))dlvsym (dlflag
, "fsetpos64", "GLIBC_2.1");
546 if (__real_fsetpos64_2_1
== NULL
)
548 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fsetpos64_2_1\n");
549 rc
= COL_ERROR_IOINIT
;
552 __real_open64_2_1
= (int (*)(const char*, int, ...))dlvsym (dlflag
, "open64", "GLIBC_2.1");
553 if (__real_open64_2_1
== NULL
)
555 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT open64_2_1\n");
556 rc
= COL_ERROR_IOINIT
;
559 __real_pread_2_1
= (int (*)(int fildes
, void *buf
, size_t nbyte
, off_t offset
))dlvsym (dlflag
, "pread", "GLIBC_2.1");
560 if (__real_pread_2_1
== NULL
)
562 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pread_2_1\n");
563 rc
= COL_ERROR_IOINIT
;
566 __real_pwrite_2_1
= (int (*)(int fildes
, const void *buf
, size_t nbyte
, off_t offset
))dlvsym (dlflag
, "pwrite", "GLIBC_2.1");
567 if (__real_pwrite_2_1
== NULL
)
569 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pwrite_2_1\n");
570 rc
= COL_ERROR_IOINIT
;
573 __real_pwrite64_2_1
= (int (*)(int fildes
, const void *buf
, size_t nbyte
, off64_t offset
))dlvsym (dlflag
, "pwrite64", "GLIBC_2.1");
574 if (__real_pwrite64_2_1
== NULL
)
576 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pwrite64_2_1\n");
577 rc
= COL_ERROR_IOINIT
;
580 __real_fgetpos64_2_2
= (int (*)(FILE*, fpos64_t
*))dlvsym (dlflag
, "fgetpos64", SYS_FGETPOS64_X_VERSION
);
581 if (__real_fgetpos64_2_2
== NULL
)
583 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fgetpos64_2_2\n");
584 rc
= COL_ERROR_IOINIT
;
587 __real_fsetpos64_2_2
= (int (*)(FILE*, const fpos64_t
*))dlvsym (dlflag
, "fsetpos64", SYS_FGETPOS64_X_VERSION
);
588 if (__real_fsetpos64_2_2
== NULL
)
590 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fsetpos64_2_2\n");
591 rc
= COL_ERROR_IOINIT
;
594 __real_open64_2_2
= (int (*)(const char*, int, ...))dlvsym (dlflag
, "open64", SYS_OPEN64_X_VERSION
);
595 if (__real_open64_2_2
== NULL
)
597 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT open64_2_2\n");
598 rc
= COL_ERROR_IOINIT
;
601 __real_pread_2_2
= (int (*)(int fildes
, void *buf
, size_t nbyte
, off_t offset
))dlvsym (dlflag
, "pread", SYS_PREAD_X_VERSION
);
602 if (__real_pread_2_2
== NULL
)
604 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pread_2_2\n");
605 rc
= COL_ERROR_IOINIT
;
608 __real_pwrite_2_2
= (int (*)(int fildes
, const void *buf
, size_t nbyte
, off_t offset
))dlvsym (dlflag
, "pwrite", SYS_PWRITE_X_VERSION
);
609 if (__real_pwrite_2_2
== NULL
)
611 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pwrite_2_2\n");
612 rc
= COL_ERROR_IOINIT
;
615 __real_pwrite64_2_2
= (int (*)(int fildes
, const void *buf
, size_t nbyte
, off64_t offset
))dlvsym (dlflag
, "pwrite64", SYS_PWRITE64_X_VERSION
);
616 if (__real_pwrite64_2_2
== NULL
)
618 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pwrite64_2_2\n");
619 rc
= COL_ERROR_IOINIT
;
624 #else /* WSIZE(64) */
626 __real_fopen
= (FILE * (*)(const char*, const char*))dlvsym (dlflag
, "fopen", SYS_FOPEN_X_VERSION
);
627 if (__real_fopen
== NULL
)
629 /* We are probably dlopened after libc,
630 * try to search in the previously loaded objects
632 __real_fopen
= (FILE * (*)(const char*, const char*))dlvsym (RTLD_DEFAULT
, "fopen", SYS_FOPEN_X_VERSION
);
633 if (__real_fopen
!= NULL
)
635 Tprintf (0, "iotrace: WARNING: init_io_intf() using RTLD_DEFAULT for Linux io routines\n");
636 dlflag
= RTLD_DEFAULT
;
640 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fopen\n");
641 rc
= COL_ERROR_IOINIT
;
645 __real_fclose
= (int (*)(FILE*))dlvsym (dlflag
, "fclose", SYS_FOPEN_X_VERSION
);
646 if (__real_fclose
== NULL
)
648 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fclose\n");
649 rc
= COL_ERROR_IOINIT
;
652 __real_fdopen
= (FILE * (*)(int, const char*))dlvsym (dlflag
, "fdopen", SYS_FOPEN_X_VERSION
);
653 if (__real_fdopen
== NULL
)
655 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fdopen\n");
656 rc
= COL_ERROR_IOINIT
;
659 __real_fgetpos
= (int (*)(FILE*, fpos_t*))dlvsym (dlflag
, "fgetpos", SYS_FGETPOS_X_VERSION
);
660 if (__real_fgetpos
== NULL
)
662 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fgetpos\n");
663 rc
= COL_ERROR_IOINIT
;
666 __real_fsetpos
= (int (*)(FILE*, const fpos_t*))dlvsym (dlflag
, "fsetpos", SYS_FGETPOS_X_VERSION
);
667 if (__real_fsetpos
== NULL
)
669 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fsetpos\n");
670 rc
= COL_ERROR_IOINIT
;
672 #endif /* WSIZE(32) */
674 __real_open
= (int (*)(const char*, int, ...))dlsym (dlflag
, "open");
675 if (__real_open
== NULL
)
677 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT open\n");
678 rc
= COL_ERROR_IOINIT
;
682 __real_open64
= (int (*)(const char*, int, ...))dlsym (dlflag
, "open64");
683 if (__real_open64
== NULL
)
685 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT open64\n");
686 rc
= COL_ERROR_IOINIT
;
690 __real_fcntl
= (int (*)(int, int, ...))dlsym (dlflag
, "fcntl");
691 if (__real_fcntl
== NULL
)
693 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fcntl\n");
694 rc
= COL_ERROR_IOINIT
;
697 __real_openat
= (int (*)(int, const char*, int, ...))dlsym (dlflag
, "openat");
698 if (__real_openat
== NULL
)
700 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT openat\n");
701 rc
= COL_ERROR_IOINIT
;
704 __real_close
= (int (*)(int))dlsym (dlflag
, "close");
705 if (__real_close
== NULL
)
707 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT close\n");
708 rc
= COL_ERROR_IOINIT
;
711 __real_dup
= (int (*)(int))dlsym (dlflag
, "dup");
712 if (__real_dup
== NULL
)
714 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT dup\n");
715 rc
= COL_ERROR_IOINIT
;
718 __real_dup2
= (int (*)(int, int))dlsym (dlflag
, "dup2");
719 if (__real_dup2
== NULL
)
721 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT dup2\n");
722 rc
= COL_ERROR_IOINIT
;
725 __real_pipe
= (int (*)(int[]))dlsym (dlflag
, "pipe");
726 if (__real_pipe
== NULL
)
728 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pipe\n");
729 rc
= COL_ERROR_IOINIT
;
732 __real_socket
= (int (*)(int, int, int))dlsym (dlflag
, "socket");
733 if (__real_socket
== NULL
)
735 __real_socket
= (int (*)(int, int, int))dlsym (RTLD_NEXT
, "socket");
736 if (__real_socket
== NULL
)
739 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERXXX_IOINIT socket\n");
740 rc
= COL_ERROR_IOINIT
;
745 __real_mkstemp
= (int (*)(char*))dlsym (dlflag
, "mkstemp");
746 if (__real_mkstemp
== NULL
)
748 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT mkstemp\n");
749 rc
= COL_ERROR_IOINIT
;
752 __real_mkstemps
= (int (*)(char*, int))dlsym (dlflag
, "mkstemps");
753 if (__real_mkstemps
== NULL
)
756 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERXXX_IOINIT mkstemps\n");
757 rc
= COL_ERROR_IOINIT
;
761 __real_creat
= (int (*)(const char*, mode_t
))dlsym (dlflag
, "creat");
762 if (__real_creat
== NULL
)
764 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT creat\n");
765 rc
= COL_ERROR_IOINIT
;
769 __real_creat64
= (int (*)(const char*, mode_t
))dlsym (dlflag
, "creat64");
770 if (__real_creat64
== NULL
)
772 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT creat64\n");
773 rc
= COL_ERROR_IOINIT
;
777 __real_read
= (ssize_t (*)(int, void*, size_t))dlsym (dlflag
, "read");
778 if (__real_read
== NULL
)
780 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT read\n");
781 rc
= COL_ERROR_IOINIT
;
784 __real_write
= (ssize_t (*)(int, const void*, size_t))dlsym (dlflag
, "write");
785 if (__real_write
== NULL
)
787 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT write\n");
788 rc
= COL_ERROR_IOINIT
;
791 __real_readv
= (ssize_t (*)(int, const struct iovec
*, int))dlsym (dlflag
, "readv");
792 if (__real_readv
== NULL
)
794 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT readv\n");
795 rc
= COL_ERROR_IOINIT
;
798 __real_writev
= (ssize_t (*)(int, const struct iovec
*, int))dlsym (dlflag
, "writev");
799 if (__real_writev
== NULL
)
801 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT writev\n");
802 rc
= COL_ERROR_IOINIT
;
805 __real_fread
= (size_t (*)(void*, size_t, size_t, FILE*))dlsym (dlflag
, "fread");
806 if (__real_fread
== NULL
)
808 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fread\n");
809 rc
= COL_ERROR_IOINIT
;
812 __real_fwrite
= (size_t (*)(const void*, size_t, size_t, FILE*))dlsym (dlflag
, "fwrite");
813 if (__real_fwrite
== NULL
)
815 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fwrite\n");
816 rc
= COL_ERROR_IOINIT
;
819 __real_pread
= (ssize_t (*)(int, void*, size_t, off_t
))dlsym (dlflag
, "pread");
820 if (__real_pread
== NULL
)
822 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pread\n");
823 rc
= COL_ERROR_IOINIT
;
826 __real_pwrite
= (ssize_t (*)(int, const void*, size_t, off_t
))dlsym (dlflag
, "pwrite");
827 if (__real_pwrite
== NULL
)
829 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pwrite\n");
830 rc
= COL_ERROR_IOINIT
;
833 __real_pwrite64
= (ssize_t (*)(int, const void*, size_t, off64_t
))dlsym (dlflag
, "pwrite64");
834 if (__real_pwrite64
== NULL
)
836 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT pwrite64\n");
837 rc
= COL_ERROR_IOINIT
;
840 __real_fgets
= (char* (*)(char*, int, FILE*))dlsym (dlflag
, "fgets");
841 if (__real_fgets
== NULL
)
843 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fgets\n");
844 rc
= COL_ERROR_IOINIT
;
847 __real_fputs
= (int (*)(const char*, FILE*))dlsym (dlflag
, "fputs");
848 if (__real_fputs
== NULL
)
850 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fputs\n");
851 rc
= COL_ERROR_IOINIT
;
854 __real_fputc
= (int (*)(int, FILE*))dlsym (dlflag
, "fputc");
855 if (__real_fputc
== NULL
)
857 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fputc\n");
858 rc
= COL_ERROR_IOINIT
;
861 __real_vfprintf
= (int (*)(FILE*, const char*, va_list))dlsym (dlflag
, "vfprintf");
862 if (__real_vfprintf
== NULL
)
864 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT vfprintf\n");
865 rc
= COL_ERROR_IOINIT
;
869 __real_lseek
= (off_t (*)(int, off_t
, int))dlsym (dlflag
, "lseek");
870 if (__real_lseek
== NULL
)
872 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT lseek\n");
873 rc
= COL_ERROR_IOINIT
;
876 __real_llseek
= (offset_t (*)(int, offset_t
, int))dlsym (dlflag
, "llseek");
877 if (__real_llseek
== NULL
)
879 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT llseek\n");
880 rc
= COL_ERROR_IOINIT
;
883 __real_chmod
= (int (*)(const char*, mode_t
))dlsym (dlflag
, "chmod");
884 if (__real_chmod
== NULL
)
886 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT chmod\n");
887 rc
= COL_ERROR_IOINIT
;
890 __real_access
= (int (*)(const char*, int))dlsym (dlflag
, "access");
891 if (__real_access
== NULL
)
893 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT access\n");
894 rc
= COL_ERROR_IOINIT
;
897 __real_rename
= (int (*)(const char*, const char*))dlsym (dlflag
, "rename");
898 if (__real_rename
== NULL
)
900 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT rename\n");
901 rc
= COL_ERROR_IOINIT
;
904 __real_mkdir
= (int (*)(const char*, mode_t
))dlsym (dlflag
, "mkdir");
905 if (__real_mkdir
== NULL
)
907 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT mkdir\n");
908 rc
= COL_ERROR_IOINIT
;
911 __real_getdents
= (int (*)(int, struct dirent
*, size_t))dlsym (dlflag
, "getdents");
912 if (__real_getdents
== NULL
)
915 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERXXX_IOINIT getdents\n");
916 rc
= COL_ERROR_IOINIT
;
920 __real_unlink
= (int (*)(const char*))dlsym (dlflag
, "unlink");
921 if (__real_unlink
== NULL
)
923 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT unlink\n");
924 rc
= COL_ERROR_IOINIT
;
927 __real_fseek
= (int (*)(FILE*, long, int))dlsym (dlflag
, "fseek");
928 if (__real_fseek
== NULL
)
930 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fseek\n");
931 rc
= COL_ERROR_IOINIT
;
934 __real_rewind
= (void (*)(FILE*))dlsym (dlflag
, "rewind");
935 if (__real_rewind
== NULL
)
937 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT rewind\n");
938 rc
= COL_ERROR_IOINIT
;
941 __real_ftell
= (long (*)(FILE*))dlsym (dlflag
, "ftell");
942 if (__real_ftell
== NULL
)
944 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT ftell\n");
945 rc
= COL_ERROR_IOINIT
;
948 __real_fsync
= (int (*)(int))dlsym (dlflag
, "fsync");
949 if (__real_fsync
== NULL
)
951 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fsync\n");
952 rc
= COL_ERROR_IOINIT
;
955 __real_readdir
= (struct dirent
* (*)(DIR*))dlsym (dlflag
, "readdir");
956 if (__real_readdir
== NULL
)
958 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT readdir\n");
959 rc
= COL_ERROR_IOINIT
;
962 __real_flock
= (int (*)(int, int))dlsym (dlflag
, "flock");
963 if (__real_flock
== NULL
)
965 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT flock\n");
966 rc
= COL_ERROR_IOINIT
;
969 __real_lockf
= (int (*)(int, int, off_t
))dlsym (dlflag
, "lockf");
970 if (__real_lockf
== NULL
)
972 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT lockf\n");
973 rc
= COL_ERROR_IOINIT
;
976 __real_fflush
= (int (*)(FILE*))dlsym (dlflag
, "fflush");
977 if (__real_fflush
== NULL
)
979 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fflush\n");
980 rc
= COL_ERROR_IOINIT
;
984 __real_fgetpos64
= (int (*)(FILE*, fpos64_t
*))dlsym (dlflag
, "fgetpos64");
985 if (__real_fgetpos64
== NULL
)
987 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fgetpos64\n");
988 rc
= COL_ERROR_IOINIT
;
991 __real_fsetpos64
= (int (*)(FILE*, const fpos64_t
*))dlsym (dlflag
, "fsetpos64");
992 if (__real_fsetpos64
== NULL
)
994 CALL_REAL (fprintf
)(stderr
, "iotrace_init COL_ERROR_IOINIT fsetpos64\n");
995 rc
= COL_ERROR_IOINIT
;
998 init_io_intf_finished
++;
1003 write_io_packet (int fd
, ssize_t ret
, hrtime_t reqt
, int iotype
)
1005 IOTrace_packet iopkt
;
1006 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
1007 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
1008 iopkt
.comm
.tstamp
= gethrtime ();
1009 iopkt
.requested
= reqt
;
1010 iopkt
.iotype
= iotype
;
1013 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
,
1014 iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1015 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
1018 /*------------------------------------------------------------- open */
1020 open (const char *path
, int oflag
, ...)
1025 IOTrace_packet
*iopkt
;
1031 va_start (ap
, oflag
);
1032 mode
= va_arg (ap
, mode_t
);
1035 if (NULL_PTR (open
))
1038 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
1039 return CALL_REAL (open
)(path
, oflag
, mode
);
1040 PUSH_REENTRANCE (guard
);
1041 hrtime_t reqt
= gethrtime ();
1042 fd
= CALL_REAL (open
)(path
, oflag
, mode
);
1043 if (RECHCK_REENTRANCE (guard
))
1045 POP_REENTRANCE (guard
);
1048 hrtime_t grnt
= gethrtime ();
1049 sz
= collector_strlen (path
);
1050 pktSize
= sizeof (IOTrace_packet
) + sz
;
1051 pktSize
= collector_align_pktsize (pktSize
);
1052 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
1053 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
1056 iopkt
= (IOTrace_packet
*) packet
;
1057 collector_memset (iopkt
, 0, pktSize
);
1058 iopkt
->comm
.tsize
= pktSize
;
1059 iopkt
->comm
.tstamp
= grnt
;
1060 iopkt
->requested
= reqt
;
1062 iopkt
->iotype
= OPEN_TRACE
;
1064 iopkt
->iotype
= OPEN_TRACE_ERROR
;
1066 iopkt
->fstype
= collector_fstype (path
);
1067 collector_strncpy (&(iopkt
->fname
), path
, sz
);
1068 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1069 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
1070 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
1074 Tprintf (0, "iotrace: ERROR: open cannot allocate memory\n");
1077 POP_REENTRANCE (guard
);
1081 /*------------------------------------------------------------- open64 */
1082 #if ARCH(Intel) && WSIZE(32)
1083 // map interposed symbol versions
1085 __collector_open64_symver (int(real_open64
) (const char *, int, ...),
1086 const char *path
, int oflag
, mode_t mode
);
1088 SYMVER_ATTRIBUTE (__collector_open64_2_2
, open64@GLIBC_2
.2
)
1090 __collector_open64_2_2 (const char *path
, int oflag
, ...)
1094 va_start (ap
, oflag
);
1095 mode
= va_arg (ap
, mode_t
);
1098 "iotrace: __collector_open64_2_2@%p(path=%s, oflag=0%o, mode=0%o\n",
1099 CALL_REAL (open64_2_2
), path
? path
: "NULL", oflag
, mode
);
1100 if (NULL_PTR (open64
))
1102 return __collector_open64_symver (CALL_REAL (open64_2_2
), path
, oflag
, mode
);
1105 SYMVER_ATTRIBUTE (__collector_open64_2_1
, open64@GLIBC_2
.1
)
1107 __collector_open64_2_1 (const char *path
, int oflag
, ...)
1111 va_start (ap
, oflag
);
1112 mode
= va_arg (ap
, mode_t
);
1115 "iotrace: __collector_open64_2_1@%p(path=%s, oflag=0%o, mode=0%o\n",
1116 CALL_REAL (open64_2_1
), path
? path
: "NULL", oflag
, mode
);
1117 if (NULL_PTR (open64
))
1119 return __collector_open64_symver (CALL_REAL (open64_2_1
), path
, oflag
, mode
);
1122 #endif /* ARCH(Intel) && WSIZE(32) */
1124 #if ARCH(Intel) && WSIZE(32)
1127 __collector_open64_symver (int(real_open64
) (const char *, int, ...),
1128 const char *path
, int oflag
, mode_t mode
)
1133 IOTrace_packet
*iopkt
;
1136 if (NULL_PTR (open64
))
1138 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
1139 return (real_open64
) (path
, oflag
, mode
);
1140 PUSH_REENTRANCE (guard
);
1141 hrtime_t reqt
= gethrtime ();
1142 fd
= real_open64 (path
, oflag
, mode
);
1143 #else /* ^ARCH(Intel) && WSIZE(32) */
1146 open64 (const char *path
, int oflag
, ...)
1151 IOTrace_packet
*iopkt
;
1157 va_start (ap
, oflag
);
1158 mode
= va_arg (ap
, mode_t
);
1160 if (NULL_PTR (open64
))
1162 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
1163 return CALL_REAL (open64
)(path
, oflag
, mode
);
1164 PUSH_REENTRANCE (guard
);
1165 hrtime_t reqt
= gethrtime ();
1166 fd
= CALL_REAL (open64
)(path
, oflag
, mode
);
1167 #endif /* ^ARCH(Intel) && WSIZE(32) */
1169 if (RECHCK_REENTRANCE (guard
) || path
== NULL
)
1171 POP_REENTRANCE (guard
);
1174 hrtime_t grnt
= gethrtime ();
1175 sz
= collector_strlen (path
);
1176 pktSize
= sizeof (IOTrace_packet
) + sz
;
1177 pktSize
= collector_align_pktsize (pktSize
);
1178 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
1179 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
1182 iopkt
= (IOTrace_packet
*) packet
;
1183 collector_memset (iopkt
, 0, pktSize
);
1184 iopkt
->comm
.tsize
= pktSize
;
1185 iopkt
->comm
.tstamp
= grnt
;
1186 iopkt
->requested
= reqt
;
1188 iopkt
->iotype
= OPEN_TRACE
;
1190 iopkt
->iotype
= OPEN_TRACE_ERROR
;
1192 iopkt
->fstype
= collector_fstype (path
);
1193 collector_strncpy (&(iopkt
->fname
), path
, sz
);
1194 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1195 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
1196 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
1200 Tprintf (0, "iotrace: ERROR: open64 cannot allocate memory\n");
1203 POP_REENTRANCE (guard
);
1208 #define F_ERROR_ARG 0
1210 #define F_LONG_ARG 2
1211 #define F_VOID_ARG 3
1214 * The following macro is not defined in the
1215 * older versions of Linux.
1216 * #define F_DUPFD_CLOEXEC 1030
1218 * Instead use the command that is defined below
1219 * until we start compiling mpmt on the newer
1220 * versions of Linux.
1222 #define TMP_F_DUPFD_CLOEXEC 1030
1224 /*------------------------------------------------------------- fcntl */
1226 fcntl (int fildes
, int cmd
, ...)
1230 IOTrace_packet iopkt
;
1233 int which_arg
= F_ERROR_ARG
;
1238 case TMP_F_DUPFD_CLOEXEC
:
1249 long_arg
= va_arg (ap
, long);
1251 which_arg
= F_LONG_ARG
;
1258 which_arg
= F_VOID_ARG
;
1261 if (NULL_PTR (fcntl
))
1263 if (CHCK_REENTRANCE (guard
))
1268 return CALL_REAL (fcntl
)(fildes
, cmd
, int_arg
);
1270 return CALL_REAL (fcntl
)(fildes
, cmd
, long_arg
);
1272 return CALL_REAL (fcntl
)(fildes
, cmd
);
1274 Tprintf (0, "iotrace: ERROR: Unsupported fcntl command\n");
1279 if (cmd
!= F_DUPFD
&& cmd
!= TMP_F_DUPFD_CLOEXEC
)
1284 return CALL_REAL (fcntl
)(fildes
, cmd
, int_arg
);
1286 return CALL_REAL (fcntl
)(fildes
, cmd
, long_arg
);
1288 return CALL_REAL (fcntl
)(fildes
, cmd
);
1290 Tprintf (0, "iotrace: ERROR: Unsupported fcntl command\n");
1295 PUSH_REENTRANCE (guard
);
1296 hrtime_t reqt
= gethrtime ();
1300 case TMP_F_DUPFD_CLOEXEC
:
1301 fd
= CALL_REAL (fcntl
)(fildes
, cmd
, long_arg
);
1304 if (RECHCK_REENTRANCE (guard
))
1306 POP_REENTRANCE (guard
);
1309 hrtime_t grnt
= gethrtime ();
1310 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
1311 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
1312 iopkt
.comm
.tstamp
= grnt
;
1313 iopkt
.requested
= reqt
;
1315 iopkt
.iotype
= OPEN_TRACE
;
1317 iopkt
.iotype
= OPEN_TRACE_ERROR
;
1320 iopkt
.fstype
= UNKNOWNFS_TYPE
;
1321 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1322 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
1323 POP_REENTRANCE (guard
);
1327 /*------------------------------------------------------------- openat */
1329 openat (int fildes
, const char *path
, int oflag
, ...)
1334 IOTrace_packet
*iopkt
;
1340 va_start (ap
, oflag
);
1341 mode
= va_arg (ap
, mode_t
);
1343 if (NULL_PTR (openat
))
1345 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
1346 return CALL_REAL (openat
)(fildes
, path
, oflag
, mode
);
1347 PUSH_REENTRANCE (guard
);
1348 hrtime_t reqt
= gethrtime ();
1349 fd
= CALL_REAL (openat
)(fildes
, path
, oflag
, mode
);
1350 if (RECHCK_REENTRANCE (guard
))
1352 POP_REENTRANCE (guard
);
1355 hrtime_t grnt
= gethrtime ();
1356 sz
= collector_strlen (path
);
1357 pktSize
= sizeof (IOTrace_packet
) + sz
;
1358 pktSize
= collector_align_pktsize (pktSize
);
1359 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
1360 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
1363 iopkt
= (IOTrace_packet
*) packet
;
1364 collector_memset (iopkt
, 0, pktSize
);
1365 iopkt
->comm
.tsize
= pktSize
;
1366 iopkt
->comm
.tstamp
= grnt
;
1367 iopkt
->requested
= reqt
;
1369 iopkt
->iotype
= OPEN_TRACE
;
1371 iopkt
->iotype
= OPEN_TRACE_ERROR
;
1373 iopkt
->fstype
= collector_fstype (path
);
1374 collector_strncpy (&(iopkt
->fname
), path
, sz
);
1375 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1376 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
1377 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
1381 Tprintf (0, "iotrace: ERROR: openat cannot allocate memory\n");
1384 POP_REENTRANCE (guard
);
1388 /*------------------------------------------------------------- creat */
1390 creat (const char *path
, mode_t mode
)
1395 IOTrace_packet
*iopkt
;
1398 if (NULL_PTR (creat
))
1400 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
1401 return CALL_REAL (creat
)(path
, mode
);
1402 PUSH_REENTRANCE (guard
);
1403 hrtime_t reqt
= gethrtime ();
1404 fd
= CALL_REAL (creat
)(path
, mode
);
1405 if (RECHCK_REENTRANCE (guard
))
1407 POP_REENTRANCE (guard
);
1410 hrtime_t grnt
= gethrtime ();
1411 sz
= collector_strlen (path
);
1412 pktSize
= sizeof (IOTrace_packet
) + sz
;
1413 pktSize
= collector_align_pktsize (pktSize
);
1414 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
1415 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
1418 iopkt
= (IOTrace_packet
*) packet
;
1419 collector_memset (iopkt
, 0, pktSize
);
1420 iopkt
->comm
.tsize
= pktSize
;
1421 iopkt
->comm
.tstamp
= grnt
;
1422 iopkt
->requested
= reqt
;
1424 iopkt
->iotype
= OPEN_TRACE
;
1426 iopkt
->iotype
= OPEN_TRACE_ERROR
;
1428 iopkt
->fstype
= collector_fstype (path
);
1429 collector_strncpy (&(iopkt
->fname
), path
, sz
);
1430 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1431 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
1432 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
1436 Tprintf (0, "iotrace: ERROR: creat cannot allocate memory\n");
1439 POP_REENTRANCE (guard
);
1443 /*------------------------------------------------------------- creat64 */
1446 creat64 (const char *path
, mode_t mode
)
1451 IOTrace_packet
*iopkt
;
1455 if (NULL_PTR (creat64
))
1457 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
1458 return CALL_REAL (creat64
)(path
, mode
);
1459 PUSH_REENTRANCE (guard
);
1460 hrtime_t reqt
= gethrtime ();
1461 fd
= CALL_REAL (creat64
)(path
, mode
);
1462 if (RECHCK_REENTRANCE (guard
))
1464 POP_REENTRANCE (guard
);
1467 hrtime_t grnt
= gethrtime ();
1468 sz
= collector_strlen (path
);
1469 pktSize
= sizeof (IOTrace_packet
) + sz
;
1470 pktSize
= collector_align_pktsize (pktSize
);
1471 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
1472 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
1475 iopkt
= (IOTrace_packet
*) packet
;
1476 collector_memset (iopkt
, 0, pktSize
);
1477 iopkt
->comm
.tsize
= pktSize
;
1478 iopkt
->comm
.tstamp
= grnt
;
1479 iopkt
->requested
= reqt
;
1481 iopkt
->iotype
= OPEN_TRACE
;
1483 iopkt
->iotype
= OPEN_TRACE_ERROR
;
1485 iopkt
->fstype
= collector_fstype (path
);
1486 collector_strncpy (&(iopkt
->fname
), path
, sz
);
1487 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1488 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
1489 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
1493 Tprintf (0, "iotrace: ERROR: creat64 cannot allocate memory\n");
1496 POP_REENTRANCE (guard
);
1501 /*------------------------------------------------------------- mkstemp */
1503 mkstemp (char *template)
1508 IOTrace_packet
*iopkt
;
1511 if (NULL_PTR (mkstemp
))
1513 if (CHCK_REENTRANCE (guard
) || template == NULL
)
1514 return CALL_REAL (mkstemp
)(template);
1515 PUSH_REENTRANCE (guard
);
1516 hrtime_t reqt
= gethrtime ();
1517 fd
= CALL_REAL (mkstemp
)(template);
1518 if (RECHCK_REENTRANCE (guard
))
1520 POP_REENTRANCE (guard
);
1523 hrtime_t grnt
= gethrtime ();
1524 sz
= collector_strlen (template);
1525 pktSize
= sizeof (IOTrace_packet
) + sz
;
1526 pktSize
= collector_align_pktsize (pktSize
);
1527 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
1528 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
1531 iopkt
= (IOTrace_packet
*) packet
;
1532 collector_memset (iopkt
, 0, pktSize
);
1533 iopkt
->comm
.tsize
= pktSize
;
1534 iopkt
->comm
.tstamp
= grnt
;
1535 iopkt
->requested
= reqt
;
1537 iopkt
->iotype
= OPEN_TRACE
;
1539 iopkt
->iotype
= OPEN_TRACE_ERROR
;
1541 iopkt
->fstype
= collector_fstype (template);
1542 collector_strncpy (&(iopkt
->fname
), template, sz
);
1543 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1544 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
1545 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
1549 Tprintf (0, "iotrace: ERROR: mkstemp cannot allocate memory\n");
1552 POP_REENTRANCE (guard
);
1556 /*------------------------------------------------------------- mkstemps */
1558 mkstemps (char *template, int slen
)
1563 IOTrace_packet
*iopkt
;
1566 if (NULL_PTR (mkstemps
))
1568 if (CHCK_REENTRANCE (guard
) || template == NULL
)
1569 return CALL_REAL (mkstemps
)(template, slen
);
1570 PUSH_REENTRANCE (guard
);
1571 hrtime_t reqt
= gethrtime ();
1572 fd
= CALL_REAL (mkstemps
)(template, slen
);
1573 if (RECHCK_REENTRANCE (guard
))
1575 POP_REENTRANCE (guard
);
1578 hrtime_t grnt
= gethrtime ();
1579 sz
= collector_strlen (template);
1580 pktSize
= sizeof (IOTrace_packet
) + sz
;
1581 pktSize
= collector_align_pktsize (pktSize
);
1582 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
1583 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
1586 iopkt
= (IOTrace_packet
*) packet
;
1587 collector_memset (iopkt
, 0, pktSize
);
1588 iopkt
->comm
.tsize
= pktSize
;
1589 iopkt
->comm
.tstamp
= grnt
;
1590 iopkt
->requested
= reqt
;
1592 iopkt
->iotype
= OPEN_TRACE
;
1594 iopkt
->iotype
= OPEN_TRACE_ERROR
;
1596 iopkt
->fstype
= collector_fstype (template);
1597 collector_strncpy (&(iopkt
->fname
), template, sz
);
1598 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1599 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
1600 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
1604 Tprintf (0, "iotrace: ERROR: mkstemps cannot allocate memory\n");
1607 POP_REENTRANCE (guard
);
1611 /*------------------------------------------------------------- close */
1617 IOTrace_packet iopkt
;
1618 if (NULL_PTR (close
))
1620 if (CHCK_REENTRANCE (guard
))
1621 return CALL_REAL (close
)(fildes
);
1622 PUSH_REENTRANCE (guard
);
1623 hrtime_t reqt
= gethrtime ();
1624 stat
= CALL_REAL (close
)(fildes
);
1625 if (RECHCK_REENTRANCE (guard
))
1627 POP_REENTRANCE (guard
);
1630 hrtime_t grnt
= gethrtime ();
1631 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
1632 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
1633 iopkt
.comm
.tstamp
= grnt
;
1634 iopkt
.requested
= reqt
;
1636 iopkt
.iotype
= CLOSE_TRACE
;
1638 iopkt
.iotype
= CLOSE_TRACE_ERROR
;
1640 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1641 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
1642 POP_REENTRANCE (guard
);
1646 /*------------------------------------------------------------- fopen */
1647 // map interposed symbol versions
1648 #if ARCH(Intel) && WSIZE(32)
1651 __collector_fopen_symver (FILE*(real_fopen
) (), const char *filename
, const char *mode
);
1653 SYMVER_ATTRIBUTE (__collector_fopen_2_1
, fopen@GLIBC_2
.1
)
1655 __collector_fopen_2_1 (const char *filename
, const char *mode
)
1657 if (NULL_PTR (fopen
))
1659 TprintfT (DBG_LTT
, "iotrace: __collector_fopen_2_1@%p\n", CALL_REAL (fopen_2_1
));
1660 return __collector_fopen_symver (CALL_REAL (fopen_2_1
), filename
, mode
);
1663 SYMVER_ATTRIBUTE (__collector_fopen_2_0
, fopen@GLIBC_2
.0
)
1665 __collector_fopen_2_0 (const char *filename
, const char *mode
)
1667 if (NULL_PTR (fopen
))
1669 TprintfT (DBG_LTT
, "iotrace: __collector_fopen_2_0@%p\n", CALL_REAL (fopen_2_0
));
1670 return __collector_fopen_symver (CALL_REAL (fopen_2_0
), filename
, mode
);
1675 #if ARCH(Intel) && WSIZE(32)
1678 __collector_fopen_symver (FILE*(real_fopen
) (), const char *filename
, const char *mode
)
1683 fopen (const char *filename
, const char *mode
)
1689 IOTrace_packet
*iopkt
;
1692 if (NULL_PTR (fopen
))
1694 if (CHCK_REENTRANCE (guard
) || filename
== NULL
)
1696 #if ARCH(Intel) && WSIZE(32)
1697 return (real_fopen
) (filename
, mode
);
1699 return CALL_REAL (fopen
)(filename
, mode
);
1702 PUSH_REENTRANCE (guard
);
1703 hrtime_t reqt
= gethrtime ();
1705 #if ARCH(Intel) && WSIZE(32)
1706 fp
= (real_fopen
) (filename
, mode
);
1708 fp
= CALL_REAL (fopen
)(filename
, mode
);
1710 if (RECHCK_REENTRANCE (guard
))
1712 POP_REENTRANCE (guard
);
1715 hrtime_t grnt
= gethrtime ();
1716 sz
= collector_strlen (filename
);
1717 pktSize
= sizeof (IOTrace_packet
) + sz
;
1718 pktSize
= collector_align_pktsize (pktSize
);
1719 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
1720 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
1723 iopkt
= (IOTrace_packet
*) packet
;
1724 collector_memset (iopkt
, 0, pktSize
);
1725 iopkt
->comm
.tsize
= pktSize
;
1726 iopkt
->comm
.tstamp
= grnt
;
1727 iopkt
->requested
= reqt
;
1730 iopkt
->iotype
= OPEN_TRACE
;
1731 iopkt
->fd
= fileno (fp
);
1735 iopkt
->iotype
= OPEN_TRACE_ERROR
;
1738 iopkt
->fstype
= collector_fstype (filename
);
1739 collector_strncpy (&(iopkt
->fname
), filename
, sz
);
1741 #if ARCH(Intel) && WSIZE(32)
1742 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK_ARG
, &iopkt
);
1744 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1746 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
1747 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
1751 Tprintf (0, "iotrace: ERROR: fopen cannot allocate memory\n");
1754 POP_REENTRANCE (guard
);
1758 /*------------------------------------------------------------- fclose */
1759 // map interposed symbol versions
1760 #if ARCH(Intel) && WSIZE(32)
1763 __collector_fclose_symver (int(real_fclose
) (), FILE *stream
);
1765 SYMVER_ATTRIBUTE (__collector_fclose_2_1
, fclose@GLIBC_2
.1
)
1767 __collector_fclose_2_1 (FILE *stream
)
1769 if (NULL_PTR (fclose
))
1771 TprintfT (DBG_LTT
, "iotrace: __collector_fclose_2_1@%p\n", CALL_REAL (fclose_2_1
));
1772 return __collector_fclose_symver (CALL_REAL (fclose_2_1
), stream
);
1775 SYMVER_ATTRIBUTE (__collector_fclose_2_0
, fclose@GLIBC_2
.0
)
1777 __collector_fclose_2_0 (FILE *stream
)
1779 if (NULL_PTR (fclose
))
1781 TprintfT (DBG_LTT
, "iotrace: __collector_fclose_2_0@%p\n", CALL_REAL (fclose_2_0
));
1782 return __collector_fclose_symver (CALL_REAL (fclose_2_0
), stream
);
1787 #if ARCH(Intel) && WSIZE(32)
1790 __collector_fclose_symver (int(real_fclose
) (), FILE *stream
)
1795 fclose (FILE *stream
)
1800 IOTrace_packet iopkt
;
1801 if (NULL_PTR (fclose
))
1803 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
1805 #if ARCH(Intel) && WSIZE(32)
1806 return (real_fclose
) (stream
);
1808 return CALL_REAL (fclose
)(stream
);
1811 PUSH_REENTRANCE (guard
);
1812 hrtime_t reqt
= gethrtime ();
1813 #if ARCH(Intel) && WSIZE(32)
1814 stat
= (real_fclose
) (stream
);
1816 stat
= CALL_REAL (fclose
)(stream
);
1818 if (RECHCK_REENTRANCE (guard
))
1820 POP_REENTRANCE (guard
);
1823 hrtime_t grnt
= gethrtime ();
1824 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
1825 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
1826 iopkt
.comm
.tstamp
= grnt
;
1827 iopkt
.requested
= reqt
;
1829 iopkt
.iotype
= CLOSE_TRACE
;
1831 iopkt
.iotype
= CLOSE_TRACE_ERROR
;
1832 iopkt
.fd
= fileno (stream
);
1834 #if ARCH(Intel) && WSIZE(32)
1835 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK_ARG
, &iopkt
);
1837 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1839 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
1840 POP_REENTRANCE (guard
);
1844 /*------------------------------------------------------------- fflush */
1846 fflush (FILE *stream
)
1850 IOTrace_packet iopkt
;
1851 if (NULL_PTR (fflush
))
1853 if (CHCK_REENTRANCE (guard
))
1854 return CALL_REAL (fflush
)(stream
);
1855 PUSH_REENTRANCE (guard
);
1856 hrtime_t reqt
= gethrtime ();
1857 stat
= CALL_REAL (fflush
)(stream
);
1858 if (RECHCK_REENTRANCE (guard
))
1860 POP_REENTRANCE (guard
);
1863 hrtime_t grnt
= gethrtime ();
1864 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
1865 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
1866 iopkt
.comm
.tstamp
= grnt
;
1867 iopkt
.requested
= reqt
;
1869 iopkt
.iotype
= OTHERIO_TRACE
;
1871 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
1873 iopkt
.fd
= fileno (stream
);
1876 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1877 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
1878 POP_REENTRANCE (guard
);
1882 /*------------------------------------------------------------- fdopen */
1883 // map interposed symbol versions
1884 #if ARCH(Intel) && WSIZE(32)
1887 __collector_fdopen_symver (FILE*(real_fdopen
) (), int fildes
, const char *mode
);
1889 SYMVER_ATTRIBUTE (__collector_fdopen_2_1
, fdopen@GLIBC_2
.1
)
1891 __collector_fdopen_2_1 (int fildes
, const char *mode
)
1893 if (NULL_PTR (fdopen
))
1895 TprintfT (DBG_LTT
, "iotrace: __collector_fdopen_2_1@%p\n", CALL_REAL (fdopen_2_1
));
1896 return __collector_fdopen_symver (CALL_REAL (fdopen_2_1
), fildes
, mode
);
1899 SYMVER_ATTRIBUTE (__collector_fdopen_2_0
, fdopen@GLIBC_2
.0
)
1901 __collector_fdopen_2_0 (int fildes
, const char *mode
)
1903 if (NULL_PTR (fdopen
))
1905 TprintfT (DBG_LTT
, "iotrace: __collector_fdopen_2_0@%p\n", CALL_REAL (fdopen_2_0
));
1906 return __collector_fdopen_symver (CALL_REAL (fdopen_2_0
), fildes
, mode
);
1911 #if ARCH(Intel) && WSIZE(32)
1913 __collector_fdopen_symver (FILE*(real_fdopen
) (), int fildes
, const char *mode
)
1917 fdopen (int fildes
, const char *mode
)
1922 IOTrace_packet iopkt
;
1923 if (NULL_PTR (fdopen
))
1925 if (CHCK_REENTRANCE (guard
))
1927 #if ARCH(Intel) && WSIZE(32)
1928 return (real_fdopen
) (fildes
, mode
);
1930 return CALL_REAL (fdopen
)(fildes
, mode
);
1933 PUSH_REENTRANCE (guard
);
1934 hrtime_t reqt
= gethrtime ();
1935 #if ARCH(Intel) && WSIZE(32)
1936 fp
= (real_fdopen
) (fildes
, mode
);
1938 fp
= CALL_REAL (fdopen
)(fildes
, mode
);
1940 if (RECHCK_REENTRANCE (guard
))
1942 POP_REENTRANCE (guard
);
1945 hrtime_t grnt
= gethrtime ();
1946 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
1947 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
1948 iopkt
.comm
.tstamp
= grnt
;
1949 iopkt
.requested
= reqt
;
1951 iopkt
.iotype
= OPEN_TRACE
;
1953 iopkt
.iotype
= OPEN_TRACE_ERROR
;
1955 iopkt
.fstype
= UNKNOWNFS_TYPE
;
1956 #if ARCH(Intel) && WSIZE(32)
1957 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK_ARG
, &iopkt
);
1959 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1961 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
1962 POP_REENTRANCE (guard
);
1966 /*------------------------------------------------------------- dup */
1972 IOTrace_packet iopkt
;
1975 if (CHCK_REENTRANCE (guard
))
1976 return CALL_REAL (dup
)(fildes
);
1977 PUSH_REENTRANCE (guard
);
1978 hrtime_t reqt
= gethrtime ();
1979 fd
= CALL_REAL (dup
)(fildes
);
1980 if (RECHCK_REENTRANCE (guard
))
1982 POP_REENTRANCE (guard
);
1985 hrtime_t grnt
= gethrtime ();
1986 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
1987 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
1988 iopkt
.comm
.tstamp
= grnt
;
1989 iopkt
.requested
= reqt
;
1991 iopkt
.iotype
= OPEN_TRACE
;
1993 iopkt
.iotype
= OPEN_TRACE_ERROR
;
1997 iopkt
.fstype
= UNKNOWNFS_TYPE
;
1998 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
1999 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2000 POP_REENTRANCE (guard
);
2004 /*------------------------------------------------------------- dup2 */
2006 dup2 (int fildes
, int fildes2
)
2010 IOTrace_packet iopkt
;
2011 if (NULL_PTR (dup2
))
2013 if (CHCK_REENTRANCE (guard
))
2014 return CALL_REAL (dup2
)(fildes
, fildes2
);
2015 PUSH_REENTRANCE (guard
);
2016 hrtime_t reqt
= gethrtime ();
2017 fd
= CALL_REAL (dup2
)(fildes
, fildes2
);
2018 if (RECHCK_REENTRANCE (guard
))
2020 POP_REENTRANCE (guard
);
2023 hrtime_t grnt
= gethrtime ();
2024 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
2025 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
2026 iopkt
.comm
.tstamp
= grnt
;
2027 iopkt
.requested
= reqt
;
2029 iopkt
.iotype
= OPEN_TRACE
;
2031 iopkt
.iotype
= OPEN_TRACE_ERROR
;
2034 iopkt
.fstype
= UNKNOWNFS_TYPE
;
2035 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2036 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2037 POP_REENTRANCE (guard
);
2041 /*------------------------------------------------------------- pipe */
2043 pipe (int fildes
[2])
2047 IOTrace_packet iopkt
;
2048 if (NULL_PTR (pipe
))
2050 if (CHCK_REENTRANCE (guard
))
2051 return CALL_REAL (pipe
)(fildes
);
2052 PUSH_REENTRANCE (guard
);
2053 hrtime_t reqt
= gethrtime ();
2054 ret
= CALL_REAL (pipe
)(fildes
);
2055 if (RECHCK_REENTRANCE (guard
))
2057 POP_REENTRANCE (guard
);
2060 hrtime_t grnt
= gethrtime ();
2061 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
2062 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
2063 iopkt
.comm
.tstamp
= grnt
;
2064 iopkt
.requested
= reqt
;
2066 iopkt
.iotype
= OPEN_TRACE
;
2068 iopkt
.iotype
= OPEN_TRACE_ERROR
;
2069 iopkt
.fd
= fildes
[0];
2070 iopkt
.fstype
= UNKNOWNFS_TYPE
;
2071 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2072 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2073 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
2074 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
2075 iopkt
.comm
.tstamp
= grnt
;
2076 iopkt
.requested
= reqt
;
2078 iopkt
.iotype
= OPEN_TRACE
;
2080 iopkt
.iotype
= OPEN_TRACE_ERROR
;
2081 iopkt
.fd
= fildes
[1];
2082 iopkt
.fstype
= UNKNOWNFS_TYPE
;
2083 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2084 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2085 POP_REENTRANCE (guard
);
2089 /*------------------------------------------------------------- socket */
2091 socket (int domain
, int type
, int protocol
)
2095 IOTrace_packet iopkt
;
2096 if (NULL_PTR (socket
))
2098 if (CHCK_REENTRANCE (guard
))
2099 return CALL_REAL (socket
)(domain
, type
, protocol
);
2100 PUSH_REENTRANCE (guard
);
2101 hrtime_t reqt
= gethrtime ();
2102 fd
= CALL_REAL (socket
)(domain
, type
, protocol
);
2103 if (RECHCK_REENTRANCE (guard
))
2105 POP_REENTRANCE (guard
);
2108 hrtime_t grnt
= gethrtime ();
2109 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
2110 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
2111 iopkt
.comm
.tstamp
= grnt
;
2112 iopkt
.requested
= reqt
;
2114 iopkt
.iotype
= OPEN_TRACE
;
2116 iopkt
.iotype
= OPEN_TRACE_ERROR
;
2118 iopkt
.fstype
= UNKNOWNFS_TYPE
;
2119 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2120 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2121 POP_REENTRANCE (guard
);
2125 /*------------------------------------------------------------- read */
2127 read (int fildes
, void *buf
, size_t nbyte
)
2131 IOTrace_packet iopkt
;
2132 if (NULL_PTR (read
))
2134 if (CHCK_REENTRANCE (guard
))
2135 return CALL_REAL (read
)(fildes
, buf
, nbyte
);
2136 PUSH_REENTRANCE (guard
);
2137 hrtime_t reqt
= gethrtime ();
2138 ret
= CALL_REAL (read
)(fildes
, buf
, nbyte
);
2139 if (RECHCK_REENTRANCE (guard
))
2141 POP_REENTRANCE (guard
);
2144 hrtime_t grnt
= gethrtime ();
2145 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2146 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2147 iopkt
.comm
.tstamp
= grnt
;
2148 iopkt
.requested
= reqt
;
2150 iopkt
.iotype
= READ_TRACE
;
2152 iopkt
.iotype
= READ_TRACE_ERROR
;
2155 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2156 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2157 POP_REENTRANCE (guard
);
2161 /*------------------------------------------------------------- write */
2163 write (int fildes
, const void *buf
, size_t nbyte
)
2167 IOTrace_packet iopkt
;
2168 if (NULL_PTR (write
))
2170 if (CHCK_REENTRANCE (guard
))
2171 return CALL_REAL (write
)(fildes
, buf
, nbyte
);
2172 PUSH_REENTRANCE (guard
);
2173 hrtime_t reqt
= gethrtime ();
2174 ret
= CALL_REAL (write
)(fildes
, buf
, nbyte
);
2175 if (RECHCK_REENTRANCE (guard
))
2177 POP_REENTRANCE (guard
);
2180 hrtime_t grnt
= gethrtime ();
2181 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2182 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2183 iopkt
.comm
.tstamp
= grnt
;
2184 iopkt
.requested
= reqt
;
2186 iopkt
.iotype
= WRITE_TRACE
;
2188 iopkt
.iotype
= WRITE_TRACE_ERROR
;
2191 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2192 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2193 POP_REENTRANCE (guard
);
2197 /*------------------------------------------------------------- readv */
2199 readv (int fildes
, const struct iovec
*iov
, int iovcnt
)
2203 IOTrace_packet iopkt
;
2204 if (NULL_PTR (readv
))
2206 if (CHCK_REENTRANCE (guard
))
2207 return CALL_REAL (readv
)(fildes
, iov
, iovcnt
);
2208 PUSH_REENTRANCE (guard
);
2209 hrtime_t reqt
= gethrtime ();
2210 ret
= CALL_REAL (readv
)(fildes
, iov
, iovcnt
);
2211 if (RECHCK_REENTRANCE (guard
))
2213 POP_REENTRANCE (guard
);
2216 hrtime_t grnt
= gethrtime ();
2217 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2218 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2219 iopkt
.comm
.tstamp
= grnt
;
2220 iopkt
.requested
= reqt
;
2222 iopkt
.iotype
= READ_TRACE
;
2224 iopkt
.iotype
= READ_TRACE_ERROR
;
2227 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2228 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2229 POP_REENTRANCE (guard
);
2233 /*------------------------------------------------------------- writev */
2235 writev (int fildes
, const struct iovec
*iov
, int iovcnt
)
2239 IOTrace_packet iopkt
;
2240 if (NULL_PTR (writev
))
2242 if (CHCK_REENTRANCE (guard
))
2243 return CALL_REAL (writev
)(fildes
, iov
, iovcnt
);
2244 PUSH_REENTRANCE (guard
);
2245 hrtime_t reqt
= gethrtime ();
2246 ret
= CALL_REAL (writev
)(fildes
, iov
, iovcnt
);
2247 if (RECHCK_REENTRANCE (guard
))
2249 POP_REENTRANCE (guard
);
2252 hrtime_t grnt
= gethrtime ();
2253 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2254 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2255 iopkt
.comm
.tstamp
= grnt
;
2256 iopkt
.requested
= reqt
;
2258 iopkt
.iotype
= WRITE_TRACE
;
2260 iopkt
.iotype
= WRITE_TRACE_ERROR
;
2263 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2264 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2265 POP_REENTRANCE (guard
);
2269 /*------------------------------------------------------------- fread */
2271 fread (void *ptr
, size_t size
, size_t nitems
, FILE *stream
)
2275 IOTrace_packet iopkt
;
2276 if (NULL_PTR (fread
))
2278 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
2279 return CALL_REAL (fread
)(ptr
, size
, nitems
, stream
);
2280 PUSH_REENTRANCE (guard
);
2281 hrtime_t reqt
= gethrtime ();
2282 ret
= CALL_REAL (fread
)(ptr
, size
, nitems
, stream
);
2283 if (RECHCK_REENTRANCE (guard
))
2285 POP_REENTRANCE (guard
);
2288 hrtime_t grnt
= gethrtime ();
2289 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2290 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2291 iopkt
.comm
.tstamp
= grnt
;
2292 iopkt
.requested
= reqt
;
2293 if (ferror (stream
) == 0)
2295 iopkt
.iotype
= READ_TRACE
;
2296 iopkt
.nbyte
= ret
* size
;
2300 iopkt
.iotype
= READ_TRACE_ERROR
;
2303 iopkt
.fd
= fileno (stream
);
2304 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2305 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2306 POP_REENTRANCE (guard
);
2310 /*------------------------------------------------------------- fwrite */
2312 fwrite (const void *ptr
, size_t size
, size_t nitems
, FILE *stream
)
2316 IOTrace_packet iopkt
;
2317 if (NULL_PTR (fwrite
))
2319 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
2320 return CALL_REAL (fwrite
)(ptr
, size
, nitems
, stream
);
2321 PUSH_REENTRANCE (guard
);
2322 hrtime_t reqt
= gethrtime ();
2323 ret
= CALL_REAL (fwrite
)(ptr
, size
, nitems
, stream
);
2324 if (RECHCK_REENTRANCE (guard
))
2326 POP_REENTRANCE (guard
);
2329 hrtime_t grnt
= gethrtime ();
2330 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2331 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2332 iopkt
.comm
.tstamp
= grnt
;
2333 iopkt
.requested
= reqt
;
2334 if (ferror (stream
) == 0)
2336 iopkt
.iotype
= WRITE_TRACE
;
2337 iopkt
.nbyte
= ret
* size
;
2341 iopkt
.iotype
= WRITE_TRACE_ERROR
;
2344 iopkt
.fd
= fileno (stream
);
2345 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2346 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2347 POP_REENTRANCE (guard
);
2351 /*------------------------------------------------------------- pread */
2352 #if ARCH(Intel) && WSIZE(32)
2353 // map interposed symbol versions
2355 __collector_pread_symver (int(real_pread
) (), int fildes
, void *buf
, size_t nbyte
, off_t offset
);
2357 SYMVER_ATTRIBUTE (__collector_pread_2_2
, pread@GLIBC_2
.2
)
2359 __collector_pread_2_2 (int fildes
, void *buf
, size_t nbyte
, off_t offset
)
2361 TprintfT (DBG_LTT
, "iotrace: __collector_pread_2_2@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
2362 CALL_REAL (pread_2_2
), fildes
, buf
, (long long) nbyte
, (long long) offset
);
2363 if (NULL_PTR (pread
))
2365 return __collector_pread_symver (CALL_REAL (pread_2_2
), fildes
, buf
, nbyte
, offset
);
2368 SYMVER_ATTRIBUTE (__collector_pread_2_1
, pread@GLIBC_2
.1
)
2370 __collector_pread_2_1 (int fildes
, void *buf
, size_t nbyte
, off_t offset
)
2372 TprintfT (DBG_LTT
, "iotrace: __collector_pread_2_1@%p(fildes=%d, buf=%p, nbyte=%lld, offset=%lld)\n",
2373 CALL_REAL (pread_2_1
), fildes
, buf
, (long long) nbyte
, (long long) offset
);
2374 if (NULL_PTR (pread
))
2376 return __collector_pread_symver (CALL_REAL (pread_2_1
), fildes
, buf
, nbyte
, offset
);
2380 __collector_pread_symver (int(real_pread
) (), int fildes
, void *buf
, size_t nbyte
, off_t offset
)
2382 #else /* ^ARCH(Intel) && WSIZE(32) */
2385 pread (int fildes
, void *buf
, size_t nbyte
, off_t offset
)
2390 IOTrace_packet iopkt
;
2391 if (NULL_PTR (pread
))
2393 if (CHCK_REENTRANCE (guard
))
2395 #if ARCH(Intel) && WSIZE(32)
2396 return (real_pread
) (fildes
, buf
, nbyte
, offset
);
2398 return CALL_REAL (pread
)(fildes
, buf
, nbyte
, offset
);
2401 PUSH_REENTRANCE (guard
);
2402 hrtime_t reqt
= gethrtime ();
2403 #if ARCH(Intel) && WSIZE(32)
2404 ret
= (real_pread
) (fildes
, buf
, nbyte
, offset
);
2406 ret
= CALL_REAL (pread
)(fildes
, buf
, nbyte
, offset
);
2408 if (RECHCK_REENTRANCE (guard
))
2410 POP_REENTRANCE (guard
);
2413 hrtime_t grnt
= gethrtime ();
2414 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2415 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2416 iopkt
.comm
.tstamp
= grnt
;
2417 iopkt
.requested
= reqt
;
2419 iopkt
.iotype
= READ_TRACE
;
2421 iopkt
.iotype
= READ_TRACE_ERROR
;
2424 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2425 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2426 POP_REENTRANCE (guard
);
2430 /*------------------------------------------------------------- pwrite */
2432 #if !defined(__MUSL_LIBC) && ARCH(Intel) && WSIZE(32)
2433 // map interposed symbol versions
2435 SYMVER_ATTRIBUTE (__collector_pwrite_2_2
, pwrite@GLIBC_2
.2
)
2437 __collector_pwrite_2_2 (int fildes
, const void *buf
, size_t nbyte
, off_t offset
)
2440 if (NULL_PTR (pwrite_2_2
))
2442 if (CHCK_REENTRANCE (guard
))
2443 return CALL_REAL (pwrite_2_2
)(fildes
, buf
, nbyte
, offset
);
2444 PUSH_REENTRANCE (guard
);
2445 hrtime_t reqt
= gethrtime ();
2446 ssize_t ret
= CALL_REAL (pwrite_2_2
)(fildes
, buf
, nbyte
, offset
);
2447 if (RECHCK_REENTRANCE (guard
))
2449 POP_REENTRANCE (guard
);
2452 write_io_packet (fildes
, ret
, reqt
, ret
>= 0 ? WRITE_TRACE
: WRITE_TRACE_ERROR
);
2453 POP_REENTRANCE (guard
);
2457 SYMVER_ATTRIBUTE (__collector_pwrite_2_1
, pwrite@GLIBC_2
.1
)
2459 __collector_pwrite_2_1 (int fildes
, const void *buf
, size_t nbyte
, off_t offset
)
2462 if (NULL_PTR (pwrite_2_1
))
2464 if (CHCK_REENTRANCE (guard
))
2465 return CALL_REAL (pwrite_2_1
)(fildes
, buf
, nbyte
, offset
);
2466 PUSH_REENTRANCE (guard
);
2467 hrtime_t reqt
= gethrtime ();
2468 ssize_t ret
= CALL_REAL (pwrite_2_1
)(fildes
, buf
, nbyte
, offset
);
2469 if (RECHCK_REENTRANCE (guard
))
2471 POP_REENTRANCE (guard
);
2474 write_io_packet (fildes
, ret
, reqt
, ret
>= 0 ? WRITE_TRACE
: WRITE_TRACE_ERROR
);
2475 POP_REENTRANCE (guard
);
2481 pwrite (int fildes
, const void *buf
, size_t nbyte
, off_t offset
)
2484 if (NULL_PTR (pwrite
))
2486 if (CHCK_REENTRANCE (guard
))
2487 return CALL_REAL (pwrite
)(fildes
, buf
, nbyte
, offset
);
2488 PUSH_REENTRANCE (guard
);
2489 hrtime_t reqt
= gethrtime ();
2490 ssize_t ret
= CALL_REAL (pwrite
)(fildes
, buf
, nbyte
, offset
);
2491 if (RECHCK_REENTRANCE (guard
))
2493 POP_REENTRANCE (guard
);
2496 write_io_packet (fildes
, ret
, reqt
, ret
>= 0 ? WRITE_TRACE
: WRITE_TRACE_ERROR
);
2497 POP_REENTRANCE (guard
);
2502 /*------------------------------------------------------------- pwrite64 */
2504 #if !defined(__MUSL_LIBC) && ARCH(Intel)
2505 // map interposed symbol versions
2507 SYMVER_ATTRIBUTE (__collector_pwrite64_2_2
, pwrite64@GLIBC_2
.2
)
2509 __collector_pwrite64_2_2 (int fildes
, const void *buf
, size_t nbyte
, off64_t offset
)
2512 if (NULL_PTR (pwrite64_2_2
))
2514 if (CHCK_REENTRANCE (guard
))
2515 return CALL_REAL (pwrite64_2_2
)(fildes
, buf
, nbyte
, offset
);
2516 PUSH_REENTRANCE (guard
);
2517 hrtime_t reqt
= gethrtime ();
2518 ssize_t ret
= CALL_REAL (pwrite64_2_2
)(fildes
, buf
, nbyte
, offset
);
2519 if (RECHCK_REENTRANCE (guard
))
2521 POP_REENTRANCE (guard
);
2524 write_io_packet (fildes
, ret
, reqt
, ret
>= 0 ? WRITE_TRACE
: WRITE_TRACE_ERROR
);
2525 POP_REENTRANCE (guard
);
2529 SYMVER_ATTRIBUTE (__collector_pwrite64_2_1
, pwrite64@GLIBC_2
.1
)
2531 __collector_pwrite64_2_1 (int fildes
, const void *buf
, size_t nbyte
, off64_t offset
)
2534 if (NULL_PTR (pwrite64_2_1
))
2536 if (CHCK_REENTRANCE (guard
))
2537 return CALL_REAL (pwrite64_2_1
)(fildes
, buf
, nbyte
, offset
);
2538 PUSH_REENTRANCE (guard
);
2539 hrtime_t reqt
= gethrtime ();
2540 ssize_t ret
= CALL_REAL (pwrite64_2_1
)(fildes
, buf
, nbyte
, offset
);
2541 if (RECHCK_REENTRANCE (guard
))
2543 POP_REENTRANCE (guard
);
2546 write_io_packet (fildes
, ret
, reqt
, ret
>= 0 ? WRITE_TRACE
: WRITE_TRACE_ERROR
);
2547 POP_REENTRANCE (guard
);
2553 pwrite64 (int fildes
, const void *buf
, size_t nbyte
, off64_t offset
)
2556 if (NULL_PTR (pwrite64
))
2558 if (CHCK_REENTRANCE (guard
))
2559 return CALL_REAL (pwrite64
)(fildes
, buf
, nbyte
, offset
);
2560 PUSH_REENTRANCE (guard
);
2561 hrtime_t reqt
= gethrtime ();
2562 ssize_t ret
= CALL_REAL (pwrite64
)(fildes
, buf
, nbyte
, offset
);
2563 if (RECHCK_REENTRANCE (guard
))
2565 POP_REENTRANCE (guard
);
2568 write_io_packet (fildes
, ret
, reqt
, ret
>= 0 ? WRITE_TRACE
: WRITE_TRACE_ERROR
);
2569 POP_REENTRANCE (guard
);
2573 #endif /* SIZE(32) */
2575 /*------------------------------------------------------------- fgets */
2577 fgets (char *s
, int n
, FILE *stream
)
2581 IOTrace_packet iopkt
;
2582 if (NULL_PTR (fgets
))
2584 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
2585 return CALL_REAL (fgets
)(s
, n
, stream
);
2586 PUSH_REENTRANCE (guard
);
2587 hrtime_t reqt
= gethrtime ();
2588 ptr
= CALL_REAL (fgets
)(s
, n
, stream
);
2589 if (RECHCK_REENTRANCE (guard
))
2591 POP_REENTRANCE (guard
);
2595 hrtime_t grnt
= gethrtime ();
2596 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2597 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2598 iopkt
.comm
.tstamp
= grnt
;
2599 iopkt
.requested
= reqt
;
2602 iopkt
.iotype
= READ_TRACE
;
2603 iopkt
.nbyte
= collector_strlen (ptr
);
2605 else if (ptr
== NULL
&& error
!= EAGAIN
&& error
!= EBADF
&& error
!= EINTR
&&
2606 error
!= EIO
&& error
!= EOVERFLOW
&& error
!= ENOMEM
&& error
!= ENXIO
)
2608 iopkt
.iotype
= READ_TRACE
;
2612 iopkt
.iotype
= READ_TRACE_ERROR
;
2613 iopkt
.fd
= fileno (stream
);
2614 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2615 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2616 POP_REENTRANCE (guard
);
2620 /*------------------------------------------------------------- fputs */
2622 fputs (const char *s
, FILE *stream
)
2626 IOTrace_packet iopkt
;
2627 if (NULL_PTR (fputs
))
2629 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
2630 return CALL_REAL (fputs
)(s
, stream
);
2631 PUSH_REENTRANCE (guard
);
2632 hrtime_t reqt
= gethrtime ();
2633 ret
= CALL_REAL (fputs
)(s
, stream
);
2634 if (RECHCK_REENTRANCE (guard
))
2636 POP_REENTRANCE (guard
);
2639 hrtime_t grnt
= gethrtime ();
2640 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2641 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2642 iopkt
.comm
.tstamp
= grnt
;
2643 iopkt
.requested
= reqt
;
2646 iopkt
.iotype
= WRITE_TRACE
;
2651 iopkt
.iotype
= WRITE_TRACE_ERROR
;
2654 iopkt
.fd
= fileno (stream
);
2655 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2656 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2657 POP_REENTRANCE (guard
);
2661 /*------------------------------------------------------------- fputc */
2663 fputc (int c
, FILE *stream
)
2667 IOTrace_packet iopkt
;
2668 if (NULL_PTR (fputc
))
2670 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
2671 return CALL_REAL (fputc
)(c
, stream
);
2672 PUSH_REENTRANCE (guard
);
2673 hrtime_t reqt
= gethrtime ();
2674 ret
= CALL_REAL (fputc
)(c
, stream
);
2675 if (RECHCK_REENTRANCE (guard
))
2677 POP_REENTRANCE (guard
);
2680 hrtime_t grnt
= gethrtime ();
2681 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2682 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2683 iopkt
.comm
.tstamp
= grnt
;
2684 iopkt
.requested
= reqt
;
2687 iopkt
.iotype
= WRITE_TRACE
;
2692 iopkt
.iotype
= WRITE_TRACE_ERROR
;
2695 iopkt
.fd
= fileno (stream
);
2696 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2697 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2698 POP_REENTRANCE (guard
);
2702 /*------------------------------------------------------------- fprintf */
2704 fprintf (FILE *stream
, const char *format
, ...)
2708 IOTrace_packet iopkt
;
2710 va_start (ap
, format
);
2711 if (NULL_PTR (fprintf
))
2713 if (NULL_PTR (vfprintf
))
2715 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
2717 ret
= CALL_REAL (vfprintf
)(stream
, format
, ap
);
2721 PUSH_REENTRANCE (guard
);
2722 hrtime_t reqt
= gethrtime ();
2723 ret
= CALL_REAL (vfprintf
)(stream
, format
, ap
);
2725 if (RECHCK_REENTRANCE (guard
))
2727 POP_REENTRANCE (guard
);
2730 hrtime_t grnt
= gethrtime ();
2731 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2732 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2733 iopkt
.comm
.tstamp
= grnt
;
2734 iopkt
.requested
= reqt
;
2736 iopkt
.iotype
= WRITE_TRACE
;
2738 iopkt
.iotype
= WRITE_TRACE_ERROR
;
2739 iopkt
.fd
= fileno (stream
);
2741 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2742 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2743 POP_REENTRANCE (guard
);
2747 /*------------------------------------------------------------- vfprintf */
2749 vfprintf (FILE *stream
, const char *format
, va_list ap
)
2753 IOTrace_packet iopkt
;
2754 if (NULL_PTR (vfprintf
))
2756 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
2757 return CALL_REAL (vfprintf
)(stream
, format
, ap
);
2758 PUSH_REENTRANCE (guard
);
2759 hrtime_t reqt
= gethrtime ();
2760 ret
= CALL_REAL (vfprintf
)(stream
, format
, ap
);
2761 if (RECHCK_REENTRANCE (guard
))
2763 POP_REENTRANCE (guard
);
2766 hrtime_t grnt
= gethrtime ();
2767 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
2768 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
2769 iopkt
.comm
.tstamp
= grnt
;
2770 iopkt
.requested
= reqt
;
2772 iopkt
.iotype
= WRITE_TRACE
;
2774 iopkt
.iotype
= WRITE_TRACE_ERROR
;
2775 iopkt
.fd
= fileno (stream
);
2777 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2778 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2779 POP_REENTRANCE (guard
);
2783 /*------------------------------------------------------------- lseek */
2785 lseek (int fildes
, off_t offset
, int whence
)
2789 IOTrace_packet iopkt
;
2790 if (NULL_PTR (lseek
))
2792 if (CHCK_REENTRANCE (guard
))
2793 return CALL_REAL (lseek
)(fildes
, offset
, whence
);
2794 PUSH_REENTRANCE (guard
);
2795 hrtime_t reqt
= gethrtime ();
2796 ret
= CALL_REAL (lseek
)(fildes
, offset
, whence
);
2797 if (RECHCK_REENTRANCE (guard
))
2799 POP_REENTRANCE (guard
);
2802 hrtime_t grnt
= gethrtime ();
2803 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
2804 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
2805 iopkt
.comm
.tstamp
= grnt
;
2806 iopkt
.requested
= reqt
;
2808 iopkt
.iotype
= OTHERIO_TRACE
;
2810 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
2812 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2813 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2814 POP_REENTRANCE (guard
);
2818 /*------------------------------------------------------------- llseek */
2820 llseek (int fildes
, offset_t offset
, int whence
)
2824 IOTrace_packet iopkt
;
2825 if (NULL_PTR (llseek
))
2827 if (CHCK_REENTRANCE (guard
))
2828 return CALL_REAL (llseek
)(fildes
, offset
, whence
);
2829 PUSH_REENTRANCE (guard
);
2830 hrtime_t reqt
= gethrtime ();
2831 ret
= CALL_REAL (llseek
)(fildes
, offset
, whence
);
2832 if (RECHCK_REENTRANCE (guard
))
2834 POP_REENTRANCE (guard
);
2837 hrtime_t grnt
= gethrtime ();
2838 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
2839 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
2840 iopkt
.comm
.tstamp
= grnt
;
2841 iopkt
.requested
= reqt
;
2843 iopkt
.iotype
= OTHERIO_TRACE
;
2845 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
2847 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2848 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
2849 POP_REENTRANCE (guard
);
2853 /*------------------------------------------------------------- chmod */
2855 chmod (const char *path
, mode_t mode
)
2860 IOTrace_packet
*iopkt
;
2863 if (NULL_PTR (chmod
))
2865 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
2866 return CALL_REAL (chmod
)(path
, mode
);
2867 PUSH_REENTRANCE (guard
);
2868 hrtime_t reqt
= gethrtime ();
2869 ret
= CALL_REAL (chmod
)(path
, mode
);
2870 if (RECHCK_REENTRANCE (guard
))
2872 POP_REENTRANCE (guard
);
2875 hrtime_t grnt
= gethrtime ();
2876 sz
= collector_strlen (path
);
2877 pktSize
= sizeof (IOTrace_packet
) + sz
;
2878 pktSize
= collector_align_pktsize (pktSize
);
2879 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
2880 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
2883 iopkt
= (IOTrace_packet
*) packet
;
2884 collector_memset (iopkt
, 0, pktSize
);
2885 iopkt
->comm
.tsize
= pktSize
;
2886 iopkt
->comm
.tstamp
= grnt
;
2887 iopkt
->requested
= reqt
;
2889 iopkt
->iotype
= OTHERIO_TRACE
;
2891 iopkt
->iotype
= OTHERIO_TRACE_ERROR
;
2892 collector_strncpy (&(iopkt
->fname
), path
, sz
);
2893 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2894 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
2895 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
2899 Tprintf (0, "iotrace: ERROR: chmod cannot allocate memory\n");
2902 POP_REENTRANCE (guard
);
2906 /*------------------------------------------------------------- access */
2908 access (const char *path
, int amode
)
2913 IOTrace_packet
*iopkt
;
2916 if (NULL_PTR (access
))
2918 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
2919 return CALL_REAL (access
)(path
, amode
);
2920 PUSH_REENTRANCE (guard
);
2921 hrtime_t reqt
= gethrtime ();
2922 ret
= CALL_REAL (access
)(path
, amode
);
2923 if (RECHCK_REENTRANCE (guard
))
2925 POP_REENTRANCE (guard
);
2928 hrtime_t grnt
= gethrtime ();
2929 sz
= collector_strlen (path
);
2930 pktSize
= sizeof (IOTrace_packet
) + sz
;
2931 pktSize
= collector_align_pktsize (pktSize
);
2932 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
2933 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
2936 iopkt
= (IOTrace_packet
*) packet
;
2937 collector_memset (iopkt
, 0, pktSize
);
2938 iopkt
->comm
.tsize
= pktSize
;
2939 iopkt
->comm
.tstamp
= grnt
;
2940 iopkt
->requested
= reqt
;
2942 iopkt
->iotype
= OTHERIO_TRACE
;
2944 iopkt
->iotype
= OTHERIO_TRACE_ERROR
;
2945 collector_strncpy (&(iopkt
->fname
), path
, sz
);
2946 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
2947 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
2948 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
2952 Tprintf (0, "iotrace: ERROR: access cannot allocate memory\n");
2955 POP_REENTRANCE (guard
);
2959 /*------------------------------------------------------------- rename */
2961 rename (const char *old
, const char *new)
2966 IOTrace_packet
*iopkt
;
2969 if (NULL_PTR (rename
))
2971 if (CHCK_REENTRANCE (guard
) || new == NULL
)
2972 return CALL_REAL (rename
)(old
, new);
2973 PUSH_REENTRANCE (guard
);
2974 hrtime_t reqt
= gethrtime ();
2975 ret
= CALL_REAL (rename
)(old
, new);
2976 if (RECHCK_REENTRANCE (guard
))
2978 POP_REENTRANCE (guard
);
2981 hrtime_t grnt
= gethrtime ();
2982 sz
= collector_strlen (new);
2983 pktSize
= sizeof (IOTrace_packet
) + sz
;
2984 pktSize
= collector_align_pktsize (pktSize
);
2985 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
2986 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
2989 iopkt
= (IOTrace_packet
*) packet
;
2990 collector_memset (iopkt
, 0, pktSize
);
2991 iopkt
->comm
.tsize
= pktSize
;
2992 iopkt
->comm
.tstamp
= grnt
;
2993 iopkt
->requested
= reqt
;
2995 iopkt
->iotype
= OTHERIO_TRACE
;
2997 iopkt
->iotype
= OTHERIO_TRACE_ERROR
;
2998 collector_strncpy (&(iopkt
->fname
), new, sz
);
2999 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3000 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
3001 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
3005 Tprintf (0, "iotrace: ERROR: rename cannot allocate memory\n");
3008 POP_REENTRANCE (guard
);
3012 /*------------------------------------------------------------- mkdir */
3014 mkdir (const char *path
, mode_t mode
)
3019 IOTrace_packet
*iopkt
;
3022 if (NULL_PTR (mkdir
))
3024 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
3025 return CALL_REAL (mkdir
)(path
, mode
);
3026 PUSH_REENTRANCE (guard
);
3027 hrtime_t reqt
= gethrtime ();
3028 ret
= CALL_REAL (mkdir
)(path
, mode
);
3029 if (RECHCK_REENTRANCE (guard
))
3031 POP_REENTRANCE (guard
);
3034 hrtime_t grnt
= gethrtime ();
3035 sz
= collector_strlen (path
);
3036 pktSize
= sizeof (IOTrace_packet
) + sz
;
3037 pktSize
= collector_align_pktsize (pktSize
);
3038 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
3039 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
3042 iopkt
= (IOTrace_packet
*) packet
;
3043 collector_memset (iopkt
, 0, pktSize
);
3044 iopkt
->comm
.tsize
= pktSize
;
3045 iopkt
->comm
.tstamp
= grnt
;
3046 iopkt
->requested
= reqt
;
3048 iopkt
->iotype
= OTHERIO_TRACE
;
3050 iopkt
->iotype
= OTHERIO_TRACE_ERROR
;
3051 collector_strncpy (&(iopkt
->fname
), path
, sz
);
3052 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3053 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
3054 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
3058 Tprintf (0, "iotrace: ERROR: mkdir cannot allocate memory\n");
3061 POP_REENTRANCE (guard
);
3065 /*------------------------------------------------------------- getdents */
3067 getdents (int fildes
, struct dirent
*buf
, size_t nbyte
)
3071 IOTrace_packet iopkt
;
3072 if (NULL_PTR (getdents
))
3074 if (CHCK_REENTRANCE (guard
))
3075 return CALL_REAL (getdents
)(fildes
, buf
, nbyte
);
3076 PUSH_REENTRANCE (guard
);
3077 hrtime_t reqt
= gethrtime ();
3078 ret
= CALL_REAL (getdents
)(fildes
, buf
, nbyte
);
3079 if (RECHCK_REENTRANCE (guard
))
3081 POP_REENTRANCE (guard
);
3084 hrtime_t grnt
= gethrtime ();
3085 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3086 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3087 iopkt
.comm
.tstamp
= grnt
;
3088 iopkt
.requested
= reqt
;
3090 iopkt
.iotype
= OTHERIO_TRACE
;
3092 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3094 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3095 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3096 POP_REENTRANCE (guard
);
3100 /*------------------------------------------------------------- unlink */
3102 unlink (const char *path
)
3107 IOTrace_packet
*iopkt
;
3110 if (NULL_PTR (unlink
))
3112 if (CHCK_REENTRANCE (guard
) || path
== NULL
)
3113 return CALL_REAL (unlink
)(path
);
3114 PUSH_REENTRANCE (guard
);
3115 hrtime_t reqt
= gethrtime ();
3116 ret
= CALL_REAL (unlink
)(path
);
3117 if (RECHCK_REENTRANCE (guard
))
3119 POP_REENTRANCE (guard
);
3122 hrtime_t grnt
= gethrtime ();
3123 sz
= collector_strlen (path
);
3124 pktSize
= sizeof (IOTrace_packet
) + sz
;
3125 pktSize
= collector_align_pktsize (pktSize
);
3126 Tprintf (DBG_LT1
, "iotrace allocating %u from io_heap\n", pktSize
);
3127 packet
= collector_interface
->allocCSize (io_heap
, pktSize
, 1);
3130 iopkt
= (IOTrace_packet
*) packet
;
3131 collector_memset (iopkt
, 0, pktSize
);
3132 iopkt
->comm
.tsize
= pktSize
;
3133 iopkt
->comm
.tstamp
= grnt
;
3134 iopkt
->requested
= reqt
;
3136 iopkt
->iotype
= OTHERIO_TRACE
;
3138 iopkt
->iotype
= OTHERIO_TRACE_ERROR
;
3139 collector_strncpy (&(iopkt
->fname
), path
, sz
);
3140 iopkt
->comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
->comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3141 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) iopkt
);
3142 collector_interface
->freeCSize (io_heap
, packet
, pktSize
);
3146 Tprintf (0, "iotrace: ERROR: unlink cannot allocate memory\n");
3149 POP_REENTRANCE (guard
);
3153 /*------------------------------------------------------------- fseek */
3155 fseek (FILE *stream
, long offset
, int whence
)
3159 IOTrace_packet iopkt
;
3160 if (NULL_PTR (fseek
))
3162 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
3163 return CALL_REAL (fseek
)(stream
, offset
, whence
);
3164 PUSH_REENTRANCE (guard
);
3165 hrtime_t reqt
= gethrtime ();
3166 ret
= CALL_REAL (fseek
)(stream
, offset
, whence
);
3167 if (RECHCK_REENTRANCE (guard
))
3169 POP_REENTRANCE (guard
);
3172 hrtime_t grnt
= gethrtime ();
3173 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3174 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3175 iopkt
.comm
.tstamp
= grnt
;
3176 iopkt
.requested
= reqt
;
3178 iopkt
.iotype
= OTHERIO_TRACE
;
3180 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3181 iopkt
.fd
= fileno (stream
);
3182 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3183 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3184 POP_REENTRANCE (guard
);
3188 /*------------------------------------------------------------- rewind */
3190 rewind (FILE *stream
)
3193 IOTrace_packet iopkt
;
3194 if (NULL_PTR (rewind
))
3196 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
3198 CALL_REAL (rewind
)(stream
);
3201 PUSH_REENTRANCE (guard
);
3202 hrtime_t reqt
= gethrtime ();
3203 CALL_REAL (rewind
)(stream
);
3204 if (RECHCK_REENTRANCE (guard
))
3206 POP_REENTRANCE (guard
);
3209 hrtime_t grnt
= gethrtime ();
3210 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3211 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3212 iopkt
.comm
.tstamp
= grnt
;
3213 iopkt
.requested
= reqt
;
3214 iopkt
.iotype
= OTHERIO_TRACE
;
3215 iopkt
.fd
= fileno (stream
);
3216 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3217 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3218 POP_REENTRANCE (guard
);
3221 /*------------------------------------------------------------- ftell */
3223 ftell (FILE *stream
)
3227 IOTrace_packet iopkt
;
3228 if (NULL_PTR (ftell
))
3230 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
3231 return CALL_REAL (ftell
)(stream
);
3232 PUSH_REENTRANCE (guard
);
3233 hrtime_t reqt
= gethrtime ();
3234 ret
= CALL_REAL (ftell
)(stream
);
3235 if (RECHCK_REENTRANCE (guard
))
3237 POP_REENTRANCE (guard
);
3240 hrtime_t grnt
= gethrtime ();
3241 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3242 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3243 iopkt
.comm
.tstamp
= grnt
;
3244 iopkt
.requested
= reqt
;
3246 iopkt
.iotype
= OTHERIO_TRACE
;
3248 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3249 iopkt
.fd
= fileno (stream
);
3250 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3251 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3252 POP_REENTRANCE (guard
);
3256 /*------------------------------------------------------------- fgetpos */
3257 // map interposed symbol versions
3258 #if ARCH(Intel) && WSIZE(32)
3260 __collector_fgetpos_symver (int(real_fgetpos
) (), FILE *stream
, fpos_t *pos
);
3262 SYMVER_ATTRIBUTE (__collector_fgetpos_2_2
, fgetpos@GLIBC_2
.2
)
3264 __collector_fgetpos_2_2 (FILE *stream
, fpos_t *pos
)
3266 if (NULL_PTR (fgetpos
))
3268 TprintfT (DBG_LTT
, "iotrace: __collector_fgetpos_2_2@%p\n", CALL_REAL (fgetpos_2_2
));
3269 return __collector_fgetpos_symver (CALL_REAL (fgetpos_2_2
), stream
, pos
);
3272 SYMVER_ATTRIBUTE (__collector_fgetpos_2_0
, fgetpos@GLIBC_2
.0
)
3274 __collector_fgetpos_2_0 (FILE *stream
, fpos_t *pos
)
3276 if (NULL_PTR (fgetpos
))
3278 TprintfT (DBG_LTT
, "iotrace: __collector_fgetpos_2_0@%p\n", CALL_REAL (fgetpos_2_0
));
3279 return __collector_fgetpos_symver (CALL_REAL (fgetpos_2_0
), stream
, pos
);
3283 #if ARCH(Intel) && WSIZE(32)
3286 __collector_fgetpos_symver (int(real_fgetpos
) (), FILE *stream
, fpos_t *pos
)
3290 fgetpos (FILE *stream
, fpos_t *pos
)
3295 IOTrace_packet iopkt
;
3296 if (NULL_PTR (fgetpos
))
3298 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
3300 #if ARCH(Intel) && WSIZE(32)
3301 return (real_fgetpos
) (stream
, pos
);
3303 return CALL_REAL (fgetpos
)(stream
, pos
);
3306 PUSH_REENTRANCE (guard
);
3307 hrtime_t reqt
= gethrtime ();
3308 #if ARCH(Intel) && WSIZE(32)
3309 ret
= (real_fgetpos
) (stream
, pos
);
3311 ret
= CALL_REAL (fgetpos
)(stream
, pos
);
3313 if (RECHCK_REENTRANCE (guard
))
3315 POP_REENTRANCE (guard
);
3318 hrtime_t grnt
= gethrtime ();
3319 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3320 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3321 iopkt
.comm
.tstamp
= grnt
;
3322 iopkt
.requested
= reqt
;
3324 iopkt
.iotype
= OTHERIO_TRACE
;
3326 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3327 iopkt
.fd
= fileno (stream
);
3329 #if ARCH(Intel) && WSIZE(32)
3330 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK_ARG
, &iopkt
);
3332 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3334 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3335 POP_REENTRANCE (guard
);
3340 /*------------------------------------------------------------- fgetpos64 */
3342 // map interposed symbol versions
3345 __collector_fgetpos64_symver (int(real_fgetpos64
) (), FILE *stream
, fpos64_t
*pos
);
3347 SYMVER_ATTRIBUTE (__collector_fgetpos64_2_2
, fgetpos64@GLIBC_2
.2
)
3349 __collector_fgetpos64_2_2 (FILE *stream
, fpos64_t
*pos
)
3351 TprintfT (DBG_LTT
, "iotrace: __collector_fgetpos64_2_2@%p(stream=%p, pos=%p)\n",
3352 CALL_REAL (fgetpos64_2_2
), stream
, pos
);
3353 if (NULL_PTR (fgetpos64
))
3355 return __collector_fgetpos64_symver (CALL_REAL (fgetpos64_2_2
), stream
, pos
);
3358 SYMVER_ATTRIBUTE (__collector_fgetpos64_2_1
, fgetpos64@GLIBC_2
.1
)
3360 __collector_fgetpos64_2_1 (FILE *stream
, fpos64_t
*pos
)
3362 TprintfT (DBG_LTT
, "iotrace: __collector_fgetpos64_2_1@%p(stream=%p, pos=%p)\n",
3363 CALL_REAL (fgetpos64_2_1
), stream
, pos
);
3364 if (NULL_PTR (fgetpos64
))
3366 return __collector_fgetpos64_symver (CALL_REAL (fgetpos64_2_1
), stream
, pos
);
3370 __collector_fgetpos64_symver (int(real_fgetpos64
) (), FILE *stream
, fpos64_t
*pos
)
3374 fgetpos64 (FILE *stream
, fpos64_t
*pos
)
3379 IOTrace_packet iopkt
;
3380 if (NULL_PTR (fgetpos64
))
3382 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
3385 return (real_fgetpos64
) (stream
, pos
);
3387 return CALL_REAL (fgetpos64
)(stream
, pos
);
3390 PUSH_REENTRANCE (guard
);
3391 hrtime_t reqt
= gethrtime ();
3393 ret
= (real_fgetpos64
) (stream
, pos
);
3395 ret
= CALL_REAL (fgetpos64
)(stream
, pos
);
3397 if (RECHCK_REENTRANCE (guard
))
3399 POP_REENTRANCE (guard
);
3402 hrtime_t grnt
= gethrtime ();
3403 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3404 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3405 iopkt
.comm
.tstamp
= grnt
;
3406 iopkt
.requested
= reqt
;
3408 iopkt
.iotype
= OTHERIO_TRACE
;
3410 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3411 iopkt
.fd
= fileno (stream
);
3413 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK_ARG
, &iopkt
);
3415 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3417 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3418 POP_REENTRANCE (guard
);
3423 /*------------------------------------------------------------- fsetpos */
3424 // map interposed symbol versions
3425 #if ARCH(Intel) && WSIZE(32)
3427 __collector_fsetpos_symver (int(real_fsetpos
) (), FILE *stream
, const fpos_t *pos
);
3429 SYMVER_ATTRIBUTE (__collector_fsetpos_2_2
, fsetpos@GLIBC_2
.2
)
3431 __collector_fsetpos_2_2 (FILE *stream
, const fpos_t *pos
)
3433 if (NULL_PTR (fsetpos
))
3435 TprintfT (DBG_LTT
, "iotrace: __collector_fsetpos_2_2@%p\n", CALL_REAL (fsetpos_2_2
));
3436 return __collector_fsetpos_symver (CALL_REAL (fsetpos_2_2
), stream
, pos
);
3439 SYMVER_ATTRIBUTE (__collector_fsetpos_2_0
, fsetpos@GLIBC_2
.0
)
3441 __collector_fsetpos_2_0 (FILE *stream
, const fpos_t *pos
)
3443 if (NULL_PTR (fsetpos
))
3445 TprintfT (DBG_LTT
, "iotrace: __collector_fsetpos_2_0@%p\n", CALL_REAL (fsetpos_2_0
));
3446 return __collector_fsetpos_symver (CALL_REAL (fsetpos_2_0
), stream
, pos
);
3450 #if ARCH(Intel) && WSIZE(32)
3453 __collector_fsetpos_symver (int(real_fsetpos
) (), FILE *stream
, const fpos_t *pos
)
3457 fsetpos (FILE *stream
, const fpos_t *pos
)
3462 IOTrace_packet iopkt
;
3463 if (NULL_PTR (fsetpos
))
3465 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
3467 #if ARCH(Intel) && WSIZE(32)
3468 return (real_fsetpos
) (stream
, pos
);
3470 return CALL_REAL (fsetpos
)(stream
, pos
);
3473 PUSH_REENTRANCE (guard
);
3474 hrtime_t reqt
= gethrtime ();
3475 #if ARCH(Intel) && WSIZE(32)
3476 ret
= (real_fsetpos
) (stream
, pos
);
3478 ret
= CALL_REAL (fsetpos
)(stream
, pos
);
3480 if (RECHCK_REENTRANCE (guard
))
3482 POP_REENTRANCE (guard
);
3485 hrtime_t grnt
= gethrtime ();
3486 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3487 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3488 iopkt
.comm
.tstamp
= grnt
;
3489 iopkt
.requested
= reqt
;
3491 iopkt
.iotype
= OTHERIO_TRACE
;
3493 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3494 iopkt
.fd
= fileno (stream
);
3495 #if ARCH(Intel) && WSIZE(32)
3496 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK_ARG
, &iopkt
);
3498 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3500 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3501 POP_REENTRANCE (guard
);
3506 /*------------------------------------------------------------- fsetpos64 */
3508 // map interposed symbol versions
3510 __collector_fsetpos64_symver (int(real_fsetpos64
) (), FILE *stream
, const fpos64_t
*pos
);
3512 SYMVER_ATTRIBUTE (__collector_fsetpos64_2_2
, fsetpos64@GLIBC_2
.2
)
3514 __collector_fsetpos64_2_2 (FILE *stream
, const fpos64_t
*pos
)
3516 TprintfT (DBG_LTT
, "iotrace: __collector_fsetpos64_2_2@%p(stream=%p, pos=%p)\n",
3517 CALL_REAL (fsetpos64_2_2
), stream
, pos
);
3518 if (NULL_PTR (fsetpos64
))
3520 return __collector_fsetpos64_symver (CALL_REAL (fsetpos64_2_2
), stream
, pos
);
3523 SYMVER_ATTRIBUTE (__collector_fsetpos64_2_1
, fsetpos64@GLIBC_2
.1
)
3525 __collector_fsetpos64_2_1 (FILE *stream
, const fpos64_t
*pos
)
3527 TprintfT (DBG_LTT
, "iotrace: __collector_fsetpos64_2_1@%p(stream=%p, pos=%p)\n",
3528 CALL_REAL (fsetpos64_2_1
), stream
, pos
);
3529 if (NULL_PTR (fsetpos64
))
3531 return __collector_fsetpos64_symver (CALL_REAL (fsetpos64_2_1
), stream
, pos
);
3535 __collector_fsetpos64_symver (int(real_fsetpos64
) (), FILE *stream
, const fpos64_t
*pos
)
3539 fsetpos64 (FILE *stream
, const fpos64_t
*pos
)
3544 IOTrace_packet iopkt
;
3545 if (NULL_PTR (fsetpos64
))
3547 if (CHCK_REENTRANCE (guard
) || stream
== NULL
)
3549 #if ARCH(Intel) && WSIZE(32)
3550 return (real_fsetpos64
) (stream
, pos
);
3552 return CALL_REAL (fsetpos64
)(stream
, pos
);
3555 PUSH_REENTRANCE (guard
);
3556 hrtime_t reqt
= gethrtime ();
3557 #if ARCH(Intel) && WSIZE(32)
3558 ret
= (real_fsetpos64
) (stream
, pos
);
3560 ret
= CALL_REAL (fsetpos64
)(stream
, pos
);
3562 if (RECHCK_REENTRANCE (guard
))
3564 POP_REENTRANCE (guard
);
3567 hrtime_t grnt
= gethrtime ();
3568 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3569 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3570 iopkt
.comm
.tstamp
= grnt
;
3571 iopkt
.requested
= reqt
;
3573 iopkt
.iotype
= OTHERIO_TRACE
;
3575 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3576 iopkt
.fd
= fileno (stream
);
3578 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK_ARG
, &iopkt
);
3580 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3582 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3583 POP_REENTRANCE (guard
);
3588 /*------------------------------------------------------------- fsync */
3594 IOTrace_packet iopkt
;
3595 if (NULL_PTR (fsync
))
3597 if (CHCK_REENTRANCE (guard
))
3598 return CALL_REAL (fsync
)(fildes
);
3599 PUSH_REENTRANCE (guard
);
3600 hrtime_t reqt
= gethrtime ();
3601 ret
= CALL_REAL (fsync
)(fildes
);
3602 if (RECHCK_REENTRANCE (guard
))
3604 POP_REENTRANCE (guard
);
3607 hrtime_t grnt
= gethrtime ();
3608 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3609 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3610 iopkt
.comm
.tstamp
= grnt
;
3611 iopkt
.requested
= reqt
;
3613 iopkt
.iotype
= OTHERIO_TRACE
;
3615 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3617 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3618 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3619 POP_REENTRANCE (guard
);
3623 /*------------------------------------------------------------- readdir */
3629 IOTrace_packet iopkt
;
3630 if (NULL_PTR (readdir
))
3632 if (CHCK_REENTRANCE (guard
))
3633 return CALL_REAL (readdir
)(dirp
);
3634 PUSH_REENTRANCE (guard
);
3635 hrtime_t reqt
= gethrtime ();
3636 ptr
= CALL_REAL (readdir
)(dirp
);
3637 if (RECHCK_REENTRANCE (guard
))
3639 POP_REENTRANCE (guard
);
3642 hrtime_t grnt
= gethrtime ();
3643 collector_memset (&iopkt
, 0, sizeof ( IOTrace_packet
));
3644 iopkt
.comm
.tsize
= sizeof ( IOTrace_packet
);
3645 iopkt
.comm
.tstamp
= grnt
;
3646 iopkt
.requested
= reqt
;
3648 iopkt
.iotype
= OTHERIO_TRACE
;
3650 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3651 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3652 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3653 POP_REENTRANCE (guard
);
3657 /*------------------------------------------------------------- flock */
3659 flock (int fd
, int operation
)
3663 IOTrace_packet iopkt
;
3664 if (NULL_PTR (flock
))
3666 if (CHCK_REENTRANCE (guard
))
3667 return CALL_REAL (flock
)(fd
, operation
);
3668 PUSH_REENTRANCE (guard
);
3669 hrtime_t reqt
= gethrtime ();
3670 ret
= CALL_REAL (flock
)(fd
, operation
);
3671 if (RECHCK_REENTRANCE (guard
))
3673 POP_REENTRANCE (guard
);
3676 hrtime_t grnt
= gethrtime ();
3677 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3678 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3679 iopkt
.comm
.tstamp
= grnt
;
3680 iopkt
.requested
= reqt
;
3682 iopkt
.iotype
= OTHERIO_TRACE
;
3684 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3686 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3687 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3688 POP_REENTRANCE (guard
);
3692 /*------------------------------------------------------------- lockf */
3694 lockf (int fildes
, int function
, off_t size
)
3698 IOTrace_packet iopkt
;
3699 if (NULL_PTR (lockf
))
3701 if (CHCK_REENTRANCE (guard
))
3702 return CALL_REAL (lockf
)(fildes
, function
, size
);
3703 PUSH_REENTRANCE (guard
);
3704 hrtime_t reqt
= gethrtime ();
3705 ret
= CALL_REAL (lockf
)(fildes
, function
, size
);
3706 if (RECHCK_REENTRANCE (guard
))
3708 POP_REENTRANCE (guard
);
3711 hrtime_t grnt
= gethrtime ();
3712 collector_memset (&iopkt
, 0, sizeof (IOTrace_packet
));
3713 iopkt
.comm
.tsize
= sizeof (IOTrace_packet
);
3714 iopkt
.comm
.tstamp
= grnt
;
3715 iopkt
.requested
= reqt
;
3717 iopkt
.iotype
= OTHERIO_TRACE
;
3719 iopkt
.iotype
= OTHERIO_TRACE_ERROR
;
3721 iopkt
.comm
.frinfo
= collector_interface
->getFrameInfo (io_hndl
, iopkt
.comm
.tstamp
, FRINFO_FROM_STACK
, &iopkt
);
3722 collector_interface
->writeDataRecord (io_hndl
, (Common_packet
*) & iopkt
);
3723 POP_REENTRANCE (guard
);