205-backtrace_module_info.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. From: Felix Fietkau <[email protected]>
  2. Subject: kernel: when KALLSYMS is disabled, print module address + size for matching backtrace entries
  3. [[email protected]: felix will add this to his upstream queue]
  4. lede-commit 53827cdc824556cda910b23ce5030c363b8f1461
  5. Signed-off-by: Felix Fietkau <[email protected]>
  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. @@ -982,8 +982,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. @@ -1004,8 +1006,14 @@ char *symbol_string(char *buf, char *end
  23. return string_nocheck(buf, end, sym, spec);
  24. #else
  25. - return special_hex_number(buf, end, value, sizeof(void *));
  26. + len = snprintf(sym, sizeof(sym), "0x%lx", value);
  27. + mod = __module_address(value);
  28. + if (mod)
  29. + snprintf(sym + len, sizeof(sym) - len, " [%s@%p+0x%x]",
  30. + mod->name, mod->mem[MOD_TEXT].base,
  31. + mod->mem[MOD_TEXT].size);
  32. #endif
  33. + return string(buf, end, sym, spec);
  34. }
  35. static const struct printf_spec default_str_spec = {