From 1e8c48386412ea5c75cbb0859df1cb895ee4c732 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 6 Jun 2022 11:19:16 +0200 Subject: Debug prints --- cbits/hook.c | 7 +++++++ test/Main.hs | 1 + 2 files changed, 8 insertions(+) diff --git a/cbits/hook.c b/cbits/hook.c index 22aa259..697b64f 100644 --- a/cbits/hook.c +++ b/cbits/hook.c @@ -137,6 +137,7 @@ static void hook_callback(const struct GCDetails_ *details) { // mutex is locked from here if (logging_enabled) { + fprintf(stderr, " gc\n"); if (detlog_length == detlog_capacity) { detlog_capacity = detlog_capacity == 0 ? 128 : 2 * detlog_capacity; detlog = realloc(detlog, detlog_capacity * sizeof(detlog[0])); @@ -152,6 +153,8 @@ static void hook_callback(const struct GCDetails_ *details) { dst->timestamp_nsec = now.tv_nsec; shadow_copy(dst, details); detlog_length++; + } else { + fprintf(stderr, " gc but not enabled\n"); } if (hook_c_delegate) hook_c_delegate(details); @@ -187,6 +190,8 @@ void copy_log_to_buffer(size_t space_available, char *buffer, size_t *unit_size, return; } + fprintf(stderr, " length = %zu\n", detlog_length); + if (detlog_length == 0) { *num_stored = 0; goto unlock_return; @@ -194,6 +199,8 @@ void copy_log_to_buffer(size_t space_available, char *buffer, size_t *unit_size, const size_t n = min_sz(space_available / sizeof(detlog[0]), detlog_length); + fprintf(stderr, " n = %zu\n", n); + // First copy over the fitting items memcpy(buffer, detlog, n * sizeof(detlog[0])); *unit_size = sizeof(detlog[0]); diff --git a/test/Main.hs b/test/Main.hs index 90e5f90..8a0a81a 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -34,6 +34,7 @@ main = do gclog <- getGCLog when (length gclog == 0) $ fail "GC log was unexpectedly empty" + print gclog when (any ((< enabletm) . detTimestamp) gclog) $ do _ <- fail "Logging was already on before enableGClogging" print enabletm -- cgit v1.2.3-54-g00ecf