kernel: when KALLSYMS is disabled, print module address + size for matching backtrace...
[openwrt.git] / target / linux / generic / patches-3.18 / 205-backtrace_module_info.patch
1 --- a/lib/vsprintf.c
2 +++ b/lib/vsprintf.c
3 @@ -613,10 +613,12 @@ static noinline_for_stack
4  char *symbol_string(char *buf, char *end, void *ptr,
5                     struct printf_spec spec, const char *fmt)
6  {
7 +#ifndef CONFIG_KALLSYMS
8 +       struct module *mod;
9 +#endif
10         unsigned long value;
11 -#ifdef CONFIG_KALLSYMS
12         char sym[KSYM_SYMBOL_LEN];
13 -#endif
14 +       int len;
15  
16         if (fmt[1] == 'R')
17                 ptr = __builtin_extract_return_addr(ptr);
18 @@ -630,13 +632,15 @@ char *symbol_string(char *buf, char *end
19         else
20                 sprint_symbol_no_offset(sym, value);
21  
22 -       return string(buf, end, sym, spec);
23  #else
24 -       spec.field_width = 2 * sizeof(void *);
25 -       spec.flags |= SPECIAL | SMALL | ZEROPAD;
26 -       spec.base = 16;
27 +       len = snprintf(sym, sizeof(sym), "0x%lx", value);
28 +
29 +       mod = __module_address(value);
30 +       if (mod)
31 +               snprintf(sym + len, sizeof(sym) - len, " [%s@%p+0x%x]",
32 +                        mod->name, mod->module_core, mod->core_size);
33  
34 -       return number(buf, end, value, spec);
35 +       return string(buf, end, sym, spec);
36  #endif
37  }
38