From 1f359c1cdbb7a9bd41f3cb9717187e8aeacce43b Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 27 Nov 2018 15:05:05 +0100 Subject: Changement du format de traces --- src/debug.h | 64 +++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/src/debug.h b/src/debug.h index 87140e5..c7fa343 100644 --- a/src/debug.h +++ b/src/debug.h @@ -5,46 +5,68 @@ #include -static inline void debug_dump_lanes(FILE *output, const char *header, size_t len, const uint8_t buf[len], int indent) -{ - if (!output) - { - return; - } +extern FILE *DUMP; /* Define this variable somewhere (eg with DUMP = stderr). */ + - fprintf(output, "%s\n", header); +static inline void debug_dump_lanes(const char *header, size_t len, const uint8_t buf[len], int indent) +{ + fprintf(DUMP, "%s\n", header); for (size_t line=0; line %zu]", line, b, byte_index); */ + fprintf(DUMP, "%02x ", buf[byte_index]); + } + fprintf(DUMP, "\n"); } - fprintf(output, "\n"); + + fprintf(DUMP, "\n"); } +static inline void debug_open_dump(const char *vector_name) +{ + size_t namelen = snprintf(NULL, 0, "/tmp/test-%s.txt", vector_name); + char name[namelen+1]; + snprintf(name, sizeof(name), "/tmp/test-%s.txt", vector_name); + DUMP = fopen(name, "w"); +} + + #endif /* DEBUG_H */ -- cgit v1.2.3