[Darshan-commits] [Git][darshan/darshan][gkl/obfuscate-fs-fix] 5 commits: bug fix in writing of name records

Glenn K. Lockwood xgitlab at cels.anl.gov
Wed Aug 24 12:02:12 CDT 2016


Glenn K. Lockwood pushed to branch gkl/obfuscate-fs-fix at darshan / darshan


Commits:
d4dc84f4 by Shane Snyder at 2016-08-17T21:30:12-05:00
bug fix in writing of name records

- - - - -
49ebb1b4 by Shane Snyder at 2016-08-17T21:30:47-05:00
make sure to write records in current version

- - - - -
173d3d49 by Phil Carns at 2016-08-20T09:11:40-04:00
tracking stdout stderr and stdin

- - - - -
6e75dade by Glenn K. Lockwood at 2016-08-24T09:57:37-07:00
Merge branch 'master' into gkl/obfuscate-fs-fix to pull in fix from d4dc84f

- - - - -
eadbecfd by Glenn K. Lockwood at 2016-08-24T10:00:07-07:00
fix wrong struct type (inconsequential as it may be in the given context)

- - - - -


12 changed files:

- darshan-runtime/lib/darshan-common.c
- darshan-runtime/lib/darshan-stdio.c
- darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
- darshan-util/darshan-bgq-logutils.c
- darshan-util/darshan-hdf5-logutils.c
- darshan-util/darshan-logutils.c
- darshan-util/darshan-lustre-logutils.c
- darshan-util/darshan-mpiio-logutils.c
- darshan-util/darshan-null-logutils.c
- darshan-util/darshan-pnetcdf-logutils.c
- darshan-util/darshan-posix-logutils.c
- darshan-util/darshan-stdio-logutils.c


Changes:

=====================================
darshan-runtime/lib/darshan-common.c
=====================================
--- a/darshan-runtime/lib/darshan-common.c
+++ b/darshan-runtime/lib/darshan-common.c
@@ -126,7 +126,11 @@ char* darshan_clean_file_path(const char* path)
     char* cwd = NULL;
     char* filter = NULL;
 
-    if(!path || strlen(path) < 1)
+    /* NOTE: the last check in this if statement is for path strings that
+     * begin with the '<' character.  We assume that these are special
+     * reserved paths used by Darshan, like <STDIN>.
+     */
+    if(!path || strlen(path) < 1 || path[0] == '<')
         return(NULL);
 
     if(path[0] == '/')


=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
--- a/darshan-runtime/lib/darshan-stdio.c
+++ b/darshan-runtime/lib/darshan-stdio.c
@@ -94,7 +94,9 @@ DARSHAN_FORWARD_DECL(fputc, int, (int c, FILE *stream));
 DARSHAN_FORWARD_DECL(putw, int, (int w, FILE *stream));
 DARSHAN_FORWARD_DECL(fputs, int, (const char *s, FILE *stream));
 DARSHAN_FORWARD_DECL(fprintf, int, (FILE *stream, const char *format, ...));
+DARSHAN_FORWARD_DECL(printf, int, (const char *format, ...));
 DARSHAN_FORWARD_DECL(vfprintf, int, (FILE *stream, const char *format, va_list));
+DARSHAN_FORWARD_DECL(vprintf, int, (const char *format, va_list));
 DARSHAN_FORWARD_DECL(fread, size_t, (void *ptr, size_t size, size_t nmemb, FILE *stream));
 DARSHAN_FORWARD_DECL(fgetc, int, (FILE *stream));
 DARSHAN_FORWARD_DECL(getw, int, (FILE *stream));
@@ -463,6 +465,25 @@ int DARSHAN_DECL(fputs)(const char *s, FILE *stream)
     return(ret);
 }
 
+int DARSHAN_DECL(vprintf)(const char *format, va_list ap)
+{
+    int ret;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(vprintf);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_vprintf(format, ap);
+    tm2 = darshan_core_wtime();
+
+    STDIO_PRE_RECORD();
+    if(ret > 0)
+        STDIO_RECORD_WRITE(stdout, ret, tm1, tm2, 0);
+    STDIO_POST_RECORD();
+
+    return(ret);
+}
+
 int DARSHAN_DECL(vfprintf)(FILE *stream, const char *format, va_list ap)
 {
     int ret;
@@ -472,14 +493,38 @@ int DARSHAN_DECL(vfprintf)(FILE *stream, const char *format, va_list ap)
     MAP_OR_FAIL(vfprintf);
 
     tm1 = darshan_core_wtime();
-    start_off = ftell(stream);
     ret = __real_vfprintf(stream, format, ap);
-    end_off = ftell(stream);
     tm2 = darshan_core_wtime();
 
     STDIO_PRE_RECORD();
     if(ret > 0)
-        STDIO_RECORD_WRITE(stream, (end_off-start_off), tm1, tm2, 0);
+        STDIO_RECORD_WRITE(stream, ret, tm1, tm2, 0);
+    STDIO_POST_RECORD();
+
+    return(ret);
+}
+
+
+int DARSHAN_DECL(printf)(const char *format, ...)
+{
+    int ret;
+    double tm1, tm2;
+    va_list ap;
+
+    MAP_OR_FAIL(vprintf);
+
+    tm1 = darshan_core_wtime();
+    /* NOTE: we intentionally switch to vprintf here to handle the variable
+     * length arguments.
+     */
+    va_start(ap, format);
+    ret = __real_vprintf(format, ap);
+    va_end(ap);
+    tm2 = darshan_core_wtime();
+
+    STDIO_PRE_RECORD();
+    if(ret > 0)
+        STDIO_RECORD_WRITE(stdout, ret, tm1, tm2, 0);
     STDIO_POST_RECORD();
 
     return(ret);
@@ -491,7 +536,6 @@ int DARSHAN_DECL(fprintf)(FILE *stream, const char *format, ...)
     int ret;
     double tm1, tm2;
     va_list ap;
-    long start_off, end_off;
 
     MAP_OR_FAIL(vfprintf);
 
@@ -499,16 +543,14 @@ int DARSHAN_DECL(fprintf)(FILE *stream, const char *format, ...)
     /* NOTE: we intentionally switch to vfprintf here to handle the variable
      * length arguments.
      */
-    start_off = ftell(stream);
     va_start(ap, format);
     ret = __real_vfprintf(stream, format, ap);
     va_end(ap);
-    end_off = ftell(stream);
     tm2 = darshan_core_wtime();
 
     STDIO_PRE_RECORD();
     if(ret > 0)
-        STDIO_RECORD_WRITE(stream, (end_off-start_off), tm1, tm2, 0);
+        STDIO_RECORD_WRITE(stream, ret, tm1, tm2, 0);
     STDIO_POST_RECORD();
 
     return(ret);
@@ -939,6 +981,11 @@ static void stdio_runtime_initialize()
         return;
     }
     memset(stdio_runtime, 0, sizeof(*stdio_runtime));
+
+    /* instantiate records for stdin, stdout, and stderr */
+    STDIO_RECORD_OPEN(stdin, "<STDIN>", 0, 0);
+    STDIO_RECORD_OPEN(stdout, "<STDOUT>", 0, 0);
+    STDIO_RECORD_OPEN(stderr, "<STDERR>", 0, 0);
 }
 
 /************************************************************************


=====================================
darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
=====================================
--- a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
+++ b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
@@ -20,6 +20,7 @@
 --wrap=fseeko64
 --wrap=fprintf
 --wrap=vfprintf
+--wrap=vprintf
 --wrap=fputc
 --wrap=fputs
 --wrap=putw
@@ -27,3 +28,4 @@
 --wrap=fsetpos64
 --wrap=rewind
 --wrap=__isoc99_fscanf
+--wrap=printf


=====================================
darshan-util/darshan-bgq-logutils.c
=====================================
--- a/darshan-util/darshan-bgq-logutils.c
+++ b/darshan-util/darshan-bgq-logutils.c
@@ -120,7 +120,7 @@ static int darshan_log_put_bgq_rec(darshan_fd fd, void* bgq_buf, int ver)
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_BGQ_MOD, rec,
-        sizeof(struct darshan_bgq_record), ver);
+        sizeof(struct darshan_bgq_record), DARSHAN_BGQ_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-hdf5-logutils.c
=====================================
--- a/darshan-util/darshan-hdf5-logutils.c
+++ b/darshan-util/darshan-hdf5-logutils.c
@@ -85,7 +85,7 @@ static int darshan_log_put_hdf5_file(darshan_fd fd, void* hdf5_buf, int ver)
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_HDF5_MOD, file,
-        sizeof(struct darshan_hdf5_file), ver);
+        sizeof(struct darshan_hdf5_file), DARSHAN_HDF5_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-logutils.c
=====================================
--- a/darshan-util/darshan-logutils.c
+++ b/darshan-util/darshan-logutils.c
@@ -586,22 +586,22 @@ int darshan_log_put_namehash(darshan_fd fd, struct darshan_name_record_ref *hash
 {
     struct darshan_fd_int_state *state = fd->state;
     struct darshan_name_record_ref *ref, *tmp;
-    struct darshan_name_record_ref *name_rec;
+    struct darshan_name_record *name_rec;
     int name_rec_len;
     int wrote;
 
     assert(state);
 
     /* allocate memory for largest possible hash record */
-    name_rec = malloc(sizeof(struct darshan_name_record) + PATH_MAX);
+    name_rec = malloc(sizeof(darshan_record_id) + PATH_MAX + 1);
     if(!name_rec)
         return(-1);
-    memset(name_rec, 0, sizeof(struct darshan_name_record) + PATH_MAX);
+    memset(name_rec, 0, sizeof(darshan_record_id) + PATH_MAX + 1);
 
     /* individually serialize each hash record and write to log file */
     HASH_ITER(hlink, hash, ref, tmp)
     {
-        name_rec_len = sizeof(struct darshan_name_record) + strlen(ref->name_record->name);
+        name_rec_len = sizeof(darshan_record_id) + strlen(ref->name_record->name) + 1;
         memcpy(name_rec, ref->name_record, name_rec_len);
 
         /* write this hash entry to log file */


=====================================
darshan-util/darshan-lustre-logutils.c
=====================================
--- a/darshan-util/darshan-lustre-logutils.c
+++ b/darshan-util/darshan-lustre-logutils.c
@@ -94,7 +94,7 @@ static int darshan_log_put_lustre_record(darshan_fd fd, void* lustre_buf, int ve
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_LUSTRE_MOD, rec,
-        LUSTRE_RECORD_SIZE(rec->counters[LUSTRE_STRIPE_WIDTH]), ver);
+        LUSTRE_RECORD_SIZE(rec->counters[LUSTRE_STRIPE_WIDTH]), DARSHAN_LUSTRE_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-mpiio-logutils.c
=====================================
--- a/darshan-util/darshan-mpiio-logutils.c
+++ b/darshan-util/darshan-mpiio-logutils.c
@@ -85,7 +85,7 @@ static int darshan_log_put_mpiio_file(darshan_fd fd, void* mpiio_buf, int ver)
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_MPIIO_MOD, file,
-        sizeof(struct darshan_mpiio_file), ver);
+        sizeof(struct darshan_mpiio_file), DARSHAN_MPIIO_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-null-logutils.c
=====================================
--- a/darshan-util/darshan-null-logutils.c
+++ b/darshan-util/darshan-null-logutils.c
@@ -102,7 +102,7 @@ static int darshan_log_put_null_record(darshan_fd fd, void* null_buf, int ver)
 
     /* append NULL record to darshan log file */
     ret = darshan_log_put_mod(fd, DARSHAN_NULL_MOD, rec,
-        sizeof(struct darshan_null_record), ver);
+        sizeof(struct darshan_null_record), DARSHAN_NULL_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-pnetcdf-logutils.c
=====================================
--- a/darshan-util/darshan-pnetcdf-logutils.c
+++ b/darshan-util/darshan-pnetcdf-logutils.c
@@ -85,7 +85,7 @@ static int darshan_log_put_pnetcdf_file(darshan_fd fd, void* pnetcdf_buf, int ve
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_PNETCDF_MOD, file,
-        sizeof(struct darshan_pnetcdf_file), ver);
+        sizeof(struct darshan_pnetcdf_file), DARSHAN_PNETCDF_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-posix-logutils.c
=====================================
--- a/darshan-util/darshan-posix-logutils.c
+++ b/darshan-util/darshan-posix-logutils.c
@@ -120,7 +120,7 @@ static int darshan_log_put_posix_file(darshan_fd fd, void* posix_buf, int ver)
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_POSIX_MOD, file,
-        sizeof(struct darshan_posix_file), ver);
+        sizeof(struct darshan_posix_file), DARSHAN_POSIX_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-stdio-logutils.c
=====================================
--- a/darshan-util/darshan-stdio-logutils.c
+++ b/darshan-util/darshan-stdio-logutils.c
@@ -99,7 +99,7 @@ static int darshan_log_put_stdio_record(darshan_fd fd, void* stdio_buf, int ver)
 
     /* append STDIO record to darshan log file */
     ret = darshan_log_put_mod(fd, DARSHAN_STDIO_MOD, rec,
-        sizeof(struct darshan_stdio_file), ver);
+        sizeof(struct darshan_stdio_file), DARSHAN_STDIO_VER);
     if(ret < 0)
         return(-1);
 



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/0d1f6e805a97b998bd5ae3f74164f48a01f2cc7c...eadbecfd7cdc040c37d1cc9b16129344b63a7bc6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160824/f8c28ba6/attachment-0001.html>


More information about the Darshan-commits mailing list