Changeset: f58e2a9f2a56 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f58e2a9f2a56
Modified Files:
        common/stream/stream.c
Branch: smapi
Log Message:

Better debugging messages


diffs (44 lines):

diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -196,14 +196,20 @@ mnstr_read(stream *restrict s, void *res
 {
        if (s == NULL || buf == NULL)
                return -1;
-#ifdef STREAM_DEBUG
-       fprintf(stderr, "read %s %zu %zu\n",
-               s->name ? s->name : "<unnamed>", elmsize, cnt);
-#endif
+
        assert(s->readonly);
        if (s->errkind != MNSTR_NO__ERROR)
                return -1;
-       return s->read(s, buf, elmsize, cnt);
+       ssize_t r = s->read(s, buf, elmsize, cnt);
+#ifdef STREAM_DEBUG
+       char *msg = (char *)malloc(elmsize*cnt);
+       strncpy(msg, buf, elmsize*cnt);
+       msg[elmsize*cnt] = 0;
+       fprintf(stderr, "read %s %zu %zu <%s>\n",
+                       s->name ? s->name : "<unnamed>", elmsize, cnt, msg);
+       free(msg);
+#endif
+       return r;
 }
 
 
@@ -216,8 +222,12 @@ mnstr_write(stream *restrict s, const vo
        if (s == NULL || buf == NULL)
                return -1;
 #ifdef STREAM_DEBUG
-       fprintf(stderr, "write %s %zu %zu\n",
-               s->name ? s->name : "<unnamed>", elmsize, cnt);
+       char *msg = (char *)malloc(elmsize*cnt);
+       strncpy(msg, buf, elmsize*cnt);
+       msg[elmsize*cnt] = 0;
+       fprintf(stderr, "write %s %zu %zu <%s>\n",
+                       s->name ? s->name : "<unnamed>", elmsize, cnt, msg);
+       free(msg);
 #endif
        assert(!s->readonly);
        if (s->errkind != MNSTR_NO__ERROR)
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to