Add grub_dcprintf for continuations without file/line
PATCH 1/1 Add grub_dcprintf for continuations without file/line
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'
grub/misc.h +2 -0
@@ -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'
misc.c +2 -1
@@ -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);
Quoted 8 lines · Josh Triplett
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");
Quoted 7 lines
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.
core is very size sensitive. You need a valid usecase to justify such a feature in it. It feels like useful only for dumping a mass of info. In practice users can only report back around 4-5 lines, sometimes a compelete screen by taking its picture, so this info would be lost in bugreports anyway. If you're developping something you usually need a dump in that exact place only once and then using grub_printf is usually easier.
Quoted 9 lines
- Josh Triplett
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko