Home | History | Annotate | Download | only in util
      1 
      2 #include <errno.h>
      3 #include <libunwind.h>
      4 #include "perf_regs.h"
      5 #include "../../util/unwind.h"
      6 
      7 int libunwind__arch_reg_id(int regnum)
      8 {
      9 	switch (regnum) {
     10 	case UNW_AARCH64_X0:
     11 		return PERF_REG_ARM64_X0;
     12 	case UNW_AARCH64_X1:
     13 		return PERF_REG_ARM64_X1;
     14 	case UNW_AARCH64_X2:
     15 		return PERF_REG_ARM64_X2;
     16 	case UNW_AARCH64_X3:
     17 		return PERF_REG_ARM64_X3;
     18 	case UNW_AARCH64_X4:
     19 		return PERF_REG_ARM64_X4;
     20 	case UNW_AARCH64_X5:
     21 		return PERF_REG_ARM64_X5;
     22 	case UNW_AARCH64_X6:
     23 		return PERF_REG_ARM64_X6;
     24 	case UNW_AARCH64_X7:
     25 		return PERF_REG_ARM64_X7;
     26 	case UNW_AARCH64_X8:
     27 		return PERF_REG_ARM64_X8;
     28 	case UNW_AARCH64_X9:
     29 		return PERF_REG_ARM64_X9;
     30 	case UNW_AARCH64_X10:
     31 		return PERF_REG_ARM64_X10;
     32 	case UNW_AARCH64_X11:
     33 		return PERF_REG_ARM64_X11;
     34 	case UNW_AARCH64_X12:
     35 		return PERF_REG_ARM64_X12;
     36 	case UNW_AARCH64_X13:
     37 		return PERF_REG_ARM64_X13;
     38 	case UNW_AARCH64_X14:
     39 		return PERF_REG_ARM64_X14;
     40 	case UNW_AARCH64_X15:
     41 		return PERF_REG_ARM64_X15;
     42 	case UNW_AARCH64_X16:
     43 		return PERF_REG_ARM64_X16;
     44 	case UNW_AARCH64_X17:
     45 		return PERF_REG_ARM64_X17;
     46 	case UNW_AARCH64_X18:
     47 		return PERF_REG_ARM64_X18;
     48 	case UNW_AARCH64_X19:
     49 		return PERF_REG_ARM64_X19;
     50 	case UNW_AARCH64_X20:
     51 		return PERF_REG_ARM64_X20;
     52 	case UNW_AARCH64_X21:
     53 		return PERF_REG_ARM64_X21;
     54 	case UNW_AARCH64_X22:
     55 		return PERF_REG_ARM64_X22;
     56 	case UNW_AARCH64_X23:
     57 		return PERF_REG_ARM64_X23;
     58 	case UNW_AARCH64_X24:
     59 		return PERF_REG_ARM64_X24;
     60 	case UNW_AARCH64_X25:
     61 		return PERF_REG_ARM64_X25;
     62 	case UNW_AARCH64_X26:
     63 		return PERF_REG_ARM64_X26;
     64 	case UNW_AARCH64_X27:
     65 		return PERF_REG_ARM64_X27;
     66 	case UNW_AARCH64_X28:
     67 		return PERF_REG_ARM64_X28;
     68 	case UNW_AARCH64_X29:
     69 		return PERF_REG_ARM64_X29;
     70 	case UNW_AARCH64_X30:
     71 		return PERF_REG_ARM64_LR;
     72 	case UNW_AARCH64_SP:
     73 		return PERF_REG_ARM64_SP;
     74 	case UNW_AARCH64_PC:
     75 		return PERF_REG_ARM64_PC;
     76 	default:
     77 		pr_err("unwind: invalid reg id %d\n", regnum);
     78 		return -EINVAL;
     79 	}
     80 
     81 	return -EINVAL;
     82 }
     83