Re: [PATCH v3 04/12] module: Add printk format to add module build ID to stacktraces
From: Stephen Boyd <hidden>
Date: 2021-04-08 06:58:52
Also in:
lkml
Quoting Petr Mladek (2021-04-07 08:03:47)
On Tue 2021-03-30 20:05:12, Stephen Boyd wrote:quoted
Let's make kernel stacktraces easier to identify by including the build ID[1] of a module if the stacktrace is printing a symbol from a module. This makes it simpler for developers to locate a kernel module's full debuginfo for a particular stacktrace. Combined with scripts/decode_stracktrace.sh, a developer can download the matching debuginfo from a debuginfod[2] server and find the exact file and line number for the functions plus offsets in a stacktrace that match the module. This is especially useful for pstore crash debugging where the kernel crashes are recorded in something like console-ramoops and the recovery kernel/modules are different or the debuginfo doesn't exist on the device due to space concerns (the debuginfo can be too large for space limited devices).@@ -359,15 +369,17 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size, /* Look up a kernel symbol and return it in a text buffer. */ static int __sprint_symbol(char *buffer, unsigned long address, - int symbol_offset, int add_offset) + int symbol_offset, int add_offset, int add_buildid) { char *modname; + const unsigned char *buildid; const char *name; unsigned long offset, size; int len; address += symbol_offset; - name = kallsyms_lookup(address, &size, &offset, &modname, buffer); + name = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid, + buffer); if (!name) return sprintf(buffer, "0x%lx", address - symbol_offset);@@ -379,8 +391,12 @@ static int __sprint_symbol(char *buffer, unsigned long address, if (add_offset) len += sprintf(buffer + len, "+%#lx/%#lx", offset, size);Please add something like: /* Keep BUILD_ID_SIZE_MAX in sync with the below used %20phN */ BUILD_BUG_ON(BUILD_ID_SIZE_MAX != 20)
Done. Hopefully the "GNU" string check also fixes this module problem you're seeing.