[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/2] Add gdb-friendly output support to grub_real_dprintf()
From: |
Robbie Harwood |
Subject: |
[PATCH v2 1/2] Add gdb-friendly output support to grub_real_dprintf() |
Date: |
Wed, 3 Nov 2021 14:22:06 -0400 |
When condition is gdb, comment out the file/line/system information by
prepending '#' and putting the command on its own line. This allows
easy copy/pasting of gdb commands into gdb while preserving the
information about where the print came from and how to disable it.
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/kern/misc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 11b8592c8..7eea900ae 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -182,7 +182,12 @@ grub_real_dprintf (const char *file, const int line, const
char *condition,
if (grub_debug_enabled (condition))
{
- grub_printf ("%s:%d:%s: ", file, line, condition);
+ /* gdb commands are on their own line to ease copy/pasting into gdb. */
+ if (!grub_strcmp(condition, "gdb"))
+ grub_printf("#%s:%d:%s:\n", file, line, condition);
+ else
+ grub_printf ("%s:%d:%s: ", file, line, condition);
+
va_start (args, fmt);
grub_vprintf (fmt, args);
va_end (args);
--
2.33.0