dwarf-regs.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * dwarf-regs.c : Mapping of DWARF debug register numbers into register names.
  3. *
  4. * Written by: Masami Hiramatsu <mhiramat@kernel.org>
  5. */
  6. #include <util.h>
  7. #include <debug.h>
  8. #include <dwarf-regs.h>
  9. #include <elf.h>
  10. #ifndef EM_AARCH64
  11. #define EM_AARCH64 183 /* ARM 64 bit */
  12. #endif
  13. /* Define const char * {arch}_register_tbl[] */
  14. #define DEFINE_DWARF_REGSTR_TABLE
  15. #include "../arch/x86/include/dwarf-regs-table.h"
  16. #include "../arch/arm/include/dwarf-regs-table.h"
  17. #include "../arch/arm64/include/dwarf-regs-table.h"
  18. #include "../arch/sh/include/dwarf-regs-table.h"
  19. #include "../arch/powerpc/include/dwarf-regs-table.h"
  20. #include "../arch/s390/include/dwarf-regs-table.h"
  21. #include "../arch/sparc/include/dwarf-regs-table.h"
  22. #include "../arch/xtensa/include/dwarf-regs-table.h"
  23. #define __get_dwarf_regstr(tbl, n) (((n) < ARRAY_SIZE(tbl)) ? (tbl)[(n)] : NULL)
  24. /* Return architecture dependent register string (for kprobe-tracer) */
  25. const char *get_dwarf_regstr(unsigned int n, unsigned int machine)
  26. {
  27. switch (machine) {
  28. case EM_NONE: /* Generic arch - use host arch */
  29. return get_arch_regstr(n);
  30. case EM_386:
  31. return __get_dwarf_regstr(x86_32_regstr_tbl, n);
  32. case EM_X86_64:
  33. return __get_dwarf_regstr(x86_64_regstr_tbl, n);
  34. case EM_ARM:
  35. return __get_dwarf_regstr(arm_regstr_tbl, n);
  36. case EM_AARCH64:
  37. return __get_dwarf_regstr(aarch64_regstr_tbl, n);
  38. case EM_SH:
  39. return __get_dwarf_regstr(sh_regstr_tbl, n);
  40. case EM_S390:
  41. return __get_dwarf_regstr(s390_regstr_tbl, n);
  42. case EM_PPC:
  43. case EM_PPC64:
  44. return __get_dwarf_regstr(powerpc_regstr_tbl, n);
  45. case EM_SPARC:
  46. case EM_SPARCV9:
  47. return __get_dwarf_regstr(sparc_regstr_tbl, n);
  48. case EM_XTENSA:
  49. return __get_dwarf_regstr(xtensa_regstr_tbl, n);
  50. default:
  51. pr_err("ELF MACHINE %x is not supported.\n", machine);
  52. }
  53. return NULL;
  54. }