1 #ifndef ARCH_PERF_REGS_H 2 #define ARCH_PERF_REGS_H 3 4 #include <stdlib.h> 5 #include "../../util/types.h" 6 #include <asm/perf_regs.h> 7 8 #ifndef HAVE_ARCH_X86_64_SUPPORT 9 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) 10 #else 11 #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \ 12 (1ULL << PERF_REG_X86_ES) | \ 13 (1ULL << PERF_REG_X86_FS) | \ 14 (1ULL << PERF_REG_X86_GS)) 15 #define PERF_REGS_MASK (((1ULL << PERF_REG_X86_64_MAX) - 1) & ~REG_NOSUPPORT) 16 #endif 17 #define PERF_REG_IP PERF_REG_X86_IP 18 #define PERF_REG_SP PERF_REG_X86_SP 19 20 static inline const char *perf_reg_name(int id) 21 { 22 switch (id) { 23 case PERF_REG_X86_AX: 24 return "AX"; 25 case PERF_REG_X86_BX: 26 return "BX"; 27 case PERF_REG_X86_CX: 28 return "CX"; 29 case PERF_REG_X86_DX: 30 return "DX"; 31 case PERF_REG_X86_SI: 32 return "SI"; 33 case PERF_REG_X86_DI: 34 return "DI"; 35 case PERF_REG_X86_BP: 36 return "BP"; 37 case PERF_REG_X86_SP: 38 return "SP"; 39 case PERF_REG_X86_IP: 40 return "IP"; 41 case PERF_REG_X86_FLAGS: 42 return "FLAGS"; 43 case PERF_REG_X86_CS: 44 return "CS"; 45 case PERF_REG_X86_SS: 46 return "SS"; 47 case PERF_REG_X86_DS: 48 return "DS"; 49 case PERF_REG_X86_ES: 50 return "ES"; 51 case PERF_REG_X86_FS: 52 return "FS"; 53 case PERF_REG_X86_GS: 54 return "GS"; 55 #ifdef HAVE_ARCH_X86_64_SUPPORT 56 case PERF_REG_X86_R8: 57 return "R8"; 58 case PERF_REG_X86_R9: 59 return "R9"; 60 case PERF_REG_X86_R10: 61 return "R10"; 62 case PERF_REG_X86_R11: 63 return "R11"; 64 case PERF_REG_X86_R12: 65 return "R12"; 66 case PERF_REG_X86_R13: 67 return "R13"; 68 case PERF_REG_X86_R14: 69 return "R14"; 70 case PERF_REG_X86_R15: 71 return "R15"; 72 #endif /* HAVE_ARCH_X86_64_SUPPORT */ 73 default: 74 return NULL; 75 } 76 77 return NULL; 78 } 79 80 #endif /* ARCH_PERF_REGS_H */ 81