2020-12-31 15:03:56 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
|
|
|
|
Date: Sat, 23 Nov 2019 14:57:41 +0100
|
|
|
|
Subject: [PATCH] New --with-debug-timestamps configure flag to prepend debug
|
|
|
|
traces with absolute and relative timestamp
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
|
|
|
|
---
|
|
|
|
configure.ac | 18 ++++++++++++++++++
|
|
|
|
grub-core/kern/misc.c | 20 ++++++++++++++++++++
|
|
|
|
config.h.in | 1 +
|
|
|
|
3 files changed, 39 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/configure.ac b/configure.ac
|
2024-07-10 18:20:32 +00:00
|
|
|
index ae7683d0693..016cd3d4e0e 100644
|
2020-12-31 15:03:56 +00:00
|
|
|
--- a/configure.ac
|
|
|
|
+++ b/configure.ac
|
2024-07-10 18:20:32 +00:00
|
|
|
@@ -1686,6 +1686,17 @@ else
|
2020-12-31 15:03:56 +00:00
|
|
|
fi
|
|
|
|
AC_SUBST([BOOT_TIME_STATS])
|
|
|
|
|
|
|
|
+AC_ARG_WITH([debug-timestamps],
|
|
|
|
+ AS_HELP_STRING([--with-debug-timestamps],
|
|
|
|
+ [prepend debug traces with absolute and relative timestamps]))
|
|
|
|
+
|
|
|
|
+if test x$with_debug_timestamps = xyes; then
|
|
|
|
+ DEBUG_WITH_TIMESTAMPS=1
|
|
|
|
+else
|
|
|
|
+ DEBUG_WITH_TIMESTAMPS=0
|
|
|
|
+fi
|
|
|
|
+AC_SUBST([DEBUG_WITH_TIMESTAMPS])
|
|
|
|
+
|
2024-07-10 18:20:32 +00:00
|
|
|
AC_ARG_ENABLE([grub-emu-sdl2],
|
|
|
|
[AS_HELP_STRING([--enable-grub-emu-sdl2],
|
|
|
|
[build and install the `grub-emu' debugging utility with SDL2 support (default=guessed)])])
|
|
|
|
@@ -2296,6 +2307,7 @@ AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
|
2020-12-31 15:03:56 +00:00
|
|
|
AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
|
|
|
|
AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
|
|
|
|
AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
|
|
|
|
+AM_CONDITIONAL([COND_DEBUG_WITH_TIMESTAMPS], [test x$DEBUG_WITH_TIMESTAMPS = x1])
|
|
|
|
|
|
|
|
AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
|
|
|
|
|
2024-07-10 18:20:32 +00:00
|
|
|
@@ -2397,6 +2409,12 @@ else
|
2020-12-31 15:03:56 +00:00
|
|
|
echo With boot time statistics: No
|
|
|
|
fi
|
|
|
|
|
|
|
|
+if [ x"$with_debug_timestamps" = xyes ]; then
|
|
|
|
+echo Debug traces with timestamps: Yes
|
|
|
|
+else
|
|
|
|
+echo Debug traces with timestamps: No
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
if [ x"$efiemu_excuse" = x ]; then
|
|
|
|
echo efiemu runtime: Yes
|
|
|
|
else
|
|
|
|
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
|
2024-07-10 18:20:32 +00:00
|
|
|
index 779586658cb..d40586b9268 100644
|
2020-12-31 15:03:56 +00:00
|
|
|
--- a/grub-core/kern/misc.c
|
|
|
|
+++ b/grub-core/kern/misc.c
|
2024-07-10 18:20:32 +00:00
|
|
|
@@ -27,6 +27,9 @@
|
|
|
|
#include <grub/types.h>
|
|
|
|
#include <grub/charset.h>
|
2020-12-31 15:03:56 +00:00
|
|
|
#include <grub/backtrace.h>
|
|
|
|
+#if DEBUG_WITH_TIMESTAMPS
|
|
|
|
+#include <grub/time.h>
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
union printf_arg
|
|
|
|
{
|
2024-07-10 18:20:32 +00:00
|
|
|
@@ -236,9 +239,26 @@ grub_real_dprintf (const char *file, const int line, const char *condition,
|
2020-12-31 15:03:56 +00:00
|
|
|
const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
+#if DEBUG_WITH_TIMESTAMPS
|
|
|
|
+ static long unsigned int last_time = 0;
|
|
|
|
+ static int last_had_cr = 1;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
if (grub_debug_enabled (condition))
|
|
|
|
{
|
|
|
|
+#if DEBUG_WITH_TIMESTAMPS
|
|
|
|
+ /* Don't print timestamp if last printed message isn't terminated yet */
|
|
|
|
+ if (last_had_cr) {
|
|
|
|
+ long unsigned int tmabs = (long unsigned int) grub_get_time_ms();
|
|
|
|
+ long unsigned int tmrel = tmabs - last_time;
|
|
|
|
+ last_time = tmabs;
|
|
|
|
+ grub_printf ("%3lu.%03lus +%2lu.%03lus ", tmabs / 1000, tmabs % 1000, tmrel / 1000, tmrel % 1000);
|
|
|
|
+ }
|
|
|
|
+ if (fmt[grub_strlen(fmt)-1] == '\n')
|
|
|
|
+ last_had_cr = 1;
|
|
|
|
+ else
|
|
|
|
+ last_had_cr = 0;
|
|
|
|
+#endif
|
2024-07-10 18:20:32 +00:00
|
|
|
grub_printf ("%s:%d:%s: ", file, line, condition);
|
2020-12-31 15:03:56 +00:00
|
|
|
va_start (args, fmt);
|
|
|
|
grub_vprintf (fmt, args);
|
|
|
|
diff --git a/config.h.in b/config.h.in
|
2024-07-10 18:20:32 +00:00
|
|
|
index d294d2c653f..39f4e5472ce 100644
|
2020-12-31 15:03:56 +00:00
|
|
|
--- a/config.h.in
|
|
|
|
+++ b/config.h.in
|
2024-07-10 18:20:32 +00:00
|
|
|
@@ -16,6 +16,7 @@
|
2020-12-31 15:03:56 +00:00
|
|
|
/* Define to 1 to enable disk cache statistics. */
|
|
|
|
#define DISK_CACHE_STATS @DISK_CACHE_STATS@
|
|
|
|
#define BOOT_TIME_STATS @BOOT_TIME_STATS@
|
|
|
|
+#define DEBUG_WITH_TIMESTAMPS @DEBUG_WITH_TIMESTAMPS@
|
|
|
|
|
|
|
|
/* We don't need those. */
|
|
|
|
#define MINILZO_CFG_SKIP_LZO_PTR 1
|