unwind-libunwind.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2016 Chandan Kumar, IBM Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <errno.h>
  10. #include <libunwind.h>
  11. #include <asm/perf_regs.h>
  12. #include "../../util/unwind.h"
  13. #include "../../util/debug.h"
  14. int libunwind__arch_reg_id(int regnum)
  15. {
  16. switch (regnum) {
  17. case UNW_PPC64_R0:
  18. return PERF_REG_POWERPC_R0;
  19. case UNW_PPC64_R1:
  20. return PERF_REG_POWERPC_R1;
  21. case UNW_PPC64_R2:
  22. return PERF_REG_POWERPC_R2;
  23. case UNW_PPC64_R3:
  24. return PERF_REG_POWERPC_R3;
  25. case UNW_PPC64_R4:
  26. return PERF_REG_POWERPC_R4;
  27. case UNW_PPC64_R5:
  28. return PERF_REG_POWERPC_R5;
  29. case UNW_PPC64_R6:
  30. return PERF_REG_POWERPC_R6;
  31. case UNW_PPC64_R7:
  32. return PERF_REG_POWERPC_R7;
  33. case UNW_PPC64_R8:
  34. return PERF_REG_POWERPC_R8;
  35. case UNW_PPC64_R9:
  36. return PERF_REG_POWERPC_R9;
  37. case UNW_PPC64_R10:
  38. return PERF_REG_POWERPC_R10;
  39. case UNW_PPC64_R11:
  40. return PERF_REG_POWERPC_R11;
  41. case UNW_PPC64_R12:
  42. return PERF_REG_POWERPC_R12;
  43. case UNW_PPC64_R13:
  44. return PERF_REG_POWERPC_R13;
  45. case UNW_PPC64_R14:
  46. return PERF_REG_POWERPC_R14;
  47. case UNW_PPC64_R15:
  48. return PERF_REG_POWERPC_R15;
  49. case UNW_PPC64_R16:
  50. return PERF_REG_POWERPC_R16;
  51. case UNW_PPC64_R17:
  52. return PERF_REG_POWERPC_R17;
  53. case UNW_PPC64_R18:
  54. return PERF_REG_POWERPC_R18;
  55. case UNW_PPC64_R19:
  56. return PERF_REG_POWERPC_R19;
  57. case UNW_PPC64_R20:
  58. return PERF_REG_POWERPC_R20;
  59. case UNW_PPC64_R21:
  60. return PERF_REG_POWERPC_R21;
  61. case UNW_PPC64_R22:
  62. return PERF_REG_POWERPC_R22;
  63. case UNW_PPC64_R23:
  64. return PERF_REG_POWERPC_R23;
  65. case UNW_PPC64_R24:
  66. return PERF_REG_POWERPC_R24;
  67. case UNW_PPC64_R25:
  68. return PERF_REG_POWERPC_R25;
  69. case UNW_PPC64_R26:
  70. return PERF_REG_POWERPC_R26;
  71. case UNW_PPC64_R27:
  72. return PERF_REG_POWERPC_R27;
  73. case UNW_PPC64_R28:
  74. return PERF_REG_POWERPC_R28;
  75. case UNW_PPC64_R29:
  76. return PERF_REG_POWERPC_R29;
  77. case UNW_PPC64_R30:
  78. return PERF_REG_POWERPC_R30;
  79. case UNW_PPC64_R31:
  80. return PERF_REG_POWERPC_R31;
  81. case UNW_PPC64_LR:
  82. return PERF_REG_POWERPC_LINK;
  83. case UNW_PPC64_CTR:
  84. return PERF_REG_POWERPC_CTR;
  85. case UNW_PPC64_XER:
  86. return PERF_REG_POWERPC_XER;
  87. case UNW_PPC64_NIP:
  88. return PERF_REG_POWERPC_NIP;
  89. default:
  90. pr_err("unwind: invalid reg id %d\n", regnum);
  91. return -EINVAL;
  92. }
  93. return -EINVAL;
  94. }