205-backtrace_module_info.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Subject: kernel: when KALLSYMS is disabled, print module address + size for matching backtrace entries
  3. [john@phrozen.org: felix will add this to his upstream queue]
  4. lede-commit 53827cdc824556cda910b23ce5030c363b8f1461
  5. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  6. ---
  7. lib/vsprintf.c | 15 +++++++++++----
  8. 1 file changed, 11 insertions(+), 4 deletions(-)
  9. --- a/lib/vsprintf.c
  10. +++ b/lib/vsprintf.c
  11. @@ -669,8 +669,10 @@ char *symbol_string(char *buf, char *end
  12. struct printf_spec spec, const char *fmt)
  13. {
  14. unsigned long value;
  15. -#ifdef CONFIG_KALLSYMS
  16. char sym[KSYM_SYMBOL_LEN];
  17. +#ifndef CONFIG_KALLSYMS
  18. + struct module *mod;
  19. + int len;
  20. #endif
  21. if (fmt[1] == 'R')
  22. @@ -684,11 +686,16 @@ char *symbol_string(char *buf, char *end
  23. sprint_symbol(sym, value);
  24. else
  25. sprint_symbol_no_offset(sym, value);
  26. -
  27. - return string(buf, end, sym, spec);
  28. #else
  29. - return special_hex_number(buf, end, value, sizeof(void *));
  30. + len = snprintf(sym, sizeof(sym), "0x%lx", value);
  31. +
  32. + mod = __module_address(value);
  33. + if (mod)
  34. + snprintf(sym + len, sizeof(sym) - len, " [%s@%p+0x%x]",
  35. + mod->name, mod->core_layout.base,
  36. + mod->core_layout.size);
  37. #endif
  38. + return string(buf, end, sym, spec);
  39. }
  40. static noinline_for_stack