kern: Include function name on debug and error print functions
With the following change, we see standard (grub_dprintf) and error (grub_error) logs with the function name embedded (see below) into the log which is particular useful when debugging: commands/efi/tpm.c:grub_tpm_measure:281:tpm: log_event, pcr = 8, size = 0xb, Including one more field on the print log impacts the binary sizes and in turn their respective distro packages. For Fedora rpm packages the increase is 20k approximately. Signed-off-by: Leo Sandoval <lsandova@redhat.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
75a20cc144
commit
894241c854
@ -38,14 +38,14 @@ static int grub_error_stack_assert;
|
||||
#endif
|
||||
|
||||
grub_err_t
|
||||
grub_error (grub_err_t n, const char *file, const int line, const char *fmt, ...)
|
||||
grub_error (grub_err_t n, const char *file, const char *function, const int line, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int m;
|
||||
|
||||
grub_errno = n;
|
||||
|
||||
m = grub_snprintf (grub_errmsg, sizeof (grub_errmsg), "%s:%d:", file, line);
|
||||
m = grub_snprintf (grub_errmsg, sizeof (grub_errmsg), "%s:%s:%d:", file, function, line);
|
||||
if (m < 0)
|
||||
m = 0;
|
||||
|
||||
|
||||
@ -231,14 +231,14 @@ grub_debug_enabled (const char * condition)
|
||||
}
|
||||
|
||||
void
|
||||
grub_real_dprintf (const char *file, const int line, const char *condition,
|
||||
grub_real_dprintf (const char *file, const char *function, const int line, const char *condition,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (grub_debug_enabled (condition))
|
||||
{
|
||||
grub_printf ("%s:%d:%s: ", file, line, condition);
|
||||
grub_printf ("%s:%s:%d:%s: ", file, function, line, condition);
|
||||
va_start (args, fmt);
|
||||
grub_vprintf (fmt, args);
|
||||
va_end (args);
|
||||
|
||||
@ -89,10 +89,10 @@ struct grub_error_saved
|
||||
extern grub_err_t EXPORT_VAR(grub_errno);
|
||||
extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG];
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const int line, const char *fmt, ...)
|
||||
__attribute__ ((format (GNU_PRINTF, 4, 5)));
|
||||
grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const char *function, const int line, const char *fmt, ...)
|
||||
__attribute__ ((format (GNU_PRINTF, 5, 6)));
|
||||
|
||||
#define grub_error(n, fmt, ...) grub_error (n, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define grub_error(n, fmt, ...) grub_error (n, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
|
||||
void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn));
|
||||
void EXPORT_FUNC(grub_error_push) (void);
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
|
||||
#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
|
||||
|
||||
#define grub_dprintf(condition, ...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, __VA_ARGS__)
|
||||
#define grub_dprintf(condition, ...) grub_real_dprintf(GRUB_FILE, __FUNCTION__, __LINE__, condition, __VA_ARGS__)
|
||||
|
||||
void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
|
||||
char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
|
||||
@ -413,9 +413,10 @@ grub_puts (const char *s)
|
||||
int EXPORT_FUNC(grub_puts_) (const char *s);
|
||||
int EXPORT_FUNC(grub_debug_enabled) (const char *condition);
|
||||
void EXPORT_FUNC(grub_real_dprintf) (const char *file,
|
||||
const char *function,
|
||||
const int line,
|
||||
const char *condition,
|
||||
const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 4, 5)));
|
||||
const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 5, 6)));
|
||||
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
|
||||
int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
|
||||
int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user