From 0b74819e788331470a24ec3805394836b826fd51 Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Fri, 26 Nov 2021 07:22:55 +0100 Subject: [PATCH] libsel4utils: use proper types for printing Signed-off-by: Axel Heider --- libsel4utils/include/sel4utils/benchmark.h | 5 ++- .../include/sel4utils/benchmark_track.h | 40 +++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/libsel4utils/include/sel4utils/benchmark.h b/libsel4utils/include/sel4utils/benchmark.h index 936090ee7..4f6814e87 100644 --- a/libsel4utils/include/sel4utils/benchmark.h +++ b/libsel4utils/include/sel4utils/benchmark.h @@ -26,11 +26,12 @@ static inline void seL4_BenchmarkTraceDumpFullLog(benchmark_tracepoint_log_entry while ((index * sizeof(benchmark_tracepoint_log_entry_t)) < logSize) { if (logBuffer[index].duration != 0) { - fprintf(fd, "tracepoint id = %u \tduration = %u\n", logBuffer[index].id, logBuffer[index].duration); + fprintf(fd, "tracepoint id = %"SEL4_PRIu_word" \tduration = %"SEL4_PRIu_word"\n", + logBuffer[index].id, logBuffer[index].duration); } index++; } - fprintf(fd, "Dumped entire log, size %" PRIu32 "\n", index); + fprintf(fd, "Dumped entire log, size %"SEL4_PRIu_word"\n", index); } #endif /* CONFIG_BENCHMARK_TRACEPOINTS */ diff --git a/libsel4utils/include/sel4utils/benchmark_track.h b/libsel4utils/include/sel4utils/benchmark_track.h index 8dd9bc806..3c8bffba6 100644 --- a/libsel4utils/include/sel4utils/benchmark_track.h +++ b/libsel4utils/include/sel4utils/benchmark_track.h @@ -39,10 +39,10 @@ static inline void seL4_BenchmarkTrackDumpSummary(benchmark_track_kernel_entry_t index++; } - fprintf(fd, "Number of system call invocations %d\n", syscall_entries); - fprintf(fd, "Number of interrupt invocations %d\n", interrupt_entries); - fprintf(fd, "Number of user-level faults %d\n", userlevelfault_entries); - fprintf(fd, "Number of VM faults %d\n", vmfault_entries); + fprintf(fd, "Number of system call invocations: %"SEL4_PRIu_word"\n", syscall_entries); + fprintf(fd, "Number of interrupt invocations: %"SEL4_PRIu_word"\n", interrupt_entries); + fprintf(fd, "Number of user-level faults: %"SEL4_PRIu_word"\n", userlevelfault_entries); + fprintf(fd, "Number of VM faults: %"SEL4_PRIu_word"\n", vmfault_entries); } /* Print out logged system call invocations */ @@ -54,22 +54,22 @@ static inline void seL4_BenchmarkTrackDumpFullSyscallLog(benchmark_track_kernel_ /* Get details of each system call invocation */ fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n"); - fprintf(fd, "| %-15s| %-15s| %-15s| %-15s| %-15s| %-15s| %-15s|\n", - "Log ID", "System Call ID", "Start Time", "Duration", "Capability Type", - "Invocation Tag", "Fastpath?"); + fprintf(fd, " %-10s | %-7s | %-20s | %-10s | %-3s | %-7s| %-8s\n", + "Log ID", "SysCall", "Start Time", "Duration", "Cap", + "Tag", "Fastpath?"); fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n"); while (logBuffer[index].start_time != 0 && (index * sizeof(benchmark_track_kernel_entry_t)) < logSize) { if (logBuffer[index].entry.path == Entry_Syscall) { - fprintf(fd, "| %-15d| %-15d| %-15llu| %-15d| %-15d| %-15d| %-15d|\n", + fprintf(fd, " %-10"SEL4_PRIu_word" | %-7u | %-20"PRIu64" | %-10u | %-3u | %-7u | %-9s\n", index, - logBuffer[index].entry.syscall_no, - (uint64_t) logBuffer[index].start_time, - logBuffer[index].duration, - logBuffer[index].entry.cap_type, - logBuffer[index].entry.invocation_tag, - logBuffer[index].entry.is_fastpath); + (unsigned int)logBuffer[index].entry.syscall_no, /* 4 bit */ + logBuffer[index].start_time, /* 64 bit */ + logBuffer[index].duration, /* 32 bit */ + (unsigned int)logBuffer[index].entry.cap_type, /* 5 bit */ + (unsigned int)logBuffer[index].entry.invocation_tag, /* 19 bit */ + logBuffer[index].entry.is_fastpath ? "yes" : "no"); } index++; } @@ -84,18 +84,18 @@ static inline void seL4_BenchmarkTrackDumpFullInterruptLog(benchmark_track_kerne /* Get details of each invocation */ fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n"); - fprintf(fd, "| %-15s| %-15s| %-15s| %-15s|\n", "Log ID", "IRQ", "Start Time", - "Duration"); + fprintf(fd, " %-10s | %-8s | %-20s | %-10s \n", + "Log ID", "IRQ", "Start Time", "Duration"); fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n"); while (logBuffer[index].start_time != 0 && (index * sizeof(benchmark_track_kernel_entry_t)) < logSize) { if (logBuffer[index].entry.path == Entry_Interrupt) { - fprintf(fd, "| %-15d| %-15d| %-15llu| %-15d|\n", \ + fprintf(fd, " %-10"SEL4_PRIu_word" | %-8u | %-20"PRIu64" | %-10u\n", \ index, - logBuffer[index].entry.word, - logBuffer[index].start_time, - logBuffer[index].duration); + (unsigned int)logBuffer[index].entry.word, /* 26 bits */ + logBuffer[index].start_time, /* 64 bit */ + logBuffer[index].duration); /* 32 bit */ } index++; }