lkml.org 
[lkml]   [2021]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 04/12] module: Add printk format to add module build ID to stacktraces
On Tue 2021-03-30 20:05:12, Stephen Boyd wrote:
> 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)

to make sure the the hard

>
> - if (modname)
> - len += sprintf(buffer + len, " [%s]", modname);
> + if (modname) {
> + len += sprintf(buffer + len, " [%s", modname);
> + if (IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) && add_buildid && buildid)
> + len += sprintf(buffer + len, " %20phN", buildid);
> + len += sprintf(buffer + len, "]");
> + }
>
> return len;
> }

Otherwise the approach looks fine to me. The main problem is that it
does not work for me as described in the other reply ;-)

Best Regards,
Petr

\
 
 \ /
  Last update: 2021-04-07 17:04    [W:0.537 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site