The attached patch adds a new variant of grub_dprintf, grub_dcprintf,
which avoids printing the __FILE__:__LINE__: prefix.  This allows
printing a single line with multiple print statements; for instance:

grub_dprintf("some_module", "Thingy: ");
print_complicated_thingy(thingy);
grub_dcprintf("some_module", ", more details here\n");

Without the dcprintf variant, this line will contain three different
file/line prefixes.

I also added support for a "no-file-line" token in the debug environment
variable, which turns off the file/line prefixes entirely.

- Josh Triplett
=== modified file 'include/grub/misc.h'
--- include/grub/misc.h	2010-07-02 17:35:07 +0000
+++ include/grub/misc.h	2010-07-24 21:33:29 +0000
@@ -47,6 +47,8 @@
 #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
 
 #define grub_dprintf(condition, fmt, args...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, fmt, ## args)
+/* A "continuation" variant of dprintf which doesn't print file and line. */
+#define grub_dcprintf(condition, fmt, args...) grub_real_dprintf(0, 0, condition, fmt, ## args)
 /* XXX: If grub_memmove is too slow, we must implement grub_memcpy.  */
 #define grub_memcpy(d,s,n)	grub_memmove ((d), (s), (n))
 

=== modified file 'kern/misc.c'
--- kern/misc.c	2010-07-02 17:35:07 +0000
+++ kern/misc.c	2010-07-24 21:17:37 +0000
@@ -180,7 +180,8 @@
 
   if (grub_strword (debug, "all") || grub_strword (debug, condition))
     {
-      grub_printf ("%s:%d: ", file, line);
+      if (line != 0 && !grub_strword (debug, "no-file-line"))
+        grub_printf ("%s:%d: ", file, line);
       va_start (args, fmt);
       grub_vprintf (fmt, args);
       va_end (args);

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to